From cc933b31fd23bb06e95bf41f848a1c99353d44ae Mon Sep 17 00:00:00 2001 From: Xe Iaso Date: Fri, 25 Nov 2022 19:01:10 -0500 Subject: Start version 3 (#573) * 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 * fix nix builds Signed-off-by: Xe Iaso * fix dhall build Signed-off-by: Xe Iaso * fix non-flakes build Signed-off-by: Xe Iaso * make new mastodon share button Signed-off-by: Xe Iaso * remove the rest of the ructe templates that I can remove Signed-off-by: Xe Iaso * refactor blogposts to its own file Signed-off-by: Xe Iaso * move resume to be generated by nix Signed-off-by: Xe Iaso * write article Signed-off-by: Xe Iaso * blog/site-update-v3: hero image Signed-off-by: Xe Iaso * add site update series tag to site updates Signed-off-by: Xe Iaso Signed-off-by: Xe Signed-off-by: Xe Iaso --- src/app/config.rs | 90 +++++++++++++++++++++++++++++++++++++++++++++++-------- src/app/mod.rs | 8 ++--- 2 files changed, 80 insertions(+), 18 deletions(-) (limited to 'src/app') 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, - pub authors: Vec, + pub authors: HashMap, + #[serde(rename = "defaultAuthor")] + pub default_author: Author, pub port: u16, #[serde(rename = "clackSet")] pub clack_set: Vec, @@ -19,6 +22,35 @@ pub struct Config { pub mi_token: String, #[serde(rename = "jobHistory")] pub job_history: Vec, + #[serde(rename = "seriesDescriptions")] + pub series_descriptions: Vec, + #[serde(rename = "seriesDescMap")] + pub series_desc_map: HashMap, + #[serde(rename = "notableProjects")] + pub notable_projects: Vec, + #[serde(rename = "contactLinks")] + pub contact_links: Vec, +} + +#[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, - pub link: Option, - pub twitter: Option, - 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, + #[serde(skip_serializing_if = "Option::is_none")] + pub url: Option, +} + +#[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())) } } } diff --git a/src/app/mod.rs b/src/app/mod.rs index 73320e1..6753ff0 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -1,7 +1,7 @@ use crate::{post::Post, signalboost::Person}; use chrono::prelude::*; use color_eyre::eyre::Result; -use std::{fs, path::PathBuf, sync::Arc}; +use std::{path::PathBuf, sync::Arc}; use tracing::{error, instrument}; pub mod config; @@ -48,7 +48,6 @@ pub const ICON: &'static str = "https://xeiaso.net/static/img/avatar.png"; pub struct State { pub cfg: Arc, pub signalboost: Vec, - pub resume: String, pub blog: Vec, pub gallery: Vec, pub talks: Vec, @@ -62,8 +61,6 @@ pub struct State { pub async fn init(cfg: PathBuf) -> Result { let cfg: Arc = Arc::new(serde_dhall::from_file(cfg).parse()?); let sb = cfg.signalboost.clone(); - let resume = fs::read_to_string(cfg.clone().resume_fname.clone())?; - let resume: String = xesite_markdown::render(&resume)?; let mi = mi::Client::new( cfg.clone().mi_token.clone(), crate::APPLICATION_NAME.to_string(), @@ -85,7 +82,7 @@ pub async fn init(cfg: PathBuf) -> Result { everything.sort(); everything.reverse(); - let today = Utc::today(); + let today = Utc::now().date_naive(); let everything: Vec = everything .into_iter() .filter(|p| today.num_days_from_ce() >= p.date.num_days_from_ce()) @@ -141,7 +138,6 @@ pub async fn init(cfg: PathBuf) -> Result { mi, cfg, signalboost: sb, - resume, blog, gallery, talks, -- cgit v1.2.3