From 25c554fe92c9a66693e925de6f17649a42bdb4bb Mon Sep 17 00:00:00 2001 From: Flancian <0@flancia.org> Date: Mon, 16 Nov 2020 21:15:02 +0100 Subject: [PATCH] Some more light fixes, plus fix the subnode "404". --- app/db.py | 8 ++++++-- app/templates/node_rendered.html | 10 +++++++--- app/templates/subnode_rendered.html | 6 +++++- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/app/db.py b/app/db.py index 9fad9c4..8f9fcdf 100644 --- a/app/db.py +++ b/app/db.py @@ -182,8 +182,12 @@ def subnodes_by_user(user): return subnodes def subnode_by_uri(uri): - subnode = [subnode for subnode in all_subnodes() if subnode.uri == uri][0] - return subnode + subnode = [subnode for subnode in all_subnodes() if subnode.uri == uri] + if subnode: + return subnode[0] + else: + # TODO: handle. + return False def nodes_by_outlink(wikilink): nodes = [node for node in all_nodes() if wikilink in node.outlinks] diff --git a/app/templates/node_rendered.html b/app/templates/node_rendered.html index 5307648..08d1da4 100644 --- a/app/templates/node_rendered.html +++ b/app/templates/node_rendered.html @@ -17,13 +17,16 @@ {% extends "base.html" %} {% block content %} {% if not subnodes %} -No node found for '{{wikilink}}'. +
+No node found at [[{{wikilink}}]].

-If you contributed a subnode named '{{wikilink}}' to the Agora, this node would not be empty :) +If you contributed a subnode named '{{wikilink}}' to the Agora, this node would exist :)

-Go back to /nodes? +Try listing nodes or perhaps search. +
{% endif %} +{% if subnodes %}
Node [[{{wikilink}}]] @@ -41,5 +44,6 @@ Go back to /nodes? {{subnode.wikilink}} by @{{subnode.user}}
{% endfor %}
+{% endif %} {% endblock %} diff --git a/app/templates/subnode_rendered.html b/app/templates/subnode_rendered.html index b3ff36c..3c74c9d 100644 --- a/app/templates/subnode_rendered.html +++ b/app/templates/subnode_rendered.html @@ -17,11 +17,14 @@ {% extends "base.html" %} {% block content %} {% if not subnode %} +
No subnode found matching '{{subnode}}'.

-Go back to /nodes, /nodes? +Try listing subnodes or perhaps search. +
{% endif %} +{% if subnode %}
Subnode {{subnode.uri}} by @{{subnode.user}} in [[{{subnode.wikilink}}]] {{ subnode.content|markdown|linkify|safe }} @@ -29,5 +32,6 @@ Go back to /nodes, /nodes?