Add cited-by links

This commit is contained in:
Tim Van Baak 2020-04-19 20:09:17 -07:00
parent 2705764a6a
commit 44bb51f0a1
3 changed files with 23 additions and 10 deletions

View File

@ -332,10 +332,19 @@ def publish_turn(lexicon, drafts):
with lexicon.ctx.article.edit(filename, create=True) as f:
f['title'] = title
f['html'] = html
f['cites'] = citations_by_title[title]
f['citedby'] = [
citer for citer, citations
in citations_by_title.items()
if title in citations]
for title in phantom_titles:
html = None
filename = filesafe_title(title)
with lexicon.ctx.article.edit(filename, create=True) as f:
f['title'] = title
f['html'] = html
f['html'] = ""
f['cites'] = []
f['citedby'] = [
citer for citer, citations
in citations_by_title.items()
if title in citations]

View File

@ -69,11 +69,8 @@ def get_bp():
@player_required_if_not_public
def article(name, title):
with g.lexicon.ctx.article.read(title) as a:
article = dict(a)
article['html'] = Markup(a['html'] or "")
with g.lexicon.ctx.read('info') as info:
cites = info[a.title]['citations']
return render_template('lexicon/article.html', article=article, cites=cites)
article = { **a, 'html': Markup(a['html']) }
return render_template('lexicon/article.html', article=article)
@bp.route('/rules/', methods=['GET'])
@lexicon_param

View File

@ -13,9 +13,16 @@
{% endblock %}
{% block citations %}
{% for cite in cites %}
<a href="{{ cite|articlelink }}">{{ cite }}</a> /
<p>
{% for citation in article.cites %}
<a href="{{ citation|articlelink }}">{{ citation }}</a> /
{% endfor %}
</p>
<p>
{% for citation in article.citedby %}
<a href="{{ citation|articlelink }}">{{ citation }}</a> /
{% endfor %}
</p>
{% endblock %}
{% set template_content_blocks = [self.main(), self.citations()] %}