From 5e9783a6ce559f76da83b2530059c9664f43306e Mon Sep 17 00:00:00 2001 From: Alex Karle Date: Thu, 18 Jun 2020 00:18:48 -0400 Subject: [PATCH] templatize: Split thoughts into posts, templatize everything This was supposed to be two commits, one for the build system and one for splitting up thoughts.html ... but it appears something went wrong and nvi aborted without committing :( and now the effort is too high to undo it. So without further ado, I present: massive refactor commit! This adds a brand new templating script (if you can even call it that...) tm.pl. I seriously considered hugo and other solutions, but the temptation to write my own was just too strong. I don't need a feature heavy library and I don't really want that dependency. 35 lines of Perl is light enough for now, and it's a great learning experience. Also, tm.pl is just too clever to pass up :) So on top of now needing to build the static content, this commit refactored thoughts into a series of posts, each with their own head/tail template. This feels like the right scalability solution, in the sense that updating the style of many posts will only involve updating the templates. Likewise, having one long "thoughts" page is both unlinkable (and thus unshareable) and just not practical. So thoughts blooms into a maybe-one-day blog. Cheers! --- .gitignore | 1 + Makefile | 8 ++++++-- README.md | 7 +++++-- bin/build.sh | 6 ++++++ bin/tm.pl | 35 +++++++++++++++++++++++++++++++++++ content/03-24-20-domain-name.html | 32 ++++++++++++++++++++++++++++++++ content/12-19-19-a-new-hope.html | 17 +++++++++++++++++ content/index.html | 29 +++++++++++++++++++++++++++++ content/style.css | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ content/thoughts.html | 16 ++++++++++++++++ index.html | 41 ----------------------------------------- style.css | 38 -------------------------------------- templates/head.tmpl | 12 ++++++++++++ templates/post-head.tmpl | 9 +++++++++ templates/post-tail.tmpl | 6 ++++++ templates/tail.tmpl | 3 +++ templates/title.tmpl | 2 ++ thoughts.html | 69 --------------------------------------------------------------------- 18 files changed, 230 insertions(+), 152 deletions(-) create mode 100644 .gitignore create mode 100755 bin/build.sh create mode 100755 bin/tm.pl create mode 100644 content/03-24-20-domain-name.html create mode 100644 content/12-19-19-a-new-hope.html create mode 100644 content/index.html create mode 100644 content/style.css create mode 100644 content/thoughts.html delete mode 100644 index.html delete mode 100644 style.css create mode 100644 templates/head.tmpl create mode 100644 templates/post-head.tmpl create mode 100644 templates/post-tail.tmpl create mode 100644 templates/tail.tmpl create mode 100644 templates/title.tmpl delete mode 100644 thoughts.html diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..84c048a --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/build/ diff --git a/Makefile b/Makefile index 1e17359..207aef2 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,10 @@ DEST = /var/www/htdocs/karleco +.PHONY: build +build: + ./bin/build.sh + .PHONY: install -install: +install: build mkdir -p $(DEST) - cp -f *.html style.css $(DEST) + cp build/* $(DEST) diff --git a/README.md b/README.md index 219f78a..ac85834 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ -# www +alexkarle.com +============= -My first take at a static website +My soap box on the internet. + +A static site with a small templating system, build with `make`. diff --git a/bin/build.sh b/bin/build.sh new file mode 100755 index 0000000..7347cea --- /dev/null +++ b/bin/build.sh @@ -0,0 +1,6 @@ +#!/bin/sh +mkdir -p build +cp content/*.css build +for f in content/*.html; do + ./bin/tm.pl $f > build/`basename $f` +done diff --git a/bin/tm.pl b/bin/tm.pl new file mode 100755 index 0000000..c9b2209 --- /dev/null +++ b/bin/tm.pl @@ -0,0 +1,35 @@ +#!/usr/bin/env perl +# tm.pl -- minimal templating script +# ^ ^^^ +use strict; +use warnings; + +use File::Basename qw(dirname); +use FindBin; + +my $TOP = dirname($FindBin::Bin); + +while (my $l = <>) { + process_line($l); +} + +sub process_line { + my $l = shift; + if ($l =~ /{% include=(.*) %}/) { + process_file($1); + } else { + print $l; + } +} + +sub process_file { + my $f = shift; + + my $tmpl = "$TOP/templates/$f.tmpl"; + die "bad template: $tmpl" unless -e $tmpl; + open(my $tfh, '<', $tmpl) or die "open: $!"; + while (my $l = <$tfh>) { + process_line($l); + } + close($tfh) or die "close: $!"; +} diff --git a/content/03-24-20-domain-name.html b/content/03-24-20-domain-name.html new file mode 100644 index 0000000..90e24cd --- /dev/null +++ b/content/03-24-20-domain-name.html @@ -0,0 +1,32 @@ + + +

Mar. 24, 2020: Domain Name Insanity

+

+I went through a phase this week of really wanting `karle.[original-tld]`. +Not for a business. Not for boosting my own webpage (it doesn't really +have much). Just for me. +

+ +

The results were... disheartening.

+ + + +

So here we are. Looks like karle.co for at least a little longer.

+ + diff --git a/content/12-19-19-a-new-hope.html b/content/12-19-19-a-new-hope.html new file mode 100644 index 0000000..45df09a --- /dev/null +++ b/content/12-19-19-a-new-hope.html @@ -0,0 +1,17 @@ + + +

Dec. 19, 2019: A New Hope

+

+Toying with the thought of starting a website/blog. +

+

+Exploring my hosting options and pleasantly surprised that +Fastmail has free static site hosting! +

+

+Inspired by Jeff Huang's article on websites +Designed to Last and +a general desire for a simpler web. +

+ + diff --git a/content/index.html b/content/index.html new file mode 100644 index 0000000..d9beeaa --- /dev/null +++ b/content/index.html @@ -0,0 +1,29 @@ + + + + + + +

About me:

+

+Hi, I'm Alex! I'm a software engineer living in the Boston area. +

+ +

+I'm currently interested in free Operating Systems (particularly Linux +and OpenBSD), SCM systems (mostly git), and developer tooling. +

+ +
+

Find me online:

+ + + + diff --git a/content/style.css b/content/style.css new file mode 100644 index 0000000..6633c95 --- /dev/null +++ b/content/style.css @@ -0,0 +1,51 @@ +body { + background-color: #F5F5F5; + font-family: "Courier New", monospace; + margin-left: 20px; + margin-right: 20px; + font-size: 1em; +} + +@media only screen and (min-width: 992px) { + #content { + width: 60%; + margin: 0 auto; + } +} + +a:link { + color: #0a7899; +} + +a:visited { + color: #033a4a; +} + +.new-post:link { + text-decoration: none; +} + +.new-post:hover { + text-decoration: underline; +} + + +#nav { + text-align: center; + margin-bottom: 20px; +} + +#nav > a { + color: dimgray; + text-decoration: none; + padding: 1em; +} + +h1.path { + margin-top: 0px; + margin-bottom: 0px; +} + +ul.find-me { + padding-left: 1.5em; +} diff --git a/content/thoughts.html b/content/thoughts.html new file mode 100644 index 0000000..b3b8d8d --- /dev/null +++ b/content/thoughts.html @@ -0,0 +1,16 @@ + + +

A collection of thoughts.

+

(Because I couldn't commit to calling it a blog)

+ + + + diff --git a/index.html b/index.html deleted file mode 100644 index e9a77c4..0000000 --- a/index.html +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Alex Karle - - - - - - -
- - -

/home/akarle

-

------------

- -

About me:

-

- Hi, I'm Alex! I'm a software engineer living in the Boston area. -

- -

- I'm currently interested in free Operating Systems (particularly Linux - and OpenBSD), SCM systems (mostly git), and developer tooling. -

- -
-

Find me online:

- - -
- - diff --git a/style.css b/style.css deleted file mode 100644 index dd9f094..0000000 --- a/style.css +++ /dev/null @@ -1,38 +0,0 @@ -body { - background-color: #F5F5F5; - font-family: "Courier New", monospace; - margin-left: 20px; - margin-right: 20px; - font-size: 1em; -} - -@media only screen and (min-width: 992px) { - #content { - width: 60%; - margin: 0 auto; - } -} - -.new-post { - margin-top: 80px; -} - -#nav { - text-align: center; - margin-bottom: 20px; -} - -#nav > a { - color: dimgray; - text-decoration: none; - padding: 1em; -} - -h1.path { - margin-top: 0px; - margin-bottom: 0px; -} - -ul.find-me { - padding-left: 1.5em; -} diff --git a/templates/head.tmpl b/templates/head.tmpl new file mode 100644 index 0000000..5f91bd9 --- /dev/null +++ b/templates/head.tmpl @@ -0,0 +1,12 @@ + + + + + Alex Karle + + + + + + +
diff --git a/templates/post-head.tmpl b/templates/post-head.tmpl new file mode 100644 index 0000000..1583c22 --- /dev/null +++ b/templates/post-head.tmpl @@ -0,0 +1,9 @@ + + + + + diff --git a/templates/post-tail.tmpl b/templates/post-tail.tmpl new file mode 100644 index 0000000..01820ca --- /dev/null +++ b/templates/post-tail.tmpl @@ -0,0 +1,6 @@ +


+
+ Back +
+


+ diff --git a/templates/tail.tmpl b/templates/tail.tmpl new file mode 100644 index 0000000..a51c933 --- /dev/null +++ b/templates/tail.tmpl @@ -0,0 +1,3 @@ +
+ + diff --git a/templates/title.tmpl b/templates/title.tmpl new file mode 100644 index 0000000..f5caafc --- /dev/null +++ b/templates/title.tmpl @@ -0,0 +1,2 @@ +

/home/akarle

+

------------

diff --git a/thoughts.html b/thoughts.html deleted file mode 100644 index f134314..0000000 --- a/thoughts.html +++ /dev/null @@ -1,69 +0,0 @@ - - - - - Alex Karle - - - - - - -
- - -

/home/akarle

-

------------

- -

A collection of thoughts.

- -

Mar. 24, 2020: Domain Name Insanity

-

- I went through a phase this week of really wanting `karle.[original-tld]`. - Not for a business. Not for boosting my own webpage (it doesn't really - have much). Just for me. -

- -

The results were... disheartening.

- - - -

So here we are. Looks like karle.co for at least a little longer.

- -

Dec. 19, 2019: A New Hope

-

- Toying with the thought of starting a website/blog. -

-

- Exploring my hosting options and pleasantly surprised that - Fastmail has free static site hosting! -

-

- Inspired by Jeff Huang's article on websites - Designed to Last and - a general desire for a simpler web. -

-
- - -- libgit2 1.1.1