summaryrefslogtreecommitdiff
path: root/.zs
diff options
context:
space:
mode:
Diffstat (limited to '.zs')
-rw-r--r--.zs/config.yml13
-rwxr-xr-x.zs/current_date3
-rwxr-xr-x.zs/generate_nav27
-rwxr-xr-x.zs/include14
-rw-r--r--.zs/layout.html44
-rwxr-xr-x.zs/list90
-rwxr-xr-x.zs/posthook19
-rwxr-xr-x.zs/prehook3
-rwxr-xr-x.zs/scripts14
-rwxr-xr-x.zs/styles14
10 files changed, 241 insertions, 0 deletions
diff --git a/.zs/config.yml b/.zs/config.yml
new file mode 100644
index 0000000..d421309
--- /dev/null
+++ b/.zs/config.yml
@@ -0,0 +1,13 @@
+---
+title: delta.twoexem.com
+description: ma olin mi lon kulupu nanpa
+
+extensions:
+ - anchor
+ - definitionlist
+ - linkify
+ - footnote
+ - strikethrough
+ - table
+ - typography
+ - wikilink
diff --git a/.zs/current_date b/.zs/current_date
new file mode 100755
index 0000000..9b6fbbb
--- /dev/null
+++ b/.zs/current_date
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+printf %s "$(date -u +%Y-%m-%dT%H:%M:%S%Z)"
diff --git a/.zs/generate_nav b/.zs/generate_nav
new file mode 100755
index 0000000..28289af
--- /dev/null
+++ b/.zs/generate_nav
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+echo "/:home /projects.html:projects /posts.html:ramblings" | awk '
+function normalize(file) {
+ sub(".[^.]*$", "", file)
+ sub(".*/", "", file)
+ return file
+}
+
+{
+ for (i=1; i<=NF; i++) {
+ match($i, /:.+/)
+ name = substr($i, RSTART+1, RLENGTH)
+
+ match($i, /.+:/)
+ file = substr($i, RSTART, RLENGTH-1)
+
+ parsed_file = ENVIRON["ZS_FILE"]
+
+ if (normalize(file) == normalize(parsed_file) || (normalize(parsed_file) == "index" && file == "/")) {
+ name = sprintf("[%s]", name)
+ }
+
+ printf "<li><a href=\"%s\">%s</a></li>", file, name
+ if (i<NF) print ""
+ }
+}'
diff --git a/.zs/include b/.zs/include
new file mode 100755
index 0000000..84e73a5
--- /dev/null
+++ b/.zs/include
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+set -e
+
+if [ ! $# = 1 ]; then
+ printf "Usage: %s <file>\n" "$(basename "$0")"
+ exit 0
+fi
+
+if [ -f "$1" ]; then
+ cat "$1"
+else
+ echo "error: file not found $1"
+fi
diff --git a/.zs/layout.html b/.zs/layout.html
new file mode 100644
index 0000000..a171791
--- /dev/null
+++ b/.zs/layout.html
@@ -0,0 +1,44 @@
+<!doctype html>
+<html lang="en">
+ <head>
+ <!-- Meta Tags -->
+ <meta charset="UTF-8" />
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+ <meta property="og:title" content="{{ title }}" />
+ <meta property="og:type" content="website" />
+ <meta property="og:url" content="http://delta.twoexem.com" />
+ <meta property="og:description" content="{{ description }}" />
+ <meta name="theme-color" content="#ecb256">
+ <title>{{ title }} - darkuss' website</title>
+
+ <!-- Favicon -->
+ <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
+ <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png" />
+ <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png" />
+
+ <!-- Stylesheets -->
+ {{ styles }}
+
+ <!-- Scripts -->
+ {{ scripts }}
+ </head>
+
+ <body>
+ <div id="lower"></div>
+ <div id="upper">
+ <nav>
+ <ul>
+ {{ generate_nav }}
+ </ul>
+ </nav>
+ <div>
+ <main><div>{{ content }}</div></main>
+ <footer class="subtle">
+ <span>made with <span style="color: var(--red)">&lt;3</span> by darkuss</span
+ ><span>built with <a href="https://git.mills.io/prologic/zs">zs</a></span
+ ><span>last modified: <time datetime="{{ current_date }}">{{ current_date }}</time></span>
+ </footer>
+ </div>
+ </div>
+ </body>
+</html>
diff --git a/.zs/list b/.zs/list
new file mode 100755
index 0000000..854eab0
--- /dev/null
+++ b/.zs/list
@@ -0,0 +1,90 @@
+#!/bin/sh
+
+# Define the directory to iterate over from the first argument
+dir="$1"
+
+# Initialize the variable to hold the HTML list and date-file pairs
+html=""
+date_file_pairs=""
+
+# Check if the directory exists
+if [ -d "$dir" ]; then
+ # Find all Markdown files in the directory and store them in a variable
+ md_files=$(find "$dir" -maxdepth 1 -type f -name "*.md")
+
+ # Process each Markdown file in a regular loop (not in a subshell)
+ for md_file in $md_files; do
+ # Extract front matter using sed, ensure the file is quoted
+ front_matter=$(sed -n '/^---$/,/^---$/p' "$md_file")
+
+ # Extract date
+ date=$(echo "$front_matter" | grep '^date:' | sed 's/^date:[[:space:]]*//')
+
+ # If no date is found, use a default date
+ if [ -z "$date" ]; then
+ date="01-01-1970" # Default date if none is found
+ fi
+
+ # Add the date and file to the date_file_pairs variable, using printf to correctly append newlines
+ date_file_pairs=$(printf "%s\n%s|%s" "$date_file_pairs" "$date" "$md_file")
+ done
+
+ # Sort the date and file pairs by date
+ sorted_date_file_pairs=$(printf "%s" "$date_file_pairs" | sort -r -t "|" -k 1,1.2n -k 1.4,1.6n -k 1.8,1.12n)
+
+ # Create a file descriptor to avoid subshell issues
+ exec 3<<EOF
+$sorted_date_file_pairs
+EOF
+
+ # Generate the navigation list
+ html="<ol class=\"list\">"
+ while IFS= read -r pair <&3; do
+ # Split the pair into date and filename using | as a delimiter
+ date=$(printf "%s" "$pair" | cut -d'|' -f1)
+ md_file=$(printf "%s" "$pair" | cut -d'|' -f2)
+
+ # Ensure md_file is not empty (safety check)
+ [ -z "$md_file" ] && continue
+
+ # Extract front matter again using sed, ensure md_file is quoted
+ front_matter=$(sed -n '/^---$/,/^---$/p' "$md_file")
+
+ # Extract title
+ title=$(echo "$front_matter" | grep '^title:' | sed 's/^title:[[:space:]]*//')
+
+ # Use filename as a fallback if title is empty
+ if [ -z "$title" ]; then
+ # Get the base filename without extension, quote the argument
+ base_name=$(basename "$md_file" .md)
+ # Replace hyphens and underscores with spaces for display
+ title=$(echo "$base_name" | sed 's/-/ /g' | sed 's/_/ /g')
+ # Capitalize each word
+ title=$(echo "$title" | awk '{ for (i=1; i<=NF; i++) $i=toupper(substr($i,1,1)) substr($i,2); print }')
+ fi
+
+ # Format the date using POSIX-compliant date formatting
+ if formatted_date=$(date -d "$date" '+%Y-%m-%d' 2>/dev/null); then
+ : # formatted_date is valid
+ else
+ formatted_date="$date"
+ fi
+
+ # Construct the link href, quote the argument
+ href="/$dir/$(basename "${md_file%.md}.html")"
+
+ # Append to the HTML list
+ html="$html<li><a href=\"$href\">$title</a><span class="subtle">(published: <time datetime=$formatted_date>$formatted_date</time>)</span></li>"
+ done
+ html="$html</ol>"
+
+ # Close file descriptor
+ exec 3<&-
+
+else
+ # If the directory doesn't exist, set a message
+ html="<p>No pages found.</p>"
+fi
+
+# Output the HTML list
+echo "$html"
diff --git a/.zs/posthook b/.zs/posthook
new file mode 100755
index 0000000..bcf1d52
--- /dev/null
+++ b/.zs/posthook
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+set -e
+
+minify_assets() {
+ p="$1"
+ t="$2"
+
+ find "$p" -type f -name "*.$t" | while read -r file; do
+ name="${file#"$p"}"
+ name="${name#"/"}"
+ minify -o "${p}/${name}" "$file"
+ done
+}
+
+if command -v minify > /dev/null; then
+ minify_assets "$ZS_OUTDIR" "css"
+ minify_assets "$ZS_OUTDIR" "js"
+fi
diff --git a/.zs/prehook b/.zs/prehook
new file mode 100755
index 0000000..c52d3c2
--- /dev/null
+++ b/.zs/prehook
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+exit 0
diff --git a/.zs/scripts b/.zs/scripts
new file mode 100755
index 0000000..17320fc
--- /dev/null
+++ b/.zs/scripts
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+set -e
+
+JS=""
+
+# Load live.js for non-production builds for faster development
+if [ -z "$ZS_PRODUCTION" ]; then
+ JS="$JS live"
+fi
+
+for js in $JS; do
+ printf "<script type=\"application/javascript\" src=\"assets/js/%s.js\"></script>\n" "$js"
+done
diff --git a/.zs/styles b/.zs/styles
new file mode 100755
index 0000000..62eb63f
--- /dev/null
+++ b/.zs/styles
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+set -e
+
+CSS="reset index"
+CSS_ZS_FILE=$(echo $ZS_FILE | sed -e 's/.[^.]*$/.css/')
+
+for css in $CSS; do
+ printf "<link rel=\"stylesheet\" href=\"assets/css/%s.css\">\n" "$css"
+done
+
+if [ -f $(printf "assets/css/%s" "$CSS_ZS_FILE") ]; then
+ printf "<link rel=\"stylesheet\" href=\"assets/css/%s\">\n" "$CSS_ZS_FILE"
+fi