diff --git a/sourcing/templates/home.html b/sourcing/templates/home.html index 39b0f21..0bc3eaf 100644 --- a/sourcing/templates/home.html +++ b/sourcing/templates/home.html @@ -1,11 +1,24 @@ {% extends "base.html" %} +{% macro new_buttons() %} +

+new source document +new xanalink +new xanadoc +

+{% endmacro %} + {% block title %}perma.pub{% endblock %} {% block content %} -

{{ self.title() }}

-
+
+
+
+

{{ self.title() }}

+ {{ new_buttons() }} +
+
item type
@@ -13,15 +26,20 @@
{% endfor %} - users
+ user
{% for item_user in users %}
{% endfor %} + link type
+ {% for link_type in link_types %} + +
+ {% endfor %}
{% for doc in docs %} -
+
{{ doc.title() }} — {{ doc.user.username }} — {{ doc.created | datetime }}
@@ -33,18 +51,10 @@
{% endfor %} -
-
-
+ {{ new_buttons() }} -

-new source document -new xanalink -new xanadoc -{# -upload a source document -#} -

+
+ {% endblock %} {% block scripts %} @@ -56,10 +66,13 @@ var element = $('[data-id=' + doc['id'] + ']'); var show_type = document.getElementById('type_' + doc['type']).checked; var show_user = document.getElementById('user_' + doc['user']).checked; - element.toggle(show_type && show_user); + var show_link_type = doc['type'] != 'xanalink' || document.getElementById('link_type_' + doc['link_type']).checked; + element.toggle(show_type && show_user && show_link_type); }); } + $(update_list()); + $('input').change(update_list); diff --git a/sourcing/view.py b/sourcing/view.py index e492ae8..3705712 100644 --- a/sourcing/view.py +++ b/sourcing/view.py @@ -62,11 +62,20 @@ def show_errors(f): @bp.route('/') def home(): docs = Item.query.order_by(Item.created) - docs_info = [{'user': doc.user.username, 'id': doc.id, 'type': doc.type} - for doc in docs] + docs_info = [] + for item in docs: + cur = {'user': item.user.username, 'id': item.id, 'type': item.type} + if item.type == 'xanalink': + cur['link_type'] = item.link_type + docs_info.append(cur) + users = [item_user.username for item_user in User.query] + + link_types = {item['link_type'] for item in docs_info if item.get('link_type')} + return render_template('home.html', docs=docs, + link_types=link_types, docs_info=docs_info, nbsp_at_start=nbsp_at_start, users=users)