Skip to content

Commit

Permalink
Merge pull request #9 from hannahilea/hr/blog-refresh
Browse files Browse the repository at this point in the history
Hr/blog refresh
  • Loading branch information
hannahilea authored May 9, 2024
2 parents e2a82d9 + e8237b6 commit 0f13c06
Show file tree
Hide file tree
Showing 14 changed files with 203 additions and 72 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ Personal website; can be viewed at [hannahilea.com](https://hannahilea.com).
- [ ] Figure out blog situation
- [ ] Set up rss feed
- [ ] Remove "under construction" flags

### Use template to add new content
Run `julia --startup-file=no add_stuff.jl <ARG>` with arg `blog` or `p5`.
101 changes: 101 additions & 0 deletions add_stuff.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
using Pkg
Pkg.activate(; temp=true)
Pkg.add("Dates")
using Dates

const NEW_PROJ_COMMENT = "<!-- Add new project here -->"
const NEW_BLOG_COMMENT = "<!-- Add new post here -->"

# Some quick and brittle Julia utilities for adding new projects
# Doesn't handle nested, only does new js projects
# Will fail if dir already exists
# Future: functions to add different types of projects
# Future: validate git state isn't dirty before starting
function new_p5_project()
project_name = lstrip(rstrip(Base.prompt("Enter project name")))
dir_name = let
default = replace(lowercase(project_name), " " => "-")
lstrip(rstrip(Base.prompt("Enter project url name"; default)))
end
dir = joinpath("projects", dir_name)

@info "Creating new project directory" project_name dir_name
cp(joinpath("projects", "__template"), dir)
for file in readdir(dir; join=true)
@info "Updating $file..."
str = read(file, String)
str = replace(str, "{{ PROJECT_NAME }}" => project_name)
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")
new_blob = """\n <li><a href="./$(dir_name)">\n $(project_name)\n </a>\n <p>TODO-description</p>\n </li>"""
str = read(index_path, String)
i = findfirst(NEW_PROJ_COMMENT, str)
isnothing(i) && throw(ArgumentError("Oh no, $(NEW_PROJ_COMMENT) not found in $(index_path)"))
str = str[1:last(i)] * new_blob * str[last(i)+1:end]
write(index_path, str)
end
@info "Do ctrl+f TODO to find regions to update for newly added project!"
end

function new_blog_post()
blog_title = lstrip(rstrip(Base.prompt("Enter blog post title")))

dir_name = let
default = replace(lowercase(blog_title), " " => "-")
lstrip(rstrip(Base.prompt("Enter blog url name"; default)))
end

dir = joinpath("blog", dir_name)
date = today()
date_pretty = Dates.format(today(), dateformat"d U yyyy")

@info "Creating new blog directory" blog_title dir_name
cp(joinpath("blog", "__template"), dir)
for file in readdir(dir; join=true)
@info "Updating $file..."
str = read(file, String)
str = replace(str, "{{ BLOG_TITLE }}" => blog_title)
str = replace(str, "{{ DATE }}" => date)
str = replace(str, "{{ BLOG_DIR }}" => dir_name)
write(file, str)
end

@info "Adding new project to blog index"
let
index_path = joinpath("blog", "index.html")
new_blob = """\n <li>$(date_pretty): <a href="./$(dir_name)">$(blog_title)</a>\n <p><em>In which TODO.</em></p>\n </li>"""
str = read(index_path, String)
i = findfirst(NEW_BLOG_COMMENT, str)
isnothing(i) && throw(ArgumentError("Oh no, $(NEW_BLOG_COMMENT) not found in $(index_path)"))
str = str[1:last(i)] * new_blob * str[last(i)+1:end]
write(index_path, str)
end

#TODO-future: also add to rss feed
@info "Do ctrl+f TODO to find regions to update for newly added project!"
end

function run_wizard(::Missing)
choice = lstrip(rstrip(Base.prompt("""Which type of content do you want to add?
Choices: p5, blog""")))
return run_wizard(choice)
end

function run_wizard(choice)
choice = rstrip(lstrip(lowercase(choice)))
choice == "blog" && return new_blog_post()
choice == "p5" && return new_p5_project()
println("Unsupported selection `$choice`")
return run_wizard(missing)
end

# CLI entrypoint
if abspath(PROGRAM_FILE) == @__FILE__
run_wizard(isempty(ARGS) ? missing : first(ARGS))
end

25 changes: 25 additions & 0 deletions blog/__template/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html lang="en">

<head>
<title>Blog: {{ BLOG_TITLE }}</title>
<link rel="stylesheet" type="text/css" href="../../css/main.css" />
<script type="module" src="https://md-block.verou.me/md-block.js"></script>
</head>

<body>
<nav class="navbar" role="navigation"></nav>
<div class="underline">
<h4><a href="../..">@hannahilea</a> > <a href="..">Blog</a> > {{ BLOG_DIR }}
</h4>
</div>
</nav>
<div style="margin-left:5%;margin-right:5%;">
<md-block src="./src.md"></md-block>
</div>

</body>

</html>


8 changes: 8 additions & 0 deletions blog/__template/src.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
### {{ BLOG_TITLE }}

Contents! They will go here.

---
- created at: {{ DATE }}
- last updated: {{ DATE }}
- tags:
25 changes: 25 additions & 0 deletions blog/hello-world/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html lang="en">

<head>
<title>Blog: Hello world</title>
<link rel="stylesheet" type="text/css" href="../../css/main.css" />
<script type="module" src="https://md-block.verou.me/md-block.js"></script>
</head>

<body>
<nav class="navbar" role="navigation"></nav>
<div class="underline">
<h4><a href="../..">@hannahilea</a> > <a href="..">Blog</a> > hello-world
</h4>
</div>
</nav>
<div style="margin-left:5%;margin-right:5%;">
<md-block src="./src.md"></md-block>
</div>

</body>

</html>


2 changes: 0 additions & 2 deletions blog/post0.md → blog/hello-world/src.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,3 @@ Thanks to [Teresa Ibarra](https://teresaibarra.com), whose site (and assistance!
---
- created at: 2/23/24
- last updated: 3/1/24
<!-- - polish level (1-10): 1
- tags: "journal", recurse -->
27 changes: 16 additions & 11 deletions blog.html → blog/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,42 +7,47 @@
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="description" content="Hannah Robertson's blog" />
<meta name="author" content="Hannah Robertson" />
<link rel="shortcut icon" type="image/png" href="./img/favicon.png" />
<link rel="stylesheet" type="text/css" href="/css/main.css" />
<link rel="shortcut icon" type="image/png" href="../img/favicon.png" />
<link rel="stylesheet" type="text/css" href="../css/main.css" />

<script type="module" src="https://md-block.verou.me/md-block.js"></script>

<title>@hannahilea: blog</title>
</head>

<body>
<body style="line-height:150%">
<div class="main-container">
<div class="row-1">
<div class="name-desc">
<div class="underline">
<h1><a href="index.html">@hannahilea</a>'s blog</h1>
<h1><a href="..">@hannahilea</a>'s blog</h1>
</div>
</div>
<nav class="navbar" role="navigation">
<a href="index.html" class="nav-link">ABOUT</a>
<a href="projects.html" class="nav-link">PROJECTS</a>
<a href=".." class="nav-link">ABOUT</a>
<a href="../projects" class="nav-link">PROJECTS</a>
<a href="mailto:[email protected]" class="nav-link">CONTACT</a>
</nav>
</div>

<div class="row-2">
<div class="links-outer">
<div class="mobile-buttons">
<p> <a href="index.html" class="nav-link">ABOUT</a></p>
<p><a href="projects.html" class="nav-link">PROJECTS</a></p>
<p><a href="blog.html" class="nav-link">BLOG</a></p>
<p> <a href=".." class="nav-link">ABOUT</a></p>
<p><a href="../projects" class="nav-link">PROJECTS</a></p>
<p><a href="mailto:[email protected]" class="nav-link">CONTACT</a></p>
</div>
</div>
</div>

<md-block src="blog/post0.md"></md-block>

<div>
<ul>
<!-- Add new post here -->
<li>23 Feb 2024: <a href="./hello-world">Hello world</a>
<p><em>In which I create a boring initial post as a placeholder while setting up this website.</em></p>
</li>
</ul>
</div>
</div>

</body>
Expand Down
8 changes: 4 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ <h5>DSP ENGINEER | MAKER </h5>
<!-- <h5><i>@hannahilea</i></h5> -->
</div>
<nav class="navbar" role="navigation">
<a href="projects.html" class="nav-link">PROJECTS</a>
<a href="blog.html" class="nav-link">BLOG</a>
<a href="projects" class="nav-link">PROJECTS</a>
<a href="blog" class="nav-link">BLOG</a>
<a href="mailto:[email protected]" class="nav-link">CONTACT</a>
</nav>
</div>

<div class="row-2">
<div class="links-outer">
<div class="mobile-buttons">
<p><a href="projects.html" class="nav-link">PROJECTS</a></p>
<p><a href="blog.html" class="nav-link">BLOG</a></p>
<p><a href="projects" class="nav-link">PROJECTS</a></p>
<p><a href="blog" class="nav-link">BLOG</a></p>
<p><a href="mailto:[email protected]" class="nav-link">CONTACT</a></p>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion projects/__template/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<body>
<nav class="navbar" role="navigation"></nav>
<div class="underline">
<h4><a href="../../index.html">@hannahilea</a> > <a href="../../projects.html">projects</a> > Sketch: {{ PROJECT_NAME }}
<h4><a href="../..">@hannahilea</a> > <a href="../../projects">projects</a> > Sketch: {{ PROJECT_NAME }}
</h4>
</div>
</nav>
Expand Down
34 changes: 17 additions & 17 deletions projects.html → projects/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
<div class="row-1">
<div class="name-desc">
<div class="underline">
<h1><a href="./index.html">@hannahilea</a>'s projects</h1>
<h1><a href="..">@hannahilea</a>'s projects</h1>
</div>
</div>
<nav class="navbar" role="navigation">
<a href="index.html" class="nav-link">ABOUT</a>
<a href="blog.html" class="nav-link">BLOG</a>
<a href=".." class="nav-link">ABOUT</a>
<a href="../blog" class="nav-link">BLOG</a>
<a href="mailto:[email protected]" class="nav-link">CONTACT</a>
</nav>
</div>
Expand Down Expand Up @@ -53,7 +53,7 @@ <h1><a href="./index.html">@hannahilea</a>'s projects</h1>
</br>
</div>
<div>
<h2 id="irtual-gallery">Virtual Gallery</h2>
<h2 id="virtual-gallery">Virtual Gallery</h2>
<!-- ADD photo thumnails -->
One-off creative coding projects, often small and interactive.
<ul>
Expand All @@ -64,20 +64,20 @@ <h2 id="irtual-gallery">Virtual Gallery</h2>
<p>Enjoy the experience of programming while a cat waves its tail in front of your screen! Built as a creative
coding exercise while at the <a href="https://www.recurse.com">Recurse Center</a>.</p>
</li>
<li><a href="./projects/wonderful-world">
<li><a href="./wonderful-world">
Sketch: Wonderful world
</a>
<p>Adapated from a creative coding excercise (prompt: <i>What a wonderful world</i>),
co-created with David Brooks while at the <a href="https://www.recurse.com">Recurse Center</a>.</p>
</li>
<li><a href="./projects/yellow-scream">
<li><a href="./yellow-scream">
Yellow Scream (2024)
</a>
<p>An homage to <a href="https://walkerart.org/magazine/now-streaming-kim-beoms-yellow-scream-2012/">Kim
Beom's <i>Yellow Scream
(2012)</i></a></p>
</li>
<li><a href="./projects/sound-ripple-sketch">
<li><a href="./sound-ripple-sketch">
Sketch: Sound ripples
</a>
<p>A creative coding excercise (prompt: <i>Particles, lots of them</i>), co-created with <a
Expand Down Expand Up @@ -185,13 +185,13 @@ <h2 id="academic">Academic</h2>
Public-facing coursework from a MA in Music Technology at <a href="http://www.mcgill.ca">McGill University</a>.
<ul>
<ul>
<li>Master's Thesis: <a href="projects/mcgill/Robertson_2013MAThesis.pdf"><em>Testing a new tool for alignment
<li>Master's Thesis: <a href="./mcgill/Robertson_2013MAThesis.pdf"><em>Testing a new tool for alignment
of musical recordings </em></a>
<p>Completed as a member of the <a href="http://ddmal.music.mcgill.ca/">Distributed Digital Music Archives &
Libraries Lab (DDMAL)</a> in the <a href="http://music.mcgill.ca">Schulich School of Music</a>.
</p>
</li>
<li><a href="projects/mcgill/ichBingo.pdf">Ich Bingo!</a> <a href="http://www.music.mcgill.ca/~ich/">Ichiro
<li><a href="./mcgill/ichBingo.pdf">Ich Bingo!</a> <a href="http://www.music.mcgill.ca/~ich/">Ichiro
Fujinaga's</a> rules for giving a strong, well-prepared presentation, in game form.</li>
<li>Coursework:
<ul>
Expand All @@ -201,7 +201,7 @@ <h2 id="academic">Academic</h2>
</li>
<ul>
<li>Final project:
<a href="./projects/mcgill/MUMT306/robertson_mumt306_fp.html">
<a href="./mcgill/MUMT306/robertson_mumt306_fp.html">
Mood Typer: A Max/MSP patch for real-time content-based text sonification</a>
</li>
</ul>
Expand All @@ -212,15 +212,15 @@ <h2 id="academic">Academic</h2>
</li>
<ul>
<li>Final project:
<a href="./projects/mcgill/MUMT307/307project.html">Mimicking the fipple sound in STK</a>
<a href="./mcgill/MUMT307/307project.html">Mimicking the fipple sound in STK</a>
</li>
</ul>
<li>MUMT 501: Digital Audio Signal Processing (Fall 2011) </li>
<ul>
<li>Final project:
<a href="./projects/mcgill/MUMT501/Robertson501.pdf">
<a href="./mcgill/MUMT501/Robertson501.pdf">
Harmonic Spectral Fit: Onset detection of slow-building attack transients (PDF)</a>
<a href="./projects/mcgill/MUMT501/Robertson501.zip">
<a href="./mcgill/MUMT501/Robertson501.zip">
[ code (.zip) ]</a>
</li>
</ul>
Expand All @@ -229,7 +229,7 @@ <h2 id="academic">Academic</h2>
</li>
<ul>
<li>Final project:
<a href="./projects/mcgill/MUMT618/stk_feadog.html">Modeling the penny-whistle in STK</a>
<a href="./mcgill/MUMT618/stk_feadog.html">Modeling the penny-whistle in STK</a>
</li>
</ul>
<li>MUMT 621: Music Information Acquisition, Preservation, and Retrieval (Winter 2012)
Expand All @@ -238,7 +238,7 @@ <h2 id="academic">Academic</h2>
</li>
<ul>

<li>Final project: <a href="./projects/mcgill/MUMT621/robertson_mumt621_project.html">Audio alignment
<li>Final project: <a href="./mcgill/MUMT621/robertson_mumt621_project.html">Audio alignment
for improved melody transcription of Irish traditional music</a>
</li>
</ul>
Expand All @@ -250,8 +250,8 @@ <h2 id="academic">Academic</h2>
<div class="row-2">
<div class="links-outer">
<div class="mobile-buttons">
<p><a href="index.html" class="nav-link">ABOUT</a></p>
<p><a href="blog.html" class="nav-link">BLOG</a></p>
<p><a href=".." class="nav-link">ABOUT</a></p>
<p><a href="../blog" class="nav-link">BLOG</a></p>
<p><a href="mailto:[email protected]" class="nav-link">CONTACT</a></p>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion projects/sound-ripple-sketch/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<body>
<nav class="navbar" role="navigation"></nav>
<div class="underline">
<h4><a href="../../index.html">@hannahilea</a> > <a href="../../projects.html">projects</a> > Sketch: Sound ripples
<h4><a href="../..">@hannahilea</a> > <a href="../../projects">projects</a> > Sketch: Sound ripples
</h4>
</div>
</nav>
Expand Down
Loading

0 comments on commit 0f13c06

Please sign in to comment.