add changelog and logout functionality
This commit is contained in:
parent
f20d1cc74b
commit
5f516f71f9
4 changed files with 48 additions and 1 deletions
25
src/changelog.rs
Normal file
25
src/changelog.rs
Normal file
|
@ -0,0 +1,25 @@
|
|||
use maud::{html, Markup};
|
||||
|
||||
use crate::templates::layout;
|
||||
|
||||
pub fn changelog_page() -> Markup {
|
||||
layout(html! {
|
||||
h1 { "Beacon Changelog" }
|
||||
|
||||
section {
|
||||
h2 { "1.1.0, 07.02.2025" }
|
||||
ul {
|
||||
li { "Fish now directly display their non-relative dates for their next or current window" }
|
||||
li { "Additionally, fish that are up now display the starting time for the subsequent window" }
|
||||
li { "The site now saves your account ID in your browser storage, and automatically redirects you on page visit" }
|
||||
}
|
||||
}
|
||||
|
||||
section {
|
||||
h2 { "1.0.0, 06.02.2025" }
|
||||
ul {
|
||||
li { "Initial release" }
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
12
src/main.rs
12
src/main.rs
|
@ -12,9 +12,11 @@ use maud::{html, Markup};
|
|||
use nanoid::nanoid;
|
||||
use serde::Deserialize;
|
||||
use sqlx::{postgres::PgPoolOptions, Pool, Postgres};
|
||||
use templates::layout;
|
||||
use tower_http::{services::ServeDir, trace::TraceLayer};
|
||||
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
|
||||
|
||||
pub mod changelog;
|
||||
pub mod clock;
|
||||
pub mod data;
|
||||
pub mod db;
|
||||
|
@ -146,6 +148,16 @@ async fn main() {
|
|||
.route("/to", get(to_handler))
|
||||
.route("/{id}", get(main_handler))
|
||||
.route("/{acc_id}/catch/{fish_id}", post(insert_cf_handler))
|
||||
.route("/changelog", get(|| async { changelog::changelog_page() }))
|
||||
.route(
|
||||
"/logout",
|
||||
get(|| async {
|
||||
layout(html! {
|
||||
h1 { "Logging you out, please wait to be redirected..." }
|
||||
script src="/static/scripts/logout.js" type="text/javascript" {}
|
||||
})
|
||||
}),
|
||||
)
|
||||
.layer(TraceLayer::new_for_http())
|
||||
.nest_service("/static", ServeDir::new("static"))
|
||||
.with_state(Arc::new(AppState {
|
||||
|
|
9
static/scripts/logout.js
Normal file
9
static/scripts/logout.js
Normal file
|
@ -0,0 +1,9 @@
|
|||
// Removes the local storage entry, and redirects to the index page.
|
||||
const ls = window.localStorage;
|
||||
if (ls.getItem("beacon:account-id")) {
|
||||
console.log("a");
|
||||
ls.removeItem("beacon:account-id");
|
||||
window.location.pathname = "/";
|
||||
} else {
|
||||
window.location.pathname = "/";
|
||||
}
|
|
@ -3,7 +3,8 @@ body {
|
|||
margin: 40px;
|
||||
}
|
||||
|
||||
section {
|
||||
section.up,
|
||||
section.always-up {
|
||||
margin-bottom: 5px;
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr 1fr 1fr;
|
||||
|
|
Loading…
Add table
Reference in a new issue