Document a little bit, plus stub pull.

This commit is contained in:
Flancian 2020-12-12 20:44:00 +01:00
parent 7f07fd0e31
commit cd258e1af3

View file

@ -22,11 +22,11 @@ from . import util
bp = Blueprint('agora', __name__) bp = Blueprint('agora', __name__)
# Special
@bp.route('/index') @bp.route('/index')
@bp.route('/') @bp.route('/')
def index(): def index():
node='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)) 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') @bp.route('/help')
@ -34,32 +34,23 @@ def help():
current_app.logger.warning('Not implemented.') 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 <a href="https://flancia.org/go/agora">code</a>.' return 'If I had implemented help already, here you\'d see documentation on all URL endpoints. For now, please refer to the <a href="https://flancia.org/go/agora">code</a>.'
@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') @bp.route('/latest')
def latest(): def latest():
return render_template('subnodes.html', header="Latest", subnodes=db.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') @bp.route('/today')
def today(): def today():
today = datetime.datetime.now().date() today = datetime.datetime.now().date()
return redirect("https://anagora.org/node/%s" % today.strftime("%Y-%m-%d")) 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/<node>') @bp.route('/go/<node>')
def go(node): def go(node):
"""Redirects to the URL in the given node in a block that starts with [[go]], if there is one.""" """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]) return redirect(links[0])
@bp.route('/pull/<node>')
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/<user>') @bp.route('/u/<user>')
@bp.route('/user/<user>') @bp.route('/user/<user>')
@bp.route('/@<user>') @bp.route('/@<user>')
@ -109,17 +113,29 @@ def wikilink(node):
def subnode(subnode): def subnode(subnode):
return render_template('subnode_rendered.html', subnode=db.subnode_by_uri(subnode), backlinks=db.subnodes_by_outlink(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/<query>') # @bp.route('/search/<query>')
# def search(query): # def search(query):
# return render_template('subnodes.html', subnodes=db.search_subnodes(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/<user>/<asset>') @bp.route('/asset/<user>/<asset>')
def asset(user, asset): def asset(user, asset):