~dricottone/blog

87e3aa45c4eddffd41649c23bd177b485a99cfc0 — Dominic Ricottone 1 year, 2 months ago 0378702
Portability bug fixes

Now building the site from a Debian-derivative system, as opposed to my
Arch PC. This has made several predictable and one very surprising bug.

First of all, `gawk` has to be specified rather than `/bin/awk` now.
This is a portable change in that `gawk` can be installed on practically
any system and is reliably found at `/usr/bin/gawk`. My mistake for
thinking all Linux distros used `gawk` for system `awk`...

The LaTeX distro for Debian-derivative systems is confusingly broken up,
and best solved by just relying on apt install `latex-cjk-all
texlive-lang-cjk` to work. As a part of this, I broke up the
PDF generation process into separate TeX and PDF file recipes.

I forgot that, due to ignored files, a certain directory wasn't created
by cloning the repo. Oops. Now that directory is explicitly created by a
recipe.

Lastly, it seems that there's an important difference in how escaped
newlines are interpretted in shell variables between `bash` and `dash`.
No idea what the actual reasoning is, but making `bsky.sh` into
`bsky.bash` works.
4 files changed, 15 insertions(+), 8 deletions(-)

M Makefile
R scripts/{bsky.sh => bsky.bash}
M scripts/cv_html.awk
M scripts/cv_tex.awk
M Makefile => Makefile +10 -3
@@ 8,19 8,26 @@ clean:
	rm -rf scripts/cv.aux scripts/cv.log scripts/cv.out scripts/cv.tex
	rm -rf content/posts/*.bak

static/files/dominic-ricottone.pdf: content/cv.md
scripts/cv.tex:
	sed content/cv.md \
		-e 's/南山大学/\\begin{CJK}{UTF8}{min}&\\end{CJK}/' \
		| scripts/cv_tex.awk > scripts/cv.tex

static/files:
	mkdir -p static/files

static/files/dominic-ricottone.pdf: static/files content/cv.md scripts/cv.tex
	cd scripts && pdflatex cv.tex
	pwd
	mv scripts/cv.pdf static/files/dominic-ricottone.pdf
	rm -rf scripts/cv.aux scripts/cv.log scripts/cv.out scripts/cv.tex

static/files/dominic-ricottone.html: content/cv.md
static/files/dominic-ricottone.html: static/files content/cv.md
	cat content/cv.md \
		| scripts/cv_html.awk > static/files/dominic-ricottone.html

layouts/partials/bsky.html:
	scripts/bsky.sh > layouts/partials/bsky.html
	scripts/bsky.bash > layouts/partials/bsky.html

layouts/partials/lastfm.html:
	scripts/lastfm.sh > layouts/partials/lastfm.html

R scripts/bsky.sh => scripts/bsky.bash +3 -3
@@ 1,15 1,15 @@
#!/bin/sh
#!/bin/bash

API_PASSWD="$(cat bsky-passwd)"

DID_HANDLE='handle=dricottone.bsky.social'
DID_URI='https://bsky.social/xrpc/com.atproto.identity.resolveHandle'
DID="$(curl --get --no-progress-meter --data-urlencode "$DID_HANDLE" "$DID_URI" | jq --raw-output .did)"
DID="$(curl --get --no-progress-meter --data-urlencode "$DID_HANDLE" "$DID_URI" | jq --raw-output '.did')"

APIKEY_URI='https://bsky.social/xrpc/com.atproto.server.createSession'
APIKEY_HEADER='Content-Type: application/json'
APIKEY_DATA="{ \"identifier\": \"$DID\", \"password\": \"$API_PASSWD\" }"
APIKEY="$(curl -X POST --no-progress-meter --header "$APIKEY_HEADER" --data "$APIKEY_DATA" "$APIKEY_URI" | jq --raw-output .accessJwt)"
APIKEY="$(curl -X POST --no-progress-meter --header "$APIKEY_HEADER" --data "$APIKEY_DATA" "$APIKEY_URI" | jq --raw-output '.accessJwt')"

FEED_URI='https://bsky.social/xrpc/app.bsky.feed.getAuthorFeed'
FEED_HEADER="Authorization: Bearer $APIKEY"

M scripts/cv_html.awk => scripts/cv_html.awk +1 -1
@@ 1,4 1,4 @@
#!/bin/awk -f
#!/usr/bin/gawk -f

function end_section() {
  print "</ul>";

M scripts/cv_tex.awk => scripts/cv_tex.awk +1 -1
@@ 1,4 1,4 @@
#!/bin/awk -f
#!/usr/bin/gawk -f

function end_introduction() {
  print "\\end{minipage}";