Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/routes/about.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
use askama::Template;
use axum::{response::Html, routing::get, Router};

use crate::auth::middleware::CurrentUser;
use crate::config::SiteConfig;
use crate::AppState;

pub fn routes() -> Router<AppState> {
Router::new().route("/about/", get(about_page))
}

#[derive(Template)]
#[template(path = "about.html")]
struct AboutTemplate {
current_user: Option<String>,
}
impl SiteConfig for AboutTemplate {}

async fn about_page(user: CurrentUser) -> Html<String> {
Html(
AboutTemplate {
current_user: user.user().map(|u| u.username.clone()),
}
.render()
.unwrap(),
)
}
20 changes: 20 additions & 0 deletions src/routes/disc_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ struct DiscViewTemplate {
ring_rows: Vec<ViewRingRow>,
ring_vis: RingColVis,
files: Vec<ViewFile>,
dat_filename: String,
sbi_rows: Vec<SbiRow>,
pvd_rows: Vec<PvdRow>,
pic_rows: Vec<HeaderRow>,
Expand Down Expand Up @@ -144,6 +145,7 @@ impl RingColVis {

struct ViewFile {
name: String,
short_name: String,
is_cue: bool,
size: i64,
crc32: String,
Expand Down Expand Up @@ -266,8 +268,25 @@ async fn disc_view(
} else {
(rom_extension, f.track_number.as_deref())
};
let short_name = if is_cue {
format!(".cue")
} else if total_tracks > 1 {
if let Some(t) = track {
let n: u32 = t.parse().unwrap_or(0);
if total_tracks >= 10 {
format!("(Track {n:02}).{ext}")
} else {
format!("(Track {n}).{ext}")
}
} else {
format!(".{ext}")
}
} else {
format!(".{ext}")
};
ViewFile {
name: build_rom_name(&rom_base_name, track, total_tracks, ext),
short_name,
is_cue,
size: f.size,
crc32: f.crc32.clone(),
Expand Down Expand Up @@ -389,6 +408,7 @@ async fn disc_view(
),
ring_rows,
files,
dat_filename: rom_base_name.clone(),
sbi_rows,
pvd_rows,
pic_rows,
Expand Down
2 changes: 1 addition & 1 deletion src/routes/main_page.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ async fn homepage(State(state): State<AppState>, user: CurrentUser) -> Html<Stri
code: rr.code.to_lowercase(),
name: rr.name,
}).collect(),
created_at: r.created_at.map(|d| d.format("%Y-%m-%d %H:%M").to_string()).unwrap_or_default(),
created_at: r.created_at.map(|d| d.format("%Y-%m-%d").to_string()).unwrap_or_default(),
});
}

Expand Down
2 changes: 2 additions & 0 deletions src/routes/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pub mod about;
pub mod api;
pub mod auth_routes;
pub mod disc_edit;
Expand All @@ -23,4 +24,5 @@ pub fn build_router() -> Router<AppState> {
.merge(queue::routes())
.merge(feeds::routes())
.merge(api::routes())
.merge(about::routes())
}
2 changes: 1 addition & 1 deletion src/services/disc_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ pub async fn get_disc_detail(pool: &PgPool, disc_id: i32) -> AppResult<DiscDetai
}

let files: Vec<File> = sqlx::query_as(
"SELECT * FROM files WHERE disc_id = $1 ORDER BY track_number"
"SELECT * FROM files WHERE disc_id = $1 ORDER BY CAST(track_number AS INTEGER) NULLS LAST, track_number NULLS LAST"
)
.bind(disc_id)
.fetch_all(pool)
Expand Down
Loading