diff --git a/amanuensis/lexicon/manage.py b/amanuensis/lexicon/manage.py index 3d756df..7d5bc55 100644 --- a/amanuensis/lexicon/manage.py +++ b/amanuensis/lexicon/manage.py @@ -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] diff --git a/amanuensis/server/lexicon.py b/amanuensis/server/lexicon.py index ca9db80..dfcf5f1 100644 --- a/amanuensis/server/lexicon.py +++ b/amanuensis/server/lexicon.py @@ -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 diff --git a/amanuensis/templates/lexicon/article.html b/amanuensis/templates/lexicon/article.html index b72e244..66b4766 100644 --- a/amanuensis/templates/lexicon/article.html +++ b/amanuensis/templates/lexicon/article.html @@ -13,9 +13,16 @@ {% endblock %} {% block citations %} -{% for cite in cites %} -{{ cite }} / -{% endfor %} +

+ {% for citation in article.cites %} + {{ citation }} / + {% endfor %} +

+

+ {% for citation in article.citedby %} + {{ citation }} / + {% endfor %} +

{% endblock %} {% set template_content_blocks = [self.main(), self.citations()] %} \ No newline at end of file