From 6cf815fd3155d5a22ee07cffc56ae8445955e14b Mon Sep 17 00:00:00 2001 From: GitHub <> Date: Fri, 29 Jul 2022 16:04:12 +0800 Subject: [PATCH] feature: prepare to deploy to github page --- src/app_router.rs | 15 +++++++++++---- src/controller/mod.rs | 13 ++----------- templates/inn.html | 4 ++-- templates/inn_edit.html | 2 +- templates/inn_list.html | 4 ++-- templates/inn_static.html | 2 +- templates/layout.html | 4 ++-- templates/notification.html | 2 +- templates/post.html | 4 ++-- templates/solo.html | 4 ++-- templates/tag.html | 2 +- templates/user.html | 2 +- templates/user_list.html | 8 ++++---- templates/user_setting.html | 2 +- 14 files changed, 33 insertions(+), 35 deletions(-) diff --git a/src/app_router.rs b/src/app_router.rs index fa1459b..333fc84 100644 --- a/src/app_router.rs +++ b/src/app_router.rs @@ -66,11 +66,18 @@ pub(super) async fn router(db: Db) -> Router { .route("/solo/:sid/like", get(solo_like)) .route("/solo/:sid/delete", get(solo_delete)) .layer(Extension(db)) - .route("/css/style.css", get(style)) .route("/health_check", get(health_check)) - .nest("/avatars", serve_dir(&CONFIG.avatars_path).await) - .nest("/inn_icons", serve_dir(&CONFIG.inn_icons_path).await) - .nest("/static/", serve_dir(&CONFIG.html_path).await); + .route("/static/style.css", get(style)) + .nest("/static/avatars", serve_dir(&CONFIG.avatars_path).await) + .nest("/static/inn_icons", serve_dir(&CONFIG.inn_icons_path).await) + .nest( + "/static/inn", + serve_dir(&format!("{}/inn", &CONFIG.html_path)).await, + ) + .nest( + "/static/post", + serve_dir(&format!("{}/post", &CONFIG.html_path)).await, + ); for (path, dir, _) in &CONFIG.serve_dir { let path = format!("/{}", path); diff --git a/src/controller/mod.rs b/src/controller/mod.rs index 5d2c70a..6867c69 100644 --- a/src/controller/mod.rs +++ b/src/controller/mod.rs @@ -283,17 +283,8 @@ where } } -pub(crate) async fn home( - Extension(db): Extension, - cookie: Option>, -) -> Result { - let site_config = get_site_config(&db)?; - let claim = cookie.and_then(|cookie| Claim::get(&db, &cookie, &site_config)); - if claim.is_some() { - Ok(Redirect::to("/inn/0")) - } else { - Ok(Redirect::to("/static/inn/0/1.html")) - } +pub(crate) async fn home() -> impl IntoResponse { + Redirect::to("/inn/0") } #[derive(Deserialize)] diff --git a/templates/inn.html b/templates/inn.html index 385e67b..687c3d4 100644 --- a/templates/inn.html +++ b/templates/inn.html @@ -84,7 +84,7 @@
-

+

@@ -138,7 +138,7 @@
- +

diff --git a/templates/inn_edit.html b/templates/inn_edit.html index 2b24ced..4066ed3 100644 --- a/templates/inn_edit.html +++ b/templates/inn_edit.html @@ -7,7 +7,7 @@
diff --git a/templates/inn_list.html b/templates/inn_list.html index 3685ec6..c212e73 100644 --- a/templates/inn_list.html +++ b/templates/inn_list.html @@ -57,7 +57,7 @@ {% if page_data.claim.is_some() %}
- +
@@ -67,7 +67,7 @@ {% else %}
- +
diff --git a/templates/inn_static.html b/templates/inn_static.html index f22b542..2e55c5d 100644 --- a/templates/inn_static.html +++ b/templates/inn_static.html @@ -31,7 +31,7 @@
-

+

diff --git a/templates/layout.html b/templates/layout.html index 6e994ae..8221822 100644 --- a/templates/layout.html +++ b/templates/layout.html @@ -11,7 +11,7 @@ - + {{ page_data.title }} @@ -84,7 +84,7 @@ - {{val.username}} + {{val.username}} {% else %} diff --git a/templates/notification.html b/templates/notification.html index 10bdcc2..2e52203 100644 --- a/templates/notification.html +++ b/templates/notification.html @@ -14,7 +14,7 @@
-

+

diff --git a/templates/post.html b/templates/post.html index 22c1024..80d3909 100644 --- a/templates/post.html +++ b/templates/post.html @@ -47,7 +47,7 @@

- {{post.username}} + {{post.username}}

@@ -86,7 +86,7 @@
- +
diff --git a/templates/solo.html b/templates/solo.html index bd5014b..d3ab09c 100644 --- a/templates/solo.html +++ b/templates/solo.html @@ -83,7 +83,7 @@

- +

@@ -126,7 +126,7 @@

- +

diff --git a/templates/tag.html b/templates/tag.html index 258a614..4a7a611 100644 --- a/templates/tag.html +++ b/templates/tag.html @@ -33,7 +33,7 @@
-

+

diff --git a/templates/user.html b/templates/user.html index 33ae5df..dce5ff4 100644 --- a/templates/user.html +++ b/templates/user.html @@ -4,7 +4,7 @@

- +

role: {{user.role}}

uid: {{user.uid}}

diff --git a/templates/user_list.html b/templates/user_list.html index 153011e..37d5248 100644 --- a/templates/user_list.html +++ b/templates/user_list.html @@ -24,19 +24,19 @@ {% match filter.as_deref() %} {% when Some with ("followers") %}

- {{info.1}} + {{info.1}}

{% when Some with ("following") %}

- {{info.1}} + {{info.1}}

{% when Some with ("inn") %}

- {{info.1}} + {{info.1}}

{% else %}{% endmatch %} @@ -48,7 +48,7 @@
- +
diff --git a/templates/user_setting.html b/templates/user_setting.html index 6eaf0fc..0bb1a94 100644 --- a/templates/user_setting.html +++ b/templates/user_setting.html @@ -7,7 +7,7 @@