Fix bug in index and improve node resolution slightly (needs cleanup).
This commit is contained in:
parent
f86bf64385
commit
e9628a2b3a
2 changed files with 13 additions and 11 deletions
16
app/agora.py
16
app/agora.py
|
@ -27,14 +27,17 @@ bp = Blueprint('agora', __name__)
|
||||||
@bp.route('/')
|
@bp.route('/')
|
||||||
def index():
|
def index():
|
||||||
node='index'
|
node='index'
|
||||||
|
n = db.wikilink_to_node(node)
|
||||||
return render_template(
|
return render_template(
|
||||||
'node_rendered.html',
|
'node_rendered.html',
|
||||||
wikilink=node,
|
wikilink=node,
|
||||||
subnodes=util.rank(db.subnodes_by_wikilink(node),
|
subnodes=util.rank(db.subnodes_by_wikilink(node),
|
||||||
user='agora'),
|
user='agora'),
|
||||||
backlinks=[x.wikilink for x in db.nodes_by_outlink(node)],
|
backlinks=[x.wikilink for x in db.nodes_by_outlink(node)],
|
||||||
|
forwardlinks=n.forward_links() if n else [],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@bp.route('/help')
|
@bp.route('/help')
|
||||||
def help():
|
def help():
|
||||||
current_app.logger.warning('Not implemented.')
|
current_app.logger.warning('Not implemented.')
|
||||||
|
@ -98,22 +101,13 @@ def pull(node):
|
||||||
return redirect('/node/{}'.format(node))
|
return redirect('/node/{}'.format(node))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Entities
|
# Entities
|
||||||
@bp.route('/node/<node>')
|
@bp.route('/node/<node>')
|
||||||
@bp.route('/wikilink/<node>') # alias for now
|
@bp.route('/wikilink/<node>') # alias for now
|
||||||
def wikilink(node):
|
def wikilink(node):
|
||||||
|
|
||||||
try:
|
n = db.wikilink_to_node(node)
|
||||||
n = db.nodes_by_wikilink(node)
|
|
||||||
except KeyError:
|
|
||||||
# We'll handle 404 in the template, as we want to show backlinks to non-existent nodes.
|
|
||||||
pass
|
|
||||||
|
|
||||||
try:
|
|
||||||
n = n[0]
|
|
||||||
except IndexError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
return render_template(
|
return render_template(
|
||||||
'node_rendered.html',
|
'node_rendered.html',
|
||||||
wikilink=node,
|
wikilink=node,
|
||||||
|
|
|
@ -264,6 +264,14 @@ def nodes_by_wikilink(wikilink):
|
||||||
nodes = [node for node in all_nodes() if node.wikilink == wikilink]
|
nodes = [node for node in all_nodes() if node.wikilink == wikilink]
|
||||||
return nodes
|
return nodes
|
||||||
|
|
||||||
|
def wikilink_to_node(node):
|
||||||
|
try:
|
||||||
|
return nodes_by_wikilink(node)[0]
|
||||||
|
except (KeyError, IndexError):
|
||||||
|
# We'll handle 404 in the template, as we want to show backlinks to non-existent nodes.
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def subnodes_by_wikilink(wikilink, fuzzy_matching=True):
|
def subnodes_by_wikilink(wikilink, fuzzy_matching=True):
|
||||||
if fuzzy_matching:
|
if fuzzy_matching:
|
||||||
# TODO
|
# TODO
|
||||||
|
|
Loading…
Reference in a new issue