Skip to content

Commit

Permalink
v2: enclosures on entries page. #318
Browse files Browse the repository at this point in the history
  • Loading branch information
lemon24 committed Jan 6, 2025
1 parent 923844e commit bbaa312
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
1 change: 0 additions & 1 deletion src/reader/_app/v2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ def entries():
# TODO: pagination
# TODO: read time
# TODO: mark as ...
# TODO: enclosures

form = EntryFilter(request.args)
kwargs = dict(form.data)
Expand Down
11 changes: 10 additions & 1 deletion src/reader/_app/v2/templates/v2/entries.html
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,18 @@ <h2 class="h5 mb-1" style="font-size: 1.125rem">
<button type="submit" class="btn btn-outline-secondary btn-sm" style="width: 2rem">
<i class="bi bi-arrow-down"></i>
</button>

</div>

{% for enclosure in entry.enclosures[:1] -%}
{%- set links = additional_enclosure_links(enclosure, entry) | list -%}
{%- set _ = links.append(('', enclosure.href)) -%}
{%- set link = links[0][1] -%}
<a class="btn text-secondary btn-sm" role="button" target="_blank"
title="{{ enclosure.type }}" href="{{ link }}">
<i class="bi bi-{{ macros.bs_file_icon(enclosure.type) }}"></i>
</a>
{%- endfor %}

</form>

</div>
Expand Down
11 changes: 11 additions & 0 deletions src/reader/_app/v2/templates/v2/macros.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,14 @@
</div>
</fieldset>
{%- endmacro %}


{%- macro bs_file_icon(mimetype) -%}
{%- set type = (mimetype or '').partition('/')[0] -%}
{%- if type == 'audio' -%} file-earmark-music
{%- elif type == 'image' -%} file-earmark-image
{%- elif type == 'video' -%} file-earmark-play
{%- elif type == 'text' -%} file-earmark-text
{%- else -%} file-earmark
{%- endif -%}
{%- endmacro -%}

0 comments on commit bbaa312

Please sign in to comment.