aboutsummaryrefslogtreecommitdiff
path: root/src/app
diff options
context:
space:
mode:
authorXe Iaso <me@christine.website>2022-11-25 19:01:10 -0500
committerGitHub <noreply@github.com>2022-11-25 19:01:10 -0500
commitcc933b31fd23bb06e95bf41f848a1c99353d44ae (patch)
treeaf8288dbd4db2ad886d6b326bffb1c9d5b568de3 /src/app
parent551e0384c923ff3ee98cfddf7e3eb42c6dbb2941 (diff)
downloadxesite-cc933b31fd23bb06e95bf41f848a1c99353d44ae.tar.xz
xesite-cc933b31fd23bb06e95bf41f848a1c99353d44ae.zip
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 <me@christine.website> * fix nix builds Signed-off-by: Xe Iaso <me@christine.website> * fix dhall build Signed-off-by: Xe Iaso <me@christine.website> * fix non-flakes build Signed-off-by: Xe Iaso <me@christine.website> * make new mastodon share button Signed-off-by: Xe Iaso <me@christine.website> * remove the rest of the ructe templates that I can remove Signed-off-by: Xe Iaso <me@christine.website> * refactor blogposts to its own file Signed-off-by: Xe Iaso <me@christine.website> * move resume to be generated by nix Signed-off-by: Xe Iaso <me@christine.website> * write article Signed-off-by: Xe Iaso <me@christine.website> * blog/site-update-v3: hero image Signed-off-by: Xe Iaso <me@christine.website> * add site update series tag to site updates Signed-off-by: Xe Iaso <me@christine.website> Signed-off-by: Xe <me@christine.website> Signed-off-by: Xe Iaso <me@christine.website>
Diffstat (limited to 'src/app')
-rw-r--r--src/app/config.rs90
-rw-r--r--src/app/mod.rs8
2 files changed, 80 insertions, 18 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())) }
}
}
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<Config>,
pub signalboost: Vec<Person>,
- pub resume: String,
pub blog: Vec<Post>,
pub gallery: Vec<Post>,
pub talks: Vec<Post>,
@@ -62,8 +61,6 @@ pub struct State {
pub async fn init(cfg: PathBuf) -> Result<State> {
let cfg: Arc<Config> = 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<State> {
everything.sort();
everything.reverse();
- let today = Utc::today();
+ let today = Utc::now().date_naive();
let everything: Vec<Post> = 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<State> {
mi,
cfg,
signalboost: sb,
- resume,
blog,
gallery,
talks,