From 41a6d16ef6a356bc286b0eafe267d04aeed174f3 Mon Sep 17 00:00:00 2001 From: delta Date: Mon, 3 Feb 2025 22:58:46 +0100 Subject: initial commit --- .zs/config.yml | 13 ++++++++ .zs/current_date | 3 ++ .zs/generate_nav | 27 +++++++++++++++++ .zs/include | 14 +++++++++ .zs/layout.html | 44 +++++++++++++++++++++++++++ .zs/list | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ .zs/posthook | 19 ++++++++++++ .zs/prehook | 3 ++ .zs/scripts | 14 +++++++++ .zs/styles | 14 +++++++++ 10 files changed, 241 insertions(+) create mode 100644 .zs/config.yml create mode 100755 .zs/current_date create mode 100755 .zs/generate_nav create mode 100755 .zs/include create mode 100644 .zs/layout.html create mode 100755 .zs/list create mode 100755 .zs/posthook create mode 100755 .zs/prehook create mode 100755 .zs/scripts create mode 100755 .zs/styles (limited to '.zs') 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 "
  • %s
  • ", file, name + if (i\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 @@ + + + + + + + + + + + + {{ title }} - darkuss' website + + + + + + + + {{ styles }} + + + {{ scripts }} + + + +
    +
    + +
    +
    {{ content }}
    +
    + made with <3 by darkussbuilt with zslast modified: +
    +
    +
    + + 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<" + 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
  • $title(published: )
  • " + done + html="$html" + + # Close file descriptor + exec 3<&- + +else + # If the directory doesn't exist, set a message + html="

    No pages found.

    " +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 "\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 "\n" "$css" +done + +if [ -f $(printf "assets/css/%s" "$CSS_ZS_FILE") ]; then + printf "\n" "$CSS_ZS_FILE" +fi -- cgit v1.2.3