From 8af8f7b665375f5b5c5a701aaf3631263a2e6515 Mon Sep 17 00:00:00 2001 From: Adam Stück Date: Sat, 14 Sep 2024 23:18:53 +0200 Subject: switch to wruby site generator --- .build.yml | 21 ++++---- .gitignore | 1 + LICENSE | 4 +- Makefile | 11 ++-- README.md | 2 +- _config.yml | 21 ++++++++ barf | 158 --------------------------------------------------------- footer.html | 5 +- header.html | 8 +-- index.md | 6 +-- pages/posts.md | 1 + wruby.rb | 150 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 12 files changed, 198 insertions(+), 190 deletions(-) create mode 100644 .gitignore create mode 100644 _config.yml delete mode 100755 barf create mode 100644 pages/posts.md create mode 100644 wruby.rb diff --git a/.build.yml b/.build.yml index 62f7428..87de057 100644 --- a/.build.yml +++ b/.build.yml @@ -1,20 +1,23 @@ -image: alpine/edge +image: alpine/latest oauth: pages.sr.ht/PAGES:RW packages: -- hut -- rsync + - ruby + - ruby-dev + - go + - hut + - rsync sources: - https://git.sr.ht/~adamski/arena-web - - https://git.btxx.org/smu environment: site: arena.adast.dk tasks: -- smu: | - cd smu - sudo make install -- package: | +- install-gems: | + sudo gem install bundler 'kramdown:2.4.0' 'rss:0.3.0' +- build: | cd arena-web make build - tar -C build -cvz . > ../site.tar.gz +- package: | + cd arena-web/build + tar -cvz . > ../../site.tar.gz - upload: | hut pages publish -d $site site.tar.gz diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..567609b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +build/ diff --git a/LICENSE b/LICENSE index 8653a47..81774c2 100644 --- a/LICENSE +++ b/LICENSE @@ -1,7 +1,7 @@ MIT License -Copyright (c) 2023 Bradley Taunt -Copyright (c) 2023 Adam Stück +Copyright (c) 2024 Bradley Taunt +Copyright (c) 2024 Adam Stück Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/Makefile b/Makefile index b16a580..9d7e5a1 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,8 @@ build: - sh ./barf - rsync -r public/ build/public + rm -rf build && mkdir build + ruby wruby.rb clean: rm -rf build/* -watch: - while true; do \ - ls -d .git/* * posts/* pages/* header.html | entr -cd make ;\ - done - -.PHONY: build clean watch +.PHONY: build clean diff --git a/README.md b/README.md index e483652..3933c87 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # arena-web -Sources for [arena.adast.dk](https://arena.adast.dk), built with [barf](https://barf.btxx.org). +Sources for [arena.adast.dk](https://arena.adast.dk), built with [wruby](https://wruby.btxx.org). [[project home]](https://sr.ht/~adamski/arena/) diff --git a/_config.yml b/_config.yml new file mode 100644 index 0000000..fef28e4 --- /dev/null +++ b/_config.yml @@ -0,0 +1,21 @@ +site_url: 'https://arena.adast.dk' +site_name: 'arena' +author_name: 'Adam Stück' + +directories: + posts: 'posts' + pages: 'pages' + public: 'public' + output: 'build' + posts_output: 'build/posts' + pages_output: 'build/' + +files: + header: 'header.html' + footer: 'footer.html' + root_index: 'index.md' + posts_index: 'pages/posts.md' + rss: 'build/index.rss' + +misc: + post_count: 5 diff --git a/barf b/barf deleted file mode 100755 index 0213a3e..0000000 --- a/barf +++ /dev/null @@ -1,158 +0,0 @@ -#!/bin/sh - -domain="https://arena.adast.dk" - -# Check the operating system -os_name=$(uname -s) - -if [ "$os_name" = "OpenBSD" ]; then - alias sed=gsed - alias date=gdate - alias rsync=openrsync -elif [ "$os_name" = "Darwin" ]; then - alias sed=gsed - alias date=gdate -fi - -set -eu -MARKDOWN=smu -IFS=' ' - -# Create tab separated file with filename, title, creation date, last update -index_tsv() { - for f in "$1"/*.md - do - title=$(sed -n '/^# /{s/# //p; q}' "$f") - printf '%s\t%s\t%s\t%s\n' "$f" "${title:="No Title"}" - done -} - -index_html() { - # Print header - title=$(sed -n '/^# /{s/# //p; q}' index.md) - sed "s/{{TITLE}}/$title/" header.html - - # Intro text - $MARKDOWN index.md - - echo '" - - # Print footer after post list - cat footer.html -} - -atom_xml() { - uri=$(sed -rn '/atom.xml/ s/.*href="([^"]*)".*/\1/ p' header.html) - first_commit_date=$(git log --pretty='format:%ai' . | cut -d ' ' -f1 | tail -1) - - cat < - - $(sed -n '/^# /{s/# //p; q}' index.md) - - $(date +%FT%TZ) - - $(git config user.name) - - $domain,$first_commit_date:default-atom-feed/ -EOF - - while read -r f title created; do - - content=$($MARKDOWN "$f" | sed 's/&/\&/g; s//\>/g; s/"/\"/g; s/'"'"'/\'/g') - post_link=$(echo "$f" | sed -E 's|posts/(.*).md|\1|') - basic_date=$(echo $(head -3 "$f" | tail -1)) - published_date=$(date -d $basic_date -u +%Y-%m-%dT10:%M:%SZ) - - cat < - $title - $content - - $domain/$post_link - $published_date - $published_date - -EOF - done < "$1" - - echo '' -} - -rss_xml() { - uri=$(sed -rn '/rss.xml/ s/.*href="([^"]*)".*/\1/ p' header.html) - first_commit_date=$(git log --pretty='format:%ai' . | cut -d ' ' -f1 | tail -1) - - cat < - - - $(sed -n '/^# /{s/# //p; q}' index.md) - $domain/rss.xml - Updates for Project Arena - $(date -u +"%a, %d %b %Y %H:%M:%S %z") - $(date -u +"%a, %d %b %Y %H:%M:%S %z") - Custom RSS Generator - 1800 -EOF - - while read -r f title created; do - content=$($MARKDOWN "$f" | sed 's/&/\&/g; s//\>/g; s/"/\"/g; s/'"'"'/\'/g') - post_link=$(echo "$f" | sed -E 's|posts/(.*).md|\1|') - basic_date=$(echo $(head -3 "$f" | tail -1)) - published_date=$(date -d "$basic_date" -u +"%a, %d %b %Y %H:%M:%S %z") - - cat < - $title - $content - $domain/$post_link - $domain/$post_link - $published_date - -EOF - done < "$1" - - echo '' - echo '' -} - -write_page() { - filename=$1 - directory=$(echo $(basename "$filename" .md)) - $(mkdir -p build/$directory) - target=$(echo "$filename" | sed -r 's|\w+/(.*).md|build/\1/index.html|') - created=$(echo $(head -3 "$filename" | tail -1)) - title=$2 - - $MARKDOWN "$filename" | \ - cat header.html - |\ - sed "s|{{TITLE}}|$title|" \ - > "$target" && cat footer.html >> "$target" -} - -rm -rf build && mkdir build - -# Blog posts -index_tsv posts | sort -rt " " -k 3 > build/posts.tsv -index_html build/posts.tsv > build/index.html -atom_xml build/posts.tsv > build/atom.xml -rss_xml build/posts.tsv > build/rss.xml -while read -r f title created; do - write_page "$f" "$title" "$created" -done < build/posts.tsv - -# Pages -index_tsv pages > build/pages.tsv -while read -r f title created; do - write_page "$f" "$title" "$created" -done < build/pages.tsv diff --git a/footer.html b/footer.html index 5c76d84..94ccd84 100644 --- a/footer.html +++ b/footer.html @@ -4,11 +4,12 @@ - Feeds: Atom | RSS
- Built with barf.
+ Built with wruby.
+ Hosted on sourcehut.
The code for this site is MIT.
diff --git a/header.html b/header.html index b687008..971a627 100644 --- a/header.html +++ b/header.html @@ -6,12 +6,8 @@ {{TITLE}} - - - + +