Change links section to have pushing/pulling.
This commit is contained in:
parent
620e430f4b
commit
ff444daf0a
3 changed files with 39 additions and 17 deletions
|
@ -35,9 +35,9 @@ def index():
|
||||||
'node_rendered.html',
|
'node_rendered.html',
|
||||||
node=n,
|
node=n,
|
||||||
backlinks=n.back_links(),
|
backlinks=n.back_links(),
|
||||||
pushlinks=n.push_links() if n else [],
|
|
||||||
pull_nodes=n.pull_nodes() if n else [],
|
pull_nodes=n.pull_nodes() if n else [],
|
||||||
pulling_nodes=n.pulling_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 [],
|
forwardlinks=n.forward_links() if n else [],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -125,11 +125,11 @@ def node(node):
|
||||||
'node_rendered.html',
|
'node_rendered.html',
|
||||||
node=n,
|
node=n,
|
||||||
backlinks=n.back_links(),
|
backlinks=n.back_links(),
|
||||||
pushlinks=n.push_links() if n else [],
|
|
||||||
pull_nodes=n.pull_nodes() if n else [],
|
pull_nodes=n.pull_nodes() if n else [],
|
||||||
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(),
|
||||||
|
pushing_nodes=n.pushing_nodes(),
|
||||||
query=n.wikilink.replace('-', '%20')
|
query=n.wikilink.replace('-', '%20')
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
26
app/db.py
26
app/db.py
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
import cachetools.func
|
import cachetools.func
|
||||||
import glob
|
import glob
|
||||||
|
import marko
|
||||||
import re
|
import re
|
||||||
import os
|
import os
|
||||||
from . import config
|
from . import config
|
||||||
|
@ -147,12 +148,24 @@ class Node:
|
||||||
nodes.append(n)
|
nodes.append(n)
|
||||||
return nodes
|
return nodes
|
||||||
|
|
||||||
def push_links(self):
|
def push_nodes(self):
|
||||||
|
# nodes pushed to from this node.
|
||||||
links = []
|
links = []
|
||||||
for subnode in self.subnodes:
|
for subnode in self.subnodes:
|
||||||
links.extend(subnode.push_links())
|
links.extend(subnode.push_nodes())
|
||||||
return sorted(set(links))
|
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):
|
def back_links(self):
|
||||||
return sorted([x.wikilink for x in nodes_by_outlink(self.wikilink)])
|
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))
|
pull_nodes = content_to_forward_links("\n".join(pull_blocks))
|
||||||
return [G.node(node) for node in pull_nodes]
|
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
|
returns a set of push links contained in this subnode
|
||||||
push links are blocks of the form:
|
push links are blocks of the form:
|
||||||
|
@ -233,10 +246,9 @@ class Subnode:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# TODO: test.
|
# TODO: test.
|
||||||
push_links = subnode_to_actions(self, 'push')
|
push_blocks = subnode_to_actions(self, 'push')
|
||||||
entities = content_to_forward_links("\n".join(push_links))
|
push_nodes = content_to_forward_links("\n".join(push_blocks))
|
||||||
return entities
|
return [G.node(node) for node in push_nodes]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def subnode_to_actions(subnode, action):
|
def subnode_to_actions(subnode, action):
|
||||||
|
|
|
@ -24,25 +24,35 @@
|
||||||
<br />
|
<br />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!--
|
|
||||||
<div class="pushlinks">
|
<div class="pushlinks">
|
||||||
<span class="pushlinks-header">push</span><br />
|
<span class="pushlinks-header">↑ pushing</span><br />
|
||||||
{% for link in pushlinks %}
|
{% if pushing_nodes %}
|
||||||
<a href="/node/{{link}}">{{link}}</a><br />
|
{% for node in pushing_nodes %}
|
||||||
|
<a href="/node/{{link}}">{{node.uri}}</a><br />
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
{% else %}
|
||||||
|
(none)
|
||||||
|
{% endif %}
|
||||||
|
<br />
|
||||||
<br />
|
<br />
|
||||||
-->
|
|
||||||
|
|
||||||
|
<!--
|
||||||
<div class="pulllinks">
|
<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 %}
|
{% for node in pull_nodes %}
|
||||||
<a href="/node/{{node.uri}}">{{node.uri}}</a><br />
|
<a href="/node/{{node.uri}}">{{node.uri}}</a><br />
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<br />
|
<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 %}
|
{% for node in pulling_nodes %}
|
||||||
<a href="/node/{{node.uri}}">{{node.uri}}</a><br />
|
<a href="/node/{{node.uri}}">{{node.uri}}</a><br />
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
{% else %}
|
||||||
|
(none)
|
||||||
|
{% endif %}
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue