mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-02-03 00:31:25 -08:00
basic instances page for the public #249
This commit is contained in:
parent
638eac45af
commit
7230cb7b97
2 changed files with 79 additions and 0 deletions
|
@ -322,6 +322,30 @@ def list_subscribed_communities():
|
|||
menu_topics=menu_topics(), site=g.site)
|
||||
|
||||
|
||||
@bp.route('/instances', methods=['GET'])
|
||||
def list_instances():
|
||||
page = request.args.get('page', 1, type=int)
|
||||
search = request.args.get('search', '')
|
||||
low_bandwidth = request.cookies.get('low_bandwidth', '0') == '1'
|
||||
|
||||
instances = Instance.query.order_by(Instance.domain)
|
||||
|
||||
# Pagination
|
||||
instances = instances.paginate(page=page,
|
||||
per_page=250 if current_user.is_authenticated and not low_bandwidth else 50,
|
||||
error_out=False)
|
||||
next_url = url_for('main.list_instances', page=instances.next_num) if instances.has_next else None
|
||||
prev_url = url_for('main.list_instances', page=instances.prev_num) if instances.has_prev and page != 1 else None
|
||||
|
||||
return render_template('list_instances.html', instances=instances,
|
||||
title=_('Instances'), search=search,
|
||||
next_url=next_url, prev_url=prev_url,
|
||||
low_bandwidth=low_bandwidth,
|
||||
moderating_communities=moderating_communities(current_user.get_id()),
|
||||
joined_communities=joined_communities(current_user.get_id()),
|
||||
menu_topics=menu_topics(), site=g.site)
|
||||
|
||||
|
||||
@bp.route('/modlog', methods=['GET'])
|
||||
def modlog():
|
||||
page = request.args.get('page', 1, type=int)
|
||||
|
|
55
app/templates/list_instances.html
Normal file
55
app/templates/list_instances.html
Normal file
|
@ -0,0 +1,55 @@
|
|||
{% if theme() and file_exists('app/templates/themes/' + theme() + '/base.html') %}
|
||||
{% extends 'themes/' + theme() + '/base.html' %}
|
||||
{% else %}
|
||||
{% extends "base.html" %}
|
||||
{% endif %} %}
|
||||
{% from 'bootstrap/form.html' import render_form %}
|
||||
|
||||
{% block app_content %}
|
||||
<div class="row">
|
||||
<div class="col-12 col-md-8 position-relative main_pane">
|
||||
{% if search == '' %}
|
||||
<h1>{{ _('Instances') }}</h1>
|
||||
{% else %}
|
||||
<h1>{{ _('Instances containing "%(search)s"', search=search) }}</h1>
|
||||
{% endif %}
|
||||
|
||||
<div class="table-responsive-sm pt-4">
|
||||
<table class="table table-striped">
|
||||
<tr>
|
||||
<th>{{ _('Instance') }}</th>
|
||||
<th>{{ _('Software') }}</th>
|
||||
<th>{{ _('Version') }}</th>
|
||||
<th>{{ _('Heard from') }}</th>
|
||||
<th>{{ _('Sent to') }}</th>
|
||||
</tr>
|
||||
{% for instance in instances %}
|
||||
<tr>
|
||||
<td><a href="https://{{ instance.domain }}" rel="noopener nofollow noindex noreferrer">{{ instance.domain }}</a></td>
|
||||
<td>{{ instance.software }}</td>
|
||||
<td>{{ instance.version }}</td>
|
||||
<td>{{ arrow.get(instance.last_seen).humanize(locale=locale) if instance.last_seen }}</td>
|
||||
<td>{{ arrow.get(instance.last_successful_send).humanize(locale=locale) if instance.last_successful_send }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
</div>
|
||||
<nav aria-label="Pagination" class="mt-4" role="navigation">
|
||||
{% if prev_url %}
|
||||
<a href="{{ prev_url }}" class="btn btn-primary" rel="nofollow">
|
||||
<span aria-hidden="true">←</span> {{ _('Previous page') }}
|
||||
</a>
|
||||
{% endif %}
|
||||
{% if next_url %}
|
||||
<a href="{{ next_url }}" class="btn btn-primary" rel="nofollow">
|
||||
{{ _('Next page') }} <span aria-hidden="true">→</span>
|
||||
</a>
|
||||
{% endif %}
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
{% endblock %}
|
||||
|
Loading…
Add table
Reference in a new issue