From cd258e1af32aeb67c0ffca4acf68be4d516b4c94 Mon Sep 17 00:00:00 2001
From: Flancian <0@flancia.org>
Date: Sat, 12 Dec 2020 20:44:00 +0100
Subject: [PATCH] Document a little bit, plus stub pull.
---
app/agora.py | 66 ++++++++++++++++++++++++++++++++--------------------
1 file changed, 41 insertions(+), 25 deletions(-)
diff --git a/app/agora.py b/app/agora.py
index 2e2ecf1..fa825fd 100644
--- a/app/agora.py
+++ b/app/agora.py
@@ -22,11 +22,11 @@ from . import util
bp = Blueprint('agora', __name__)
+# Special
@bp.route('/index')
@bp.route('/')
def index():
node='index'
- # return render_template('index.html', version=config.AGORA_VERSION, help_url=url_for('agora.help'), nodes_url=url_for('agora.nodes'), subnodes_url=url_for('agora.subnodes'), users_url=url_for('agora.users'), journals_url=url_for('agora.journals'), search_url=url_for('agora.search'), latest_url=url_for('agora.latest'), wikilink=node, subnodes=db.subnodes_by_wikilink(node), backlinks=db.subnodes_by_outlink(node))
return render_template('node_rendered.html', wikilink=node, subnodes=util.rank(db.subnodes_by_wikilink(node), user='agora'), backlinks=db.subnodes_by_outlink(node))
@bp.route('/help')
@@ -34,32 +34,23 @@ def help():
current_app.logger.warning('Not implemented.')
return 'If I had implemented help already, here you\'d see documentation on all URL endpoints. For now, please refer to the code.'
-@bp.route('/nodes')
-def nodes():
- return render_template('nodes.html', nodes=db.all_nodes(include_journals=False))
-
-@bp.route('/notes') # alias
-@bp.route('/subnodes')
-def subnodes():
- return render_template('subnodes.html', subnodes=db.all_subnodes())
-
@bp.route('/latest')
def latest():
return render_template('subnodes.html', header="Latest", subnodes=db.latest())
-@bp.route('/users')
-def users():
- return render_template('users.html', users=db.all_users())
-
-@bp.route('/journals')
-def journals():
- return render_template('nodes.html', header="Journals", nodes=db.all_journals())
-
@bp.route('/today')
def today():
today = datetime.datetime.now().date()
return redirect("https://anagora.org/node/%s" % today.strftime("%Y-%m-%d"))
+@bp.route('/search', methods=('GET', 'POST'))
+def search():
+ form = forms.SearchForm()
+ if form.validate_on_submit():
+ return render_template('search.html', form=form, subnodes=db.search_subnodes(form.query.data))
+ return render_template('search.html', form=form)
+
+# Actions
@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."""
@@ -89,6 +80,19 @@ def go(node):
return redirect(links[0])
+@bp.route('/pull/')
+def pull(node):
+ """In the context of a node, "pulls attention" from the parameter node to the current subnode.
+
+ Here it "broadcasts": it renders all nodes that pull from a given node.
+
+ Unclear at this point if this should exist at all, or whether it should do something else.
+ """
+
+ return redirect('/node/{}'.format(node))
+
+
+# Entities
@bp.route('/u/')
@bp.route('/user/')
@bp.route('/@')
@@ -109,17 +113,29 @@ def wikilink(node):
def subnode(subnode):
return render_template('subnode_rendered.html', subnode=db.subnode_by_uri(subnode), backlinks=db.subnodes_by_outlink(subnode))
- # Searching with GET: potentially useful but probably not a good idea.
+# Lists
+@bp.route('/nodes')
+def nodes():
+ return render_template('nodes.html', nodes=db.all_nodes(include_journals=False))
+
+@bp.route('/notes') # alias
+@bp.route('/subnodes')
+def subnodes():
+ return render_template('subnodes.html', subnodes=db.all_subnodes())
+
+@bp.route('/users')
+def users():
+ return render_template('users.html', users=db.all_users())
+
+@bp.route('/journals')
+def journals():
+ return render_template('nodes.html', header="Journals", nodes=db.all_journals())
+
+# Searching with GET: potentially useful but probably not a good idea.
# @bp.route('/search/')
# def search(query):
# return render_template('subnodes.html', subnodes=db.search_subnodes(query))
-@bp.route('/search', methods=('GET', 'POST'))
-def search():
- form = forms.SearchForm()
- if form.validate_on_submit():
- return render_template('search.html', form=form, subnodes=db.search_subnodes(form.query.data))
- return render_template('search.html', form=form)
@bp.route('/asset//')
def asset(user, asset):