Patch: fix non-existent nodes.
This commit is contained in:
parent
0a614808f2
commit
03a5e5c71e
3 changed files with 7 additions and 8 deletions
|
@ -20,8 +20,6 @@ from . import db
|
||||||
from . import forms
|
from . import forms
|
||||||
from . import util
|
from . import util
|
||||||
bp = Blueprint('agora', __name__)
|
bp = Blueprint('agora', __name__)
|
||||||
|
|
||||||
|
|
||||||
G = db.G
|
G = db.G
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -50,8 +50,7 @@ class Graph:
|
||||||
def node(self, uri):
|
def node(self, uri):
|
||||||
# looks up a node by uri (essentially [[wikilink]]).
|
# looks up a node by uri (essentially [[wikilink]]).
|
||||||
# horrible
|
# horrible
|
||||||
nodes = self.nodes()
|
return wikilink_to_node(uri)
|
||||||
return nodes_by_wikilink(uri)[0]
|
|
||||||
|
|
||||||
def nodes(self, include_journals=True):
|
def nodes(self, include_journals=True):
|
||||||
# returns a list of all nodes
|
# returns a list of all nodes
|
||||||
|
@ -285,7 +284,8 @@ def wikilink_to_node(node):
|
||||||
return nodes_by_wikilink(node)[0]
|
return nodes_by_wikilink(node)[0]
|
||||||
except (KeyError, IndexError):
|
except (KeyError, IndexError):
|
||||||
# We'll handle 404 in the template, as we want to show backlinks to non-existent nodes.
|
# 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):
|
def subnodes_by_wikilink(wikilink, fuzzy_matching=True):
|
||||||
if fuzzy_matching:
|
if fuzzy_matching:
|
||||||
|
|
|
@ -16,11 +16,12 @@
|
||||||
|
|
||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{% if not node %}
|
|
||||||
|
{% if not node.subnodes %}
|
||||||
<div class="not-found">
|
<div class="not-found">
|
||||||
No node found at [[{{node}}]].
|
No node found at [[{{node.uri}}]].
|
||||||
<br /><br />
|
<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 />
|
<br /><br />
|
||||||
Try listing all <a href="/nodes">nodes</a> or perhaps <a href="/search">search</a>.
|
Try listing all <a href="/nodes">nodes</a> or perhaps <a href="/search">search</a>.
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue