From 7ec751d40ba7a294ec9b95bceaee15024dc4a29b Mon Sep 17 00:00:00 2001 From: lemon24 Date: Sat, 28 Nov 2020 17:44:59 +0200 Subject: [PATCH] Add counts to the tag page. For #185. --- src/reader/_app/__init__.py | 14 ++++++++- src/reader/_app/static/style.css | 18 +++++++++++- src/reader/_app/templates/entries.html | 2 +- src/reader/_app/templates/feeds.html | 4 +-- src/reader/_app/templates/tags.html | 40 +++++++++++++++++--------- 5 files changed, 60 insertions(+), 18 deletions(-) diff --git a/src/reader/_app/__init__.py b/src/reader/_app/__init__.py index 18c58d3d..5aeb457a 100644 --- a/src/reader/_app/__init__.py +++ b/src/reader/_app/__init__.py @@ -402,7 +402,19 @@ def entry(): @blueprint.route('/tags') def tags(): reader = get_reader() - tags = itertools.chain([True, False], reader.get_feed_tags()) + + with_counts = request.args.get('counts') + with_counts = {None: None, 'no': False, 'yes': True}[with_counts] + + tags = ( + ( + tag, + reader.get_feed_counts(tags=[tag]) if with_counts else None, + reader.get_entry_counts(feed_tags=[tag]) if with_counts else None, + ) + for tag in itertools.chain([True, False], reader.get_feed_tags()) + ) + return render_template('tags.html', tags=tags) diff --git a/src/reader/_app/static/style.css b/src/reader/_app/static/style.css index cd6dcfe7..04d0fddf 100644 --- a/src/reader/_app/static/style.css +++ b/src/reader/_app/static/style.css @@ -157,9 +157,25 @@ ul.controls .collapsible { } +.tag-list dt { + clear: left; + float: left; + min-width: 8em; +} +.tag-list dd { + display: inline; + margin-left: 1em; +} +.tag-list dd::after { + content: ""; + display: block; + height: 1em; +} + + abbr[title]:hover::after, abbr[title]:focus::after { - content: attr(title); + content: " " attr(title); } diff --git a/src/reader/_app/templates/entries.html b/src/reader/_app/templates/entries.html index b606df90..aaf993d7 100644 --- a/src/reader/_app/templates/entries.html +++ b/src/reader/_app/templates/entries.html @@ -210,7 +210,7 @@ {% if counts %}

- + {{ counts.total }} entries {% endif %} diff --git a/src/reader/_app/templates/feeds.html b/src/reader/_app/templates/feeds.html index f65e8604..2599074a 100644 --- a/src/reader/_app/templates/feeds.html +++ b/src/reader/_app/templates/feeds.html @@ -64,7 +64,7 @@ {% if counts %}

- + {{ counts.total }} feeds {% endif %} @@ -98,7 +98,7 @@

{% if entry_counts %}
  • - + {{ entry_counts.total }} entries {% endif %} diff --git a/src/reader/_app/templates/tags.html b/src/reader/_app/templates/tags.html index 47e64486..6d4943cc 100644 --- a/src/reader/_app/templates/tags.html +++ b/src/reader/_app/templates/tags.html @@ -22,18 +22,30 @@ -
      - -{% for tag in tags %} -
    • -

      - feeds or - entries - with - {% if tag is true %} any tags - {% elif tag is false %} no tags - {% else %} {{ tag }} - {% endif %} +

      + +{% for tag, feed_counts, entry_counts in tags %} +
      + {% if tag is true %} any tags + {% elif tag is false %} no tags + {% else %} {{ tag }} + {% endif %} +
      + +
      + {% if feed_counts %} + {{ feed_counts.total }} + {% endif %} + feeds + {%- if feed_counts %}{% endif -%} + , + {% if entry_counts %} + {{ entry_counts.total }} + {% endif %} + entries + {% if entry_counts %}{% endif %} +
      + {% else %} {% if not error %} @@ -41,6 +53,8 @@ {% endif %} {% endfor %} -
    + + + {% endblock %}