From d98fb246c08788ecfc292957ec8adc6618257334 Mon Sep 17 00:00:00 2001 From: Tim Van Baak Date: Tue, 17 Dec 2019 09:29:24 -0800 Subject: [PATCH] Improve feed control item --- inquisitor/app.py | 33 ++++++++++++++++++++++--------- inquisitor/resources/feed.css | 4 ++++ inquisitor/templates/feed.html | 36 ++++++++++++---------------------- 3 files changed, 40 insertions(+), 33 deletions(-) diff --git a/inquisitor/app.py b/inquisitor/app.py index 12b4c5d..7ebf5fb 100644 --- a/inquisitor/app.py +++ b/inquisitor/app.py @@ -42,10 +42,13 @@ def root(): total = 0 items, errors = loader.load_active_items() active_items = [] - active_tags = set() + active_tags = {} for item in items: if item['active']: - active_tags |= set(item['tags']) + for tag in item['tags']: + if tag not in active_tags: active_tags[tag] = 0 + active_tags[tag] += 1 + # active_tags |= set(item['tags']) total += 1 if not any(map(lambda f: f(item), filters)): active_items.append(item) @@ -63,16 +66,28 @@ def root(): if total > 0: # Create the feed control item - wl_minus = [make_query_link("only - {}".format(tag), [t for t in wl if t != tag], bl) for tag in wl] - wl_plus = [make_query_link("only + {}".format(tag), wl + [tag], bl) for tag in active_tags if tag not in wl] - bl_minus = [make_query_link("not - {}".format(tag), wl, [t for t in bl if t != tag]) for tag in bl] - bl_plus = [make_query_link("not + {}".format(tag), wl, bl + [tag]) for tag in active_tags if tag not in bl] - body = "
{}
".format("\n".join(wl_minus + wl_plus + bl_minus + bl_plus)) + link_table = [] + for tag, count in sorted(active_tags.items()): + links = [count] + links.append(make_query_link(tag, [tag], [])) + if tag in wl: + new_wl = [t for t in wl if t != tag] + links.append(make_query_link("-only", new_wl, bl)) + else: + new_bl = [t for t in bl if t != tag] + links.append(make_query_link("+only", wl + [tag], new_bl)) + if tag in bl: + new_bl = [t for t in bl if t != tag] + links.append(make_query_link("-not", wl, new_bl)) + else: + new_wl = [t for t in wl if t != tag] + links.append(make_query_link("+not", new_wl, bl + [tag])) + link_table.append("{0}{1}{2}{3}".format(*links)) + body = '{}
'.format("\n".join(link_table)) feed_control = { - 'title': 'Feed Control [{}]'.format(total), + 'title': 'Feed Control [{}/{}]'.format(len(active_items), total), 'body': body, - 'created': None, } active_items.insert(0, feed_control) diff --git a/inquisitor/resources/feed.css b/inquisitor/resources/feed.css index 356a355..b533f0f 100644 --- a/inquisitor/resources/feed.css +++ b/inquisitor/resources/feed.css @@ -43,4 +43,8 @@ summary:focus { } pre { white-space: pre-wrap; +} +table.feed-control td /*:nth-child(2), td:nth-child(3), td:nth-child(4)*/ { + font-family: monospace; + padding: 5px 10px; } \ No newline at end of file diff --git a/inquisitor/templates/feed.html b/inquisitor/templates/feed.html index 6796bd4..a2cf0c8 100644 --- a/inquisitor/templates/feed.html +++ b/inquisitor/templates/feed.html @@ -26,37 +26,25 @@ {% if items %} {% for item in items %}
- {% if item.id %} - - {% endif %} - {% if item.link %} - - {% endif %} - {% if item.body %} -
+ {% if item.id %}{% endif %} + {% if item.link %}{% endif %} + {% if item.body %}
{{item.title}}

{{item.body|safe}}

- {% else %} - {{item.title}}
+ {% else %}{{item.title}}
{% endif %} - {% if item.author or item.time %} - - {% if item.author %} - {{item.author}} - {% endif %} - {% if item.time %} - {{item.time|datetimeformat}} - {% endif %} + {% if item.author or item.time %} + {% if item.author %}{{item.author}}{% endif %} + {% if item.time %}{{item.time|datetimeformat}}{% endif %}
{% endif %} - - {{item.source}} - {% if item.id %} - {{item.id}} - {% endif %} - {{item.created|datetimeformat}} + {% if item.source or item.id or item.created %} + {% if item.source %}{{item.source}}{% endif %} + {% if item.id %}{{item.id}}{% endif %} + {% if item.created %}{{item.created|datetimeformat}}{% endif %} + {% endif %}
{% endfor %} {% else %}