aboutsummaryrefslogtreecommitdiff
path: root/allium/templates/relay-list.html
diff options
context:
space:
mode:
authorJordan <me@jordan.im>2020-09-20 23:40:16 -0700
committerJordan <me@jordan.im>2020-09-20 23:40:16 -0700
commit3af4f2023be71ec0fb6ec564515dcaae6a9947a8 (patch)
tree8b0093ec78ac3b8ef0a64daf4235f1bf4e4911a6 /allium/templates/relay-list.html
parente76473531d770279961a84272f14e1930919194c (diff)
downloadallium-3af4f2023be71ec0fb6ec564515dcaae6a9947a8.tar.gz
allium-3af4f2023be71ec0fb6ec564515dcaae6a9947a8.zip
improve readability of templates (as much as one can)
Diffstat (limited to 'allium/templates/relay-list.html')
-rw-r--r--allium/templates/relay-list.html197
1 files changed, 113 insertions, 84 deletions
diff --git a/allium/templates/relay-list.html b/allium/templates/relay-list.html
index dca3d9a..d312af9 100644
--- a/allium/templates/relay-list.html
+++ b/allium/templates/relay-list.html
@@ -1,97 +1,126 @@
-{% extends "skeleton.html" %}
-{% block title %}Tor Relays{% endblock %}
-{% block body %}
-<h2>{% block header %}{% endblock %}</h2>
-<p>{% block description %}{% endblock %}</p>
+{% extends "skeleton.html" -%}
+{% block title -%}Tor Relays{% endblock -%}
+{% block body -%}
+<h2>{% block header -%}{% endblock -%}</h2>
+<p>{% block description -%}{% endblock -%}</p>
<table class="table table-condensed">
- <tr>
- <th></th>
- <th>Nickname</th>
- <th></th>
- <th>Bandwidth</th>
- <th class="visible-md visible-lg">IP Address</th>
- <th>AS Number</th>
- <th>AS Name</th>
- <th>Country</th>
- <th>Platform</th>
- <th>Flags</th>
- <th class="visible-md visible-lg">First Seen</th>
- </tr>
- <tbody>
- {% if is_index %}{% set relay_list = relays.json['relay_subset'][:500] %}
- {% else %}{% set relay_list = relays.json['relay_subset'] %}{% endif %}
- {% for relay in relay_list %}
- <tr>
- {% if relay['observed_bandwidth'] > 1000000 %}
- {% set obs_bandwidth = '%s %s'|format((relay['observed_bandwidth'] / 1000000)|round(2, 'common'), 'MB/s') %}
- {% else %}
- {% set obs_bandwidth = '%s %s'|format((relay['observed_bandwidth'] / 1000)|round(2, 'common'), 'KB/s') %}{% endif %}
+<tr>
+<th></th>
+<th>Nickname</th>
+<th></th>
+<th>Bandwidth</th>
+<th class="visible-md visible-lg">IP Address</th>
+<th>AS Number</th>
+<th>AS Name</th>
+<th>Country</th>
+<th>Platform</th>
+<th>Flags</th>
+<th class="visible-md visible-lg">First Seen</th>
+</tr>
+<tbody>
+{% if is_index -%}{% set relay_list = relays.json['relay_subset'][:500] -%}
+{% else -%}{% set relay_list = relays.json['relay_subset'] -%}{% endif -%}
+{% for relay in relay_list -%}
+<tr>
+{% if relay['observed_bandwidth'] > 1000000 -%}
+{% set obs_bandwidth = '%s %s'|format((relay['observed_bandwidth']
+/ 1000000)|round(2, 'common'), 'MB/s') -%}
+{% else -%}
+{% set obs_bandwidth = '%s %s'|format((relay['observed_bandwidth'] / 1000)|
+round(2, 'common'), 'KB/s') -%}{% endif -%}
- {% if relay['running'] %}
- <td><span class="circle circle-online" title="This relay is online"></span></td>
- {% else %}
- <td><span class="circle circle-offline" title="This relay is offline"></span></td>
- {% endif %}
+{% if relay['running'] -%}
+<td><span class="circle circle-online" title="This relay is online"></span></td>
+{% else -%}
+<td><span class="circle circle-offline" title="This relay is offline"></span>
+</td>
+{% endif -%}
- {% if relay['effective_family']|length > 1 %}
- <td title="{{ relay['nickname']|escape }}"><a href="{{ path_prefix }}relay/{{ relay['fingerprint']|escape }}.html">{{ relay['nickname']|truncate(10)|escape }}</a> (<a href="{{ path_prefix }}family/{{ relay['fingerprint']|escape }}/">{{ relay['effective_family']|length }}</a>)</td>
- {% else %}
- <td title="{{ relay['nickname']|escape }}"><a href="{{ path_prefix}}relay/{{ relay['fingerprint']|escape }}.html">{{ relay['nickname']|truncate(15)|escape }}</a></td>
- {% endif %}
+{% if relay['effective_family']|length > 1 -%}
+<td title="{{ relay['nickname']|escape }}"><a href="{{ path_prefix }}relay/{{
+relay['fingerprint']|escape }}.html">{{ relay['nickname']|truncate(10)|escape
+}}</a> (<a href="{{ path_prefix }}family/{{ relay['fingerprint']|escape }}/">{{
+relay['effective_family']| length }}</a>)</td>
+{% else -%}
+<td title="{{ relay['nickname']|escape }}"><a href="{{ path_prefix}}relay/{{
+relay['fingerprint']|escape }}.html">{{ relay['nickname']|truncate(15)|escape
+}}</a></td>
+{% endif -%}
- {% if key != 'contact' %}
- {% if relay['contact'] %}
- <td><a href="{{ path_prefix }}contact/{{ relay['contact']|hash }}/" title="{{ relay['contact']|escape }}">&#9993;</a></td>
- {% else %}
- <td title="none">&#9993;</td>
- {% endif %}
- {% else %}
- <td title="{{ relay['contact']|escape }}">&#9993;</td>
- {% endif %}
+{% if key != 'contact' -%}
+{% if relay['contact'] -%}
+<td><a href="{{ path_prefix }}contact/{{ relay['contact']|hash }}/" title="{{
+relay['contact']|escape }}">&#9993;</a></td>
+{% else -%}
+<td title="none">&#9993;</td>
+{% endif -%}
+{% else -%}
+<td title="{{ relay['contact']|escape }}">&#9993;</td>
+{% endif -%}
- <td>{{ obs_bandwidth }}</td>
+<td>{{ obs_bandwidth }}</td>
- <td class="visible-md visible-lg"><a href="https://bgp.he.net/ip/{{ relay['or_addresses'][0].split(':', 1)[0]|escape }}">{{ relay['or_addresses'][0].split(':', 1)[0]|escape }}</a></td>
+<td class="visible-md visible-lg"><a href="https://bgp.he.net/ip/{{
+relay['or_addresses'][0].split(':', 1)[0]|escape }}">{{
+relay['or_addresses'][0].split(':', 1)[0]|escape }}</a></td>
- {% if relay['as'] %}{% if key != 'as' %}
- <td><a href="{{ path_prefix }}as/{{ relay['as']|escape }}/">{{ relay['as']|escape }}</a></td>
- {% else %}
- <td>{{ relay['as']|escape }}</td>
- {% endif %}
- {% else %}
- <td>Unknown</td>
- {% endif %}
+{% if relay['as'] -%}
+{% if key != 'as' -%}
+<td><a href="{{ path_prefix }}as/{{ relay['as']|escape }}/">{{
+relay['as']|escape }}</a></td>
+{% else -%}
+<td>{{ relay['as']|escape }}</td>
+{% endif -%}
+{% else -%}
+<td>Unknown</td>
+{% endif -%}
- {% if relay['as_name'] %}
- <td><a href="https://bgp.he.net/{{ relay['as']|escape }}" title="{{ relay['as_name']|escape }}">{{ relay['as_name']|escape|truncate(length=20) }}</a></td>
- {% else %}
- <td>Unknown</td>
- {% endif %}
+{% if relay['as_name'] -%}
+<td><a href="https://bgp.he.net/{{ relay['as']|escape }}" title="{{
+relay['as_name']|escape }}">{{
+relay['as_name']|escape|truncate(length=20) }}</a></td>
+{% else -%}
+<td>Unknown</td>
+{% endif -%}
- {% if relay['country'] %}{% if key != 'country' %}
- <td><a href="{{ path_prefix }}country/{{ relay['country']|escape }}/"><img src="{{ path_prefix }}static/images/cc/{{ relay['country']|escape }}.png" title="{{ relay['country_name']|escape }}" alt="{{ relay['country_name']|escape }}"></a></td>
- {% else %}
- <td><img src="{{ path_prefix }}static/images/cc/{{ relay['country']|escape }}.png" title="{{ relay['country_name']|escape }}" alt="{{ relay['country_name']|escape }}"></td>
- {% endif %}
- {% else %}
- <td>X</td>
- {% endif %}
+{% if relay['country'] -%}
+{% if key != 'country' -%}
+<td><a href="{{ path_prefix }}country/{{ relay['country']|escape }}/"><img
+src="{{ path_prefix }}static/images/cc/{{ relay['country']|escape
+}}.png" title="{{ relay['country_name']|escape }}" alt="{{
+relay['country_name']|escape }}"></a></td>
+{% else -%}
+<td><img src="{{ path_prefix }}static/images/cc/{{ relay['country']|escape
+}}.png" title="{{ relay['country_name']|escape }}" alt="{{
+relay['country_name']|escape }}"></td>
+{% endif -%}
+{% else -%}
+<td>X</td>
+{% endif -%}
- {% if key != 'platform' %}
- <td><a href="{{ path_prefix }}platform/{{ relay['platform']|escape }}/">{{ relay['platform']|truncate(length=10)|escape }}</a></td>
- {% else %}
- <td>{{ relay['platform']|truncate(length=10)|escape }}</td>
- {% endif %}
+{% if key != 'platform' -%}
+<td><a href="{{ path_prefix }}platform/{{ relay['platform']|escape }}/">{{
+relay['platform']|truncate(length=10)|escape }}</a></td>
+{% else -%}
+<td>{{ relay['platform']|truncate(length=10)|escape }}</td>
+{% endif -%}
- <td>{% for flag in relay['flags'] %}{% if flag != 'StaleDesc' %}<a href="{{ path_prefix }}flag/{{ flag.lower()|escape }}"><img src="{{ path_prefix}}static/images/flags/{{ flag.lower()|escape }}.png" title="{{ flag|escape }}" alt="{{ flag|escape }}"></a> {% endif %}{% endfor %}</td>
+<td>{% for flag in relay['flags'] -%}{% if flag != 'StaleDesc' -%}<a href="{{
+path_prefix }}flag/{{ flag.lower()|escape }}"><img src="{{
+path_prefix}}static/images/flags/{{ flag.lower()|escape }}.png"
+title="{{ flag|escape }}" alt="{{ flag|escape }}"></a> {% endif -%}{% endfor
+-%}</td>
- {% if key != 'first_seen' %}
- <td class="visible-md visible-lg"><a href="{{ path_prefix }}first_seen/{{ relay['first_seen'].split(' ', 1)[0]|escape }}">{{ relay['first_seen'].split(' ', 1)[0]|escape }}</a></td>
- {% else %}
- <td class="visible-md visible-lg">{{ relay['first_seen'].split(' ', 1)[0]|escape }}</td>
- {% endif %}
- </tr>
- {% endfor %}
- </tbody>
+{% if key != 'first_seen' -%}
+<td class="visible-md visible-lg"><a href="{{ path_prefix }}first_seen/{{
+relay['first_seen'].split(' ', 1)[0]|escape }}">{{
+relay['first_seen'].split(' ', 1)[0]|escape }}</a></td>
+{% else -%}
+<td class="visible-md visible-lg">{{ relay['first_seen'].split(' ', 1)[0]|escape
+}}</td>
+{% endif -%}
+</tr>
+{% endfor -%}
+</tbody>
</table>
-{% endblock %}
+{% endblock -%}