Skip to content

Commit bbaa312

Browse files
committedJan 6, 2025·
v2: enclosures on entries page. #318
1 parent 923844e commit bbaa312

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed
 

‎src/reader/_app/v2/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ def entries():
2525
# TODO: pagination
2626
# TODO: read time
2727
# TODO: mark as ...
28-
# TODO: enclosures
2928

3029
form = EntryFilter(request.args)
3130
kwargs = dict(form.data)

‎src/reader/_app/v2/templates/v2/entries.html

+10-1
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,18 @@ <h2 class="h5 mb-1" style="font-size: 1.125rem">
110110
<button type="submit" class="btn btn-outline-secondary btn-sm" style="width: 2rem">
111111
<i class="bi bi-arrow-down"></i>
112112
</button>
113-
114113
</div>
115114

115+
{% for enclosure in entry.enclosures[:1] -%}
116+
{%- set links = additional_enclosure_links(enclosure, entry) | list -%}
117+
{%- set _ = links.append(('', enclosure.href)) -%}
118+
{%- set link = links[0][1] -%}
119+
<a class="btn text-secondary btn-sm" role="button" target="_blank"
120+
title="{{ enclosure.type }}" href="{{ link }}">
121+
<i class="bi bi-{{ macros.bs_file_icon(enclosure.type) }}"></i>
122+
</a>
123+
{%- endfor %}
124+
116125
</form>
117126

118127
</div>

‎src/reader/_app/v2/templates/v2/macros.html

+11
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,14 @@
3434
</div>
3535
</fieldset>
3636
{%- endmacro %}
37+
38+
39+
{%- macro bs_file_icon(mimetype) -%}
40+
{%- set type = (mimetype or '').partition('/')[0] -%}
41+
{%- if type == 'audio' -%} file-earmark-music
42+
{%- elif type == 'image' -%} file-earmark-image
43+
{%- elif type == 'video' -%} file-earmark-play
44+
{%- elif type == 'text' -%} file-earmark-text
45+
{%- else -%} file-earmark
46+
{%- endif -%}
47+
{%- endmacro -%}

0 commit comments

Comments
 (0)
Please sign in to comment.