update
This commit is contained in:
parent
14a9704249
commit
e0d2a5876d
3 changed files with 32 additions and 6 deletions
|
@ -1,11 +1,10 @@
|
||||||
|
|
||||||
projects:
|
projects:
|
||||||
root:
|
root:
|
||||||
name: "Root Project"
|
name: "Root Project"
|
||||||
description: "Root Project"
|
description: "Root Project"
|
||||||
website: "https://example.com"
|
website: "https://example.com"
|
||||||
documentation: "https://docs.example.com"
|
documentation: "https://docs.example.com"
|
||||||
since: 1999-00-00
|
since: "1999-00-00"
|
||||||
contact:
|
contact:
|
||||||
email: "mail@example.com"
|
email: "mail@example.com"
|
||||||
sub:
|
sub:
|
||||||
|
|
|
@ -15,7 +15,7 @@ pub struct Project {
|
||||||
pub documentation: Option<String>,
|
pub documentation: Option<String>,
|
||||||
pub since: Option<String>,
|
pub since: Option<String>,
|
||||||
pub contact: Option<ContactInfo>,
|
pub contact: Option<ContactInfo>,
|
||||||
pub sub: HashMap<String, Project>,
|
pub sub: Option<HashMap<String, Project>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize)]
|
#[derive(Debug, Clone, Deserialize)]
|
||||||
|
@ -23,9 +23,21 @@ pub struct ContactInfo {
|
||||||
pub email: Option<String>,
|
pub email: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ContactInfo {
|
||||||
|
pub fn build(&self) -> maud::PreEscaped<String> {
|
||||||
|
maud::html!(
|
||||||
|
@if let Some(mail) = &self.email {
|
||||||
|
h3 { "Contact:" };
|
||||||
|
p { "Mail: "; a href=(format!("mailto:{mail}")) { (mail) }};
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Config {
|
impl Config {
|
||||||
pub fn load(path: &str) -> Self {
|
pub fn load(path: &str) -> Self {
|
||||||
serde_yml::from_str(&std::fs::read_to_string(path).unwrap()).unwrap()
|
let content = std::fs::read_to_string(path).unwrap();
|
||||||
|
serde_yml::from_str(&content).unwrap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,12 +49,26 @@ impl Project {
|
||||||
maud::html!(
|
maud::html!(
|
||||||
div class="card" id=(card_id) {
|
div class="card" id=(card_id) {
|
||||||
h3 { (self.name) };
|
h3 { (self.name) };
|
||||||
p { "Description" };
|
p { (self.description) };
|
||||||
|
@if let Some(website) = &self.website {
|
||||||
|
p { "Website: "; a href=(website) { (website) }};
|
||||||
|
}
|
||||||
|
@if let Some(doc) = &self.documentation {
|
||||||
|
p { "Documentation: "; a href=(doc) { (doc) }};
|
||||||
|
}
|
||||||
|
@if let Some(since) = &self.since {
|
||||||
|
p { "Started: "; a href=(since) { (since) }};
|
||||||
|
}
|
||||||
|
@if let Some(contact) = &self.contact {
|
||||||
|
(contact.build())
|
||||||
|
}
|
||||||
button class="expand-button" onclick=(format!("toggleSubcards('{subcard_id}')")) { "Expand" };
|
button class="expand-button" onclick=(format!("toggleSubcards('{subcard_id}')")) { "Expand" };
|
||||||
div class="subcards" id=(subcard_id) {
|
div class="subcards" id=(subcard_id) {
|
||||||
@for (id, prj) in &self.sub {
|
@if let Some(sub) = &self.sub {
|
||||||
|
@for (id, prj) in sub {
|
||||||
(prj.build(id))
|
(prj.build(id))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
)
|
)
|
||||||
|
|
|
@ -12,6 +12,7 @@ pub fn main_page(c: &State<Config>) -> String {
|
||||||
#[launch]
|
#[launch]
|
||||||
async fn rocket() -> _ {
|
async fn rocket() -> _ {
|
||||||
let conf_path: String = std::env::args()
|
let conf_path: String = std::env::args()
|
||||||
|
.skip(1)
|
||||||
.next()
|
.next()
|
||||||
.unwrap_or("./config.yml".to_string());
|
.unwrap_or("./config.yml".to_string());
|
||||||
let conf = config::Config::load(&conf_path);
|
let conf = config::Config::load(&conf_path);
|
||||||
|
|
Loading…
Add table
Reference in a new issue