intermediary
This commit is contained in:
parent
149fd3e572
commit
ce7d00af0b
7
.gitignore
vendored
7
.gitignore
vendored
@ -9,6 +9,7 @@ Cargo.lock
|
|||||||
# These are backup files generated by rustfmt
|
# These are backup files generated by rustfmt
|
||||||
**/*.rs.bk
|
**/*.rs.bk
|
||||||
|
|
||||||
/public/
|
# Buildsystem files
|
||||||
|
/public
|
||||||
/node_modules/
|
/node_modules
|
||||||
|
/build
|
5
Cargo.toml
Normal file
5
Cargo.toml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
[workspace]
|
||||||
|
members = [
|
||||||
|
"buildsystem/common",
|
||||||
|
"buildsystem/blogc"
|
||||||
|
]
|
24
Makefile
Normal file
24
Makefile
Normal file
@ -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)
|
12
buildsystem/blogc/Cargo.toml
Normal file
12
buildsystem/blogc/Cargo.toml
Normal file
@ -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"
|
7
buildsystem/blogc/README.md
Normal file
7
buildsystem/blogc/README.md
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# BlogC: Blog Compiler
|
||||||
|
|
||||||
|
## Structure of a blog post
|
||||||
|
|
||||||
|
- Title
|
||||||
|
- Metadata
|
||||||
|
- Body
|
49
buildsystem/blogc/src/main.rs
Normal file
49
buildsystem/blogc/src/main.rs
Normal file
@ -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::<BlogFileHeader>(&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();
|
||||||
|
}
|
9
buildsystem/common/Cargo.toml
Normal file
9
buildsystem/common/Cargo.toml
Normal file
@ -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"
|
1
buildsystem/common/README.md
Normal file
1
buildsystem/common/README.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
# Common code for build tools
|
1
buildsystem/common/src/lib.rs
Normal file
1
buildsystem/common/src/lib.rs
Normal file
@ -0,0 +1 @@
|
|||||||
|
pub mod model;
|
17
buildsystem/common/src/model.rs
Normal file
17
buildsystem/common/src/model.rs
Normal file
@ -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(())
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
---
|
---
|
||||||
layout: page
|
layout: page
|
||||||
title: "The language hunt"
|
title: "The language hunt"
|
||||||
|
description: ""
|
||||||
date: 2019-04-30
|
date: 2019-04-30
|
||||||
tags: frc
|
tags: frc
|
||||||
alises: [https://retrylife.ca/blog/2019/04/30/frc-languages]
|
alises: [https://retrylife.ca/blog/2019/04/30/frc-languages]
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
---
|
---
|
||||||
layout: page
|
layout: page
|
||||||
title: "GitHub's CSS is boring. So I refreshed the design"
|
title: "GitHub's CSS is boring. So I refreshed the design"
|
||||||
|
description: ""
|
||||||
date: 2019-06-12
|
date: 2019-06-12
|
||||||
tags: projects
|
tags: projects
|
||||||
aliases: [/blog/2019/06/12/styiling-github]
|
aliases: [/blog/2019/06/12/styiling-github]
|
||||||
|
@ -1,14 +1,12 @@
|
|||||||
+++
|
---
|
||||||
title = "Notes from FRC: Converting joystick data to tank-drive outputs"
|
title: "Notes from FRC: Converting joystick data to tank-drive outputs"
|
||||||
description = "and making a tank-based robot's movements look natural"
|
description: "and making a tank-based robot's movements look natural"
|
||||||
date = "2020-08-03"
|
date: "2020-08-03"
|
||||||
tags = ["frc"]
|
|
||||||
aliases = ["/blog/2020/08/03/joystick-to-voltage"]
|
|
||||||
|
|
||||||
[extra]
|
extra:
|
||||||
uses = ["katex"]
|
uses: ["katex"]
|
||||||
excerpt = "This post covers the algorithm I devised for converting joystick data to motor commands at Raider Robotics"
|
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).
|
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).
|
||||||
|
|
||||||
|
79
package-lock.json
generated
79
package-lock.json
generated
@ -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=="
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,7 +0,0 @@
|
|||||||
{
|
|
||||||
"dependencies": {
|
|
||||||
"bootstrap": "^5.2.3",
|
|
||||||
"github-markdown-css": "^5.1.0",
|
|
||||||
"line-awesome": "^1.3.0"
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user