Add support for Gopher builds

This commit is contained in:
~lucidiot 2022-07-29 19:29:36 +02:00
parent b96273f42d
commit e6d25a105d
27 changed files with 62 additions and 31 deletions

View File

@ -10,41 +10,60 @@ now="$(date -Iseconds)"
generator="$(pandoc --version | head -n1)" generator="$(pandoc --version | head -n1)"
function convert { function convert {
pandoc \ # Usage: convert input_file output_file output_format
--read markdown \ if [ "$3" = html ]; then
--write html \ pandoc \
--standalone \ --read markdown \
--template template.html \ --write html \
--highlight-style zenburn \ --standalone \
--css "/~$USER/theme.css" \ --template template.html \
--variable generator="$generator" \ --highlight-style zenburn \
--variable now="$now" \ --css "/~$USER/theme.css" \
-o "$2" \ --variable generator="$generator" \
"$1" --variable now="$now" \
-o "$2" \
"$1"
else
pandoc \
--read markdown \
--write "$3" \
-o "$2" \
"$1"
fi
chmod 644 "$2" chmod 644 "$2"
} }
for file in content/**/*.md; do function convert_all_md {
output="${file/#content/html}" # Usage: convert_all_md output_directory file_extension pandoc_output_format
output="${output/%.md/.html}" local file
mkdir -p "$(dirname "$output")" local output
chmod 711 "$(dirname "$output")" echo "Converting all Markdown files to .$2 files under $1/"
echo "Building $file to $output" for file in content/**/*.md; do
convert "$file" "$output" output="${file/#content/$1}"
done output="${output/%.md/.$2}"
mkdir -p "$(dirname "$output")"
function link_assets { chmod 755 "$(dirname "$output")"
for src in "$1"/*; do echo " $file -> $output"
dest="${src/#assets/html}" convert "$file" "$output" "$3"
if [ ! -h "$dest" ] && [ -d "$dest" ]; then
link_assets "$src"
else
echo "Symlinking $src to $dest"
ln -fTs "$(echo "$dest" | sed 's|[^/]*/|../|g;s|/[^/]*$||')/$src" "$dest"
fi
done done
} }
link_assets assets convert_all_md html html html
convert_all_md gopher txt plain
function link_assets {
echo "Copying assets from $1 to $2"
for path in $1/*; do
echo " $path -> $2"
cp -dr --no-preserve=mode "$path" "$2"
done
echo " Fixing asset attributes"
find "$1" -type d | sed "s|^$1|$2|" | xargs chmod 755
find "$1" -type f | sed "s|^$1|$2|" | xargs chmod 644
}
link_assets assets html
link_assets assets gopher
link_assets html_assets html
link_assets gopher_assets gopher
# Build the 'everything' page and CDF feed # Build the 'everything' page and CDF feed
echo 'Building article list' echo 'Building article list'
@ -57,7 +76,7 @@ title: everything
--- ---
" > "$tree_file" " > "$tree_file"
xsltproc xsl/tree-html.xsl "$tree_output" >> "$tree_file" xsltproc xsl/tree-html.xsl "$tree_output" >> "$tree_file"
convert "$tree_file" "html/everything.html" convert "$tree_file" "html/everything.html" html
xsltproc xsl/tree-cdf.xsl "$tree_output" | xmllint --format - > "html/everything.cdf" xsltproc xsl/tree-cdf.xsl "$tree_output" | xmllint --format - > "html/everything.cdf"
xmllint --noout --schema "assets/xsd/cdf.xsd" "html/everything.cdf" xmllint --noout --schema "assets/xsd/cdf.xsd" "html/everything.cdf"

12
gopher_assets/gophermap Normal file
View File

@ -0,0 +1,12 @@
Welcome to lucidiot's gopherhole on envs.net!
This is an attempt at building a gopher version of my wiki.
Below are plain-text version of all the articles; they are
generated using pandoc from Markdown files, and therefore may not
contain all of the interesting content that the original files
might have had, for example images or diagrams.
hThis wiki over HTTP URL:https://envs.net/~lucidiot/
___________________________________________________________________
*

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Before

Width:  |  Height:  |  Size: 44 B

After

Width:  |  Height:  |  Size: 44 B

View File

Before

Width:  |  Height:  |  Size: 172 B

After

Width:  |  Height:  |  Size: 172 B

View File

Before

Width:  |  Height:  |  Size: 163 B

After

Width:  |  Height:  |  Size: 163 B

View File

Before

Width:  |  Height:  |  Size: 450 B

After

Width:  |  Height:  |  Size: 450 B

View File

Before

Width:  |  Height:  |  Size: 166 B

After

Width:  |  Height:  |  Size: 166 B

View File

Before

Width:  |  Height:  |  Size: 318 B

After

Width:  |  Height:  |  Size: 318 B

View File

Before

Width:  |  Height:  |  Size: 166 B

After

Width:  |  Height:  |  Size: 166 B