add: profile connections, spotify connection
This commit is contained in:
parent
a5c2356940
commit
33ba576d4a
31 changed files with 931 additions and 19 deletions
|
@ -44,6 +44,7 @@ pub const MISC_REQUESTS: &str = include_str!("./public/html/misc/requests.html")
|
|||
pub const AUTH_BASE: &str = include_str!("./public/html/auth/base.html");
|
||||
pub const AUTH_LOGIN: &str = include_str!("./public/html/auth/login.html");
|
||||
pub const AUTH_REGISTER: &str = include_str!("./public/html/auth/register.html");
|
||||
pub const AUTH_CONNECTION: &str = include_str!("./public/html/auth/connection.html");
|
||||
|
||||
pub const PROFILE_BASE: &str = include_str!("./public/html/profile/base.html");
|
||||
pub const PROFILE_POSTS: &str = include_str!("./public/html/profile/posts.html");
|
||||
|
@ -94,6 +95,8 @@ pub const LANG_EN_US: &str = include_str!("./langs/en-US.toml");
|
|||
|
||||
// ...
|
||||
|
||||
pub const VENDOR_SPOTIFY_ICON: &str = include_str!("./public/images/vendor/spotify.svg");
|
||||
|
||||
/// A container for all loaded icons.
|
||||
pub(crate) static ICONS: LazyLock<RwLock<HashMap<String, String>>> =
|
||||
LazyLock::new(|| RwLock::new(HashMap::new()));
|
||||
|
@ -120,6 +123,16 @@ pub(crate) async fn pull_icon(icon: &str, icons_dir: &str) {
|
|||
writer.insert(icon.to_string(), svg);
|
||||
}
|
||||
|
||||
macro_rules! vendor_icon {
|
||||
($name:literal, $icon:ident, $icons_dir:expr) => {{
|
||||
let writer = &mut ICONS.write().await;
|
||||
writer.insert($name.to_string(), $icon.to_string());
|
||||
|
||||
let file_path = PathBufD::current().extend(&[$icons_dir.clone(), $name.to_string()]);
|
||||
std::fs::write(file_path, $icon).unwrap();
|
||||
}};
|
||||
}
|
||||
|
||||
/// Read a string and replace all custom blocks with the corresponding correct HTML.
|
||||
///
|
||||
/// # Replaces
|
||||
|
@ -179,6 +192,9 @@ pub(crate) async fn replace_in_html(input: &str, config: &Config) -> String {
|
|||
|
||||
/// Set up public directories.
|
||||
pub(crate) async fn write_assets(config: &Config) -> PathBufD {
|
||||
vendor_icon!("spotify", VENDOR_SPOTIFY_ICON, config.dirs.icons);
|
||||
|
||||
// ...
|
||||
let html_path = PathBufD::current().join(&config.dirs.templates);
|
||||
|
||||
write_template!(html_path->"root.html"(crate::assets::ROOT) --config=config);
|
||||
|
@ -194,6 +210,7 @@ pub(crate) async fn write_assets(config: &Config) -> PathBufD {
|
|||
write_template!(html_path->"auth/base.html"(crate::assets::AUTH_BASE) -d "auth" --config=config);
|
||||
write_template!(html_path->"auth/login.html"(crate::assets::AUTH_LOGIN) --config=config);
|
||||
write_template!(html_path->"auth/register.html"(crate::assets::AUTH_REGISTER) --config=config);
|
||||
write_template!(html_path->"auth/connection.html"(crate::assets::AUTH_CONNECTION) --config=config);
|
||||
|
||||
write_template!(html_path->"profile/base.html"(crate::assets::PROFILE_BASE) -d "profile" --config=config);
|
||||
write_template!(html_path->"profile/posts.html"(crate::assets::PROFILE_POSTS) --config=config);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue