Implement supercededby and supercedes proposal metadata

This commit is contained in:
str4d
2016-04-10 07:17:19 +00:00
parent 5bbfd5987c
commit 9ab4b287ff
6 changed files with 47 additions and 2 deletions

View File

@ -42,6 +42,12 @@
</div>
{%- endmacro -%}
{%- macro render_supercedes(supercedes) -%}
{%- if supercedes and supercedes|length -%}
{% for proposal in supercedes %}<a href="{{ proposal_url(proposal) }}">{{ proposal }}</a>{% if not loop.last %}, {% endif %}{% endfor %}
{%- endif %}
{%- endmacro %}
{%- macro render_categories(categories) -%}
{%- if categories and categories|length -%}
{{ _('Posted in') }} {% for category in categories %}<a href="{{ get_url('blog_index', category=category) }}">{{ category }}</a>{% if not loop.last %}, {% endif %}{% endfor %}

View File

@ -1,5 +1,5 @@
{% extends "global/layout.html" %}
{%- from "global/macros" import render_categories with context -%}
{%- from "global/macros" import render_supercedes with context -%}
{% block title %}{{ title }}{% endblock %}
{% block content_nav %}
{% autoescape false %}
@ -19,6 +19,14 @@
<dt>Last updated</dt>
<dd><time datetime="{{ meta.lastupdated }}">{{ meta.lastupdated }}</time></dd>
<dt>Status</dt><dd>{{ meta.status }}</dd>
{% if meta.supercededby -%}
<dt>Superceded by</dt>
<dd><a href="{{ proposal_url(meta.supercededby) }}">{{ meta.supercededby }}</a></dd>
{%- endif %}
{% if meta.supercedes -%}
<dt>Supercedes</dt>
<dd>{{ render_supercedes(meta.supercedes)|safe }}</dd>
{%- endif %}
</dl>
{% autoescape false %}
{{ body }}

View File

@ -7,6 +7,7 @@ NTCP Obfuscation
:thread: http://zzz.i2p/topics/774
:lastupdated: 2014-01-03
:status: Rejected
:supercededby: 111
.. contents::

View File

@ -7,6 +7,7 @@ NTCP 2
:thread: http://zzz.i2p/topics/1577
:lastupdated: 2014-09-21
:status: Draft
:supercedes: 106
.. contents::

View File

@ -43,9 +43,12 @@ PROPOSAL_METATAGS = {
'created': None,
'lastupdated': None,
'status': u'Draft',
'supercededby': None,
'supercedes': None,
'thread': None,
}
PROPOSAL_LIST_METATAGS = [
'supercedes',
]
PROPOSAL_STATUS_SORT = {
'Draft': 1,
@ -60,6 +63,7 @@ METATAG_LABELS = {
'created': u'Created',
'lastupdated': u'Last updated',
'status': u'Status',
'supercededby': u'Superceded by',
'thread': u'Thread',
}

View File

@ -2,7 +2,17 @@ import ctags
from flask import g, request, safe_join, url_for
import os.path
from i2p2www import CANONICAL_DOMAIN, CURRENT_I2P_VERSION, RTL_LANGS, SUPPORTED_LANGS, SUPPORTED_LANG_NAMES, SPEC_DIR, STATIC_DIR, app
from i2p2www import (
CANONICAL_DOMAIN,
CURRENT_I2P_VERSION,
PROPOSAL_DIR,
RTL_LANGS,
SUPPORTED_LANGS,
SUPPORTED_LANG_NAMES,
SPEC_DIR,
STATIC_DIR,
app,
)
INPROXY = '.xyz' # http://zzz.i2p/topics/1771-i2p-xyz-inproxy
@ -46,6 +56,20 @@ def utility_processor():
url = url[:url.index('?')]
return url
def get_proposal_url(identifier):
name = None
for f in os.listdir(PROPOSAL_DIR):
if f.startswith(identifier):
name = f[:-4]
break
if not name:
return ''
url = url_for('proposal_show', name=name, _external=True)
# Remove ?lang=xx
if '?' in url:
url = url[:url.index('?')]
return url
def get_ctags_url(value):
filename, kind = _lookup_ctag(value)
# Handle message types
@ -149,6 +173,7 @@ def utility_processor():
logo_url=get_logo_for_theme,
site_url=get_site_url,
spec_url=get_spec_url,
proposal_url=get_proposal_url,
ctags_url=get_ctags_url,
get_url=get_url_with_lang,
is_rtl=is_rtl_lang,