use std::{cmp::Ordering, sync::Arc}; use axum::extract::State; use maud::{html, Markup, DOCTYPE}; use crate::{clock, data::CombinedFish, AppState}; pub fn layout(content: Markup) -> Markup { html! { (DOCTYPE) html { head { title { "beacon" } meta name="viewport" content="width=device-width"; link rel="stylesheet" href="/static/style.css"; } body { (content) } } } } pub fn main_page(state: State>) -> Markup { let meta = state.data.fish_with_meta(); let mut values: Vec<&CombinedFish> = meta.values().filter(|f| f.entry.big_fish).collect(); values.sort_by(|afish, bfish| { bfish .is_up .cmp(&afish.is_up) .then(bfish.is_always_up.cmp(&afish.is_always_up)) .then(bfish.rarity.total_cmp(&afish.rarity).reverse()) // if (afish.is_up || afish.is_always_up) && !(bfish.is_up && bfish.is_always_up) { // Ordering::Less // } else { // Ordering::Greater // } }); layout(html! { h1 { "Hello! Current ET: " (clock::get_current_eorzea_date().format("%H:%M")) } @for fish in values { section.up[fish.is_up || fish.is_always_up] { .title { h3 { (fish.meta.name_en) } .subtitle { (fish.entry.patch) } } .meta { @if fish.entry.start_hour.is_some() && fish.entry.end_hour.is_some() { div { @if !fish.is_always_up { (clock::display_eorzea_time(&clock::set_hm_from_float(&clock::get_current_eorzea_date(), fish.entry.start_hour.unwrap()))) " to " (clock::display_eorzea_time(&clock::set_hm_from_float(&clock::get_current_eorzea_date(), fish.entry.end_hour.unwrap()))) } @else { "always up!" } } } div { "Rarity: " (format!("{:.2}", fish.rarity * 100.)) "%" } } } } }) }