diff --git a/src/generic_handlers.rs b/src/generic_handlers.rs index 09e0cd1..a344808 100644 --- a/src/generic_handlers.rs +++ b/src/generic_handlers.rs @@ -1,6 +1,6 @@ use axum::response::{IntoResponse, Redirect}; -use crate::{templates::Index, AuthContext}; +use crate::{AuthContext, MainPage}; pub async fn handle_slash_redir() -> impl IntoResponse { Redirect::to("/") @@ -13,7 +13,7 @@ pub async fn handle_slash(auth: AuthContext) -> impl IntoResponse { } else { tracing::debug!("Not logged in."); } - Index { + MainPage { user: auth.current_user, } } diff --git a/src/lib.rs b/src/lib.rs index e4b88d5..87f46a3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -18,6 +18,9 @@ pub(crate) mod templates; pub mod users; pub(crate) mod util; pub mod watches; +pub use templates::*; +pub use watches::templates::*; +use watches::{ShowKind, Watch}; #[cfg(test)] pub mod test_utils; diff --git a/src/login.rs b/src/login.rs index f9532f2..5467de1 100644 --- a/src/login.rs +++ b/src/login.rs @@ -10,11 +10,7 @@ use axum::{ }; use sqlx::SqlitePool; -use crate::{ - templates::{LoginGet, LoginPost, LogoutGet, LogoutPost}, - util::form_decode, - AuthContext, User, -}; +use crate::{util::form_decode, AuthContext, LoginGet, LoginPost, LogoutGet, LogoutPost, User}; //-************************************************************************ // Constants @@ -104,7 +100,7 @@ pub async fn post_logout(mut auth: AuthContext) -> impl IntoResponse { #[cfg(test)] mod test { use crate::{ - templates::{Index, LoginGet, LogoutGet, LogoutPost}, + templates::{LoginGet, LogoutGet, LogoutPost, MainPage}, test_utils::{get_test_user, massage, server, FORM_CONTENT_TYPE}, }; @@ -198,7 +194,7 @@ mod test { .await; assert_eq!(resp.status_code(), 303); - let logged_in = Index { + let logged_in = MainPage { user: Some(get_test_user()), } .to_string(); diff --git a/src/signup.rs b/src/signup.rs index 71e2369..523e28e 100644 --- a/src/signup.rs +++ b/src/signup.rs @@ -11,10 +11,7 @@ use sqlx::{query_as, SqlitePool}; use unicode_segmentation::UnicodeSegmentation; use uuid::Uuid; -use crate::{ - templates::{CreateUser, CreateUserSuccess}, - User, -}; +use crate::{CreateUser, CreateUserSuccess, User}; pub(crate) const CREATE_QUERY: &str = "insert into witches (id, username, displayname, email, pwhash) values ($1, $2, $3, $4, $5)"; @@ -29,7 +26,7 @@ const ID_QUERY: &str = "select * from witches where id = $1"; pub struct CreateUserError(#[from] CreateUserErrorKind); impl IntoResponse for CreateUserError { - fn into_response(self) -> askama_axum::Response { + fn into_response(self) -> Response { match self.0 { CreateUserErrorKind::UnknownDBError => { (StatusCode::INTERNAL_SERVER_ERROR, format!("{self}")).into_response() diff --git a/src/templates.rs b/src/templates.rs index 9f8748d..4d624f6 100644 --- a/src/templates.rs +++ b/src/templates.rs @@ -41,6 +41,6 @@ pub struct LogoutPost; #[derive(Debug, Default, Template, Deserialize, Serialize, PartialEq, Eq)] #[template(path = "index.html")] -pub struct Index { +pub struct MainPage { pub user: Option, } diff --git a/src/watches/templates.rs b/src/watches/templates.rs new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/src/watches/templates.rs @@ -0,0 +1 @@ + diff --git a/templates/get_watches.rs b/templates/get_watches.rs new file mode 100644 index 0000000..e69de29