Skip to content

Commit

Permalink
some optimisations for details page
Browse files Browse the repository at this point in the history
  • Loading branch information
mrmegatelo committed Dec 18, 2024
1 parent ebf225e commit 38d4888
Showing 1 changed file with 62 additions and 59 deletions.
121 changes: 62 additions & 59 deletions feed/templates/blocks/feed/detail/base.html
Original file line number Diff line number Diff line change
@@ -1,82 +1,85 @@
{% load i18n %}
{% load cache %}

{% if update_list %}
<div {% if oob_value %}hx-swap-oob="{{ oob_value }}"{% endif %}>
{% include 'blocks/feed/list/item.html' with feed_item=object %}
</div>
{% endif %}
<div class="feed-detail-container">
<header class="feed-links-list-item-footer">
<form method="post"
class="feed-links-list-item-controls"
id="feed-item-controls"
hx-target="#feed-detail"
hx-params="*"
>
{% csrf_token %}
{% with subscribers=object.feed.subscribers.all %}
<button class="button button--ghost button--sm feed-links-list-item-controls__button"
title="{% translate 'Like' noop %}"
type="submit"
formaction="{% url 'api_feed_item_toggle_interesting' pk=object.id action='toggle_liked' %}"
hx-post="{% url 'api_feed_item_toggle_interesting' pk=object.id action='toggle_liked' %}"
>
{% cache None feed_item_detail request.user.username is_liked is_disliked %}
<div class="feed-detail-container">
<header class="feed-links-list-item-footer">
<form method="post"
class="feed-links-list-item-controls"
id="feed-item-controls"
hx-target="#feed-detail"
hx-params="*"
>
{% csrf_token %}
{% with subscribers=object.feed.subscribers.all %}
<button class="button button--ghost button--sm feed-links-list-item-controls__button"
title="{% translate 'Like' noop %}"
type="submit"
formaction="{% url 'api_feed_item_toggle_interesting' pk=object.id action='toggle_liked' %}"
hx-post="{% url 'api_feed_item_toggle_interesting' pk=object.id action='toggle_liked' %}"
>
<span class="button__icon {% if user in subscribers and is_liked %}active{% endif %}">
{% if user in subscribers and is_liked %}
{% include 'icons/favorite_filled.svg' %}
{% else %}
{% include 'icons/favorite.svg' %}
{% endif %}
</span>
</button>
<button class="button button--ghost button--sm feed-links-list-item-controls__button"
title="{% translate 'Not interesting' noop %}"
type="submit"
formaction="{% url 'api_feed_item_toggle_interesting' pk=object.id action='toggle_interesting' %}"
hx-post="{% url 'api_feed_item_toggle_interesting' pk=object.id action='toggle_interesting' %}"
>
</button>
<button class="button button--ghost button--sm feed-links-list-item-controls__button"
title="{% translate 'Not interesting' noop %}"
type="submit"
formaction="{% url 'api_feed_item_toggle_interesting' pk=object.id action='toggle_interesting' %}"
hx-post="{% url 'api_feed_item_toggle_interesting' pk=object.id action='toggle_interesting' %}"
>
<span class="button__icon {% if user in subscribers and is_disliked %}active{% endif %}">
{% if user in subscribers and is_disliked %}
{% include 'icons/thumb_down_filled.svg' %}
{% else %}
{% include 'icons/thumb_down.svg' %}
{% endif %}
</span>
</button>
{% endwith %}
</form>
</header>
{% block preview %}
{% if object.preview %}
<section class="feed-detail-section">
<img class="feed-detail-preview"
src="{{ object.preview }}"
alt="{{ object.title }}"
onerror="this.src='{{ object.feed.icon }}'"
/>
</section>
{% endif %}
{% endblock %}
<section class="feed-detail-section">
<h1>
{{ object.title }}&nbsp;
{% if object.has_paid_content %}
<span class="feed-item-feature feed-item-feature--paid"
title="There may be paid content"
>
</button>
{% endwith %}
</form>
</header>
{% block preview %}
{% if object.preview %}
<section class="feed-detail-section">
<img class="feed-detail-preview"
src="{{ object.preview }}"
alt="{{ object.title }}"
onerror="this.src='{{ object.feed.icon }}'"
/>
</section>
{% endif %}
{% endblock %}
<section class="feed-detail-section">
<h1>
{{ object.title }}&nbsp;
{% if object.has_paid_content %}
<span class="feed-item-feature feed-item-feature--paid"
title="There may be paid content"
>
{% include 'icons/paid.svg' %}
</span>
{% endif %}
</h1>
</section>
{% block enclosures %}{% endblock %}
<section class="feed-detail-section feed-detail-description">
{% autoescape off %}
{{ object.description }}
{% endautoescape %}
</section>
<a class="button button--ghost button--sm button--outline" href="{{ object.link }}" target="_blank">
<span class="button__icon">{% include 'icons/link.svg' %}</span>
{% translate 'View on' noop %} <strong>{{ object.feed.domain_name }}</strong>
</a>
</div>
{% endif %}
</h1>
</section>
{% block enclosures %}{% endblock %}
<section class="feed-detail-section feed-detail-description">
{% autoescape off %}
{{ object.description }}
{% endautoescape %}
</section>
<a class="button button--ghost button--sm button--outline" href="{{ object.link }}" target="_blank">
<span class="button__icon">{% include 'icons/link.svg' %}</span>
{% translate 'View on' noop %} <strong>{{ object.feed.domain_name }}</strong>
</a>
</div>
{% endcache %}

0 comments on commit 38d4888

Please sign in to comment.