From 340b4e29a605ba998640e37d371a96560651756f Mon Sep 17 00:00:00 2001 From: Olivier 'reivilibre Date: Tue, 5 Apr 2022 22:14:42 +0100 Subject: [PATCH] Simplify web config --- quickpeep/src/config.rs | 4 ++-- quickpeep/src/web/searcher.rs | 7 ++----- quickpeep/src/web/seed_collector.rs | 4 ++-- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/quickpeep/src/config.rs b/quickpeep/src/config.rs index 79e3bb0..9c02d05 100644 --- a/quickpeep/src/config.rs +++ b/quickpeep/src/config.rs @@ -11,8 +11,6 @@ pub struct SeedCollectionConfig { pub column1: SeedTagColumn, pub column2: SeedTagColumn, pub column3: SeedTagColumn, - /// Name, URL pairs - pub contact: Vec<(String, String)>, } #[derive(Debug, Clone, Deserialize)] @@ -20,6 +18,8 @@ pub struct WebConfig { pub seed_collection: SeedCollectionConfig, pub sqlite_db_path: PathBuf, pub index: BackendConfig, + /// Name, URL pairs + pub contact: Vec<(String, String)>, } impl WebConfig { diff --git a/quickpeep/src/web/searcher.rs b/quickpeep/src/web/searcher.rs index 1dca677..639f29e 100644 --- a/quickpeep/src/web/searcher.rs +++ b/quickpeep/src/web/searcher.rs @@ -30,11 +30,10 @@ pub struct ExcerptFragment { } pub async fn search_root(Extension(web_config): Extension) -> impl IntoResponse { - let seed_config = &web_config.seed_collection; TemplatedHtml(SearchTemplate { search_term: String::with_capacity(0), results: vec![], - contact: seed_config.contact.clone(), + contact: web_config.contact.clone(), }) } @@ -59,8 +58,6 @@ pub async fn search_search_inner( Extension(index_access): Extension, Query(params): Query, ) -> anyhow::Result { - let seed_config = &web_config.seed_collection; - let raw_results = index_access.backend.query(params.q.clone())?; let mut results = Vec::with_capacity(raw_results.len()); @@ -78,6 +75,6 @@ pub async fn search_search_inner( Ok(TemplatedHtml(SearchTemplate { search_term: params.q.clone(), results, - contact: seed_config.contact.clone(), + contact: web_config.contact.clone(), })) } diff --git a/quickpeep/src/web/seed_collector.rs b/quickpeep/src/web/seed_collector.rs index a0fa8c3..217e6cc 100644 --- a/quickpeep/src/web/seed_collector.rs +++ b/quickpeep/src/web/seed_collector.rs @@ -43,7 +43,7 @@ pub async fn seed_collection_root( column2: seed_config.column2.clone(), column3: seed_config.column3.clone(), thanks_for_submitting: false, - contact: seed_config.contact.clone(), + contact: web_config.contact.clone(), }) } @@ -117,7 +117,7 @@ pub async fn seed_collection_root_post_inner( column2: seed_config.column2.clone(), column3: seed_config.column3.clone(), thanks_for_submitting: true, - contact: seed_config.contact.clone(), + contact: web_config.contact.clone(), })) }