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?