diff --git a/.gitignore b/.gitignore index 8395e0d..353b43f 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ Cargo.lock # These are backup files generated by rustfmt **/*.rs.bk -/public/ - -/node_modules/ \ No newline at end of file +# Buildsystem files +/public +/node_modules +/build \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..e1aadcf --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,5 @@ +[workspace] +members = [ + "buildsystem/common", + "buildsystem/blogc" +] \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..4fd3871 --- /dev/null +++ b/Makefile @@ -0,0 +1,24 @@ + +# Buildsystem tool paths +TOOL_BLOGC = target/debug/blogc + +.PHONY: all clean + +all: build/intermediary/blog + +clean: + rm -rf build + +# This rule builds a single blog post into an intermediary file +build/intermediary/blog/%.json: data/blog/*/%.md + $(TOOL_BLOGC) $< $@ + +# This rule will auto-build all intermediary blog files +ALL_INTERMEDIARY = $(patsubst data/blog/2017/%.md, build/intermediary/blog/%.json, $(wildcard data/blog/*/*.md)) +ALL_INTERMEDIARY += $(patsubst data/blog/2018/%.md, build/intermediary/blog/%.json, $(wildcard data/blog/*/*.md)) +ALL_INTERMEDIARY += $(patsubst data/blog/2019/%.md, build/intermediary/blog/%.json, $(wildcard data/blog/*/*.md)) +ALL_INTERMEDIARY += $(patsubst data/blog/2020/%.md, build/intermediary/blog/%.json, $(wildcard data/blog/*/*.md)) +ALL_INTERMEDIARY += $(patsubst data/blog/2021/%.md, build/intermediary/blog/%.json, $(wildcard data/blog/*/*.md)) +ALL_INTERMEDIARY += $(patsubst data/blog/2022/%.md, build/intermediary/blog/%.json, $(wildcard data/blog/*/*.md)) +ALL_INTERMEDIARY += $(patsubst data/blog/2023/%.md, build/intermediary/blog/%.json, $(wildcard data/blog/*/*.md)) +build/intermediary/blog: $(ALL_INTERMEDIARY) \ No newline at end of file diff --git a/buildsystem/blogc/Cargo.toml b/buildsystem/blogc/Cargo.toml new file mode 100644 index 0000000..f7f52d7 --- /dev/null +++ b/buildsystem/blogc/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "blogc" +publish = false +version = "0.0.0" +edition = "2021" + +[dependencies] +common = { version = "*", path = "../common" } +clap = { version = "4.2.7", features = ["derive"] } +serde = { version = "1.0", features = ["derive"] } +serde-frontmatter = "0.1.0" +comrak = "0.18" \ No newline at end of file diff --git a/buildsystem/blogc/README.md b/buildsystem/blogc/README.md new file mode 100644 index 0000000..9e7be4f --- /dev/null +++ b/buildsystem/blogc/README.md @@ -0,0 +1,7 @@ +# BlogC: Blog Compiler + +## Structure of a blog post + +- Title +- Metadata +- Body diff --git a/buildsystem/blogc/src/main.rs b/buildsystem/blogc/src/main.rs new file mode 100644 index 0000000..3635281 --- /dev/null +++ b/buildsystem/blogc/src/main.rs @@ -0,0 +1,49 @@ +use clap::Parser; +use common::model::BlogPost; +use comrak::ComrakOptions; + +#[derive(Debug, Parser)] +struct Args { + /// Blog post `.md` file to compile + pub input: std::path::PathBuf, + + /// File to write to + pub output: std::path::PathBuf, +} + +#[derive(Debug, serde::Deserialize)] +struct BlogFileHeader { + pub title: String, + pub description: String, + #[serde(default)] + pub draft: bool, +} + +pub fn main() { + let args = Args::parse(); + + // Read the input file + let input = std::fs::read_to_string(&args.input).unwrap(); + + // Parse into a header and body + let (header, body) = serde_frontmatter::deserialize::(&input).unwrap(); + + // Compile the body into HTML + let options = ComrakOptions { + ..ComrakOptions::default() + }; + let html = comrak::markdown_to_html(&body, &options); + + // Build the intermediary file + let intermediary = BlogPost{ + title: header.title, + description: header.description, + is_draft: header.draft, + body: html, + }; + + // Write to the output file + println!("Writing to {:?}", args.output); + std::fs::create_dir_all(&args.output.parent().unwrap()).unwrap(); + intermediary.write_to_file(&args.output).unwrap(); +} diff --git a/buildsystem/common/Cargo.toml b/buildsystem/common/Cargo.toml new file mode 100644 index 0000000..68d627a --- /dev/null +++ b/buildsystem/common/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "common" +publish = false +version = "0.0.0" +edition = "2021" + +[dependencies] +serde = { version = "1.0", features = ["derive"] } +serde_json = "1.0" diff --git a/buildsystem/common/README.md b/buildsystem/common/README.md new file mode 100644 index 0000000..2ea63c6 --- /dev/null +++ b/buildsystem/common/README.md @@ -0,0 +1 @@ +# Common code for build tools \ No newline at end of file diff --git a/buildsystem/common/src/lib.rs b/buildsystem/common/src/lib.rs new file mode 100644 index 0000000..99bbd12 --- /dev/null +++ b/buildsystem/common/src/lib.rs @@ -0,0 +1 @@ +pub mod model; \ No newline at end of file diff --git a/buildsystem/common/src/model.rs b/buildsystem/common/src/model.rs new file mode 100644 index 0000000..5cb38ac --- /dev/null +++ b/buildsystem/common/src/model.rs @@ -0,0 +1,17 @@ +use std::io::Write; + +#[derive(Debug, serde::Serialize)] +pub struct BlogPost { + pub title: String, + pub description: String, + pub is_draft: bool, + pub body: String, +} + +impl BlogPost { + pub fn write_to_file(&self, path: &std::path::Path) -> std::io::Result<()> { + let mut file = std::fs::File::create(path)?; + file.write_all(serde_json::to_string(self).unwrap().as_bytes())?; + Ok(()) + } +} diff --git a/data/blog/2019/2019-04-30-FRC-Languages.md b/data/blog/2019/2019-04-30-FRC-Languages.md index ad170b3..5fab574 100644 --- a/data/blog/2019/2019-04-30-FRC-Languages.md +++ b/data/blog/2019/2019-04-30-FRC-Languages.md @@ -1,6 +1,7 @@ --- layout: page title: "The language hunt" +description: "" date: 2019-04-30 tags: frc alises: [https://retrylife.ca/blog/2019/04/30/frc-languages] diff --git a/data/blog/2019/2019-06-12-Styiling-GitHub.md b/data/blog/2019/2019-06-12-Styiling-GitHub.md index adc3a9a..3ea7b5e 100644 --- a/data/blog/2019/2019-06-12-Styiling-GitHub.md +++ b/data/blog/2019/2019-06-12-Styiling-GitHub.md @@ -1,6 +1,7 @@ --- layout: page title: "GitHub's CSS is boring. So I refreshed the design" +description: "" date: 2019-06-12 tags: projects aliases: [/blog/2019/06/12/styiling-github] diff --git a/data/blog/2020/2020-08-03-Joystick-to-Voltage.md b/data/blog/2020/2020-08-03-Joystick-to-Voltage.md index c5436ca..96a4251 100644 --- a/data/blog/2020/2020-08-03-Joystick-to-Voltage.md +++ b/data/blog/2020/2020-08-03-Joystick-to-Voltage.md @@ -1,14 +1,12 @@ -+++ -title = "Notes from FRC: Converting joystick data to tank-drive outputs" -description = "and making a tank-based robot's movements look natural" -date = "2020-08-03" -tags = ["frc"] -aliases = ["/blog/2020/08/03/joystick-to-voltage"] +--- +title: "Notes from FRC: Converting joystick data to tank-drive outputs" +description: "and making a tank-based robot's movements look natural" +date: "2020-08-03" -[extra] -uses = ["katex"] -excerpt = "This post covers the algorithm I devised for converting joystick data to motor commands at Raider Robotics" -+++ +extra: + uses: ["katex"] + excerpt: "This post covers the algorithm I devised for converting joystick data to motor commands at Raider Robotics" +--- I am starting a new little series here called "Notes from FRC". The idea is that I am going to write about what I have learned over the past three years of working (almost daily) with robots, and hopefully someone in the future will find them useful. The production source code I based this post around is available [here](https://github.com/frc5024/lib5k/blob/cd8ad407146b514cf857c1d8ac82ac8f3067812b/common_drive/src/main/java/io/github/frc5024/common_drive/calculation/DifferentialDriveCalculation.java). diff --git a/package-lock.json b/package-lock.json deleted file mode 100644 index 38ff267..0000000 --- a/package-lock.json +++ /dev/null @@ -1,79 +0,0 @@ -{ - "name": "ewpratten.com", - "lockfileVersion": 2, - "requires": true, - "packages": { - "": { - "dependencies": { - "bootstrap": "^5.2.3", - "github-markdown-css": "^5.1.0", - "line-awesome": "^1.3.0" - } - }, - "node_modules/@popperjs/core": { - "version": "2.11.6", - "resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.11.6.tgz", - "integrity": "sha512-50/17A98tWUfQ176raKiOGXuYpLyyVMkxxG6oylzL3BPOlA6ADGdK7EYunSa4I064xerltq9TGXs8HmOk5E+vw==", - "peer": true, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/popperjs" - } - }, - "node_modules/bootstrap": { - "version": "5.2.3", - "resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-5.2.3.tgz", - "integrity": "sha512-cEKPM+fwb3cT8NzQZYEu4HilJ3anCrWqh3CHAok1p9jXqMPsPTBhU25fBckEJHJ/p+tTxTFTsFQGM+gaHpi3QQ==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/twbs" - }, - { - "type": "opencollective", - "url": "https://opencollective.com/bootstrap" - } - ], - "peerDependencies": { - "@popperjs/core": "^2.11.6" - } - }, - "node_modules/github-markdown-css": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/github-markdown-css/-/github-markdown-css-5.1.0.tgz", - "integrity": "sha512-QLtORwHHtUHhPMHu7i4GKfP6Vx5CWZn+NKQXe+cBhslY1HEt0CTEkP4d/vSROKV0iIJSpl4UtlQ16AD8C6lMug==", - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/line-awesome": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/line-awesome/-/line-awesome-1.3.0.tgz", - "integrity": "sha512-Y0YHksL37ixDsHz+ihCwOtF5jwJgCDxQ3q+zOVgaSW8VugHGTsZZXMacPYZB1/JULBi6BAuTCTek+4ZY/UIwcw==" - } - }, - "dependencies": { - "@popperjs/core": { - "version": "2.11.6", - "resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.11.6.tgz", - "integrity": "sha512-50/17A98tWUfQ176raKiOGXuYpLyyVMkxxG6oylzL3BPOlA6ADGdK7EYunSa4I064xerltq9TGXs8HmOk5E+vw==", - "peer": true - }, - "bootstrap": { - "version": "5.2.3", - "resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-5.2.3.tgz", - "integrity": "sha512-cEKPM+fwb3cT8NzQZYEu4HilJ3anCrWqh3CHAok1p9jXqMPsPTBhU25fBckEJHJ/p+tTxTFTsFQGM+gaHpi3QQ==", - "requires": {} - }, - "github-markdown-css": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/github-markdown-css/-/github-markdown-css-5.1.0.tgz", - "integrity": "sha512-QLtORwHHtUHhPMHu7i4GKfP6Vx5CWZn+NKQXe+cBhslY1HEt0CTEkP4d/vSROKV0iIJSpl4UtlQ16AD8C6lMug==" - }, - "line-awesome": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/line-awesome/-/line-awesome-1.3.0.tgz", - "integrity": "sha512-Y0YHksL37ixDsHz+ihCwOtF5jwJgCDxQ3q+zOVgaSW8VugHGTsZZXMacPYZB1/JULBi6BAuTCTek+4ZY/UIwcw==" - } - } -} diff --git a/package.json b/package.json deleted file mode 100644 index 6a589d7..0000000 --- a/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "dependencies": { - "bootstrap": "^5.2.3", - "github-markdown-css": "^5.1.0", - "line-awesome": "^1.3.0" - } -}