Change links section to have pushing/pulling.
This commit is contained in:
parent
620e430f4b
commit
ff444daf0a
|
@ -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')
|
||||
)
|
||||
|
||||
|
|
26
app/db.py
26
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):
|
||||
|
|
|
@ -24,31 +24,41 @@
|
|||
<br />
|
||||
</div>
|
||||
|
||||
<!--
|
||||
<div class="pushlinks">
|
||||
<span class="pushlinks-header">push</span><br />
|
||||
{% for link in pushlinks %}
|
||||
<a href="/node/{{link}}">{{link}}</a><br />
|
||||
<span class="pushlinks-header">↑ pushing</span><br />
|
||||
{% if pushing_nodes %}
|
||||
{% for node in pushing_nodes %}
|
||||
<a href="/node/{{link}}">{{node.uri}}</a><br />
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
(none)
|
||||
{% endif %}
|
||||
<br />
|
||||
<br />
|
||||
-->
|
||||
|
||||
<!--
|
||||
<div class="pulllinks">
|
||||
<span class="pulllinks-header">↑ pulled by this node</span><br />
|
||||
<span class="pulllinks-header"> ↑pushing</span><br />
|
||||
{% for node in pull_nodes %}
|
||||
<a href="/node/{{node.uri}}">{{node.uri}}</a><br />
|
||||
{% endfor %}
|
||||
<br />
|
||||
<span class="pulllinks-header">↓ pulling this node</span><br />
|
||||
-->
|
||||
|
||||
<span class="pulllinks-header">↓ pulling</span><br />
|
||||
{% if pulling_nodes %}
|
||||
{% for node in pulling_nodes %}
|
||||
<a href="/node/{{node.uri}}">{{node.uri}}</a><br />
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
(none)
|
||||
{% endif %}
|
||||
<br />
|
||||
|
||||
</div>
|
||||
|
||||
<div class="forwardlinks">
|
||||
<span class="forwardlinks-header">→ forward</span><br />
|
||||
<span class="forwardlinks-header">→ forward</span><br />
|
||||
{% for link in forwardlinks %}
|
||||
<a href="/node/{{link}}">{{link}}</a><br />
|
||||
{% endfor %}
|
||||
|
|
Loading…
Reference in New Issue