Add permutations; exploit open.
This commit is contained in:
parent
b5de675e8b
commit
4bc5703aa7
11
app/agora.py
11
app/agora.py
|
@ -145,8 +145,13 @@ def jump():
|
||||||
def node(node):
|
def node(node):
|
||||||
|
|
||||||
n = G.node(node)
|
n = G.node(node)
|
||||||
# earlier in the list means more highly ranked.
|
if n.subnodes:
|
||||||
n.subnodes = util.uprank(n.subnodes, users=['agora', 'flancian'])
|
# earlier in the list means more highly ranked.
|
||||||
|
n.subnodes = util.uprank(n.subnodes, users=['agora', 'flancian'])
|
||||||
|
permutations = []
|
||||||
|
# if it's a 404, include permutations.
|
||||||
|
else:
|
||||||
|
permutations = G.existing_permutations(node)
|
||||||
|
|
||||||
search_subnodes = db.search_subnodes(node)
|
search_subnodes = db.search_subnodes(node)
|
||||||
|
|
||||||
|
@ -154,7 +159,7 @@ def node(node):
|
||||||
'node_rendered.html',
|
'node_rendered.html',
|
||||||
node=n,
|
node=n,
|
||||||
backlinks=n.back_links(),
|
backlinks=n.back_links(),
|
||||||
pull_nodes=n.pull_nodes() if n else [],
|
pull_nodes=n.pull_nodes() if n.subnodes else permutations,
|
||||||
forwardlinks=n.forward_links() if n else [],
|
forwardlinks=n.forward_links() if n else [],
|
||||||
search=search_subnodes,
|
search=search_subnodes,
|
||||||
pulling_nodes=n.pulling_nodes(),
|
pulling_nodes=n.pulling_nodes(),
|
||||||
|
|
10
app/db.py
10
app/db.py
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
import cachetools.func
|
import cachetools.func
|
||||||
import glob
|
import glob
|
||||||
|
import itertools
|
||||||
import re
|
import re
|
||||||
import os
|
import os
|
||||||
from . import config
|
from . import config
|
||||||
|
@ -64,6 +65,15 @@ class Graph:
|
||||||
# Return an empty.
|
# Return an empty.
|
||||||
return Node(uri)
|
return Node(uri)
|
||||||
|
|
||||||
|
def existing_permutations(self, uri):
|
||||||
|
# looks up nodes matching a permutation of the tokenized uri.
|
||||||
|
#
|
||||||
|
# example use: if [[server-agora]] does not exist, serve [[agora-server]]
|
||||||
|
permutations = itertools.permutations(uri.split('-'))
|
||||||
|
permutations = ['-'.join(permutation) for permutation in permutations]
|
||||||
|
nodes = [node for node in G.nodes() if node.wikilink in permutations and node.subnodes]
|
||||||
|
return nodes
|
||||||
|
|
||||||
@cachetools.func.ttl_cache(maxsize=2, ttl=20)
|
@cachetools.func.ttl_cache(maxsize=2, ttl=20)
|
||||||
def nodes(self, include_journals=True):
|
def nodes(self, include_journals=True):
|
||||||
# returns a list of all nodes
|
# returns a list of all nodes
|
||||||
|
|
|
@ -23,7 +23,8 @@ 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.uri}}' 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>.<br/><br />
|
||||||
|
<strong>Any existing permutations</strong> are automatically pulled below.<br/>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue