Swap in 'latest' in lieu of 'subnodes', which is made less interesting
by the per-user views. Right now it shows all subnodes in mtime order, but eventually it should only show top N.
This commit is contained in:
parent
f6fad2f95e
commit
ddcdb8de8b
6 changed files with 30 additions and 9 deletions
|
@ -23,7 +23,7 @@ bp = Blueprint('agora', __name__)
|
|||
|
||||
@bp.route('/')
|
||||
def index():
|
||||
return render_template('index.html', version=config.AGORA_VERSION, help=url_for('agora.help'), nodes=url_for('agora.nodes'), subnodes=url_for('agora.subnodes'), users=url_for('agora.users'), journals=url_for('agora.journals'), search=url_for('agora.search'))
|
||||
return render_template('index.html', version=config.AGORA_VERSION, help=url_for('agora.help'), nodes=url_for('agora.nodes'), subnodes=url_for('agora.subnodes'), users=url_for('agora.users'), journals=url_for('agora.journals'), search=url_for('agora.search'), latest=url_for('agora.latest'))
|
||||
|
||||
@bp.route('/help')
|
||||
def help():
|
||||
|
@ -39,13 +39,17 @@ def nodes():
|
|||
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', nodes=db.all_journals())
|
||||
return render_template('nodes.html', header="Journals", nodes=db.all_journals())
|
||||
|
||||
@bp.route('/today')
|
||||
def today():
|
||||
|
|
10
app/db.py
10
app/db.py
|
@ -77,6 +77,7 @@ class Subnode:
|
|||
self.user = path_to_user(path)
|
||||
with open(path) as f:
|
||||
self.content = f.read()
|
||||
self.mtime = os.path.getmtime(path)
|
||||
self.outlinks = content_to_outlinks(self.content)
|
||||
self.node = self.wikilink
|
||||
# Initiate node for wikilink if this is the first subnode, append otherwise.
|
||||
|
@ -124,9 +125,16 @@ def content_to_outlinks(content):
|
|||
else:
|
||||
return []
|
||||
|
||||
def all_subnodes():
|
||||
def all_subnodes(sort=True):
|
||||
subnodes = [Subnode(f) for f in glob.glob(os.path.join(config.AGORA_PATH, '**/*.md'), recursive=True)]
|
||||
if sort:
|
||||
return sorted(subnodes, key=lambda x: x.uri.lower())
|
||||
else:
|
||||
return subnodes
|
||||
|
||||
def latest():
|
||||
subnodes = all_subnodes(sort=False)
|
||||
return sorted(subnodes, key=lambda x: -x.mtime)
|
||||
|
||||
def all_nodes(include_journals=True):
|
||||
# first we fetch all subnodes, put them in a dict {wikilink -> [subnode]}.
|
||||
|
|
|
@ -31,9 +31,9 @@
|
|||
</span>
|
||||
<span align=left>
|
||||
<a href="/nodes">nodes</a>
|
||||
| <a href="/subnodes">subnodes</a>
|
||||
| <a href="/journals">journals</a>
|
||||
| <a href="/users">users</a>
|
||||
| <a href="/latest">latest</a>
|
||||
| <a href="/search">search</a>
|
||||
</span>
|
||||
<span style="vertical-align: bottom; float:right">
|
||||
|
|
|
@ -23,10 +23,10 @@ This is the <strong>Agora v{{version}}</strong>.<br />
|
|||
<br />
|
||||
This site is very much under construction, but feel free to look around:
|
||||
<ul>
|
||||
<li><a href="{{nodes}}">{{nodes}}</a> lists all nodes in this Agora; a node is the set of all subnodes with a given title, or otherwise about the same entity. Subnodes can come from a variety of sources.</li>
|
||||
<li><a href="{{subnodes}}">{{subnodes}}</a> lists all subnodes in this Agora; currently these are mostly notes as volunteered by users.</li>
|
||||
<li><a href="{{journals}}">{{journals}}</a> displays all journal entries (these are notes matching YYYY-MM-DD).</li>
|
||||
<li><a href="{{users}}">{{users}}</a> displays all users in this Agora, click through to see their subnodes.</li>
|
||||
<li><a href="{{nodes}}">{{nodes}}</a> lists all non-journal nodes in this Agora; a node is the set of all subnodes with a given title, or otherwise about the same entity. Subnodes can come from a variety of sources; currently these are mostly notes as volunteered by users.</li>
|
||||
<li><a href="{{journals}}">{{journals}}</a> displays all journal entries (these are just nodes matching YYYY-MM-DD).</li>
|
||||
<li><a href="{{users}}">{{users}}</a> displays all users in this Agora. Click through to see their subnodes.</li>
|
||||
<li><a href="{{subnodes}}">{{latest}}</a> shows which subnodes were added or modified recently.</li>
|
||||
<li><a href="{{search}}">{{search}}</a> offers full text search over all subnodes (supports regexes).</li>
|
||||
</ul>
|
||||
|
||||
|
|
|
@ -17,7 +17,11 @@
|
|||
{% extends "base.html" %}
|
||||
{% block content %}
|
||||
<div class="listing">
|
||||
{% if header %}
|
||||
<h1> {{header}} </h1>
|
||||
{% else %}
|
||||
<h1> Nodes </h1>
|
||||
{% endif %}
|
||||
{% for node in nodes %}
|
||||
<a href="{{node.url}}">{{node.wikilink}}</a> ({{node.size()}})<br />
|
||||
{% endfor %}
|
||||
|
|
|
@ -17,7 +17,12 @@
|
|||
{% extends "base.html" %}
|
||||
{% block content %}
|
||||
<div class="listing">
|
||||
{% if header %}
|
||||
<h1> {{header}} </h1>
|
||||
{% else %}
|
||||
<h1> Subnodes </h1>
|
||||
{% endif %}
|
||||
|
||||
{% if not subnodes %}
|
||||
No subnodes found for the given term or path.
|
||||
<br /><br />
|
||||
|
|
Loading…
Reference in a new issue