Simplify web config
This commit is contained in:
parent
3c3e2fc0bf
commit
340b4e29a6
@ -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 {
|
||||
|
@ -30,11 +30,10 @@ pub struct ExcerptFragment {
|
||||
}
|
||||
|
||||
pub async fn search_root(Extension(web_config): Extension<WebConfig>) -> 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<IndexAccess>,
|
||||
Query(params): Query<QueryParameters>,
|
||||
) -> anyhow::Result<impl IntoResponse> {
|
||||
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(),
|
||||
}))
|
||||
}
|
||||
|
@ -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(),
|
||||
}))
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user