From eebce42d74f8c0e5176bf0a0cfa8036f88a3da34 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Fri, 22 Feb 2019 14:28:27 -0800 Subject: rework container page (search, stats) --- python/fatcat_web/routes.py | 13 ++++++++- python/fatcat_web/templates/container_view.html | 39 ++++++++++++++++++++++--- 2 files changed, 47 insertions(+), 5 deletions(-) (limited to 'python') diff --git a/python/fatcat_web/routes.py b/python/fatcat_web/routes.py index 693adf25..acc4b3e2 100644 --- a/python/fatcat_web/routes.py +++ b/python/fatcat_web/routes.py @@ -87,13 +87,24 @@ def container_view(ident): entity = api.get_container(ident) except ApiException as ae: abort(ae.status) + + if entity.issnl: + try: + stats = get_elastic_container_stats(entity.issnl) + except Exception as e: + stats = None + print(e) + else: + stats = None + if entity.state == "redirect": return redirect('/container/{}'.format(entity.redirect)) if entity.state == "deleted": return render_template('deleted_entity.html', entity=entity) if entity.state == "active": entity.es = container_to_elasticsearch(entity, force_bool=False) - return render_template('container_view.html', container=entity) + return render_template('container_view.html', + container=entity, container_stats=stats) @app.route('/creator//history', methods=['GET']) def creator_history(ident): diff --git a/python/fatcat_web/templates/container_view.html b/python/fatcat_web/templates/container_view.html index ffe01185..1d237023 100644 --- a/python/fatcat_web/templates/container_view.html +++ b/python/fatcat_web/templates/container_view.html @@ -13,17 +13,37 @@
-

Publisher: -{% if container.publisher != None %}{{ container.publisher }}{% else %}Unknown{% endif %} +

{% if (container.extra != None) and (container.extra['urls'] != None) and (container.extra['urls']|length > 0) %} -
Homepage:  {{ container.extra['urls'][0] }} + {{ container.extra['urls'][0] }}
+{% endif %} +{% if container.publisher != None %} + Published by {{ container.publisher }} +{% endif %} + +{% if container.issnl %} +

Search Releases from this Container

+
+
+
+ + + +
+
+
{% endif %} {% if container.extra %}

Extra Metadata (raw JSON)

+ + {% for (key, value) in container.extra.items() %} -{{ key }}: {{ value }}
+ + +
{{ key }}{{ value }} {% endfor %} +
{% endif %}