Add unread count to channel links
This commit is contained in:
parent
887a75bb29
commit
40ad075e96
|
@ -115,10 +115,23 @@ def root():
|
||||||
if channels_config_path.exists():
|
if channels_config_path.exists():
|
||||||
channels = json.loads(channels_config_path.read_text(encoding="utf8"))
|
channels = json.loads(channels_config_path.read_text(encoding="utf8"))
|
||||||
|
|
||||||
|
channel_counts = {
|
||||||
|
channel: len(
|
||||||
|
[
|
||||||
|
item
|
||||||
|
for source in sources
|
||||||
|
for item in LocalSource(data_path, source).get_all_items()
|
||||||
|
if not item.is_hidden
|
||||||
|
]
|
||||||
|
)
|
||||||
|
for channel, sources in channels.items()
|
||||||
|
}
|
||||||
|
|
||||||
return render_template(
|
return render_template(
|
||||||
"home.jinja2",
|
"home.jinja2",
|
||||||
sources=sources,
|
sources=sources,
|
||||||
channels=channels,
|
channels=channels,
|
||||||
|
channel_counts=channel_counts,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,13 @@ summary:focus {
|
||||||
<p>No channels found.</p>
|
<p>No channels found.</p>
|
||||||
{% else %}
|
{% else %}
|
||||||
{% for channel in channels %}
|
{% for channel in channels %}
|
||||||
<p><a href="{{ url_for('channel_feed', name=channel) }}">{{ channel }}</a></p>
|
<p><a href="{{ url_for('channel_feed', name=channel) }}">
|
||||||
|
{%- if channel_counts[channel] -%}
|
||||||
|
({{ channel_counts[channel] }}) {{ channel }}
|
||||||
|
{%- else -%}
|
||||||
|
{{ channel }}
|
||||||
|
{%- endif -%}
|
||||||
|
</a></p>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<p><a href="{{ url_for('channels_edit') }}">Edit channels</a></p>
|
<p><a href="{{ url_for('channels_edit') }}">Edit channels</a></p>
|
||||||
|
|
Loading…
Reference in New Issue