cleanup, add macro render_communityname

This commit is contained in:
Hendrik L 2024-07-04 14:26:18 +02:00
parent e153b177a0
commit 4c0eb87c25
11 changed files with 23 additions and 27 deletions

View file

@ -31,9 +31,7 @@
{% for community in communities.items %}
<tr>
<td><a href="/c/{{ community.link() }}">{{ community.name }}</a></td>
<td><a href="/c/{{ community.link() }}">
<img src="{{ community.icon_image('tiny') }}" class="community_icon rounded-circle" loading="lazy" />
{{ community.display_name() }}{% if community.banned %} (banned){% endif %}</a></td>
<td>{{ render_communityname(community) }}{% if community.banned %} (banned){% endif %}</td>
<td>{{ community.topic.name }}</td>
<td>{{ community.post_count }}</td>
<th>{{ '&check;'|safe if community.show_home else '&cross;'|safe }}</th>

View file

@ -26,6 +26,16 @@
{% endif -%}
</span>
{% endmacro -%}
{% macro render_communityname(community) -%}
<span class="render_community">
<a href="/c/{{ community.link() }}" aria-label="{{ _('Go to community %(name)s', name=community.name) }}">
{% if community.icon_id and not low_bandwidth and not collapsed -%}
<img src="{{ community.icon_image() }}" class="community_icon rounded-circle" alt="" loading="lazy" />
{% endif -%}
c/{{ community.display_name() }}
</a>
</span>
{% endmacro -%}
<!doctype html>
<html lang="en">
<head>

View file

@ -25,8 +25,7 @@
<div class="card-title">{{ _('Found a community:') }}</div>
<div class="card-body">
<p>
<a href="/c/{{ new_community.link() }}"><img src="{{ new_community.icon_image()}}" class="community_icon rounded-circle" style="width: 30px; vertical-align: middle;" /></a>
<a href="/c/{{ new_community.link() }}">{{ new_community.title }}@{{ new_community.ap_domain }}</a>
{{ render_communityname(new_community) }}
</p>
<p> {% if subscribed %}
<a class="btn btn-primary mt-4" href="/community/{{ new_community.link() }}/unsubscribe">{{ _('Leave') }}</a>

View file

@ -170,9 +170,7 @@
<ul class="list-group list-group-flush">
{% for community in related_communities -%}
<li class="list-group-item">
<a href="/c/{{ community.link() }}" aria-label="{{ _('Go to community') }}"><img src="{{ community.icon_image() }}" class="community_icon rounded-circle" loading="lazy" alt="" />
{{ community.display_name() }}
</a>
{{ render_communityname(community) }}
</li>
{% endfor -%}
</ul>

View file

@ -14,8 +14,7 @@
<div class="card-title">{{ _('Found a community:') }}</div>
<div class="card-body">
<p>
<a href="/c/{{ new_community.link() }}"><img src="{{ new_community.icon_image()}}" class="community_icon rounded-circle" style="width: 30px; vertical-align: middle;" /></a>
<a href="/c/{{ new_community.link() }}">{{ new_community.title }}@{{ new_community.ap_domain }}</a>
{{ render_communityname(new_community) }}
</p>
<p> {% if subscribed %}
<a class="btn btn-primary mt-4" href="/community/{{ new_community.link() }}/unsubscribe">{{ _('Leave') }}</a>

View file

@ -53,9 +53,7 @@
<ul class="list-group list-group-flush">
{% for community in active_communities %}
<li class="list-group-item">
<a href="/c/{{ community.link() }}"><img src="{{ community.icon_image() }}" class="community_icon rounded-circle" loading="lazy" alt="" />
{{ community.display_name() }}
</a>
{{ render_communityname(community) }}
</li>
{% endfor %}
</ul>

View file

@ -193,9 +193,7 @@
<ul class="list-group list-group-flush">
{% for community in related_communities -%}
<li class="list-group-item">
<a href="/c/{{ community.link() }}" aria-label="{{ _('Go to community') }}"><img src="{{ community.icon_image() }}" class="community_icon rounded-circle" loading="lazy" alt="" />
{{ community.display_name() }}
</a>
{{ render_communityname(community) }}
</li>
{% endfor -%}
</ul>

View file

@ -51,9 +51,7 @@
<ul class="list-group list-group-flush">
{% for community in active_communities %}
<li class="list-group-item">
<a href="/c/{{ community.link() }}"><img src="{{ community.icon_image() }}" class="community_icon rounded-circle" loading="lazy" alt="" />
{{ community.display_name() }}
</a>
{{ render_communityname(community) }}
</li>
{% endfor %}
</ul>

View file

@ -92,9 +92,7 @@
<ul class="list-group list-group-flush">
{% for community in topic_communities %}
<li class="list-group-item">
<a href="/c/{{ community.link() }}" aria-label="{{ _('Go to community') }}"><img src="{{ community.icon_image() }}" class="community_icon rounded-circle" loading="lazy" alt="" />
{{ community.display_name() }}
</a>
{{ render_communityname(community) }}
</li>
{% endfor %}
</ul>

View file

@ -71,7 +71,7 @@
<ul>
{% for community in subscribed %}
<li>
<a href="/c/{{ community.link() }}"><img src="{{ community.icon_image() }}" class="community_icon rounded-circle" loading="lazy" />{{ community.display_name() }}</a>
{{ render_communityname(community) }}
</li>
{% endfor %}
</ul>
@ -81,7 +81,7 @@
<ul>
{% for community in moderates %}
<li>
<a href="/c/{{ community.link() }}"><img src="{{ community.icon_image() }}" class="community_icon rounded-circle" loading="lazy" />{{ community.display_name() }}</a>
{{ render_communityname(community) }}
</li>
{% endfor %}
</ul>

View file

@ -171,7 +171,7 @@
<ul class="list-group list-group-flush">
{% for community in subscribed %}
<li class="list-group-item">
<a href="/c/{{ community.link() }}"><img src="{{ community.icon_image() }}" class="community_icon rounded-circle" loading="lazy" />{{ community.display_name() }}</a>
{{ render_communityname(community) }}
</li>
{% endfor %}
</ul>
@ -181,7 +181,7 @@
<ul class="list-group list-group-flush">
{% for community in moderates %}
<li class="list-group-item">
<a href="/c/{{ community.link() }}"><img src="{{ community.icon_image() }}" class="community_icon rounded-circle" loading="lazy" />{{ community.display_name() }}</a>
{{ render_communityname(community) }}
</li>
{% endfor %}
</ul>