30 lines
1.0 KiB
Rust
30 lines
1.0 KiB
Rust
use maud::PreEscaped;
|
|
|
|
use crate::{
|
|
templates,
|
|
utils::{sbot, theme},
|
|
};
|
|
|
|
// ROUTE: /scuttlebutt/blocks
|
|
|
|
/// Scuttlebutt blocks list template builder.
|
|
pub fn build_template() -> PreEscaped<String> {
|
|
// retrieve the list of blocked peers
|
|
match sbot::get_blocks_list() {
|
|
// populate the peers_list template with blocks and render it
|
|
Ok(blocks) => templates::peers_list::build_template(blocks, "Blocks"),
|
|
Err(e) => {
|
|
// render the sbot error template with the error message
|
|
let error_template = templates::error::build_template(e.to_string());
|
|
// wrap the nav bars around the error template content
|
|
let body = templates::nav::build_template(error_template, "Blocks", 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)
|
|
}
|
|
}
|
|
}
|