From 56109f3afe343bad1b7a142acb6b6cb79f5bad2d Mon Sep 17 00:00:00 2001 From: Jon Seager Date: Thu, 5 Feb 2026 17:48:18 +0000 Subject: [PATCH] refactor: reorganize templates into pages/, partials/lists/, and forms/ Move 9 page templates to templates/pages/, nav to partials/, 7 list partials + table.html to partials/lists/. Extract duplicated scan result form (~85 lines) from home.html and add.html into partials/forms/scan_result_form.html. Update all Askama template paths, include/import directives. --- src/application/routes/account.rs | 2 +- src/application/routes/auth.rs | 2 +- src/application/routes/webauthn.rs | 4 +- src/presentation/web/templates.rs | 24 +++--- templates/base.html | 2 +- templates/{ => pages}/account.html | 0 templates/{ => pages}/add.html | 85 +------------------ templates/{ => pages}/checkin.html | 0 templates/{ => pages}/cli_callback.html | 0 templates/{ => pages}/data.html | 0 templates/{ => pages}/home.html | 85 +------------------ templates/{ => pages}/login.html | 0 templates/{ => pages}/register.html | 0 templates/{ => pages}/timeline.html | 0 .../partials/forms/scan_result_form.html | 84 ++++++++++++++++++ templates/partials/{ => lists}/bag_list.html | 2 +- templates/partials/{ => lists}/brew_list.html | 2 +- templates/partials/{ => lists}/cafe_list.html | 2 +- templates/partials/{ => lists}/cup_list.html | 2 +- templates/partials/{ => lists}/gear_list.html | 2 +- .../partials/{ => lists}/roast_list.html | 2 +- .../partials/{ => lists}/roaster_list.html | 2 +- templates/partials/{ => lists}/table.html | 0 templates/{ => partials}/nav.html | 0 24 files changed, 110 insertions(+), 192 deletions(-) rename templates/{ => pages}/account.html (100%) rename templates/{ => pages}/add.html (84%) rename templates/{ => pages}/checkin.html (100%) rename templates/{ => pages}/cli_callback.html (100%) rename templates/{ => pages}/data.html (100%) rename templates/{ => pages}/home.html (69%) rename templates/{ => pages}/login.html (100%) rename templates/{ => pages}/register.html (100%) rename templates/{ => pages}/timeline.html (100%) create mode 100644 templates/partials/forms/scan_result_form.html rename templates/partials/{ => lists}/bag_list.html (99%) rename templates/partials/{ => lists}/brew_list.html (99%) rename templates/partials/{ => lists}/cafe_list.html (99%) rename templates/partials/{ => lists}/cup_list.html (98%) rename templates/partials/{ => lists}/gear_list.html (98%) rename templates/partials/{ => lists}/roast_list.html (99%) rename templates/partials/{ => lists}/roaster_list.html (99%) rename templates/partials/{ => lists}/table.html (100%) rename templates/{ => partials}/nav.html (100%) diff --git a/src/application/routes/account.rs b/src/application/routes/account.rs index a4abb57..d7e3010 100644 --- a/src/application/routes/account.rs +++ b/src/application/routes/account.rs @@ -69,7 +69,7 @@ fn format_date(dt: DateTime) -> String { // --- Templates --- #[derive(Template)] -#[template(path = "account.html")] +#[template(path = "pages/account.html")] struct AccountTemplate { nav_active: &'static str, is_authenticated: bool, diff --git a/src/application/routes/auth.rs b/src/application/routes/auth.rs index 3eec5d4..ccc2a0f 100644 --- a/src/application/routes/auth.rs +++ b/src/application/routes/auth.rs @@ -17,7 +17,7 @@ pub struct LoginQuery { } #[derive(Template)] -#[template(path = "login.html")] +#[template(path = "pages/login.html")] struct LoginTemplate { nav_active: &'static str, is_authenticated: bool, diff --git a/src/application/routes/webauthn.rs b/src/application/routes/webauthn.rs index 2339c9a..b5ccde5 100644 --- a/src/application/routes/webauthn.rs +++ b/src/application/routes/webauthn.rs @@ -25,7 +25,7 @@ const SESSION_COOKIE_NAME: &str = "brewlog_session"; // --- Templates --- #[derive(Template)] -#[template(path = "register.html")] +#[template(path = "pages/register.html")] struct RegisterTemplate { nav_active: &'static str, is_authenticated: bool, @@ -34,7 +34,7 @@ struct RegisterTemplate { } #[derive(Template)] -#[template(path = "cli_callback.html")] +#[template(path = "pages/cli_callback.html")] struct CliCallbackTemplate { nav_active: &'static str, is_authenticated: bool, diff --git a/src/presentation/web/templates.rs b/src/presentation/web/templates.rs index 79daf9e..4204c46 100644 --- a/src/presentation/web/templates.rs +++ b/src/presentation/web/templates.rs @@ -15,7 +15,7 @@ use crate::domain::roasts::{RoastSortKey, RoastWithRoaster}; use crate::domain::timeline::TimelineSortKey; #[derive(Template)] -#[template(path = "partials/roaster_list.html")] +#[template(path = "partials/lists/roaster_list.html")] pub struct RoasterListTemplate { pub is_authenticated: bool, pub roasters: Paginated, @@ -23,7 +23,7 @@ pub struct RoasterListTemplate { } #[derive(Template)] -#[template(path = "partials/roast_list.html")] +#[template(path = "partials/lists/roast_list.html")] pub struct RoastListTemplate { pub is_authenticated: bool, pub roasts: Paginated, @@ -31,7 +31,7 @@ pub struct RoastListTemplate { } #[derive(Template)] -#[template(path = "timeline.html")] +#[template(path = "pages/timeline.html")] pub struct TimelineTemplate { pub nav_active: &'static str, pub is_authenticated: bool, @@ -52,7 +52,7 @@ pub struct TimelineChunkTemplate { } #[derive(Template)] -#[template(path = "partials/bag_list.html")] +#[template(path = "partials/lists/bag_list.html")] pub struct BagListTemplate { pub is_authenticated: bool, pub bags: Paginated, @@ -60,7 +60,7 @@ pub struct BagListTemplate { } #[derive(Template)] -#[template(path = "partials/gear_list.html")] +#[template(path = "partials/lists/gear_list.html")] pub struct GearListTemplate { pub is_authenticated: bool, pub gear: Paginated, @@ -74,7 +74,7 @@ pub struct RoastOptionsTemplate { } #[derive(Template)] -#[template(path = "partials/brew_list.html")] +#[template(path = "partials/lists/brew_list.html")] pub struct BrewListTemplate { pub is_authenticated: bool, pub brews: Paginated, @@ -82,7 +82,7 @@ pub struct BrewListTemplate { } #[derive(Template)] -#[template(path = "partials/cafe_list.html")] +#[template(path = "partials/lists/cafe_list.html")] pub struct CafeListTemplate { pub is_authenticated: bool, pub cafes: Paginated, @@ -90,7 +90,7 @@ pub struct CafeListTemplate { } #[derive(Template)] -#[template(path = "partials/cup_list.html")] +#[template(path = "partials/lists/cup_list.html")] pub struct CupListTemplate { pub is_authenticated: bool, pub cups: Paginated, @@ -98,7 +98,7 @@ pub struct CupListTemplate { } #[derive(Template)] -#[template(path = "home.html")] +#[template(path = "pages/home.html")] pub struct HomeTemplate { pub nav_active: &'static str, pub is_authenticated: bool, @@ -111,7 +111,7 @@ pub struct HomeTemplate { } #[derive(Template)] -#[template(path = "checkin.html")] +#[template(path = "pages/checkin.html")] pub struct CheckInTemplate { pub nav_active: &'static str, pub is_authenticated: bool, @@ -128,7 +128,7 @@ pub struct NearbyCafesFragment { } #[derive(Template)] -#[template(path = "data.html")] +#[template(path = "pages/data.html")] pub struct DataTemplate { pub nav_active: &'static str, pub is_authenticated: bool, @@ -150,7 +150,7 @@ pub struct Tab { } #[derive(Template)] -#[template(path = "add.html")] +#[template(path = "pages/add.html")] pub struct AddTemplate { pub nav_active: &'static str, pub is_authenticated: bool, diff --git a/templates/base.html b/templates/base.html index e8ae349..66220e1 100644 --- a/templates/base.html +++ b/templates/base.html @@ -99,7 +99,7 @@
- {% include "nav.html" %} {% block content %}{% endblock %} + {% include "partials/nav.html" %} {% block content %}{% endblock %} diff --git a/templates/account.html b/templates/pages/account.html similarity index 100% rename from templates/account.html rename to templates/pages/account.html diff --git a/templates/add.html b/templates/pages/add.html similarity index 84% rename from templates/add.html rename to templates/pages/add.html index 7b31ea3..733633b 100644 --- a/templates/add.html +++ b/templates/pages/add.html @@ -44,90 +44,7 @@ data-on:submit="$_scanSubmitting = true; $_scanError = ''; @post('/api/v1/scan', {contentType: 'form'})" data-on:datastar-fetch="if (!$_scanSubmitting) return; if (evt.detail.type === 'finished') { $_scanSubmitting = false; window.location.href = '/data?type=bags' } else if (evt.detail.type === 'error') { $_scanSubmitting = false; $_scanError = 'Save failed. Please try again.' }" > -
-

Roaster

-

If this roaster already exists, it will be matched automatically.

-
- - - - -
-
-
-

Roast

-

Details about this specific coffee.

-
- - - - - - -
-
-
- -
- -
-
- - -
- - -
+ {% include "partials/forms/scan_result_form.html" %} diff --git a/templates/checkin.html b/templates/pages/checkin.html similarity index 100% rename from templates/checkin.html rename to templates/pages/checkin.html diff --git a/templates/cli_callback.html b/templates/pages/cli_callback.html similarity index 100% rename from templates/cli_callback.html rename to templates/pages/cli_callback.html diff --git a/templates/data.html b/templates/pages/data.html similarity index 100% rename from templates/data.html rename to templates/pages/data.html diff --git a/templates/home.html b/templates/pages/home.html similarity index 69% rename from templates/home.html rename to templates/pages/home.html index a6f7f82..c76ed8c 100644 --- a/templates/home.html +++ b/templates/pages/home.html @@ -66,90 +66,7 @@ data-on:submit="$_scanSubmitting = true; $_scanError = ''; @post('/api/v1/scan', {contentType: 'form'})" data-on:datastar-fetch="if (!$_scanSubmitting) return; if (evt.detail.type === 'finished') { $_scanSubmitting = false; $_scanExtracted = false; $_roasterName = ''; $_roasterCountry = ''; $_roasterCity = ''; $_roasterHomepage = ''; $_roastName = ''; $_origin = ''; $_region = ''; $_producer = ''; $_process = ''; $_tastingNotes = ''; $_openBag = true; $_bagAmount = 250; window.location.reload() } else if (evt.detail.type === 'error') { $_scanSubmitting = false; $_scanError = 'Save failed. Please try again.' }" > -
-

Roaster

-

If this roaster already exists, it will be matched automatically.

-
- - - - -
-
-
-

Roast

-

Details about this specific coffee.

-
- - - - - - -
-
-
- -
- -
-
- - -
- - -
+ {% include "partials/forms/scan_result_form.html" %} diff --git a/templates/login.html b/templates/pages/login.html similarity index 100% rename from templates/login.html rename to templates/pages/login.html diff --git a/templates/register.html b/templates/pages/register.html similarity index 100% rename from templates/register.html rename to templates/pages/register.html diff --git a/templates/timeline.html b/templates/pages/timeline.html similarity index 100% rename from templates/timeline.html rename to templates/pages/timeline.html diff --git a/templates/partials/forms/scan_result_form.html b/templates/partials/forms/scan_result_form.html new file mode 100644 index 0000000..bc5c93f --- /dev/null +++ b/templates/partials/forms/scan_result_form.html @@ -0,0 +1,84 @@ +
+

Roaster

+

If this roaster already exists, it will be matched automatically.

+
+ + + + +
+
+
+

Roast

+

Details about this specific coffee.

+
+ + + + + + +
+
+
+ +
+ +
+
+ + +
+ + +
diff --git a/templates/partials/bag_list.html b/templates/partials/lists/bag_list.html similarity index 99% rename from templates/partials/bag_list.html rename to templates/partials/lists/bag_list.html index 3f7a786..a404f2e 100644 --- a/templates/partials/bag_list.html +++ b/templates/partials/lists/bag_list.html @@ -1,4 +1,4 @@ -{% import "partials/table.html" as table %} +{% import "partials/lists/table.html" as table %} {% import "partials/icons.html" as icons %}
diff --git a/templates/partials/brew_list.html b/templates/partials/lists/brew_list.html similarity index 99% rename from templates/partials/brew_list.html rename to templates/partials/lists/brew_list.html index adfd279..9cc4363 100644 --- a/templates/partials/brew_list.html +++ b/templates/partials/lists/brew_list.html @@ -1,4 +1,4 @@ -{% import "partials/table.html" as table %} +{% import "partials/lists/table.html" as table %} {% import "partials/icons.html" as icons %}
diff --git a/templates/partials/cafe_list.html b/templates/partials/lists/cafe_list.html similarity index 99% rename from templates/partials/cafe_list.html rename to templates/partials/lists/cafe_list.html index 9d65e0c..6b836a9 100644 --- a/templates/partials/cafe_list.html +++ b/templates/partials/lists/cafe_list.html @@ -1,4 +1,4 @@ -{% import "partials/table.html" as table %} +{% import "partials/lists/table.html" as table %} {% import "partials/icons.html" as icons %}
diff --git a/templates/partials/cup_list.html b/templates/partials/lists/cup_list.html similarity index 98% rename from templates/partials/cup_list.html rename to templates/partials/lists/cup_list.html index a0f014c..ddac0a7 100644 --- a/templates/partials/cup_list.html +++ b/templates/partials/lists/cup_list.html @@ -1,4 +1,4 @@ -{% import "partials/table.html" as table %} +{% import "partials/lists/table.html" as table %} {% import "partials/icons.html" as icons %}
diff --git a/templates/partials/gear_list.html b/templates/partials/lists/gear_list.html similarity index 98% rename from templates/partials/gear_list.html rename to templates/partials/lists/gear_list.html index 55d89eb..81b931f 100644 --- a/templates/partials/gear_list.html +++ b/templates/partials/lists/gear_list.html @@ -1,4 +1,4 @@ -{% import "partials/table.html" as table %} +{% import "partials/lists/table.html" as table %} {% import "partials/icons.html" as icons %}
diff --git a/templates/partials/roast_list.html b/templates/partials/lists/roast_list.html similarity index 99% rename from templates/partials/roast_list.html rename to templates/partials/lists/roast_list.html index dca9964..6de0ca7 100644 --- a/templates/partials/roast_list.html +++ b/templates/partials/lists/roast_list.html @@ -1,4 +1,4 @@ -{% import "partials/table.html" as table %} +{% import "partials/lists/table.html" as table %} {% import "partials/icons.html" as icons %}
diff --git a/templates/partials/roaster_list.html b/templates/partials/lists/roaster_list.html similarity index 99% rename from templates/partials/roaster_list.html rename to templates/partials/lists/roaster_list.html index 44bcd04..a97074e 100644 --- a/templates/partials/roaster_list.html +++ b/templates/partials/lists/roaster_list.html @@ -1,4 +1,4 @@ -{% import "partials/table.html" as table %} +{% import "partials/lists/table.html" as table %} {% import "partials/icons.html" as icons %}
diff --git a/templates/partials/table.html b/templates/partials/lists/table.html similarity index 100% rename from templates/partials/table.html rename to templates/partials/lists/table.html diff --git a/templates/nav.html b/templates/partials/nav.html similarity index 100% rename from templates/nav.html rename to templates/partials/nav.html