mirror of
https://github.com/4cuck/nitter-status.git
synced 2026-10-27 00:57:39 +00:00
1 parent
533cc753db
commit
bc156af23e
17 files changed
+284
-52
No files matched your search
@@ -32,6 +32,7 @@ pub async fn instances(
|
||||
}
|
||||
|
||||
pub async fn about(
|
||||
State(ref cache): State<Cache>,
|
||||
State(ref template): State<Arc<tera::Tera>>,
|
||||
State(ref scanner_config): State<ScannerConfig>,
|
||||
) -> Result<axum::response::Response> {
|
||||
@@ -53,6 +54,10 @@ pub async fn about(
|
||||
"ping_avg_interval_h",
|
||||
&scanner_config.ping_range.num_hours(),
|
||||
);
|
||||
{
|
||||
let guard = cache.read().map_err(|_| ServerError::MutexFailure)?;
|
||||
context.insert("latest_commit", &guard.latest_commit);
|
||||
}
|
||||
|
||||
let mut res = Html(template.render("about.html.j2", &context)?).into_response();
|
||||
res.headers_mut().insert(
|
||||
|
||||
@@ -14,12 +14,13 @@
|
||||
<p><a href="/">Home</a></p>
|
||||
<p>Uptime check interval: {{uptime_interval_s}}s.</p>
|
||||
<p>Instance re-fetching interval, including RSS & version check: {{wiki_interval_s}}s.</p>
|
||||
<p>Fetched latest commit: {{latest_commit}}</p>
|
||||
|
||||
<p>The following paths are checked per instance:</p>
|
||||
<ul>
|
||||
{% for path in checked_paths %}
|
||||
{%- for path in checked_paths %}
|
||||
<li><code>{{path}}</code></li>
|
||||
{% endfor %}
|
||||
{%- endfor %}
|
||||
</ul>
|
||||
|
||||
<p>The same data can also be fetched as JSON from <code>/api/v1/instances</code></p>
|
||||
|
||||
@@ -30,64 +30,81 @@
|
||||
{% for host in instances -%}
|
||||
<tr>
|
||||
<td><a href="{{host.url}}">{{host.domain}}</a></td>
|
||||
<td>{% if host.healthy -%} ✅ {% else -%} ❌ {% endif -%}</td>
|
||||
<td>{% if host.healthy -%} ✅ {%- else -%} ❌ {%- endif -%}</td>
|
||||
<td>
|
||||
{% if host.recent_pings|length > 0 -%}
|
||||
{% set height = 57 -%}
|
||||
{% set width = 182 -%}
|
||||
{% set amount = host.recent_pings|length -%}
|
||||
{% set width_bar = width / amount -%}
|
||||
{% set offset = 5 -%}
|
||||
{% set error_size = height / 3 %}
|
||||
{% if host.ping_max and host.ping_min -%}
|
||||
{%- if host.recent_pings|length > 0 -%}
|
||||
{%- set height = 57 -%}
|
||||
{%- set width = 182 -%}
|
||||
{%- set amount = host.recent_pings|length -%}
|
||||
{%- set width_bar = width / amount -%}
|
||||
{%- set offset = 5 -%}
|
||||
{%- set error_size = height / 3 %}
|
||||
{%- if host.ping_max and host.ping_min -%}
|
||||
{# only one entry, so max = min => step_size would be 0 #}
|
||||
{% if host.ping_max == host.ping_min -%}
|
||||
{% set step_size = 5/(height-offset) -%}
|
||||
{% else -%}
|
||||
{% set step_size = (host.ping_max - host.ping_min)/(height-offset) -%}
|
||||
{% endif -%}
|
||||
{% else %}
|
||||
{%- if host.ping_max == host.ping_min -%}
|
||||
{%- set step_size = 5/(height-offset) -%}
|
||||
{%- else -%}
|
||||
{%- set step_size = (host.ping_max - host.ping_min)/(height-offset) -%}
|
||||
{%- endif -%}
|
||||
{%- else %}
|
||||
{# no valid entries, only nulls #}
|
||||
{% set step_size = 5/(height-offset) -%}
|
||||
{% endif %}
|
||||
{%- set step_size = 5/(height-offset) -%}
|
||||
{%- endif -%}
|
||||
{# <!-- step size {{step_size}} -->
|
||||
<!-- ping_max {{host.ping_max}} -->
|
||||
<!-- ping_min {{host.ping_min}} --> #}
|
||||
{% if host.ping_min -%}
|
||||
{%- if host.ping_min -%}
|
||||
<svg viewBox="0 0 182 56" width="{{width - 1}}" height="{{height - 1}}">
|
||||
{% if host.ping_avg and host.ping_min -%}
|
||||
{% set avg_pos = (height-(host.ping_avg - host.ping_min )/step_size) - offset -%}
|
||||
{%- if host.ping_avg and host.ping_min -%}
|
||||
{%- set avg_pos = (height-(host.ping_avg - host.ping_min )/step_size) - offset -%}
|
||||
<line x1="1" x2="181" y1="{{avg_pos}}" y2="{{avg_pos}}" stroke="black" stroke-width="0.72727275" stroke-linecap="butt" stroke-opacity="0.3"><title>Average</title></line>
|
||||
{% endif -%}
|
||||
{% for ping in host.recent_pings -%}
|
||||
{% if ping -%}
|
||||
{% set height_bar = (ping - host.ping_min )/step_size + offset -%}
|
||||
{% set color_bar = "#a09df2" -%}
|
||||
{% else %}
|
||||
{% set height_bar = error_size -%}
|
||||
{% set color_bar = "#cc0000" -%}
|
||||
{% endif %}
|
||||
{%- endif -%}
|
||||
{%- for ping in host.recent_pings -%}
|
||||
{%- if ping -%}
|
||||
{%- set height_bar = (ping - host.ping_min )/step_size + offset -%}
|
||||
{%- set color_bar = "#a09df2" -%}
|
||||
{%- else -%}
|
||||
{%- set height_bar = error_size -%}
|
||||
{%- set color_bar = "#cc0000" -%}
|
||||
{%- endif -%}
|
||||
<rect x="{{(loop.index-1) * width_bar}}" y="{{height - height_bar - offset}}" width="{{width_bar}}" height="{{height_bar}}" fill="{{color_bar}}" fill-opacity="0.95"><title>{{ping | default(value="unhealthy") }}</title></rect>
|
||||
{% endfor -%}
|
||||
{%- endfor -%}
|
||||
</svg>
|
||||
{% else -%}
|
||||
{%- else -%}
|
||||
{# <!-- no healthy entries, show last time host was seen healthy --> #}
|
||||
{% if host.last_healthy -%}
|
||||
{%- if host.last_healthy -%}
|
||||
Last seen healthy: {{host.last_healthy | truncate(length=10, end="") | replace(from="-", to=".")}}
|
||||
{% else -%}
|
||||
{%- else -%}
|
||||
Never seen healthy.
|
||||
{% endif -%}
|
||||
{% endif -%}
|
||||
{% else -%}
|
||||
{%- endif -%}
|
||||
{%- endif -%}
|
||||
{%- else -%}
|
||||
No recent data!
|
||||
{% endif -%}
|
||||
{%- endif -%}
|
||||
</td>
|
||||
<td>{{host.ping_avg}}</td>
|
||||
<td>{% if host.rss -%} ✅ {% else -%} ❌ {% endif -%}</td>
|
||||
<td>{{host.version}}</td>
|
||||
<td>{% if host.rss -%} ✅ {%- else -%} ❌ {%- endif -%}</td>
|
||||
<td>
|
||||
{%- if host.version_url -%}
|
||||
<a href="{{host.version_url}}">
|
||||
{{host.version | default(value="missing version")}}
|
||||
</a>
|
||||
{%- else -%}
|
||||
<a href="{{host.url ~ '/about'}}">missing version</a>
|
||||
{%- endif -%}
|
||||
{%- if host.healthy and not host.version -%}
|
||||
<span class="ms-1 badge bg-warning">missing</span>
|
||||
{%- elif host.version and not host.is_upstream -%}
|
||||
<span class="ms-1 badge bg-secondary">foreign repo</span>
|
||||
{%- elif host.is_latest_version -%}
|
||||
<span class="ms-1 badge bg-success">latest</span>
|
||||
{%- elif host.version and not host.is_latest_version -%}
|
||||
<span class="ms-1 badge bg-info">outdated</span>
|
||||
{%- endif -%}
|
||||
</td>
|
||||
<td>{{host.points}}</td>
|
||||
</tr>
|
||||
{% endfor -%}
|
||||
{%- endfor -%}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user