From b5de675e8bc9403c337c8b83c6205f379d9fb103 Mon Sep 17 00:00:00 2001 From: Flancian <0@flancia.org> Date: Sun, 24 Jan 2021 20:20:18 +0100 Subject: [PATCH] Fix humbling bug :) --- app/agora.py | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/app/agora.py b/app/agora.py index 7b4c34e..23646e3 100644 --- a/app/agora.py +++ b/app/agora.py @@ -53,6 +53,7 @@ def search(): return render_template('search.html', form=form) # Actions +# Simple go. @bp.route('/go/') def go(node): """Redirects to the URL in the given node in a block that starts with [[go]], if there is one.""" @@ -82,17 +83,10 @@ def go(node): return redirect(links[0]) -@bp.route('/push//') -def push(node, other): - n = G.node(node) - o = G.node(other) - pushing = n.pushing(o) - - return Response(pushing) - -# [default action](https://anagora.org/node/default-action) +# Composite go. +# Likely equivalent to [default action](https://anagora.org/node/default-action) @bp.route('/go//') -def default_action(node0, node1): +def composite_go(node0, node1): """Redirects to the URL in the given node in a block that starts with [[]], if there is one.""" # TODO(flancian): all node-scoped stuff should move to actually use node objects. # TODO(flancian): make [[go]] call this? @@ -110,10 +104,12 @@ def default_action(node0, node1): # Redirect to composite node, which might exist and provides search. return redirect(f'https://anagora.org/node/{node0}-{node1}') + links = [] if len(n0) != 0: - links = n0[0].filter(node1) - elif len(n1) != 0: - links += n1[0].filter(node0) + links.extend(n0[0].filter(node1)) + + if len(n1) != 0: + links.extend(n1[0].filter(node0)) if len(links) == 0: # No matching links found. @@ -128,6 +124,15 @@ def default_action(node0, node1): return redirect(links[0]) +@bp.route('/push//') +def push(node, other): + n = G.node(node) + o = G.node(other) + pushing = n.pushing(o) + + return Response(pushing) + + @bp.route('/jump') def jump(): """Redirects to a context; in "jump" mode, a node *always* exists (nodes map one to one to all possible queries)."""