about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorelioat@tilde.institute <eli@newstartmobile.com>2023-01-10 22:18:29 -0500
committerelioat@tilde.institute <eli@newstartmobile.com>2023-01-10 22:18:29 -0500
commit0b233305f90a815992a840bc687f18f2eaa0d456 (patch)
treee886df7e711eccdb3b06f93ff199b4cffdd2921c
downloadwiki-0b233305f90a815992a840bc687f18f2eaa0d456.tar.gz
gonna try to do the wiki thing
-rw-r--r--.gitignore88
-rw-r--r--archive.md3
-rw-r--r--changelog.md2
-rw-r--r--content/index.md3
-rwxr-xr-xmynah149
-rw-r--r--public/archive.html5
-rw-r--r--public/changelog.html6
-rw-r--r--public/feed.xml27
-rw-r--r--public/index.html2
-rw-r--r--updated1
10 files changed, 286 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..574cd5d
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,88 @@
+# Created by https://www.toptal.com/developers/gitignore/api/macos,emacs
+# Edit at https://www.toptal.com/developers/gitignore?templates=macos,emacs
+
+### Emacs ###
+# -*- mode: gitignore; -*-
+*~
+\#*\#
+/.emacs.desktop
+/.emacs.desktop.lock
+*.elc
+auto-save-list
+tramp
+.\#*
+
+# Org-mode
+.org-id-locations
+*_archive
+
+# flymake-mode
+*_flymake.*
+
+# eshell files
+/eshell/history
+/eshell/lastdir
+
+# elpa packages
+/elpa/
+
+# reftex files
+*.rel
+
+# AUCTeX auto folder
+/auto/
+
+# cask packages
+.cask/
+dist/
+
+# Flycheck
+flycheck_*.el
+
+# server auth directory
+/server/
+
+# projectiles files
+.projectile
+
+# directory configuration
+.dir-locals.el
+
+# network security
+/network-security.data
+
+
+### macOS ###
+# General
+.DS_Store
+.AppleDouble
+.LSOverride
+
+# Icon must end with two \r
+Icon
+
+
+# Thumbnails
+._*
+
+# Files that might appear in the root of a volume
+.DocumentRevisions-V100
+.fseventsd
+.Spotlight-V100
+.TemporaryItems
+.Trashes
+.VolumeIcon.icns
+.com.apple.timemachine.donotpresent
+
+# Directories potentially created on remote AFP share
+.AppleDB
+.AppleDesktop
+Network Trash Folder
+Temporary Items
+.apdisk
+
+### macOS Patch ###
+# iCloud generated files
+*.icloud
+
+# End of https://www.toptal.com/developers/gitignore/api/macos,emacs
\ No newline at end of file
diff --git a/archive.md b/archive.md
new file mode 100644
index 0000000..e808141
--- /dev/null
+++ b/archive.md
@@ -0,0 +1,3 @@
+# Archive
+
+- [index](https://elioat.tilde.institute/wiki/index.html)
diff --git a/changelog.md b/changelog.md
new file mode 100644
index 0000000..5577a5d
--- /dev/null
+++ b/changelog.md
@@ -0,0 +1,2 @@
+- [index](https://elioat.tilde.institute/wiki/index.html), Tue, 10 Jan 2023 22:15:47 -0500
+- [index](/index.html), Tue, 10 Jan 2023 22:11:32 -0500
diff --git a/content/index.md b/content/index.md
new file mode 100644
index 0000000..365ad2a
--- /dev/null
+++ b/content/index.md
@@ -0,0 +1,3 @@
+# wiki
+
+the start of a little wiki.
\ No newline at end of file
diff --git a/mynah b/mynah
new file mode 100755
index 0000000..e42250d
--- /dev/null
+++ b/mynah
@@ -0,0 +1,149 @@
+#!/usr/bin/env bash
+
+# requires pandoc
+#          coreutils
+#          uuidgen
+#          tidy
+#          the_silver_searcher (could use grep instead)
+
+set -o errexit
+set -o nounset
+set -o pipefail
+if [[ "${TRACE-0}" == "1" ]]; then
+    set -o xtrace
+fi
+
+SITENAME="wiki"
+SITEURL="https://elioat.tilde.institute/wiki"
+SITEDESCRIPTION="a little wiki"
+if [[ -f updated ]]; then
+   LASTUPDATE=$(<updated)
+fi
+TIMESTAMP=$(gdate +"%s")
+RFC822=$(gdate -R)
+RSSHEADER='<?xml version="1.0" encoding="UTF-8"?>
+<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
+<channel>
+<title>
+<![CDATA[ '${SITENAME}']]>
+</title>
+<link>'${SITEURL}'</link>
+<atom:link href="'${SITEURL}'/feed.rss" rel="self" type="application/rss+xml"/>
+<description>
+<![CDATA[ '${SITEDESCRIPTION}' ]]>
+</description>'
+RSSEND='</channel></rss>'
+
+build_logs() {
+    pandoc changelog.md -o public/changelog.html
+    cd content
+    rm ../archive.md
+    echo -e "# Archive\n" > ../archive.md
+    for file in *;
+    do
+        archive_entry="- [${file%.*}](${SITEURL}/${file%.*}.html)"
+        echo -e "$archive_entry" >> ../archive.md
+    done
+    cd ..
+    pandoc archive.md -o public/archive.html
+}
+
+build() {
+    cd content
+    i=0
+
+    rm ../public/feed.xml
+    touch ../public/feed.xml
+    echo -e "${RSSHEADER}" > ../public/feed.xml
+
+    for file in *; 
+    do
+        file_last_updated=$(stat -f %m "$file")
+        if [ "$file_last_updated" -gt "$LASTUPDATE" ]; 
+        then
+            (( i++ ))
+            updated_at="- [${file%.*}](${SITEURL}/${file%.*}.html), ${RFC822}"
+            echo -e "$updated_at\n$(cat ../changelog.md)" > ../changelog.md
+            pandoc "${file}" -o ../public/"${file%.*}".html
+            rss_entry='<item>
+<title>
+<![CDATA[ the page "'${file%.*}'" was updated! ]]>
+</title>
+<link>'${SITEURL}'/'${file%.*}.html'</link>
+<guid>'${SITEURL}/${file%.*}.html#$(uuidgen)'</guid>
+<pubDate>'${RFC822}'</pubDate>
+<description>
+<![CDATA[ 
+<p><a href="'${SITEURL}/${file%.*}.html'">'${file%.*}'</a> updated!</p><br><br><pre><code>'$(fold -sw 80 <"$file")'</code></pre>  ]]>
+</description>
+</item>'
+            echo -e "$rss_entry" >> ../public/feed.xml
+        fi
+    done
+    cd ..
+    echo -e "$RSSEND" >> public/feed.xml
+    # this is stupid and superfluous, but I was bugged by the weirdly formatted RSS output
+    tidy \
+        -xml \
+        --show-body-only yes \
+        --indent auto \
+        --indent-spaces 2 \
+        --quiet yes \
+        -w 80 \
+        -m \
+        --force-output y \
+        --wrap 0 \
+            public/feed.xml
+    if [ $i -gt 0 ];
+    then
+        build_logs "$@"
+    fi
+    echo "$TIMESTAMP" > updated
+    echo "updated" $i "items."
+}
+
+help_text() {
+    echo '
+    mynah, a little wiki bird
+
+    usage: ./mynah
+                     -b(uild)....to build the site
+                     -s(earch)...to search for a pattern across all wiki entries
+                     -d(eploy)...to publish the public directory to a host
+                     -h(elp).....to display this message
+                     -n(est).....to start a new wiki
+'
+}
+
+if [[ "${1-}" =~ ^-*h(elp)?$ ]]; then
+    help_text "$@"
+    exit
+elif [[ "${1-}" =~ ^-*b(uild)?$ ]]; then
+    build "$@"
+    exit
+elif [[ "${1-}" =~ ^-*s(earch)?$ ]]; then
+    ag "$2" content/*
+    exit
+elif [[ "${1-}" =~ ^-*d(eploy)?$ ]]; then
+    scp -r public/* elioat@tilde.institute:~/public_html/wiki/
+    exit
+elif [[ "${1-}" =~ ^-*n(est)?$ ]]; then
+    if [[ -f content ]]; then
+        echo -e "   
+            a content directory already exists 
+            so you can't build a new nest here
+            "
+    else
+        mkdir content public
+        touch archive.md changelog.md updated public/feed.xml
+    fi
+    exit
+fi
+
+cd "$(dirname "$0")"
+
+main() {
+    help_text "$@"
+}
+
+main "$@"
diff --git a/public/archive.html b/public/archive.html
new file mode 100644
index 0000000..98d3b82
--- /dev/null
+++ b/public/archive.html
@@ -0,0 +1,5 @@
+<h1 id="archive">Archive</h1>
+<ul>
+<li><a
+href="https://elioat.tilde.institute/wiki/index.html">index</a></li>
+</ul>
diff --git a/public/changelog.html b/public/changelog.html
new file mode 100644
index 0000000..c32a4af
--- /dev/null
+++ b/public/changelog.html
@@ -0,0 +1,6 @@
+<ul>
+<li><a href="https://elioat.tilde.institute/wiki/index.html">index</a>,
+Tue, 10 Jan 2023 22:15:47 -0500</li>
+<li><a href="/index.html">index</a>, Tue, 10 Jan 2023 22:11:32
+-0500</li>
+</ul>
diff --git a/public/feed.xml b/public/feed.xml
new file mode 100644
index 0000000..688e84c
--- /dev/null
+++ b/public/feed.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
+  <channel>
+    <title>
+      <![CDATA[ wiki]]>
+</title>
+    <link>https://elioat.tilde.institute/wiki</link>
+    <atom:link href="https://elioat.tilde.institute/wiki/feed.rss" rel="self" type="application/rss+xml" />
+    <description>
+      <![CDATA[ a little wiki ]]>
+</description>
+    <item>
+      <title>
+        <![CDATA[ the page "index" was updated! ]]>
+</title>
+      <link>https://elioat.tilde.institute/wiki/index.html</link>
+      <guid>https://elioat.tilde.institute/wiki/index.html#D81AA6D9-A45A-4FEF-9801-DE390B9AA66C</guid>
+      <pubDate>Tue, 10 Jan 2023 22:15:47 -0500</pubDate>
+      <description>
+        <![CDATA[ 
+<p><a href="https://elioat.tilde.institute/wiki/index.html">index</a> updated!</p><br><br><pre><code># wiki
+
+the start of a little wiki.</code></pre>  ]]>
+</description>
+    </item>
+  </channel>
+</rss>
diff --git a/public/index.html b/public/index.html
new file mode 100644
index 0000000..cc8b10b
--- /dev/null
+++ b/public/index.html
@@ -0,0 +1,2 @@
+<h1 id="wiki">wiki</h1>
+<p>the start of a little wiki.</p>
diff --git a/updated b/updated
new file mode 100644
index 0000000..0f34261
--- /dev/null
+++ b/updated
@@ -0,0 +1 @@
+1673406947