new functions and fixes
This commit is contained in:
+21
-7
@@ -38,6 +38,7 @@ const MODULES: &[&str] = &[
|
||||
"toast",
|
||||
"theme",
|
||||
"url-state",
|
||||
"vendor-libs",
|
||||
"security",
|
||||
];
|
||||
|
||||
@@ -51,10 +52,20 @@ pub fn render_html(
|
||||
entrypoint: &str,
|
||||
) -> Response {
|
||||
let urls = AssetUrls::new(asset_version);
|
||||
let frontend_config = frontend_config(frontend_log_level, upload_max_size_bytes, external_auth);
|
||||
let frontend_config = frontend_config(
|
||||
frontend_log_level,
|
||||
upload_max_size_bytes,
|
||||
external_auth,
|
||||
asset_version,
|
||||
);
|
||||
let app_stylesheets = format!(
|
||||
"{}{}",
|
||||
urls.stylesheet("styles"),
|
||||
urls.stylesheet_path("libs/rustpad-player/player.css"),
|
||||
);
|
||||
let html = template
|
||||
.replace("__APP_THEME_BOOTSTRAP__", theme_bootstrap())
|
||||
.replace("__APP_STYLESHEET__", &urls.stylesheet("styles"))
|
||||
.replace("__APP_STYLESHEET__", &app_stylesheets)
|
||||
.replace("__APP_IMPORT_MAP__", &urls.import_map())
|
||||
.replace("__APP_ENTRYPOINT__", &urls.entrypoint(entrypoint))
|
||||
.replace(
|
||||
@@ -92,12 +103,14 @@ fn frontend_config(
|
||||
frontend_log_level: &str,
|
||||
upload_max_size_bytes: usize,
|
||||
external_auth: bool,
|
||||
asset_version: &str,
|
||||
) -> String {
|
||||
format!(
|
||||
r#"<script>window.__RUSTPAD_CONFIG__=Object.freeze({{frontendLogLevel:"{}",uploadMaxSizeBytes:{},externalAuth:{}}});</script>"#,
|
||||
r#"<script>window.__RUSTPAD_CONFIG__=Object.freeze({{frontendLogLevel:"{}",uploadMaxSizeBytes:{},externalAuth:{},assetVersion:"{}"}});</script>"#,
|
||||
escape_js_string(frontend_log_level),
|
||||
upload_max_size_bytes,
|
||||
external_auth,
|
||||
escape_js_string(asset_version),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -115,10 +128,11 @@ impl<'a> AssetUrls<'a> {
|
||||
}
|
||||
|
||||
fn stylesheet(&self, name: &str) -> String {
|
||||
format!(
|
||||
r#"<link rel="stylesheet" href="{}">"#,
|
||||
self.url(&format!("css/{name}.css"))
|
||||
)
|
||||
self.stylesheet_path(&format!("css/{name}.css"))
|
||||
}
|
||||
|
||||
fn stylesheet_path(&self, path: &str) -> String {
|
||||
format!(r#"<link rel="stylesheet" href="{}">"#, self.url(path))
|
||||
}
|
||||
|
||||
fn entrypoint(&self, name: &str) -> String {
|
||||
|
||||
Reference in New Issue
Block a user