Skip to content

Commit

Permalink
feat: add auto-formatting to blog html (#33)
Browse files Browse the repository at this point in the history
* format julia

* wip

* wip

* tune

* tweak

* blah

* run blog build on file save - vscode

* fix markdown cross-out
  • Loading branch information
hannahilea authored Oct 9, 2024
1 parent a477184 commit 3d2072a
Show file tree
Hide file tree
Showing 12 changed files with 1,291 additions and 1,518 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ Run `julia --startup-file=no add_stuff.jl <ARG>` with arg `blog` or `p5`.
### Convert

Will be automated (soon); in the meantime, run `julia build-blogs/run.jl` to convert all block markdown src.md files to index.html files.
Requires a local installation of [prettier](https://formulae.brew.sh/formula/prettier)
14 changes: 8 additions & 6 deletions add_stuff.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function new_p5_project()
str = replace(str, "{{ DIR_NAME }}" => dir_name)
write(file, str)
end

@info "Adding new project to project index"
let
index_path = joinpath("projects", "index.html")
Expand Down Expand Up @@ -58,12 +58,12 @@ function new_blog_post()
@info "Creating new blog directory" blog_title dir_name
cp(joinpath("blog", "__template"), dir)
for file in readdir(dir; join=true)
if endswith(file, ".rss_blob.xml") || endswith(file, ".html.template")
if endswith(file, ".rss_blob.xml") || endswith(file, ".html.template")
rm(file)
continue
end
startswith(basename(file), ".") && continue

@info "Updating $file..."
str = read(file, String)
str = replace(str, "{{ BLOG_TITLE }}" => blog_title)
Expand All @@ -88,13 +88,15 @@ function new_blog_post()
let
new_blob = read(joinpath("blog", "__template", ".rss_blob.xml"), String)
pub_date = Dates.format(now(Dates.UTC), dateformat"e, d U yyyy HH:MM:SS ") * "GMT"
new_blob = replace(new_blob, "{{ BLOG_TITLE }}" => blog_title,
"{{ PUB_DATE }}" => pub_date, "{{ BLOG_DIR }}" => dir_name)
new_blob = replace(new_blob,
"{{ BLOG_TITLE }}" => blog_title,
"{{ PUB_DATE }}" => pub_date,
"{{ BLOG_DIR }}" => dir_name)
str = read("rss.xml", String)
i = findfirst(NEW_BLOG_COMMENT, str)
isnothing(i) &&
throw(ArgumentError("Oh no, $(NEW_BLOG_COMMENT) not found in $(index_path)"))
str = str[1:first(i)-1] * new_blob * str[(first(i)):end]
str = str[1:(first(i) - 1)] * new_blob * str[(first(i)):end]
write("rss.xml", str)
end

Expand Down
56 changes: 27 additions & 29 deletions blog/__template/index.html.template
Original file line number Diff line number Diff line change
@@ -1,33 +1,31 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<link rel="shortcut icon" type="image/png" href="../../assets/img/favicon.png" />
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>$if(rawtitle)$$rawtitle$$else$$title$$endif$</title>
<link rel="stylesheet" type="text/css" href="../../assets/css/main.css" />
$header$
</head>

<head>
<link rel="shortcut icon" type="image/png" href="../../assets/img/favicon.png" />
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>$if(rawtitle)$$rawtitle$$else$$title$$endif$</title>
<link rel="stylesheet" type="text/css" href="../../assets/css/main.css" />
$header$
</head>

<body>
<div class="main-container blog">
<nav class="blog-navbar" role="navigation">
@hannahilea:
<a class="nav-link" href="../.." >home</a> |
<a class="nav-link" href="../../projects">projects</a> |
<a class="nav-link" href="..">blog</a> |
<a class="nav-link" href="mailto:[email protected]">contact</a>
</nav>
<h1>$title$</h1>
<body>
<div class="main-container blog">
<nav class="blog-navbar" role="navigation">
@hannahilea:
<a class="nav-link" href="../..">home</a> |
<a class="nav-link" href="../../projects">projects</a> |
<a class="nav-link" href="..">blog</a> |
<a class="nav-link" href="mailto:[email protected]">contact</a>
</nav>
<h1>$title$</h1>
$body$
<hr>
<ul>
<li>created: $created$</li>
<li>last updated: $updated$</li>
<li>tags: $for(tags)$$tags$$sep$, $endfor$</li>
</ul>
</div>
</body>

<hr />
<ul>
<li>created: $created$</li>
<li>last updated: $updated$</li>
<li>tags: $for(tags)$$tags$$sep$, $endfor$</li>
</ul>
</div>
</body>
</html>
812 changes: 429 additions & 383 deletions blog/clapping-music-for-flip-disc-displays/index.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion blog/clapping-music-for-flip-disc-displays/src.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ As soon as we had successfully sent commands to the boards (a win in its own rig

They were right: I ***did*** gotta make it do clapping music. Immediately. :D

## ~Clapping~ Flipping music
## ~~Clapping~~ Flipping music

Steve Reich's [***Clapping Music***](https://en.wikipedia.org/wiki/Clapping_Music) is a composition in which two performers (or sets of performers) repeatedly clap a single 12-beat pattern. After eight or twelve repeats, the second performer shifts their position in the pattern back by a single beat. This process is repeated until the second performer has shifted back to playing the original no-offset pattern. The shifting offset causes a delightful phasing effect for listeners.

Expand Down
Loading

0 comments on commit 3d2072a

Please sign in to comment.