use maud::{html, PreEscaped}; use peach_lib::sbot::SbotStatus; use crate::{templates, utils::theme}; /// 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 { let menu_template = match SbotStatus::read() { Ok(status) if status.state == Some("active".to_string()) => { // render the scuttlebutt peers menu html! { (PreEscaped("")) div class="card center" { div class="card-container" { (PreEscaped("")) 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("/")); // query the current theme so we can pass it into the base template builder let theme = theme::get_theme(); // render the base template with the provided body templates::base::build_template(body, theme) }