diff --git a/app/agora.py b/app/agora.py index 8a6b021..1b8a17e 100644 --- a/app/agora.py +++ b/app/agora.py @@ -35,9 +35,9 @@ def index(): 'node_rendered.html', node=n, backlinks=n.back_links(), - pushlinks=n.push_links() if n else [], pull_nodes=n.pull_nodes() if n else [], pulling_nodes=n.pulling_nodes() if n else [], + pushing_nodes=n.pushing_nodes() if n else [], forwardlinks=n.forward_links() if n else [], ) @@ -125,11 +125,11 @@ def node(node): 'node_rendered.html', node=n, backlinks=n.back_links(), - pushlinks=n.push_links() if n else [], pull_nodes=n.pull_nodes() if n else [], forwardlinks=n.forward_links() if n else [], search=search_subnodes, pulling_nodes=n.pulling_nodes(), + pushing_nodes=n.pushing_nodes(), query=n.wikilink.replace('-', '%20') ) diff --git a/app/db.py b/app/db.py index 4beca8d..580423b 100644 --- a/app/db.py +++ b/app/db.py @@ -14,6 +14,7 @@ import cachetools.func import glob +import marko import re import os from . import config @@ -147,12 +148,24 @@ class Node: nodes.append(n) return nodes - def push_links(self): + def push_nodes(self): + # nodes pushed to from this node. links = [] for subnode in self.subnodes: - links.extend(subnode.push_links()) + links.extend(subnode.push_nodes()) return sorted(set(links)) + def pushing_nodes(self): + # the nodes pushing to *this* node. + # compare with: push_nodes. + nodes = [] + for wikilink in self.back_links(): + n = G.node(wikilink) + if self.wikilink in [x.wikilink for x in n.push_nodes()]: + nodes.append(n) + return nodes + + def back_links(self): return sorted([x.wikilink for x in nodes_by_outlink(self.wikilink)]) @@ -223,7 +236,7 @@ class Subnode: pull_nodes = content_to_forward_links("\n".join(pull_blocks)) return [G.node(node) for node in pull_nodes] - def push_links(self): + def push_nodes(self): """ returns a set of push links contained in this subnode push links are blocks of the form: @@ -233,10 +246,9 @@ class Subnode: """ # TODO: test. - push_links = subnode_to_actions(self, 'push') - entities = content_to_forward_links("\n".join(push_links)) - return entities - + push_blocks = subnode_to_actions(self, 'push') + push_nodes = content_to_forward_links("\n".join(push_blocks)) + return [G.node(node) for node in push_nodes] def subnode_to_actions(subnode, action): diff --git a/app/templates/links.html b/app/templates/links.html index 44e0758..e97bd91 100644 --- a/app/templates/links.html +++ b/app/templates/links.html @@ -24,31 +24,41 @@
- + + + ↓ pulling
+ {% if pulling_nodes %} {% for node in pulling_nodes %} {{node.uri}}
{% endfor %} + {% else %} + (none) + {% endif %}