Skip to content

Commit

Permalink
Add counts to the tag page.
Browse files Browse the repository at this point in the history
For #185.
  • Loading branch information
lemon24 committed Nov 28, 2020
1 parent cec4634 commit 7ec751d
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 18 deletions.
14 changes: 13 additions & 1 deletion src/reader/_app/__init__.py
Expand Up @@ -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)


Expand Down
18 changes: 17 additions & 1 deletion src/reader/_app/static/style.css
Expand Up @@ -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);
}


Expand Down
2 changes: 1 addition & 1 deletion src/reader/_app/templates/entries.html
Expand Up @@ -210,7 +210,7 @@

{% if counts %}
<p>
<abbr title='({{ counts.read }} read, {{ counts.important }} important )'>
<abbr title='({{ counts.read }} read, {{ counts.important }} important)'>
{{ counts.total }} entries
</abbr>
{% endif %}
Expand Down
4 changes: 2 additions & 2 deletions src/reader/_app/templates/feeds.html
Expand Up @@ -64,7 +64,7 @@

{% if counts %}
<p>
<abbr title='({{ counts.broken }} broken, {{ counts.total - counts.updates_enabled }} disabled )'>
<abbr title='({{ counts.broken }} broken, {{ counts.total - counts.updates_enabled }} disabled)'>
{{ counts.total }} feeds
</abbr>
{% endif %}
Expand Down Expand Up @@ -98,7 +98,7 @@ <h2 title="{{ macros.feed_title_secondary(feed) }}">

{% if entry_counts %}
<li>
<abbr title='({{ entry_counts.read }} read, {{ entry_counts.important }} important )'>
<abbr title='({{ entry_counts.read }} read, {{ entry_counts.important }} important)'>
{{ entry_counts.total }} entries
</abbr>
{% endif %}
Expand Down
40 changes: 27 additions & 13 deletions src/reader/_app/templates/tags.html
Expand Up @@ -22,25 +22,39 @@
</div>


<ul>

{% for tag in tags %}
<li id="tag-{{ loop.index }}">
<p>
<a href="{{ url_for('.feeds', tags=[tag] | tojson) }}">feeds</a> or
<a href="{{ url_for('.entries', tags=[tag] | tojson) }}">entries</a>
with
{% if tag is true %} any tags
{% elif tag is false %} no tags
{% else %} <span class="tag">{{ tag }}</span>
{% endif %}
<dl class="tag-list">

{% for tag, feed_counts, entry_counts in tags %}
<dt id="tag-{{ loop.index }}">
{% if tag is true %} <span class="tag-text">any tags</span>
{% elif tag is false %} <span class="tag-text">no tags</span>
{% else %} <span class="tag">{{ tag }}</span>
{% endif %}
</dt>

<dd>
{% if feed_counts %}
<abbr title='({{ feed_counts.broken }} broken, {{ feed_counts.total - feed_counts.updates_enabled }} disabled)'>{{ feed_counts.total }}
{% endif %}
<a href="{{ url_for('.feeds', tags=[tag] | tojson) }}">feeds</a>
{%- if feed_counts %}</abbr>{% endif -%}
,
{% if entry_counts %}
<abbr title='({{ entry_counts.read }} read, {{ entry_counts.important }} important)'>{{ entry_counts.total }}
{% endif %}
<a href="{{ url_for('.entries', tags=[tag] | tojson) }}">entries</a>
{% if entry_counts %}</abbr>{% endif %}
</dd>

{% else %}

{% if not error %}
<p>no tags</p>
{% endif %}

{% endfor %}
</ul>
</dl>



{% endblock %}

0 comments on commit 7ec751d

Please sign in to comment.