Files @ 3abda675c94a
Branch filter:

Location: FVDE/ennstatus/ennstatus/templates/status/macros.html

Dennis Fink
updated ennstatus
{% macro colorize_status(status) %}
  {% if status == "Online" %}
    {% set color = "text-success" %}
  {% elif status == "Unknown" %}
    {% set color = "text-warning" %}
  {% else %}
    {% set color = "text-danger" %}
  {% endif %}
  <p class={{ color }}>{{ status}}</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) %}
  <a href="http://torstatus.enn.lu/#details/{{ fingerprint }}">{{ fingerprint|upper}}</a>
{% endmacro %}

{% macro create_server_table(server_type, servers) %}
  {% if server_type in ('Exit', 'Relay') %}
    {% set headers = ['#', 'Name', 'IP', 'Server Status', 'Tor Status', 'Country', 'Fingerprint', 'Last Updated (UTC)'] %}
  {% else %}
    {% set headers = ['#', 'Name', 'Server Status', 'Tor Status', 'Country', 'OBFS', 'Last Updated (UTC)'] %}
  {% endif %}
  <h2>{{ server_type }}</h2>
  <table class="table table-bordered table-striped">
    <thead>
      <tr>
        {% for name in headers %}
          <th>{{ name }}</th>
        {% endfor %}
      </tr>
    </thead>
    <tbody>
      {% for server in servers %}
        <tr>
          <td>{{ loop.index }}</td>
          <td>{{ server['server_name'] }}</td>
          {% if server_type in ('Exit', 'Relay') %}
            <td>{{ server['ip'] }}</td>
          {% endif %}
          {% for status in [server['server_status'], server['tor_status']] %}
            <td>{{ colorize_status(status) }}</td>
          {% endfor %}
          <td>{{ create_country(server['country']) }}</td>
          {% if server_type in ('Exit', 'Relay') %}
            <td>{{ create_fingerprint(server['fingerprint']) }}</td>
          {% else %}
            <td>{{ server['obfs'] }}</td>
          {% endif %}
          <td>{{ server['last_updated'] }}</td>
        </tr>
      {% endfor %}
    </tbody>
  </table>
{% endmacro %}