aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhitlerrip <git@hitler.rip>2025-07-29 17:46:12 +0200
committerhitlerrip <git@hitler.rip>2025-07-29 17:46:12 +0200
commit2a51b9df1e2f56cb885f1db731cfa70dd05da528 (patch)
treebb83ae790a3290b9d69581eac285c1636c068558
parentd48ea3fff0f7a08e9acf2be7b11a58e063498bf8 (diff)
downloadwebsite-2a51b9df1e2f56cb885f1db731cfa70dd05da528.tar.gz
website-2a51b9df1e2f56cb885f1db731cfa70dd05da528.tar.bz2
website-2a51b9df1e2f56cb885f1db731cfa70dd05da528.zip
article sorting
added (somewhat) proper article sorting to the build script
-rw-r--r--README.md2
-rwxr-xr-xbuild.sh137
-rwxr-xr-xsort.sh59
-rw-r--r--src/articles/allerersterartikel.md1
-rw-r--r--src/articles/allerersterartikel.meta1
-rw-r--r--src/articles/besterartikel.md1
-rw-r--r--src/articles/besterartikel.meta1
-rw-r--r--src/articles/lol.md1
-rw-r--r--src/articles/lol.meta1
-rw-r--r--src/articles/zefinivderletzteartikel.md1
-rw-r--r--src/articles/zefinivderletzteartikel.meta1
11 files changed, 108 insertions, 98 deletions
diff --git a/README.md b/README.md
index bf465f7..81bc301 100644
--- a/README.md
+++ b/README.md
@@ -35,8 +35,6 @@ custom directories are not supported yet. you will have to manually edit the bui
- title share options that link to id
- add a copy button to code blocks
-- sort articles by date, add latest article to home page
-
- allow user to create directories
- 404 page
diff --git a/build.sh b/build.sh
index e7c8032..3cd53bf 100755
--- a/build.sh
+++ b/build.sh
@@ -46,15 +46,7 @@ for i in *.md; do
convert "../con/contact.md" "../tmp/con-contact-tmp-file.html"
- cat ../con/header.html \
- ../tmp/"$filename".html \
- ../tmp/con-contact-tmp-file.html \
- ../con/footer.html \
- > ../web/"$filename".html
-
- cat "$i" \
- ../con/contact.md \
- > ../web/"$filename".md
+ echo "[build] skipping index file for later..."
else
@@ -74,6 +66,10 @@ done
echo "[build] writing articles..."
cd ./articles/
+declare -A articlearr
+declare -a workingarr
+declare -a thebestarr
+
for i in *.md; do
echo "[build] converting: $i"
@@ -94,10 +90,7 @@ for i in *.md; do
cp "$i" ../../web/articles/"$filename"/index.md
- export WEBMETA_TITLE=""
export WEBMETA_DATE=""
- export WEBMETA_AUTH=""
- export WEBMETA_SUMMARY=""
if [ -e "$filename".meta ]; then
echo "[build] running script: $filename.meta"
@@ -111,57 +104,127 @@ for i in *.md; do
# please note that you have to actually check if this data is correct
# and you should not just import random `.meta` files as they can arbitrarily
# execute code on your system and are directly injected into the HTML.
+ #
+ # NOTE:
+ # I do not expect to have multiple articles written on the same day
+ # as I am a lazy fuck. The generator below does not expect multiple
+ # articles to have the exact same date.
+ # If I were you, I would maybe add hours and minutes to the timestamps
+ # and maybe change this script accordingly.
fi
-
+
if [ "$WEBMETA_DATE" == "" ]; then
- export WEBMETA_DATE="2001-09-11*REDACTED!*"
- fi
- if [ "$WEBMETA_AUTH" == "" ]; then
- export WEBMETA_AUTH="Anonymous"
- fi
- if [ "$WEBMETA_SUMMARY" == "" ]; then
- export WEBMETA_SUMMARY="redacted"
+ export WEBMETA_DATE="2001-09-11*"
fi
- if [ "$WEBMETA_TITLE" == "" ]; then
- export WEBMETA_TITLE="$filename"
+
+ articlearr["$filename"]="$WEBMETA_DATE"
+
+ fi
+
+done
+
+echo "[build] sorting articles..."
+
+workingarr=($( sort -nr < <(printf '%s\n' "${articlearr[@]}") ))
+
+for date in "${workingarr[@]}"; do
+ for key in "${!articlearr[@]}"; do
+ if [ "${articlearr[$key]}" == "$date" ]; then
+ thebestarr+=("$key")
fi
+ done
+done
+
+for i in "${thebestarr[@]}"; do
+
+ export WEBMETA_TITLE=""
+ export WEBMETA_DATE=""
+ export WEBMETA_AUTH=""
+ export WEBMETA_SUMMARY=""
+ if [ -e "$i".meta ]; then
+ echo "[build] re-running script: $i.meta"
+ source ./"$i".meta
+ # see above
+ fi
- touch ../../tmp/articles/gen-articles-tmp-list.html
- tee -a ../../tmp/articles/gen-articles-tmp-list.html > /dev/null << EOF
+ if [ "$WEBMETA_DATE" == "" ]; then
+ export WEBMETA_DATE="2001-09-11*"
+ fi
+ if [ "$WEBMETA_AUTH" == "" ]; then
+ export WEBMETA_AUTH="Anonymous"
+ fi
+ if [ "$WEBMETA_SUMMARY" == "" ]; then
+ export WEBMETA_SUMMARY="redacted"
+ fi
+ if [ "$WEBMETA_TITLE" == "" ]; then
+ export WEBMETA_TITLE="$i"
+ fi
+
+ if [ "$i" == "${thebestarr[0]}" ]; then
+ tee ../../tmp/articles/gen-first-article-tmp.html > /dev/null << EOF
+ <h2>Latest Post:</h2>
+ <article>
+ <a href="/articles/$i"><h3>$WEBMETA_TITLE</h3></a>
+ <h6><code>$WEBMETA_DATE</code> by $WEBMETA_AUTH</h6>
+ <p>$WEBMETA_SUMMARY</p>
+ </article>
+ <a href="/articles/"><h5>See more Articles →</h5></a>
+EOF
+ tee ../../tmp/articles/gen-first-article-tmp.md > /dev/null << EOF
+
+## Latest Post:
+
+## [$WEBMETA_TITLE](/articles/$i)
+###### \`$WEBMETA_DATE\` by $WEBMETA_AUTH
+$WEBMETA_SUMMARY
+EOF
+ fi
+
+ touch ../../tmp/articles/gen-articles-tmp-list.html
+ tee -a ../../tmp/articles/gen-articles-tmp-list.html > /dev/null << EOF
<article>
- <a href="$filename"><h2>$WEBMETA_TITLE</h2></a>
+ <a href="$i"><h2>$WEBMETA_TITLE</h2></a>
<h6><code>$WEBMETA_DATE</code> by $WEBMETA_AUTH</h6>
<p>$WEBMETA_SUMMARY</p>
</article>
EOF
- touch ../../tmp/articles/gen-articles-tmp-list.md
- tee -a ../../tmp/articles/gen-articles-tmp-list.md > /dev/null << EOF
+ touch ../../tmp/articles/gen-articles-tmp-list.md
+ tee -a ../../tmp/articles/gen-articles-tmp-list.md > /dev/null << EOF
-## [$WEBMETA_TITLE]($filename)
+## [$WEBMETA_TITLE]($i)
###### \`$WEBMETA_DATE\` by $WEBMETA_AUTH
$WEBMETA_SUMMARY
EOF
- touch ../../tmp/articles/gen-articles-tmp-rss.xml
- tee -a ../../tmp/articles/gen-articles-tmp-rss.xml > /dev/null << EOF
+ touch ../../tmp/articles/gen-articles-tmp-rss.xml
+ tee -a ../../tmp/articles/gen-articles-tmp-rss.xml > /dev/null <<EOF
<item>
<title>$WEBMETA_TITLE</title>
- <pubDate>$(date -d "${WEBMETA_DATE:0:10}" +"%a, %d %b %Y %H:%M:%S +0000" )</pubDate>
- <author>$WEBMETA_AUTHOR</author>
+ <pubDate>$(date -d "${WEBMETA_DATE:0:10}" +"%a, %d %b %Y %H:%M:%S +0000")</pubDate>
+ <author>$WEBMETA_AUTH</author>
<description>$WEBMETA_SUMMARY</description>
- <link>/$filename</link>
- <guid>/$filename</guid>
+ <link>/$i</link>
+ <guid>/$i</guid>
</item>
EOF
- fi
-
done
+echo "[build] generating feed..."
cd ../..
-echo "[build] generating feed..."
+cat ./con/header.html \
+ ./tmp/index.html \
+ ./tmp/articles/gen-first-article-tmp.html \
+ ./tmp/con-contact-tmp-file.html \
+ ./con/footer.html \
+ > ./web/index.html
+
+cat ./src/index.md \
+ ./tmp/articles/gen-first-article-tmp.md \
+ ./con/contact.md \
+ > ./web/index.md
cat ./con/header.html \
./tmp/articles/index.html \
diff --git a/sort.sh b/sort.sh
deleted file mode 100755
index 10d64a1..0000000
--- a/sort.sh
+++ /dev/null
@@ -1,59 +0,0 @@
-#!/bin/bash
-
-# hitler.rip
-# temporary script that implements sorting articles by date
-# © 2025 hitler.rip <git@hitler.rip>
-# licensed under AGPLv3-or-later; see licenses/code.md for more information
-
-declare -A articlearr
-declare -a workingarr
-declare -A thebestarr
-
-cd ./src/articles/
-
-echo "[test] SECTION - DETERMINE DATE"
-
-for i in *.md; do
-
- echo "[test] reading: $i"
-
- filename=$( echo "$i" | rev | cut -c4- | rev )
-
- if [ "$filename" != "index" ]; then
-
- export WEBMETA_DATE=""
-
- if [ -e "$filename.meta" ]; then
- echo "[test] running script: $filename.meta"
- source ./"$filename".meta
- fi
-
- if [ "$WEBMETA_DATE" == "" ]; then
- export WEBMETA_DATE="2001-09-11*"
- fi
-
- articlearr["$filename"]="$WEBMETA_DATE"
-
- fi
-
-done
-
-echo "[test] SECTION - SORT"
-
-workingarr=($( sort -nr < <(printf '%s\n' "${articlearr[@]}") ))
-
-for date in "${workingarr[@]}"; do
-
- for key in "${!articlearr[@]}"; do
- if [ "${articlearr[$key]}" == "$date" ]; then
- echo "$date matches $key"
- thebestarr["$date"]="$key"
- fi
- done
-
-done
-
-echo "[test] SECTION - GENERATE"
-
-# ...
-
diff --git a/src/articles/allerersterartikel.md b/src/articles/allerersterartikel.md
new file mode 100644
index 0000000..7898192
--- /dev/null
+++ b/src/articles/allerersterartikel.md
@@ -0,0 +1 @@
+a
diff --git a/src/articles/allerersterartikel.meta b/src/articles/allerersterartikel.meta
new file mode 100644
index 0000000..b6c3e7e
--- /dev/null
+++ b/src/articles/allerersterartikel.meta
@@ -0,0 +1 @@
+export WEBMETA_DATE="1990-07-28"
diff --git a/src/articles/besterartikel.md b/src/articles/besterartikel.md
new file mode 100644
index 0000000..6178079
--- /dev/null
+++ b/src/articles/besterartikel.md
@@ -0,0 +1 @@
+b
diff --git a/src/articles/besterartikel.meta b/src/articles/besterartikel.meta
new file mode 100644
index 0000000..2885fe7
--- /dev/null
+++ b/src/articles/besterartikel.meta
@@ -0,0 +1 @@
+export WEBMETA_DATE="1988-07-28"
diff --git a/src/articles/lol.md b/src/articles/lol.md
new file mode 100644
index 0000000..fc1585b
--- /dev/null
+++ b/src/articles/lol.md
@@ -0,0 +1 @@
+ajksnd
diff --git a/src/articles/lol.meta b/src/articles/lol.meta
new file mode 100644
index 0000000..4b472f3
--- /dev/null
+++ b/src/articles/lol.meta
@@ -0,0 +1 @@
+export WEBMETA_DATE="2024-07-28"
diff --git a/src/articles/zefinivderletzteartikel.md b/src/articles/zefinivderletzteartikel.md
new file mode 100644
index 0000000..b680253
--- /dev/null
+++ b/src/articles/zefinivderletzteartikel.md
@@ -0,0 +1 @@
+z
diff --git a/src/articles/zefinivderletzteartikel.meta b/src/articles/zefinivderletzteartikel.meta
new file mode 100644
index 0000000..83c5df5
--- /dev/null
+++ b/src/articles/zefinivderletzteartikel.meta
@@ -0,0 +1 @@
+export WEBMETA_DATE="2030-07-28"