Files
@ 6f0311367ffd
Branch filter:
Location: FVDE/ennstatus/ennstatus/templates/status/macros.html
6f0311367ffd
4.0 KiB
text/html
Make tables sortable
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | {% macro colorize_status(status) %}
{% if status %}
{% set color = "text-success" %}
{% elif status is none %}
{% set color = "text-warning" %}
{% else %}
{% set color = "text-danger" %}
{% endif %}
<p class={{ color }}>{{ status }}</p>
{% endmacro %}
{% macro colorize_obfs(obfs) %}
{% if obfs %}
{% set color = "text-success" %}
{% else %}
{% set color = "text-danger" %}
{% endif %}
<p class={{ color }}>{{ obfs }}</p>
{% endmacro %}
{% macro create_country(country) %}
{% set country_class = "flag-" + country|lower|replace(' ', '-') %}
<i class={{ country_class }}></i> {{ country|title }}
{% endmacro %}
{% macro create_fingerprint(fingerprint, server_type) %}
{% if server_type in ('exit', 'relay') %}
{% set url_type = 'relay' %}
{% else %}
{% set url_type = 'bridge' %}
{% endif %}
{% if '.onion' in request.url_root %}
{% set url_root = '//%s' % config['ENNSTATUS_GLOBE_ONION_ADDRESS'] %}
{% elif '.bit' in request.url_root %}
{% set url_root = '//%s' % config['ENNSTATUS_GLOBE_BIT_ADDRESS'] %}
{% else %}
{% set url_root = '//globe.enn.lu' %}
{% endif %}
<a href="{{ url_root }}/#/{{ url_type }}/{{ fingerprint }}">{{ fingerprint|upper}}</a>
{% endmacro %}
{% macro create_name(name) %}
<a href="http://{{ name|lower }}.enn.lu">{{ name }}</a>
{% endmacro %}
{% macro create_date(date) %}
{{ moment(date).format(config['ENNSTATUS_MOMENTJS_FORMAT']) }}
<noscript>{{ date.strftime(config['ENNSTATUS_STRFTIME_FORMAT']) }}</noscript>
{% endmacro %}
{% macro create_server_table(server_type, servers) %}
{% if server_type in ('exit', 'relay') %}
{% set headers = ('#', 'Name', 'IP', 'IP6', 'Server Status', 'Tor Status', 'Country', 'Fingerprint', 'Last Updated <noscript>(UTC)</noscript>') %}
{% else %}
{% set headers = ('#', 'Name', 'Server Status', 'Tor Status', 'Country', 'Fingerprint', 'OBFS', 'FTEProxy', 'Flashproxy', 'meek', 'Last Updated <noscript>(UTC)</noscript>') %}
{% endif %}
<h2>{{ server_type.capitalize() }}</h2>
<table class="table table-bordered table-striped sortable">
<thead>
<tr>
{% for name in headers %}
<th>{{ name|safe }}</th>
{% endfor %}
</tr>
</thead>
<tbody>
{% for server in servers|sort(attribute='name')|sort(attribute='country') %}
<tr {% if server.name in config['ENNSTATUS_BRIDGE_PROGRAM'] %}class="info"{% endif %}>
<td>{{ loop.index }}</td>
{% if server_type in ('exit', 'relay') %}
<td>{{ create_name(server.name) }}</td>
<td>{{ server.ip }}</td>
<td>{{ server.ip6 or 'N/A' }}</td>
{% else %}
{% if server.name in config['ENNSTATUS_BRIDGE_PROGRAM'] %}
<td><a href="{{ url_for('root.bridgeprogram') }}">{{ server.name }}</a></td>
{% else %}
<td>{{ server.name }}</td>
{% endif %}
{% endif %}
{% for status in (server.status, server.tor_status) %}
<td>{{ colorize_status(status) }}</td>
{% endfor %}
<td>{{ create_country(server.country) }}</td>
<td>{{ create_fingerprint(server.fingerprint, server.type) }}</td>
{% if server_type == 'bridge' %}
<td>{{ colorize_obfs(server.obfs) }}</td>
<td>{{ colorize_obfs(server.fteproxy) }}</td>
<td>{{ colorize_obfs(server.flashproxy) }}</td>
<td>{{ colorize_obfs(server.meek) }}</td>
{% endif %}
<td>{{ create_date(server.last_updated) }}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% if server_type == 'bridge' %}
<div class="alert alert-info alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
<p>See our <a class="alert-link" href="{{ url_for('root.bridgeprogram') }}">bridge program</a>, if you want to fund some bridges!</p>
</div>
{% endif %}
{% endmacro %}
|