THE WRITER MUST EAT -> patreon.com/trn1ty <-

| \    |   | blah!
|\ | `\|\  | the rantings and ravings
|/ |(_|| | * of a depraved lunatic

<^>

2023-02-07

#!/bin/sh
set -ex;mkdir -p blah;python -c "import os;os.chdir('blah')
with open('../$0', 'r') as f:
	for day in f.read().split('\n\n\n'):
		if day.split('\n')[0] == '#!/bin/sh':
			prefix='\n'.join(day.split('\n')[day.split('\n').index(
				'exit 0')+1:])+'\n';continue
		elif day.split('\n')[0][:4] == '<!--': suffix=day;continue
		with open(day.split('\n')[0]+'.html', 'x') as g:
			g.write(prefix+day+'\n'+suffix)
";cd blah;for f in *.html;do #in glob we trust
test -z "$last" || sed -i "s,_NAVIGATION_,$nav<A HREF=\"$f\">\></A></P>," \
"$last";nav="<P>";test -z "$last"||nav="$nav<A HREF=\"$last\">\<</A>"
nav="$nav<A HREF=\"index.html\">^</A>";last="$f";done
sed -i "s,_NAVIGATION_,$nav</P>," "$last";for f in *.html;do #e unibus puellam
fi="$(echo "$f" | cut -d . -f 1)";test "$fi" = "index" && continue
printf '<A HREF="/blah/%s.html">%s</A>\n' "$fi" "$fi"; done|sort -r|\
sed -e "1i<!DOCTYPE html><HTML><HEAD><TITLE>blah</TITLE></HEAD><BODY><PRE>\
<A HREF="..">..</A>" -e '$a</PRE></BODY></HTML>'>index.html
exit 0

	That's the source code to this blog, in its entirety. My writing
process was simple:
	- write the beginning and initial Python portion
	- pass out
	- wake up at 0600 not knowing who or where I am
	- see this code and continue it
	- pass out again
	- wake up at 1700 knowing who but not where I am
	- write most of the rest
	- pass out again
	- wake up half an hour later, finish

	It's organized in sections though it doesn't appear to be organized
whatsoever:

#!/bin/sh
set -ex
mkdir -p blah
python -c "
import os
os.chdir('blah')
with open('../$0', 'r') as f:
	for day in f.read().split('\n\n\n'):
		if day.split('\n')[0] == '#!/bin/sh':
			prefix = '\n'.join(
				day.split('\n')[
					day.split('\n').index('exit 0')+1:
				
				]
			) + '\n'
			continue
		elif day.split('\n')[0][:4] == '<!--':
			suffix = day
			continue
		with open(day.split('\n')[0]+'.html', 'x') as g:
			g.write(prefix + day + '\n' + suffix)
"

	This splits the blog into days, where each day is delimited by three
newlines. Every day is two lines apart.
	A day that starts with the POSIX shell shebang is the /prefix/, which
is prepended to each day. It cuts off everything until after "exit 0", the end
of the script, and after that is the actual HTML prefix to each blah page.
	A day that starts as an HTML comment is the /suffix/, appended to each
day. This obligates an HTML comment at the end of each post, the same comment,
so I just made it something sort of interesting yet sort of bog standard.
	I explained this poorly but I spread the code out so it's a little
easier to read, I think it's pretty simple. git.sr.ht/~trinity/homepage/tree
/main/blog, you can see how it's laid out.
	Each day, prefixed and suffixed, is output as its own [day].html to the
created blah/ directory.

	Next:

cd blah
for f in *.html
	do
		test -z "$last" || sed -i \
-e "s,_NAVIGATION_,$nav<A HREF=\"$f\">\></A></P>," "$last"
		nav="<P>"
		test -z "$last" \
			|| nav="$nav<A HREF=\"$last\">\<</A>"
		nav="$nav<A HREF=\"index.html\">^</A>"
		last="$f"
	done
sed -i "s,_NAVIGATION_,$nav</P>," "$last"

	This replaces _NAVIGATION_ with an actual navigation bar. The actual
string has two underscores before and after NAVIGATION but this blog is held
together with shoelaces and bubble gum and I don't wanna fuck around and find
out.
	I don't know how this works, I let my fingers handle the flow.
		(The secret is that I just run it in my head and adjust the
		 beginnings and ends until it runs in my head for two times
		 correctly. Then as long as state doesn't drift it's all good.
		 This is fucky and I don't know how to explain it and I don't
		 really know how it all goes about but you can do really
		 complex but really really tight program flow just by vibing
		 against it and letting your fingers tap tap tap, yknow?)

Next:

for f in *.html
	do
		fi="$(echo "$f" | cut -d . -f 1)"
		test "$fi" = "index" \
			&& continue
		printf '<A HREF="/blah/%s.html">%s</A>\n' "$fi" "$fi"
	done \
		| sort -r \
		| sed \
			-e "1i\
<!DOCTYPE html>blah
.." \
			-e '$a
' \ > index.html exit 0 This takes all the files in blah/, builds an index, adds a prefix and suffix to the stream, and outputs it all to blah/index.html in one go. This is the simplest part of the script and I was worried it would be hard but it wasn't really, it just required a little bit of embracing of UNIX piping. ["Streambreak"]: After experiencing a genocide, Ada Karina time travels back to the past to prevent it from happening. However things start diverging from plan when a soup-fueled arsonist grows from nuisance to idol to geopolitical disaster. ["Antero"]: Tales from a future dystopia where the very formation of memories is outlawed. ["Sponge"]: Olive Edgerton is an employee at an impossibly popular burger joint, where every ingredient is grown or produced in-house. ["Saikokon"]: After an apocalypse, the last survivor is selected as an exhibit at Saikokon, a conference for psychic time travelers. ["Pasture"]: Tales from after the end of the world. <^> No rights reserved, all rights exercised, rights turned to lefts, left in this corner of the web.