aboutsummaryrefslogtreecommitdiff
path: root/src/app/config.rs
diff options
context:
space:
mode:
authorXe Iaso <me@christine.website>2022-11-24 15:46:42 -0500
committerXe Iaso <me@christine.website>2022-11-24 15:46:42 -0500
commit18fcf051499912f17dd49bc0413e1de58b2d44f2 (patch)
treed16ed58127bfcb8b1b4ee9bdb88fd35cb687c8c9 /src/app/config.rs
parent551e0384c923ff3ee98cfddf7e3eb42c6dbb2941 (diff)
downloadxesite-18fcf051499912f17dd49bc0413e1de58b2d44f2.tar.xz
xesite-18fcf051499912f17dd49bc0413e1de58b2d44f2.zip
Start version 3
* Change version to 3.0.0 in Cargo.toml * Add metadata for series * Change types for signal boosts * Add start of LaTeX resume generation at Nix time * Add start of proper author tagging for posts in JSONFeed and ldjson * Convert templates to use Maud * Add start of dynamic resume generation from dhall * Make patrons page embed thumbnails TODO: * [ ] Remove the rest of the old templates * [ ] Bring in Xeact for the share on mastodon button * [ ] Site update post Signed-off-by: Xe <me@christine.website>
Diffstat (limited to 'src/app/config.rs')
-rw-r--r--src/app/config.rs90
1 files changed, 78 insertions, 12 deletions
diff --git a/src/app/config.rs b/src/app/config.rs
index e0a4d90..6499e72 100644
--- a/src/app/config.rs
+++ b/src/app/config.rs
@@ -1,7 +1,8 @@
use crate::signalboost::Person;
-use maud::{html, Markup};
+use maud::{html, Markup, Render};
use serde::{Deserialize, Serialize};
use std::{
+ collections::HashMap,
fmt::{self, Display},
path::PathBuf,
};
@@ -9,7 +10,9 @@ use std::{
#[derive(Clone, Deserialize, Default)]
pub struct Config {
pub signalboost: Vec<Person>,
- pub authors: Vec<Author>,
+ pub authors: HashMap<String, Author>,
+ #[serde(rename = "defaultAuthor")]
+ pub default_author: Author,
pub port: u16,
#[serde(rename = "clackSet")]
pub clack_set: Vec<String>,
@@ -19,6 +22,35 @@ pub struct Config {
pub mi_token: String,
#[serde(rename = "jobHistory")]
pub job_history: Vec<Job>,
+ #[serde(rename = "seriesDescriptions")]
+ pub series_descriptions: Vec<SeriesDescription>,
+ #[serde(rename = "seriesDescMap")]
+ pub series_desc_map: HashMap<String, String>,
+ #[serde(rename = "notableProjects")]
+ pub notable_projects: Vec<Link>,
+ #[serde(rename = "contactLinks")]
+ pub contact_links: Vec<Link>,
+}
+
+#[derive(Clone, Deserialize, Serialize, Default)]
+pub struct Link {
+ pub url: String,
+ pub title: String,
+ pub description: String,
+}
+
+impl Render for Link {
+ fn render(&self) -> Markup {
+ html! {
+ span {
+ a href=(self.url) {(self.title)}
+ @if !self.description.is_empty() {
+ ": "
+ (self.description)
+ }
+ }
+ }
+ }
}
#[derive(Clone, Deserialize, Serialize)]
@@ -33,17 +65,51 @@ impl Default for StockKind {
}
}
+fn schema_context() -> String {
+ "http://schema.org/".to_string()
+}
+
+fn schema_person_type() -> String {
+ "Person".to_string()
+}
+
#[derive(Clone, Deserialize, Serialize, Default)]
pub struct Author {
+ #[serde(rename = "@context", default = "schema_context")]
+ pub context: String,
+ #[serde(rename = "@type", default = "schema_person_type")]
+ pub schema_type: String,
pub name: String,
+ #[serde(skip_serializing)]
pub handle: String,
- #[serde(rename = "picUrl")]
+ #[serde(rename = "image", skip_serializing_if = "Option::is_none")]
pub pic_url: Option<String>,
- pub link: Option<String>,
- pub twitter: Option<String>,
- pub default: bool,
- #[serde(rename = "inSystem")]
+ #[serde(rename = "inSystem", skip_serializing)]
pub in_system: bool,
+ #[serde(rename = "jobTitle")]
+ pub job_title: String,
+ #[serde(rename = "sameAs")]
+ pub same_as: Vec<String>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub url: Option<String>,
+}
+
+#[derive(Clone, Deserialize, Serialize, Default)]
+pub struct SeriesDescription {
+ pub name: String,
+ pub details: String,
+}
+
+impl Render for SeriesDescription {
+ fn render(&self) -> Markup {
+ html! {
+ span {
+ a href={"/blog/series/" (self.name)} { (self.name) }
+ ": "
+ (self.details)
+ }
+ }
+ }
}
#[derive(Clone, Deserialize, Serialize, Default)]
@@ -80,8 +146,8 @@ impl Display for Salary {
}
}
-impl Salary {
- pub fn html(&self) -> Markup {
+impl Render for Salary {
+ fn render(&self) -> Markup {
if self.stock.is_none() {
return html! { (maud::display(self)) };
}
@@ -162,15 +228,15 @@ pub struct Company {
pub defunct: bool,
}
-impl Job {
- pub fn pay_history_row(&self) -> Markup {
+impl Render for Job {
+ fn render(&self) -> Markup {
html! {
tr {
td { (self.title) }
td { (self.start_date) }
td { (self.end_date.as_ref().unwrap_or(&"current".to_string())) }
td { (if self.days_worked.is_some() { self.days_worked.as_ref().unwrap().to_string() } else { "n/a".to_string() }) }
- td { (self.salary.html()) }
+ td { (self.salary) }
td { (self.leave_reason.as_ref().unwrap_or(&"n/a".to_string())) }
}
}