This commit is contained in:
nora 2024-01-21 18:12:51 +01:00
parent 5f1f9bd6a6
commit 2da77e8af5
13 changed files with 314 additions and 33 deletions

View file

@ -16,8 +16,8 @@ pub fn build(config: &SlidesConfig, slides: &Path, dist: &Path) -> Result<()> {
utils::cp_r(&slides.join("plugin"), &dist.join("plugin")).wrap_err("copying reveal.js dist")?;
for talk in &config.talks {
let path = slides.join(talk);
let dist = dist.join(talk);
let path = slides.join(talk.dirname());
let dist = dist.join(talk.dirname());
utils::cp_r(&path, &dist).wrap_err("copying slide data")?;
}

View file

@ -5,12 +5,12 @@ use std::{fs, path::Path};
use askama::Template;
use color_eyre::{eyre::WrapErr, Result};
use crate::{utils, SlidesConfig};
use crate::{utils, SlidesConfig, Talk};
#[derive(askama::Template)]
#[template(path = "slides.html")]
struct Slides {
talks: Vec<String>,
talks: Vec<Talk>,
}
pub fn build(config: &SlidesConfig, statics: &Path, dist: &Path) -> Result<()> {

View file

@ -29,7 +29,24 @@ struct Config {
#[derive(Deserialize)]
struct SlidesConfig {
talks: Vec<String>,
talks: Vec<Talk>,
}
#[derive(Deserialize, Clone)]
struct Talk {
name: String,
date: String,
location: String,
}
impl Talk {
fn dirname(&self) -> String {
format!(
"{}-{}",
self.date,
self.name.replace(" ", "-").to_lowercase()
)
}
}
fn main() -> Result<()> {
@ -64,6 +81,7 @@ fn main() -> Result<()> {
}
fn watch(root: &'static Path) -> Result<()> {
build(root).wrap_err("initial build")?;
let (send, recv) = std::sync::mpsc::sync_channel(1);
let mut watcher = notify::recommended_watcher(move |res| match res {
Ok(_) => {