Use the unified config in the web UI
This commit is contained in:
parent
340b4e29a6
commit
dd0097c1aa
|
@ -60,6 +60,7 @@ pub async fn main() -> anyhow::Result<()> {
|
||||||
})
|
})
|
||||||
.connect(
|
.connect(
|
||||||
&web_config
|
&web_config
|
||||||
|
.web
|
||||||
.sqlite_db_path
|
.sqlite_db_path
|
||||||
.to_str()
|
.to_str()
|
||||||
.context("SQLite DB path should be UTF-8")?,
|
.context("SQLite DB path should be UTF-8")?,
|
||||||
|
|
|
@ -57,6 +57,7 @@ pub async fn main() -> anyhow::Result<()> {
|
||||||
})
|
})
|
||||||
.connect(
|
.connect(
|
||||||
&web_config
|
&web_config
|
||||||
|
.web
|
||||||
.sqlite_db_path
|
.sqlite_db_path
|
||||||
.to_str()
|
.to_str()
|
||||||
.context("SQLite DB path should be UTF-8")?,
|
.context("SQLite DB path should be UTF-8")?,
|
||||||
|
|
|
@ -23,12 +23,13 @@ async fn main() -> anyhow::Result<()> {
|
||||||
)
|
)
|
||||||
.init();
|
.init();
|
||||||
|
|
||||||
let config_path =
|
let config_path = PathBuf::from(
|
||||||
PathBuf::from(std::env::var("QP_WEB_CONFIG").unwrap_or_else(|_| "qp_web.ron".to_owned()));
|
std::env::var("QUICKPEEP_CONFIG").unwrap_or_else(|_| "quickpeep.ron".to_owned()),
|
||||||
|
);
|
||||||
|
|
||||||
if !config_path.exists() {
|
if !config_path.exists() {
|
||||||
bail!(
|
bail!(
|
||||||
"Config path {:?} doesn't exist. QP_WEB_CONFIG env var overrides.",
|
"Config path {:?} doesn't exist. QUICKPEEP_CONFIG env var overrides.",
|
||||||
config_path
|
config_path
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -54,6 +55,7 @@ async fn main() -> anyhow::Result<()> {
|
||||||
})
|
})
|
||||||
.connect(
|
.connect(
|
||||||
&web_config
|
&web_config
|
||||||
|
.web
|
||||||
.sqlite_db_path
|
.sqlite_db_path
|
||||||
.to_str()
|
.to_str()
|
||||||
.context("SQLite DB path should be UTF-8")?,
|
.context("SQLite DB path should be UTF-8")?,
|
||||||
|
|
|
@ -15,9 +15,14 @@ pub struct SeedCollectionConfig {
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize)]
|
#[derive(Debug, Clone, Deserialize)]
|
||||||
pub struct WebConfig {
|
pub struct WebConfig {
|
||||||
|
pub web: WebOnlyConfig,
|
||||||
|
pub index: BackendConfig,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Deserialize)]
|
||||||
|
pub struct WebOnlyConfig {
|
||||||
pub seed_collection: SeedCollectionConfig,
|
pub seed_collection: SeedCollectionConfig,
|
||||||
pub sqlite_db_path: PathBuf,
|
pub sqlite_db_path: PathBuf,
|
||||||
pub index: BackendConfig,
|
|
||||||
/// Name, URL pairs
|
/// Name, URL pairs
|
||||||
pub contact: Vec<(String, String)>,
|
pub contact: Vec<(String, String)>,
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ pub async fn search_root(Extension(web_config): Extension<WebConfig>) -> impl In
|
||||||
TemplatedHtml(SearchTemplate {
|
TemplatedHtml(SearchTemplate {
|
||||||
search_term: String::with_capacity(0),
|
search_term: String::with_capacity(0),
|
||||||
results: vec![],
|
results: vec![],
|
||||||
contact: web_config.contact.clone(),
|
contact: web_config.web.contact.clone(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,6 +75,6 @@ pub async fn search_search_inner(
|
||||||
Ok(TemplatedHtml(SearchTemplate {
|
Ok(TemplatedHtml(SearchTemplate {
|
||||||
search_term: params.q.clone(),
|
search_term: params.q.clone(),
|
||||||
results,
|
results,
|
||||||
contact: web_config.contact.clone(),
|
contact: web_config.web.contact.clone(),
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,13 +37,13 @@ pub async fn seed_collection_root(
|
||||||
Extension(web_config): Extension<WebConfig>,
|
Extension(web_config): Extension<WebConfig>,
|
||||||
) -> impl IntoResponse {
|
) -> impl IntoResponse {
|
||||||
// TODO(perf): cloning is a bit ugly; can we do better?
|
// TODO(perf): cloning is a bit ugly; can we do better?
|
||||||
let seed_config = &web_config.seed_collection;
|
let seed_config = &web_config.web.seed_collection;
|
||||||
TemplatedHtml(SeedCollectionFormTemplate {
|
TemplatedHtml(SeedCollectionFormTemplate {
|
||||||
column1: seed_config.column1.clone(),
|
column1: seed_config.column1.clone(),
|
||||||
column2: seed_config.column2.clone(),
|
column2: seed_config.column2.clone(),
|
||||||
column3: seed_config.column3.clone(),
|
column3: seed_config.column3.clone(),
|
||||||
thanks_for_submitting: false,
|
thanks_for_submitting: false,
|
||||||
contact: web_config.contact.clone(),
|
contact: web_config.web.contact.clone(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ pub async fn seed_collection_root_post_inner(
|
||||||
eprintln!("{:?}", form);
|
eprintln!("{:?}", form);
|
||||||
|
|
||||||
let mut tags = BTreeSet::new();
|
let mut tags = BTreeSet::new();
|
||||||
let seed_config = &web_config.seed_collection;
|
let seed_config = &web_config.web.seed_collection;
|
||||||
|
|
||||||
for tag_group in itertools::chain!(
|
for tag_group in itertools::chain!(
|
||||||
&seed_config.column1,
|
&seed_config.column1,
|
||||||
|
@ -117,7 +117,7 @@ pub async fn seed_collection_root_post_inner(
|
||||||
column2: seed_config.column2.clone(),
|
column2: seed_config.column2.clone(),
|
||||||
column3: seed_config.column3.clone(),
|
column3: seed_config.column3.clone(),
|
||||||
thanks_for_submitting: true,
|
thanks_for_submitting: true,
|
||||||
contact: web_config.contact.clone(),
|
contact: web_config.web.contact.clone(),
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue