add /cam page
This commit is contained in:
67
src/index.rs
67
src/index.rs
@@ -58,6 +58,73 @@ pub(super) async fn index(cookies: CookieJar, headers: HeaderMap) -> Markup {
|
||||
})
|
||||
}
|
||||
|
||||
pub(super) async fn cam(cookies: CookieJar, headers: HeaderMap) -> Markup {
|
||||
let lang = language(&cookies, &headers);
|
||||
rust_i18n::set_locale(lang.to_locale());
|
||||
|
||||
let page = Page::new(lang);
|
||||
page.content(html! {
|
||||
hgroup {
|
||||
h1 { (PreEscaped(t!("cam_title"))) }
|
||||
p { (t!("cam_title2")) }
|
||||
}
|
||||
hgroup {
|
||||
h2 { (t!("cam_subtitle")) }
|
||||
p { (t!("cam_description")) }
|
||||
}
|
||||
p {
|
||||
(t!("cam_project_by"))
|
||||
span.highlight { (t!("cam_institute")) }
|
||||
}
|
||||
blockquote {
|
||||
(t!("cam_mission_quote"))
|
||||
footer {
|
||||
cite { (t!("cam_mission_attribution")) }
|
||||
}
|
||||
}
|
||||
p { (t!("cam_project_description")) }
|
||||
|
||||
h2 { (t!("cam_how_it_works")) }
|
||||
|
||||
div.grid.gap-lg {
|
||||
article {
|
||||
header { (t!("cam_tech_setup_title")) }
|
||||
|
||||
p { (t!("cam_tech_setup_p1")) }
|
||||
|
||||
p { (t!("cam_tech_setup_p2")) }
|
||||
}
|
||||
article {
|
||||
header { (PreEscaped(t!("cam_data_processing_title"))) }
|
||||
|
||||
p { (PreEscaped(t!("cam_data_processing_p1"))) }
|
||||
}
|
||||
}
|
||||
|
||||
h2 { (t!("cam_festival_details")) }
|
||||
|
||||
div.info-box {
|
||||
h3 { (t!("cam_when_where_title")) }
|
||||
p {
|
||||
(t!("cam_festival_info")) br;
|
||||
(t!("cam_festival_dates")) br;
|
||||
(t!("cam_festival_location"))
|
||||
}
|
||||
}
|
||||
|
||||
h2 { (t!("cam_legal_compliance")) }
|
||||
|
||||
p { (t!("cam_legal_description")) }
|
||||
|
||||
div.legal-docs {
|
||||
a href="/static/dsb-request.pdf" target="_blank" title=(t!("cam_legal_request_title")) { (t!("cam_legal_request")) }
|
||||
" | "
|
||||
a href="/static/dsb-accept.pdf" target="_blank" title=(t!("cam_legal_decision_title")) { (t!("cam_legal_decision")) }
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub(super) struct PrivacyQuery {
|
||||
deleted: Option<u8>,
|
||||
|
19
src/main.rs
19
src/main.rs
@@ -309,7 +309,7 @@ impl Config {
|
||||
.take(15)
|
||||
.map(char::from)
|
||||
.collect();
|
||||
|
||||
|
||||
Self {
|
||||
key: Key::generate().master().to_vec(),
|
||||
admin_password,
|
||||
@@ -323,19 +323,19 @@ fn load_or_create_config() -> Result<(Key, Config), Box<dyn std::error::Error>>
|
||||
// Try to read existing config
|
||||
if Path::new(config_path).exists() {
|
||||
let content = fs::read_to_string(config_path)?;
|
||||
|
||||
|
||||
// Try to parse as complete config first
|
||||
if let Ok(config) = toml::from_str::<Config>(&content) {
|
||||
let key = Key::from(&config.key);
|
||||
return Ok((key, config));
|
||||
}
|
||||
|
||||
|
||||
// If that fails, try to parse just the key and generate new admin password
|
||||
#[derive(Deserialize)]
|
||||
struct PartialConfig {
|
||||
key: Vec<u8>,
|
||||
}
|
||||
|
||||
|
||||
if let Ok(partial_config) = toml::from_str::<PartialConfig>(&content) {
|
||||
use rand::{distributions::Alphanumeric, thread_rng, Rng};
|
||||
let admin_password: String = thread_rng()
|
||||
@@ -343,16 +343,16 @@ fn load_or_create_config() -> Result<(Key, Config), Box<dyn std::error::Error>>
|
||||
.take(15)
|
||||
.map(char::from)
|
||||
.collect();
|
||||
|
||||
|
||||
let config = Config {
|
||||
key: partial_config.key,
|
||||
admin_password,
|
||||
};
|
||||
|
||||
|
||||
// Write the updated config back
|
||||
let toml_string = toml::to_string(&config)?;
|
||||
fs::write(config_path, toml_string)?;
|
||||
|
||||
|
||||
let key = Key::from(&config.key);
|
||||
return Ok((key, config));
|
||||
}
|
||||
@@ -409,10 +409,10 @@ async fn main() {
|
||||
.unwrap();
|
||||
|
||||
let (key, config) = load_or_create_config().unwrap();
|
||||
|
||||
|
||||
// Print admin password for convenience
|
||||
tracing::info!("Admin password: {}", config.admin_password);
|
||||
|
||||
|
||||
let state = AppState {
|
||||
backend: Arc::new(Backend::Sqlite(db)),
|
||||
key,
|
||||
@@ -422,6 +422,7 @@ async fn main() {
|
||||
let app = Router::new()
|
||||
.route("/", get(index::index))
|
||||
.route("/privacy", get(index::data))
|
||||
.route("/cam", get(index::cam))
|
||||
.route("/delete-data", post(delete_personal_data))
|
||||
.nest_service("/static", ServeDir::new("./static/serve"))
|
||||
.merge(game::routes())
|
||||
|
Reference in New Issue
Block a user