30 lines
1.0 KiB
Rust
30 lines
1.0 KiB
Rust
use maud::PreEscaped;
|
|
|
|
use crate::{
|
|
templates,
|
|
utils::{sbot, theme},
|
|
};
|
|
|
|
// ROUTE: /scuttlebutt/friends
|
|
|
|
/// Scuttlebutt friends list template builder.
|
|
pub fn build_template() -> PreEscaped<String> {
|
|
// retrieve the list of friends
|
|
match sbot::get_friends_list() {
|
|
// populate the peers_list template with friends and render it
|
|
Ok(friends) => templates::peers_list::build_template(friends, "Friends"),
|
|
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, "Friends", 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)
|
|
}
|
|
}
|
|
}
|