~tekk/tekk.in-src

2edda98fb4ad806544eedb4a509ce1607d11dd31 — Daniel Wilkins 2 months ago 3b8c45f
Add automatic image handling
4 files changed, 55 insertions(+), 11 deletions(-)

M Makefile
A flowers.jpg
M meta.in
A mountainside.jpg
M Makefile => Makefile +19 -4
@@ 1,18 1,33 @@
#Use all .in files in this directory as posts
POSTS != ls *.in
# As well as all images.
JPEGS != ls *.jpg
PNGS != ls *.png

# Specify where to put the html files
OUTDIR ?= ~/www

# Declare "all" as phony (doesn't actually generate a file named "all")
.phony: all
.phony: all posts images

# Tell make that we have suffix rules for .in and .html
.SUFFIXES: .in .html
.SUFFIXES: .in .html .jpg .png .ping

# Apply the rule by saying that all depends on html versions of all of our .in files
# The variable expansion is a search&replace.
all: ${POSTS:S/.in$/.html$/}
all:   images

posts: ${POSTS:S/.in$/.html$/}

images: ${JPEGS:S/.jpg$/.png$/} ${PNGS:S/.png$/.ping$/}

# Suffix rule. When asked to build a .html file, look for a corresponding .in file and build it with cat.
.in.html:
	cat templates/header.html $< templates/footer.html > ${OUTDIR}/$@
\ No newline at end of file
	cat templates/header.html $< templates/footer.html > ${OUTDIR}/$@

.jpg.png:
	lowtechify $< ${OUTDIR}/$@

# Fake suffix to trick make into doing what we want.
.png.ping:
	lowtechify "$<" "${OUTDIR}/$<"
\ No newline at end of file

A flowers.jpg => flowers.jpg +0 -0
M meta.in => meta.in +36 -7
@@ 5,27 5,56 @@ Want to make an amazing webbed site like the one burning its way into your very 
Here you go:
</p>
<pre>
 #Use all .in files in this directory as posts
#Use all .in files in this directory as posts
POSTS != ls *.in
# As well as all images.
JPEGS != ls *.jpg
PNGS != ls *.png

# Specify where to put the html files
OUTDIR ?= ~/www

# Declare "all" as phony (doesn't actually generate a file named "all")
.phony: all
.phony: all posts images

# Tell make that we have suffix rules for .in and .html
.SUFFIXES: .in .html
.SUFFIXES: .in .html .jpg .png .ping

# Apply the rule by saying that all depends on html versions of all of our .in files
# The variable expansion is a search&replace.
all: ${POSTS:S/.in$/.html$/}
all:   images

posts: ${POSTS:S/.in$/.html$/}

images: ${JPEGS:S/.jpg$/.png$/} ${PNGS:S/.png$/.ping$/}

# Suffix rule. When asked to build a .html file, look for a corresponding .in file and build it with cat.
.in.html:
	cat templates/header.html $< templates/footer.html > ${OUTDIR}/$@

.jpg.png:
	lowtechify $< ${OUTDIR}/$@

# Fake suffix to trick make into doing what we want.
.png.ping:
	lowtechify "$<" "${OUTDIR}/$<"
</pre>
<p>
No really, that's what makes this site. Put your header-ey stuff in templates/header.html, the footer-ey stuff in templates/footer.html, all of your posts are ".in" files in the same directory as the makefile. I keep my www directory in ~/www but you can do whatever, I'm not your mom. For what it's worth this runs on bmake, I use openbsd as my primary OS. It doesn't work on GNU Make as far as I know.
<p>In addition, this makes use of my "lowtechify" script, which is here</p>
<pre>
#!/bin/sh

If you want to see the whole thing, you can just check out its <a href="https://hg.sr.ht/~tekk/www">repository</a>
# Resize to a max of 1024x1024 (keeping aspect ratio)
# Then reduce to 2 colors with dithering
# The color reduction picks something close to the "average" color
# of the image, so then
convert "$1" -resize '1024x1024>' -define module:colorspace=HSB  -dither FloydSteinberg -colors 2 -modulate 100,1000 "$2"
</pre>
<p>I've included a couple of images to demonstrate how it works:</p>
<img src="/mountainside.png" alt="A picture of a mountainside on a slightly cloudy day"/>
<img src="/flowers.png" alt="A close-up of cherry blossoms"/>
<p>
No really, that's what makes this site. Put your header-ey stuff in templates/header.html, the footer-ey stuff in templates/footer.html, all of your posts are ".in" files in the same directory as the makefile. I keep my www directory in ~/www but you can do whatever, I'm not your mom. For what it's worth this runs on bmake, I use openbsd as my primary OS.
</p>
<p>
If you want to see the whole thing, you can just check out its <a href="https://git.sr.ht/~tekk/www">repository</a>
</p>
\ No newline at end of file

A mountainside.jpg => mountainside.jpg +0 -0