features, cleanup and bug fixes #26
5 changed files with 71 additions and 23 deletions
allow adding/changing/removing footer links via configuration
commit
353414720a
|
|
@ -7,3 +7,7 @@ type = 'Development'
|
|||
[email]
|
||||
from = "jobs@localhost"
|
||||
subject = "Test"
|
||||
|
||||
[[footer_links]]
|
||||
title = "Test"
|
||||
url = "https://fs-infmath.uni-kiel.de"
|
||||
|
|
|
|||
|
|
@ -33,3 +33,17 @@ type = 'Disabled' # deny all login attempts without further configuration option
|
|||
# from = "jobs@example.com"
|
||||
# # content of the SUBJECT header for the confirmation emails
|
||||
# subject = "[Jobbörse] Please, confirm your job-offer submission."
|
||||
|
||||
# you can add additional footer links by adding [[footer_links]] entries
|
||||
# [[footer_links]]
|
||||
# title = "Example"
|
||||
# url = "https://example.com"
|
||||
|
||||
# the default footer links Impressum, Homepage and Source Repository can be overriten by adding a matching [[footer_links]] entry
|
||||
# [[footer_links]]
|
||||
# title = "Homepage"
|
||||
# url = "https://example.com/home"
|
||||
|
||||
# default footer links can also be removed by adding a matching section here without an URL
|
||||
# [[footer_links]]
|
||||
# title = "Source Repository"
|
||||
|
|
|
|||
57
src/route.rs
57
src/route.rs
|
|
@ -56,7 +56,7 @@ async fn static_index_css() -> Result<NamedFile, actix_web::Error> {
|
|||
struct BaseData<'a> {
|
||||
title: Cow<'a, str>,
|
||||
short_lang: Cow<'a, str>,
|
||||
links: BaseLinks<'a>,
|
||||
links: Vec<Link<'a>>,
|
||||
#[serde(serialize_with = "crate::route::urls_as_string")]
|
||||
styles: Vec<Url>,
|
||||
routes: StaticRoutes,
|
||||
|
|
@ -66,13 +66,6 @@ struct BaseData<'a> {
|
|||
date: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct BaseLinks<'a> {
|
||||
impress: Cow<'a, str>,
|
||||
repository: Option<Cow<'a, str>>,
|
||||
homepage: Option<Cow<'a, str>>,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct StaticRoutes {
|
||||
#[serde(serialize_with = "crate::route::url_as_string")]
|
||||
|
|
@ -112,9 +105,15 @@ where
|
|||
.serialize(serializer)
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct Link<'a> {
|
||||
title: &'a str,
|
||||
url: &'a str,
|
||||
}
|
||||
|
||||
fn base<'a>(
|
||||
req: &HttpRequest,
|
||||
config: &ServerConfig,
|
||||
config: &'a ServerConfig,
|
||||
title: &'a str,
|
||||
) -> Result<BaseData<'a>, UrlGenerationError> {
|
||||
let licenses_route = req.url_for_static(LICENSES_ROUTE)?;
|
||||
|
|
@ -128,26 +127,52 @@ fn base<'a>(
|
|||
let joboffers_delete_expired_route = req.url_for_static(JOBOFFER_DELETE_EXPIRED_ROUTE)?;
|
||||
let index_css = req.url_for_static(INDEX_CSS_ROUTE)?;
|
||||
|
||||
let mut default_links = vec![(
|
||||
"Impressum",
|
||||
Some("https://www.fs-infmath.uni-kiel.de/wiki/Fachschaften_Informatik_%26_Mathematik:Impressum"),
|
||||
),
|
||||
(
|
||||
"Homepage",
|
||||
crate::PROJECT_HOMEPAGE
|
||||
),
|
||||
(
|
||||
"Source Repository",
|
||||
crate::PROJECT_REPO,
|
||||
)
|
||||
];
|
||||
|
||||
let links = config
|
||||
.config
|
||||
.footer_links
|
||||
.iter()
|
||||
.map(|elem| {
|
||||
default_links.retain(|&(title, _)| title != &elem.title);
|
||||
(elem.title.as_str(), elem.url.as_deref())
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let links: Vec<_> = default_links
|
||||
.into_iter()
|
||||
.chain(links.into_iter())
|
||||
.filter_map(|(title, url)| url.map(|url| Link { title, url }))
|
||||
.collect();
|
||||
|
||||
let dev_available = cfg!(feature = "dev_mode");
|
||||
let data = BaseData {
|
||||
title: title.into(),
|
||||
short_lang: "de".into(),
|
||||
styles: vec![index_css],
|
||||
links: BaseLinks {
|
||||
impress: "https://www.fs-infmath.uni-kiel.de/wiki/Fachschaften_Informatik_%26_Mathematik:Impressum".into(),
|
||||
repository: crate::PROJECT_REPO.map(Into::into),
|
||||
homepage: crate::PROJECT_HOMEPAGE.map(Into::into)
|
||||
},
|
||||
links,
|
||||
routes: StaticRoutes {
|
||||
licenses: licenses_route,
|
||||
login: login_route,
|
||||
logout: logout_route,
|
||||
sync: sync_route,
|
||||
index:index_route,
|
||||
index: index_route,
|
||||
joboffer_overview: joboffer_overview_route,
|
||||
joboffer_create: joboffer_creation_route,
|
||||
joboffer_summary: joboffer_summary_route,
|
||||
joboffers_delete_expired: joboffers_delete_expired_route
|
||||
joboffers_delete_expired: joboffers_delete_expired_route,
|
||||
},
|
||||
banner: config.config.banner.clone(),
|
||||
operation_mode: config.args.mode.clone(),
|
||||
|
|
|
|||
|
|
@ -31,11 +31,20 @@ pub(crate) struct ProgramConfig {
|
|||
pub(crate) data_storage_path: PathBuf,
|
||||
#[serde(skip_serializing_if = "Option::is_none", default)]
|
||||
pub(crate) banner: Option<String>,
|
||||
#[serde(default)]
|
||||
pub(crate) footer_links: Vec<Link>,
|
||||
pub(crate) login_provider: LoginProviderConfig,
|
||||
#[serde(skip_serializing_if = "Option::is_none", default)]
|
||||
pub(crate) email: Option<EmailConfig>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub(crate) struct Link {
|
||||
pub(crate) title: String,
|
||||
#[serde(default)]
|
||||
pub(crate) url: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub(crate) struct EmailConfig {
|
||||
pub(crate) from: Mailbox,
|
||||
|
|
|
|||
|
|
@ -1,12 +1,8 @@
|
|||
<footer class="footer">
|
||||
<nav class="footer-inner">
|
||||
<a class="footer-element" href="{{base.links.impress}}"><h3 class="inline">Impressum</h3></a>
|
||||
{{#if base.links.homepage}}
|
||||
<span>|</span><a class="footer-element" href="{{base.links.homepage}}"><h3 class="inline">Homepage</h3></a>
|
||||
{{/if}}
|
||||
{{#if base.links.repository}}
|
||||
<span>|</span><a class="footer-element" href="{{base.links.repository}}"><h3 class="inline">Source Repository</h3></a>
|
||||
{{/if}}
|
||||
{{#each base.links as |link|}}
|
||||
{{#unless @first}}<span>|</span>{{/unless}}<a class="footer-element" href="{{link.url}}"><h3 class="inline">{{link.title}}</h3></a>
|
||||
{{/each}}
|
||||
<span>|</span><a class="footer-element" href="{{base.routes.licenses}}"><h3 class="inline">Third-party Licenses</h3></a>
|
||||
<span>|</span><a class="footer-element" href="{{base.routes.joboffer_create}}"><h3 class="inline">Stellenanzeige Einreichen</h3></a>
|
||||
{{#if user}}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue