diff --git a/src/main.rs b/src/main.rs index f982144..e53fe50 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,12 +1,13 @@ use axum::{ extract::{FromRef, Path, Query}, - http::{StatusCode}, + http::StatusCode, response::{IntoResponse, Response}, - routing::{get}, Json, Router, + routing::get, Json, Router, }; +use axum_extra::routing::SpaRouter; use metrics::increment_counter; use metrics_util::MetricKindMask; -use metrics_exporter_prometheus::{PrometheusBuilder}; +use metrics_exporter_prometheus::PrometheusBuilder; use serde_json::json; use sigh::{PrivateKey, PublicKey}; use std::{net::SocketAddr, sync::Arc, time::Duration, collections::HashMap}; @@ -287,7 +288,8 @@ async fn main() { hostname, priv_key: config.priv_key(), pub_key: config.pub_key(), - }); + }) + .merge(SpaRouter::new("/", "static")); let addr = SocketAddr::from(([127, 0, 0, 1], config.listen_port)); let server = axum::Server::bind(&addr) diff --git a/static/index.html b/static/index.html new file mode 100644 index 0000000..e18a9ed --- /dev/null +++ b/static/index.html @@ -0,0 +1,72 @@ + + + + #FediBuzz Relay + + + + + + + + + + +
+

#FediBuzz Relay

+

The buzzing ActivityPub relay service

+
+ +
+

+ Mastodon and many other ActivityPub-compatible services live + and breathe decentralization. Mastoadmins can still bring the + global buzz of toots into the Federated Timeline of their + small server by following ActivityPub relays. +

+

+ With this service #FediBuzz + provides relay endpoints for you to customize. In Mastodon's + preferences go to: +

+
    +
  1. Administration
  2. +
  3. Relay
  4. +
  5. Click the button to setup a new relay
  6. +
  7. Generate a relay address below
  8. +
  9. Copy & paste into Mastodon's preferences
  10. +
+
+ +
+ +
+

Follow posts by #tag

+
+ +
+

+      
+
+

Follow posts by instance

+
+ +
+

+      
+
+ + + + + + diff --git a/static/style.css b/static/style.css new file mode 100644 index 0000000..88a1199 --- /dev/null +++ b/static/style.css @@ -0,0 +1,52 @@ +body { + background-color: #DFCFEF; + color: #1F2F4F; + font-family: sans-serif; + margin: 0; +} +a { + text-decoration: none; + font-weight: bold; + color: #9F2F1F; +} +h1 { + text-align: center; + font-size: 300%; +} +h2 { +} +p, ol { + margin: 2rem auto; + max-width: 30rem; + padding: 0; + line-height: 2em; +} +li { + margin: 0.5rem; + padding: 0; + list-style-type: disclosure-closed; +} + +.boxes { + display: flex; + flex-direction: row; + justify-content: space-around; + flex-wrap: wrap; +} +.boxes article { + background-color: #EFDFFF; + padding: 0.5rem 1rem; + text-align: center; + margin: 1rem 0.5rem; + min-width: 25rem; +} +.boxes article pre { + margin: 1rem 0; + padding: 0.5rem; + background-color: #DFCFEF; +} + +footer { + margin-top: 8rem; + text-align: center; +} diff --git a/static/urlgen.js b/static/urlgen.js new file mode 100644 index 0000000..526b45a --- /dev/null +++ b/static/urlgen.js @@ -0,0 +1,19 @@ +(function() { + function setup(id) { + var inputEl = document.getElementById(id); + var preEl = document.getElementById(id + "-url"); + function onChange(ev) { + setTimeout(function() { + var value = encodeURIComponent(inputEl.value.replace(/^#/, "")); + preEl.innerText = value ? + "https://relay.fedi.buzz/" + id + "/" + value : + ""; + }, 10); + } + inputEl.addEventListener('change', onChange); + inputEl.addEventListener('keyup', onChange); + } + + setup("tag"); + setup("instance"); +})()