From 82eeead643c7f4ba9a957fc87e090ed540cb9111 Mon Sep 17 00:00:00 2001 From: Brent Schroeter Date: Tue, 25 Mar 2025 11:40:02 -0700 Subject: [PATCH] add placeholder i18n segment to url paths --- src/channels_router.rs | 8 ++++---- src/nav_state.rs | 8 ++++---- src/projects_router.rs | 2 +- src/router.rs | 9 ++++++--- src/teams_router.rs | 8 ++++---- templates/channel-email.html | 8 ++++---- templates/channels.html | 6 +++--- templates/nav.html | 6 +++--- templates/new-team.html | 9 ++------- templates/project.html | 4 ++-- templates/projects.html | 4 ++-- templates/teams.html | 4 ++-- 12 files changed, 37 insertions(+), 39 deletions(-) diff --git a/src/channels_router.rs b/src/channels_router.rs index b3e7871..b4c630f 100644 --- a/src/channels_router.rs +++ b/src/channels_router.rs @@ -158,7 +158,7 @@ async fn post_new_channel( }; Ok(Redirect::to(&format!( - "{}/teams/{}/channels/{}", + "{}/en/teams/{}/channels/{}", base_path, team.id.simple(), channel.id.simple() @@ -276,7 +276,7 @@ async fn update_channel( )); } Ok(Redirect::to(&format!( - "{}/teams/{}/channels/{}", + "{}/en/teams/{}/channels/{}", base_path, team_id.simple(), channel_id.simple() @@ -366,7 +366,7 @@ async fn update_channel_email_recipient( mailer.send_batch(vec![email]).await.remove(0)?; Ok(Redirect::to(&format!( - "{}/teams/{}/channels/{}", + "{}/en/teams/{}/channels/{}", base_path, team_id.simple(), channel_id.simple() @@ -447,7 +447,7 @@ async fn verify_email( }; Ok(Redirect::to(&format!( - "{}/teams/{}/channels/{}", + "{}/en/teams/{}/channels/{}", base_path, team_id.simple(), channel_id.simple() diff --git a/src/nav_state.rs b/src/nav_state.rs index 652a69b..e957929 100644 --- a/src/nav_state.rs +++ b/src/nav_state.rs @@ -34,11 +34,11 @@ impl NavState { self.team_id = Some(team.id); self.navbar_active_item = "teams".to_string(); self.breadcrumbs.push(Breadcrumb { - href: format!("{}/teams", self.base_path), + href: format!("{}/en/teams", self.base_path), label: "Teams".to_string(), }); self.breadcrumbs.push(Breadcrumb { - href: format!("{}/teams/{}", self.base_path, team.id.simple()), + href: format!("{}/en/teams/{}", self.base_path, team.id.simple()), label: team.name.clone(), }); self @@ -50,12 +50,12 @@ impl NavState { ))?; self.navbar_active_item = "projects".to_string(); self.breadcrumbs.push(Breadcrumb { - href: format!("{}/teams/{}/projects", self.base_path, team_id), + href: format!("{}/en/teams/{}/projects", self.base_path, team_id), label: "Projects".to_string(), }); self.breadcrumbs.push(Breadcrumb { href: format!( - "{}/teams/{}/projects/{}", + "{}/en/teams/{}/projects/{}", self.base_path, team_id, project.id.simple() diff --git a/src/projects_router.rs b/src/projects_router.rs index 6aba665..3dfc35b 100644 --- a/src/projects_router.rs +++ b/src/projects_router.rs @@ -230,7 +230,7 @@ async fn update_enabled_channels( .unwrap()?; Ok(Redirect::to(&format!( - "{}/teams/{}/projects/{}", + "{}/en/teams/{}/projects/{}", base_path, team_id, project_id )) .into_response()) diff --git a/src/router.rs b/src/router.rs index 664d5f9..c7163f1 100644 --- a/src/router.rs +++ b/src/router.rs @@ -18,12 +18,15 @@ use crate::{ pub fn new_router(state: AppState) -> Router<()> { let base_path = state.settings.base_path.clone(); - let app = Router::new() + let ui_router = Router::new() .route("/", get(landing_page)) .merge(channels_router::new_router()) .merge(projects_router::new_router()) - .merge(teams_router::new_router()) + .merge(teams_router::new_router()); + let app = Router::new() + .route("/", get(landing_page)) .merge(v0_router::new_router()) + .nest("/en", ui_router) .nest("/auth", auth::new_router()) .layer(SetResponseHeaderLayer::if_not_present( CACHE_CONTROL, @@ -57,5 +60,5 @@ pub fn new_router(state: AppState) -> Router<()> { } async fn landing_page(State(Settings { base_path, .. }): State) -> impl IntoResponse { - Redirect::to(&format!("{}/teams", base_path)) + Redirect::to(&format!("{}/en/teams", base_path)) } diff --git a/src/teams_router.rs b/src/teams_router.rs index d5de798..2754a8d 100644 --- a/src/teams_router.rs +++ b/src/teams_router.rs @@ -51,7 +51,7 @@ async fn teams_page( let nav_state = NavState::new() .set_base_path(&base_path) .push_slug(Breadcrumb { - href: "teams".to_string(), + href: "en/teams".to_string(), label: "Teams".to_string(), }) .set_navbar_active_item("teams"); @@ -76,7 +76,7 @@ async fn team_page( State(Settings { base_path, .. }): State, Path(team_id): Path, ) -> impl IntoResponse { - Redirect::to(&format!("{}/teams/{}/projects", base_path, team_id)) + Redirect::to(&format!("{}/en/teams/{}/projects", base_path, team_id)) } #[derive(Deserialize)] @@ -96,7 +96,7 @@ async fn post_new_api_key( ApiKey::generate_for_team(&db_conn, team.id).await?; Ok(Redirect::to(&format!( - "{}/teams/{}/projects", + "{}/en/teams/{}/projects", base_path, team.id.hyphenated() )) @@ -113,7 +113,7 @@ async fn new_team_page( let nav_state = NavState::new() .set_base_path(&base_path) .push_slug(Breadcrumb { - href: "new-team".to_string(), + href: "en/new-team".to_string(), label: "New Team".to_string(), }) .set_navbar_active_item("teams"); diff --git a/templates/channel-email.html b/templates/channel-email.html index 97e9ccb..7165c5f 100644 --- a/templates/channel-email.html +++ b/templates/channel-email.html @@ -12,7 +12,7 @@
@@ -51,7 +51,7 @@
@@ -81,7 +81,7 @@
@@ -50,7 +50,7 @@ {% for channel in channels %} - + {{ channel.name }} diff --git a/templates/nav.html b/templates/nav.html index df19e34..77beb67 100644 --- a/templates/nav.html +++ b/templates/nav.html @@ -18,7 +18,7 @@ Teams @@ -28,7 +28,7 @@ Projects @@ -37,7 +37,7 @@ Channels diff --git a/templates/new-team.html b/templates/new-team.html index 4cb9f37..5b0dd49 100644 --- a/templates/new-team.html +++ b/templates/new-team.html @@ -1,12 +1,7 @@ {% extends "base.html" %} {% block main %} - +{% include "breadcrumbs.html" %}

New Team

@@ -19,7 +14,7 @@
- + Cancel
diff --git a/templates/project.html b/templates/project.html index cc99c04..c283c08 100644 --- a/templates/project.html +++ b/templates/project.html @@ -12,7 +12,7 @@

Enabled Channels

@@ -29,7 +29,7 @@ @@ -53,7 +53,7 @@

API Keys

- + diff --git a/templates/teams.html b/templates/teams.html index a607459..a52e894 100644 --- a/templates/teams.html +++ b/templates/teams.html @@ -9,7 +9,7 @@

Teams

@@ -24,7 +24,7 @@ {% for team in teams %}
- + {{ project.name }}
- + {{ team.name }}