use askama::Template; use super::views::{ BagDetailView, BagOptionView, BagView, BrewDefaultsView, BrewDetailView, BrewView, CafeDetailView, CafeOptionView, CafeView, CupDetailView, CupView, GearDetailView, GearOptionView, GearView, ListNavigator, NearbyCafeView, Paginated, QuickNoteView, RoastDetailView, RoastOptionView, RoastView, RoasterDetailView, RoasterOptionView, RoasterView, StatCard, StatsView, TimelineEventView, TimelineMonthView, }; use crate::domain::bags::BagSortKey; use crate::domain::brews::BrewSortKey; use crate::domain::cafes::CafeSortKey; use crate::domain::cups::CupSortKey; use crate::domain::gear::GearSortKey; use crate::domain::roasters::RoasterSortKey; use crate::domain::roasts::{RoastSortKey, RoastWithRoaster}; use crate::domain::stats::{BrewingSummaryStats, ConsumptionStats, RoastSummaryStats}; use crate::domain::timeline::TimelineSortKey; #[derive(Template)] #[template(path = "partials/lists/roaster_list.html")] pub struct RoasterListTemplate { pub is_authenticated: bool, pub roasters: Paginated, pub navigator: ListNavigator, } #[derive(Template)] #[template(path = "partials/lists/roast_list.html")] pub struct RoastListTemplate { pub is_authenticated: bool, pub roasts: Paginated, pub navigator: ListNavigator, } #[derive(Template)] #[template(path = "pages/timeline.html")] pub struct TimelineTemplate { pub nav_active: &'static str, pub is_authenticated: bool, pub version_info: &'static crate::VersionInfo, pub events: Paginated, pub navigator: ListNavigator, pub months: Vec, } #[derive(Template)] #[template(path = "partials/timeline_chunk.html")] pub struct TimelineChunkTemplate { pub is_authenticated: bool, pub events: Paginated, pub navigator: ListNavigator, pub months: Vec, } #[derive(Template)] #[template(path = "partials/lists/bag_list.html")] pub struct BagListTemplate { pub is_authenticated: bool, pub bags: Paginated, pub navigator: ListNavigator, } #[derive(Template)] #[template(path = "partials/lists/gear_list.html")] pub struct GearListTemplate { pub is_authenticated: bool, pub gear: Paginated, pub navigator: ListNavigator, } #[derive(Template)] #[template(path = "partials/roast_options.html")] pub struct RoastOptionsTemplate { pub roasts: Vec, } #[derive(Template)] #[template(path = "partials/lists/brew_list.html")] pub struct BrewListTemplate { pub is_authenticated: bool, pub brews: Paginated, pub navigator: ListNavigator, } #[derive(Template)] #[template(path = "partials/lists/cafe_list.html")] pub struct CafeListTemplate { pub is_authenticated: bool, pub cafes: Paginated, pub navigator: ListNavigator, } #[derive(Template)] #[template(path = "partials/lists/cup_list.html")] pub struct CupListTemplate { pub is_authenticated: bool, pub cups: Paginated, pub navigator: ListNavigator, } #[derive(Template)] #[template(path = "pages/home.html")] pub struct HomeTemplate { pub nav_active: &'static str, pub is_authenticated: bool, pub version_info: &'static crate::VersionInfo, pub base_url: &'static str, pub recent_brews: Vec, pub open_bags: Vec, pub recent_events: Vec, pub stats: StatsView, pub stat_cards: Vec, } #[derive(Template)] #[template(path = "pages/checkin.html")] pub struct CheckInTemplate { pub nav_active: &'static str, pub is_authenticated: bool, pub version_info: &'static crate::VersionInfo, pub roast_options: Vec, pub cafe_options: Vec, } #[derive(Template)] #[template(path = "partials/nearby_cafes.html")] pub struct NearbyCafesFragment { pub cafes: Vec, } #[derive(Template)] #[template(path = "pages/data.html")] pub struct DataTemplate { pub nav_active: &'static str, pub is_authenticated: bool, pub version_info: &'static crate::VersionInfo, pub active_type: String, pub tabs: Vec, pub tab_signal: &'static str, pub tab_signal_js: &'static str, pub tab_base_url: &'static str, pub tab_fetch_target: &'static str, pub tab_fetch_mode: &'static str, pub content: String, pub search_value: String, } pub struct Tab { pub key: &'static str, pub label: &'static str, } #[derive(Template)] #[template(path = "pages/add.html")] pub struct AddTemplate { pub nav_active: &'static str, pub is_authenticated: bool, pub version_info: &'static crate::VersionInfo, pub active_type: String, pub tabs: Vec, pub tab_signal: &'static str, pub tab_signal_js: &'static str, pub tab_base_url: &'static str, pub tab_fetch_target: &'static str, pub tab_fetch_mode: &'static str, pub roaster_options: Vec, pub roast_options: Vec, pub bag_options: Vec, pub grinder_options: Vec, pub brewer_options: Vec, pub filter_paper_options: Vec, pub cafe_options: Vec, pub defaults: BrewDefaultsView, pub quick_note_options: Vec, pub pre_select_bag_id: Option, } #[derive(Template)] #[template(path = "pages/stats.html")] pub struct StatsPageTemplate { pub nav_active: &'static str, pub is_authenticated: bool, pub version_info: &'static crate::VersionInfo, pub base_url: &'static str, pub active_type: String, pub tabs: Vec, pub tab_signal: &'static str, pub tab_signal_js: &'static str, pub tab_base_url: &'static str, pub tab_fetch_target: &'static str, pub tab_fetch_mode: &'static str, pub content: String, pub roast_summary: RoastSummaryStats, pub consumption: ConsumptionStats, pub brewing_summary: BrewingSummaryStats, pub grinder_weights: Vec<(String, f64, String)>, pub max_grinder_weight: f64, pub consumption_30d_weight: String, pub consumption_all_time_weight: String, pub cache_age: String, pub has_data: bool, } #[derive(Template)] #[template(path = "partials/stats_map.html")] pub struct StatsMapFragment<'a> { pub geo_stats: &'a crate::domain::country_stats::GeoStats, } #[derive(Template)] #[template(path = "pages/bag.html")] pub struct BagDetailTemplate { pub nav_active: &'static str, pub is_authenticated: bool, pub version_info: &'static crate::VersionInfo, pub base_url: &'static str, pub bag: BagDetailView, pub roaster_slug: String, pub roast_slug: String, } #[derive(Template)] #[template(path = "pages/brew.html")] pub struct BrewDetailTemplate { pub nav_active: &'static str, pub is_authenticated: bool, pub version_info: &'static crate::VersionInfo, pub base_url: &'static str, pub brew: BrewDetailView, pub roaster_slug: String, pub roast_slug: String, } #[derive(Template)] #[template(path = "pages/cup.html")] pub struct CupDetailTemplate { pub nav_active: &'static str, pub is_authenticated: bool, pub version_info: &'static crate::VersionInfo, pub base_url: &'static str, pub cup: CupDetailView, pub roaster_slug: String, pub roast_slug: String, pub cafe_slug: String, } #[derive(Template)] #[template(path = "pages/roast.html")] pub struct RoastDetailTemplate { pub nav_active: &'static str, pub is_authenticated: bool, pub version_info: &'static crate::VersionInfo, pub base_url: &'static str, pub roast: RoastDetailView, pub roaster_slug: String, } #[derive(Template)] #[template(path = "pages/roaster.html")] pub struct RoasterDetailTemplate { pub nav_active: &'static str, pub is_authenticated: bool, pub version_info: &'static crate::VersionInfo, pub base_url: &'static str, pub roaster: RoasterDetailView, } #[derive(Template)] #[template(path = "pages/cafe.html")] pub struct CafeDetailTemplate { pub nav_active: &'static str, pub is_authenticated: bool, pub version_info: &'static crate::VersionInfo, pub base_url: &'static str, pub cafe: CafeDetailView, } #[derive(Template)] #[template(path = "pages/gear.html")] pub struct GearDetailTemplate { pub nav_active: &'static str, pub is_authenticated: bool, pub version_info: &'static crate::VersionInfo, pub base_url: &'static str, pub gear: GearDetailView, } pub fn render_template(template: T) -> Result { template.render() }