peach-workspace/peach-web/src/routes/scuttlebutt/peers.rs

43 lines
2.0 KiB
Rust

use maud::{html, PreEscaped};
use peach_lib::sbot::SbotStatus;
use crate::templates;
/// Scuttlebutt peer menu template builder.
///
/// A peer menu which allows navigating to lists of friends, follows, followers
/// and blocks, as well as accessing the invite creation form.
pub fn build_template() -> PreEscaped<String> {
let menu_template = match SbotStatus::read() {
Ok(status) if status.state == Some("active".to_string()) => {
// render the scuttlebutt peers menu
html! {
(PreEscaped("<!-- SCUTTLEBUTT PEERS -->"))
div class="card center" {
div class="card-container" {
(PreEscaped("<!-- BUTTONS -->"))
div id="buttons" {
a id="search" class="button button-primary center" href="/scuttlebutt/search" title="Search for a peer" { "Search" }
a id="friends" class="button button-primary center" href="/scuttlebutt/friends" title="List friends" { "Friends" }
a id="follows" class="button button-primary center" href="/scuttlebutt/follows" title="List follows" { "Follows" }
a id="blocks" class="button button-primary center" href="/scuttlebutt/blocks" title="List blocks" { "Blocks" }
a id="invites" class="button button-primary center" href="/scuttlebutt/invites" title="Create invites" { "Invites" }
}
}
}
}
}
_ => {
// the sbot is not active; render a message instead of the menu
templates::inactive::build_template("Social lists and interactions are unavailable.")
}
};
// wrap the nav bars around the settings menu template content
// parameters are template, title and back url
let body = templates::nav::build_template(menu_template, "Scuttlebutt Peers", Some("/"));
// render the base template with the provided body
templates::base::build_template(body)
}