diff --git a/serve.py b/serve.py index e5e3129..618324f 100644 --- a/serve.py +++ b/serve.py @@ -287,6 +287,21 @@ def profile(): context = default_context() return render_template('profile.html', **context) +@app.route('/stats') +def stats(): + context = default_context() + mdb = get_metas() + kv = {k:v for k,v in mdb.items()} # read all of metas to memory at once, for efficiency + tstr = lambda t: time.strftime('%b %d %Y', time.localtime(t)) + context['num_papers'] = len(kv) + if len(kv) > 0: + context['earliest_paper'] = tstr(min(kv.values(), key=lambda x: x['_time'])['_time']) + context['latest_paper'] = tstr(max(kv.values(), key=lambda x: x['_time'])['_time']) + else: + context['earliest_paper'] = 'N/A' + context['latest_paper'] = 'N/A' + return render_template('stats.html', **context) + # ----------------------------------------------------------------------------- # tag related endpoints: add, delete tags for any paper diff --git a/static/style.css b/static/style.css index 6a251f8..5c5da9e 100644 --- a/static/style.css +++ b/static/style.css @@ -4,7 +4,6 @@ body { font-family: sans-serif; line-height: 1.2; } - #header { height: 24px; background-color: #844; @@ -13,6 +12,17 @@ body { padding-left: 10px; border-bottom: 1px solid #622; } +#home-link { + display: inline-block; + } + #stats-link { + float: right; + margin: 0 10px 0 10px; + } + #login-link { + float: right; + margin: 0 10px 0 10px; + } #controls { margin: 10px 40px 0 40px; background-color: #eee; @@ -178,12 +188,6 @@ body { display: inline-block; margin-left: 5px; } -#login-link { - /* position on the right of the header */ - position: absolute; - right: 10px; - top: 10px; -} #profile-warning { margin: 10px; padding: 10px; @@ -234,3 +238,7 @@ body { font-size: 14px; padding: 3px; } +#statswrap { + margin: 10px 40px 0 40px; + font-size: 16px; +} diff --git a/templates/base.html b/templates/base.html index 02f8fdf..7b0fc1f 100644 --- a/templates/base.html +++ b/templates/base.html @@ -20,10 +20,11 @@ var user = {{ user | tojson }}; {% block content %} diff --git a/templates/stats.html b/templates/stats.html new file mode 100644 index 0000000..f588332 --- /dev/null +++ b/templates/stats.html @@ -0,0 +1,16 @@ +{% extends "base.html" %} + +{% block variables %} +{% endblock %} + +{% block content %} +
+
Current database index:
+
Number of papers: {{ num_papers }}
+
Earliest paper: {{ earliest_paper }}
+
Latest paper: {{ latest_paper }}
+
+{% endblock %} + +{% block elements %} +{% endblock %}