Patch: fix non-existent nodes.

This commit is contained in:
Flancian 2020-12-27 21:07:46 +01:00
parent 0a614808f2
commit 03a5e5c71e
3 changed files with 7 additions and 8 deletions

View File

@ -20,8 +20,6 @@ from . import db
from . import forms
from . import util
bp = Blueprint('agora', __name__)
G = db.G

View File

@ -50,8 +50,7 @@ class Graph:
def node(self, uri):
# looks up a node by uri (essentially [[wikilink]]).
# horrible
nodes = self.nodes()
return nodes_by_wikilink(uri)[0]
return wikilink_to_node(uri)
def nodes(self, include_journals=True):
# returns a list of all nodes
@ -285,7 +284,8 @@ def wikilink_to_node(node):
return nodes_by_wikilink(node)[0]
except (KeyError, IndexError):
# We'll handle 404 in the template, as we want to show backlinks to non-existent nodes.
return False
# Return an empty.
return Node(node)
def subnodes_by_wikilink(wikilink, fuzzy_matching=True):
if fuzzy_matching:

View File

@ -16,11 +16,12 @@
{% extends "base.html" %}
{% block content %}
{% if not node %}
{% if not node.subnodes %}
<div class="not-found">
No node found at [[{{node}}]].
No node found at [[{{node.uri}}]].
<br /><br />
If you <a href="https://flancia.org/go/agora">contributed a subnode</a> that mapped to '{{node}}' in the Agora, this node would exist :)
If you <a href="https://flancia.org/go/agora">contributed a subnode</a> that mapped to '{{node.uri}}' in the Agora, this node would exist :)
<br /><br />
Try listing all <a href="/nodes">nodes</a> or perhaps <a href="/search">search</a>.
</div>