From 139b7ec10bc7f08dae9bd57eef8eff73fbb22061 Mon Sep 17 00:00:00 2001 From: Vika Date: Sat, 7 May 2022 20:28:43 +0300 Subject: Split into different crates Templates and utility types are now separate crates to speed up compilation, linting and potential reuse/replacement. Potentially more crates could be split out/modularized, resulting in speedups, smaller binaries (whenever features are excluded) and even more reuse capabilities. --- src/frontend/mod.rs | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) (limited to 'src/frontend/mod.rs') diff --git a/src/frontend/mod.rs b/src/frontend/mod.rs index daeebd9..106d839 100644 --- a/src/frontend/mod.rs +++ b/src/frontend/mod.rs @@ -4,21 +4,12 @@ use serde::{Deserialize, Serialize}; use futures_util::TryFutureExt; use warp::{http::StatusCode, Filter, host::Authority, path::FullPath}; -static POSTS_PER_PAGE: usize = 20; - //pub mod login; -mod templates; #[allow(unused_imports)] -use templates::{ErrorPage, MainPage, OnboardingPage, Template}; - -#[derive(Clone, Serialize, Deserialize)] -pub struct IndiewebEndpoints { - pub authorization_endpoint: String, - pub token_endpoint: String, - pub webmention: Option, - pub microsub: Option, -} +use kittybox_templates::{ErrorPage, MainPage, OnboardingPage, Template, POSTS_PER_PAGE}; + +pub use kittybox_util::IndiewebEndpoints; #[derive(Deserialize)] struct QueryParams { @@ -364,17 +355,17 @@ pub fn catchall(db: D, endpoints: IndiewebEndpoints) -> impl Filter< { Some("h-entry") => Ok(( post_name.unwrap_or("Note").to_string(), - templates::Entry { post: &post }.to_string(), + kittybox_templates::Entry { post: &post }.to_string(), StatusCode::OK )), Some("h-card") => Ok(( post_name.unwrap_or("Contact card").to_string(), - templates::VCard { card: &post }.to_string(), + kittybox_templates::VCard { card: &post }.to_string(), StatusCode::OK )), Some("h-feed") => Ok(( post_name.unwrap_or("Feed").to_string(), - templates::Feed { feed: &post }.to_string(), + kittybox_templates::Feed { feed: &post }.to_string(), StatusCode::OK )), _ => Err(warp::reject::custom(FrontendError::with_code( -- cgit 1.4.1