pyfedi/app/templates/list_communities.html
2023-12-22 14:05:39 +13:00

70 lines
3.5 KiB
HTML

{% extends "base.html" %}
{% from 'bootstrap5/form.html' import render_form %}
{% block app_content %}
<div class="row g-2 justify-content-between mt-2">
<div class="col-auto">
<div class="btn-group">
<a href="/communities" class="btn {{ 'btn-primary' if request.path == '/communities' else 'btn-outline-secondary' }}">
{{ _('All') }}
</a>
<a href="/communities/local" class="btn {{ 'btn-primary' if request.path == '/communities/local' else 'btn-outline-secondary' }}">
{{ _('Local') }}
</a>
<a href="/communities/subscribed" class="btn {{ 'btn-primary' if request.path == '/communities/subscribed' else 'btn-outline-secondary' }}">
{{ _('Subscribed') }}
</a>
</div>
</div>
<div class="col-auto">
<div class="btn-group">
<a href="{{ url_for('community.add_local') }}" class="btn btn-outline-secondary">{{ _('Create local') }}</a>
<a href="{{ url_for('community.add_remote') }}" class="btn btn-outline-secondary">{{ _('Add remote') }}</a>
</div>
<form method="get" action="/communities">
<input name='search' type="search" placeholder="Find a community" class="form-control" value="{{ search }}" />
</form>
</div>
</div>
{% if len(communities) > 0 %}
<div class="table-responsive-md">
<table class="communities_table table table-striped table-hover w-100">
<thead>
<tr>
<th scope="col" colspan="2">{{ _('Community') }}</th>
<th scope="col">{{ _('Posts') }}</th>
<th scope="col">{{ _('Comments') }}</th>
<th scope="col">{{ _('Active') }}</th>
<th scope="col">{{ _('Actions') }}</th>
</tr>
</thead>
<tbody>
{% for community in communities %}
<tr class="">
<td width="46"><a href="/c/{{ community.link() }}"><img src="{{ community.icon_image('tiny') }}" class="community_icon rounded-circle" loading="lazy" /></a></td>
<td scope="row" class="pl-0"><a href="/c/{{ community.link() }}">{{ community.display_name() }}</a></td>
<td>{{ community.post_count }}</td>
<td>{{ community.post_reply_count }}</td>
<td>{{ moment(community.last_active).fromNow(refresh=True) }}</td>
<td>{% if current_user.is_authenticated %}
{% if community_membership(current_user, community) in [SUBSCRIPTION_MEMBER, SUBSCRIPTION_OWNER] %}
<a class="btn btn-primary btn-sm" href="/community/{{ community.link() }}/unsubscribe">Unsubscribe</a>
{% elif community_membership(current_user, community) == SUBSCRIPTION_PENDING %}
<a class="btn btn-outline-secondary btn-sm" href="/community/{{ community.link() }}/unsubscribe">Pending</a>
{% else %}
<a class="btn btn-primary btn-sm" href="/community/{{ community.link() }}/subscribe">Subscribe</a>
{% endif %}
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<p>{{ _('There are no communities yet.') }}</p>
{% endif %}
{% endblock %}