about summary refs log tree commit diff
path: root/splorm
diff options
context:
space:
mode:
Diffstat (limited to 'splorm')
-rw-r--r--splorm/README.md4
-rw-r--r--splorm/splorm.conf4
-rw-r--r--splorm/src/config.rs31
-rw-r--r--splorm/src/handler/quark/markup/mod.rs7
4 files changed, 46 insertions, 0 deletions
diff --git a/splorm/README.md b/splorm/README.md
index 846c813..60b779e 100644
--- a/splorm/README.md
+++ b/splorm/README.md
@@ -22,6 +22,10 @@ location of configuration file
 **Subsection: `Me`**  
 `Email` - My email, for the `/.me/email` route
 
+**Subsection: `Opengraph`**  
+`DefaultImage` - webroot-relative path to use as the default opengraph image when none is provided
+`DefaultImage/Text` - alt text for the default image
+
 **Subsection: `Templates`**  
 `$` - Directory templates are located in  
 `Default` - Name of the default template *(assumed to end in .html)*
diff --git a/splorm/splorm.conf b/splorm/splorm.conf
index 9900ff0..8edd57a 100644
--- a/splorm/splorm.conf
+++ b/splorm/splorm.conf
@@ -7,6 +7,10 @@ Serving /Users/gen/src/inf/served
 	Templates /Users/gen/src/inf/templates
 		Default post
 
+	Opengraph
+		DefaultImage dreamlike/dreamlike_opengraphdark.png
+			Text site logo; a large cloud set against a pale blue sky with smaller, pinkish clouds
+
 	Wikarden /Users/gen/src/awake/target/quark
 		Index index
 		GitName Splorm Wikarden
diff --git a/splorm/src/config.rs b/splorm/src/config.rs
index 9c5a86c..09e6171 100644
--- a/splorm/src/config.rs
+++ b/splorm/src/config.rs
@@ -78,6 +78,10 @@ impl Config {
 		let templates: Utf8PathBuf = templates_sec.parse().unwrap();
 		let default_template = templates_sec.child_owned("Default").unwrap();
 
+		let opengraph = serving.child("Opengraph").unwrap();
+		let og_image = opengraph.child_owned("DefaultImage").unwrap();
+		let og_image_alt = opengraph.get_delim("DefaultImage/Text", '/').unwrap();
+
 		let wikarden_sec = serving.child("Wikarden").unwrap();
 		let wikarden_root = wikarden_sec.parse().unwrap();
 		let wikarden_index = wikarden_sec.child_owned("Index").unwrap();
@@ -101,6 +105,11 @@ impl Config {
 				default_template,
 				template_dir: templates, // webroot.join(templates),
 
+				opengraph: Opengraph {
+					image: og_image,
+					image_alt: og_image_alt.to_owned(),
+				},
+
 				hostname,
 				webroot,
 
@@ -147,6 +156,8 @@ pub struct Settings {
 	default_template: String,
 	template_dir: Utf8PathBuf,
 
+	opengraph: Opengraph,
+
 	wikarden_root: Utf8PathBuf,
 	wikarden_index: String,
 	wikarden_gitname: String,
@@ -221,6 +232,10 @@ impl Settings {
 		&self.database_path
 	}
 
+	pub fn opengraph(&self) -> &Opengraph {
+		&self.opengraph
+	}
+
 	pub fn connectors(&self) -> &Connectors {
 		&self.connectors
 	}
@@ -249,3 +264,19 @@ pub fn create_tracing_subscriber() {
 		)
 		.init();
 }
+
+#[derive(Clone, Debug)]
+pub struct Opengraph {
+	image: String,
+	image_alt: String,
+}
+
+impl Opengraph {
+	pub fn default_image(&self) -> &str {
+		&self.image
+	}
+
+	pub fn default_image_alt(&self) -> &str {
+		&self.image_alt
+	}
+}
diff --git a/splorm/src/handler/quark/markup/mod.rs b/splorm/src/handler/quark/markup/mod.rs
index 422424b..bf22c11 100644
--- a/splorm/src/handler/quark/markup/mod.rs
+++ b/splorm/src/handler/quark/markup/mod.rs
@@ -131,6 +131,7 @@ impl<'r> PageTemplate<'r> {
 
 	fn apply_frontmatter<'p>(&self, template: &mut Document, pf: &PageFrontmatter<'p>) {
 		if let Some(description) = pf.description() {
+			let og = self.settings.opengraph();
 			let hostname = self.settings.hostname();
 			let page = self.page;
 
@@ -138,6 +139,12 @@ impl<'r> PageTemplate<'r> {
 			template.set("og_url", format!("https://{hostname}/quark/{page}"));
 			template.set("og_description", description);
 
+			let image = og.default_image();
+			let image_alt = og.default_image_alt();
+
+			template.set("og_image", format!("https://{hostname}/{image}"));
+			template.set("og_image_alt", image_alt);
+
 			template.set("og_site_name", format!("{hostname}/quark"));
 		}
 	}