aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.build.yml21
-rw-r--r--.gitignore1
-rwxr-xr-xbarf81
-rw-r--r--footer.html2
-rw-r--r--index.md2
-rw-r--r--posts/2024-01-10-introducing-jsfree.md2
6 files changed, 94 insertions, 15 deletions
diff --git a/.build.yml b/.build.yml
new file mode 100644
index 0000000..63bba05
--- /dev/null
+++ b/.build.yml
@@ -0,0 +1,21 @@
+image: alpine/latest
+oauth: pages.sr.ht/PAGES:RW
+packages:
+- rsync
+- coreutils
+- lowdown
+- go
+- hut
+environment:
+site: jsfree.org
+sources:
+- https://git.sr.ht/~bt/jsfree.org
+tasks:
+- build: |
+ cd jsfree.org
+ make build
+- package: |
+ cd jsfree.org/build
+ tar -cvz . > ../../site.tar.gz
+- upload: |
+ hut pages publish -d jsfree.org site.tar.gz \ No newline at end of file
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..d163863
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+build/ \ No newline at end of file
diff --git a/barf b/barf
index 81bbcd2..5c0db4d 100755
--- a/barf
+++ b/barf
@@ -1,9 +1,24 @@
#!/bin/sh
+
+domain="https://jsfree.org"
+
+# 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
+MARKDOWN=lowdown
IFS=' '
-# Create tab separated file with filename, title, creation date, last update
+# Create tab-separated file with filename, title, creation date, last update
index_tsv() {
for f in "$1"/*.md
do
@@ -20,13 +35,13 @@ index_html() {
# Intro text
$MARKDOWN index.md
- echo "<ul>"
+ echo "<ul class='posts'>"
# Posts
while read -r f title created; do
- link=$(echo "$f" | sed -E 's|.*/(.*).md|\1/|')
+ link=$(echo "$f" | sed -E 's|.*/(.*).md|posts/\1/|')
created=$(echo $(head -3 "$f" | tail -1))
- echo "<li>$created &middot; <a href=\"$link\">$title</a></li>"
+ echo "<li><span>$created</span><a href=\"$link\">$title</a></li>"
done < "$1" | sort -r
echo "</ul>"
@@ -37,7 +52,6 @@ index_html() {
atom_xml() {
uri=$(sed -rn '/atom.xml/ s/.*href="([^"]*)".*/\1/ p' header.html)
- domain=$(echo "$uri" | sed 's/atom.xml//g' | sed 's|/[^/]*$||')
first_commit_date=$(git log --pretty='format:%ai' . | cut -d ' ' -f1 | tail -1)
cat <<EOF
@@ -53,9 +67,8 @@ atom_xml() {
EOF
while read -r f title created; do
-
content=$($MARKDOWN "$f" | sed 's/&/\&amp;/g; s/</\&lt;/g; s/>/\&gt;/g; s/"/\&quot;/g; s/'"'"'/\&#39;/g')
- post_link=$(echo "$f" | sed -E 's|posts/(.*).md|\1|')
+ post_link=$(echo "$f" | sed -E 's|posts/(.*).md|posts/\1|')
basic_date=$(echo $(head -3 "$f" | tail -1))
published_date=$(date -d $basic_date -u +%Y-%m-%dT10:%M:%SZ)
@@ -74,11 +87,56 @@ EOF
echo '</feed>'
}
+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 <<EOF
+<?xml version="1.0" encoding="utf-8"?>
+<rss version="2.0">
+ <channel>
+ <title>$(sed -n '/^# /{s/# //p; q}' index.md)</title>
+ <link>$domain/rss.xml</link>
+ <description>Feed description here</description>
+ <lastBuildDate>$(date -u +"%a, %d %b %Y %H:%M:%S %z")</lastBuildDate>
+ <pubDate>$(date -u +"%a, %d %b %Y %H:%M:%S %z")</pubDate>
+ <generator>Custom RSS Generator</generator>
+ <ttl>1800</ttl>
+EOF
+
+ while read -r f title created; do
+ content=$($MARKDOWN "$f" | sed 's/&/\&amp;/g; s/</\&lt;/g; s/>/\&gt;/g; s/"/\&quot;/g; s/'"'"'/\&#39;/g')
+ post_link=$(echo "$f" | sed -E 's|posts/(.*).md|posts/\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 <<EOF
+ <item>
+ <title>$title</title>
+ <description>$content</description>
+ <link>$domain/$post_link</link>
+ <guid isPermaLink="false">$domain/$post_link</guid>
+ <pubDate>$published_date</pubDate>
+ </item>
+EOF
+ done < "$1"
+
+ echo '</channel>'
+ echo '</rss>'
+}
+
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|')
+ if echo "$filename" | grep -q "^posts/"; then
+ # Create a directory under build/posts
+ $(mkdir -p build/posts/$directory)
+ target=$(echo "$filename" | sed -r 's|posts/(.*).md|build/posts/\1/index.html|')
+ else
+ # Create a directory under build for pages
+ $(mkdir -p build/$directory)
+ target=$(echo "$filename" | sed -r 's|pages/(.*).md|build/\1/index.html|')
+ fi
created=$(echo $(head -3 "$filename" | tail -1))
title=$2
@@ -88,12 +146,11 @@ write_page() {
> "$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
diff --git a/footer.html b/footer.html
index 477bece..894338a 100644
--- a/footer.html
+++ b/footer.html
@@ -20,7 +20,7 @@
</ul>
<small>
Built with <a href="https://git.sr.ht/~bt/barf">barf</a>. <br>
- Hosted on <a href="https://nearlyfreespeech.net">NearlyFreeSpeech.net</a>. <br>
+ Hosted on <a href="https://sourcehut.org">sourcehut</a>. <br>
The <a href="https://git.sr.ht/~bt/jsfree.org">code for this site</a> is <a href="https://git.sr.ht/~bt/jsfree.org/tree/master/item/LICENSE">MIT</a>.
</small>
</footer> \ No newline at end of file
diff --git a/index.md b/index.md
index b0814c2..f927869 100644
--- a/index.md
+++ b/index.md
@@ -19,7 +19,7 @@ If you're looking for the reasoning behind this project, read [Introducing jsfre
Things you can do to contribute to the project (in order of importance):
-* [Submit a patch](mailto:jsfree@patches.btxx.org) for new service/category suggestions or improvements to the main website.
+* [Submit a patch](https://git.sr.ht/~bt/jsfree.org) for new service/category suggestions or improvements to the main website.
* Create your own JavaScript-free web service / application. (Then submit it!)
* Spread the word, so the world knows they can go JavaScript-free.
diff --git a/posts/2024-01-10-introducing-jsfree.md b/posts/2024-01-10-introducing-jsfree.md
index af75e82..77bdf59 100644
--- a/posts/2024-01-10-introducing-jsfree.md
+++ b/posts/2024-01-10-introducing-jsfree.md
@@ -20,7 +20,7 @@ So, if you feel offended by the concept of others not liking JavaScript, maybe g
I'm far from an expert in the field of "all-things JavaScript-free". Consider helping me out and making this site even better!
-* [Submit](mailto:jsfree@patches.btxx.org) service/category suggestions or improvements to the main website.
+* [Submit](https://git.sr.ht/~bt/jsfree.org) service/category suggestions or improvements to the main website.
* Create your own JavaScript-free web service / application. (Then submit it!)
* Spread the word, so the world knows they can go JavaScript-free.