]> Nishi Git Mirror - aya.git/commitdiff
Add sites that use zs and a collection of hooks and plugins to contrib 0.3.2
authorJames Mills <1290234+prologic@users.noreply.github.com>
Mon, 27 Mar 2023 14:26:11 +0000 (00:26 +1000)
committerJames Mills <1290234+prologic@users.noreply.github.com>
Mon, 27 Mar 2023 14:26:11 +0000 (00:26 +1000)
.vscode/settings.json
README.md
contrib/hooks/posthook [new file with mode: 0755]
contrib/hooks/prehook [new file with mode: 0755]
contrib/plugins/importmap [new file with mode: 0755]
contrib/plugins/include [new file with mode: 0755]
contrib/plugins/scripts [new file with mode: 0755]
contrib/plugins/styles [new file with mode: 0755]

index 94d2725812df96cc20fa038d4e0c3423e06b55c4..bf10f164be31cc0fba69f29b46ff35a8b5a04b3b 100644 (file)
@@ -4,6 +4,7 @@
         "alecthomas",
         "chromahtml",
         "definitionlist",
+        "divs",
         "errbuf",
         "Furqan",
         "goldmark",
@@ -11,6 +12,7 @@
         "newext",
         "oldext",
         "outbuf",
+        "pandoc",
         "PUBDIR",
         "sabhiram",
         "sirupsen",
index 111873c3c3e23e3e2415014cb973eff276d8dab9..505d56a0975284421462225c496b88f380f0d2c0 100644 (file)
--- a/README.md
+++ b/README.md
@@ -50,7 +50,7 @@ EOF
 zs serve
 ```
 
-For a starter template see the [zs-starter-tempate](https://git.mills.io/prologic/zs-stater-template) which can also be found running live at [zs.mills.io](https://zs.mills.io).
+For a starter template see the [zs-starter-template](https://git.mills.io/prologic/zs-stater-template) which can also be found running live at [zs.mills.io](https://zs.mills.io).
 
 ## Features
 
@@ -215,6 +215,8 @@ for f in ./blog/*.md ; do
 done | sort -r -n | cut -d' ' -f2-
 ```
 
+Looking for more plugins? Check out the [contrib/plugins](https://git.mills.io/prologic/zs/src/branch/main/contrib/plugins) collection!
+
 ## Hooks
 
 There are two special plugin names that are executed every time the build
@@ -234,6 +236,8 @@ minify -o "$ZS_OUTDIR/css/fa.min.css" "$ZS_OUTDIR/css/fa.css"
 minify -o "$ZS_OUTDIR/css/site.min.css" "$ZS_OUTDIR/css/site.css"
 ```
 
+Looking for more hooks? Check out the [contrib/hooks](https://git.mills.io/prologic/zs/src/branch/main/contrib/hooks) collection!
+
 ## Command line usage
 
 - `zs build` re-builds your site.
@@ -282,6 +286,17 @@ Flags:
 Use "zs [command] --help" for more information about a command.
 ```
 
+## Who's using zs?
+
+Here's a few sites that use `zs` today:
+
+- https://yarn.social -- Landing page of the decentralized microBlogging ecosystem.
+- https://salty.im -- Landing page of the e2e encrypted IndieWeb inspired messaging protocol.
+- https://zs.mills.io -- zs starter template demo.
+- https://prologic.shortcircuit.net.au -- Home page of James Mills / prologic (author of zs)
+
+Want to add your site here? File an issue or submit a pull-request!
+
 ## Frequently Asked Questions
 
 ### How do I link to other pages?
diff --git a/contrib/hooks/posthook b/contrib/hooks/posthook
new file mode 100755 (executable)
index 0000000..fd56793
--- /dev/null
@@ -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#"/"}"
+    #name="${name%.*}"
+    #minify -o "${p}/${name}.min.$t" "$file"
+    minify -o "${p}/${name}" "$file"
+  done
+}
+
+minify_assets "$ZS_OUTDIR" "css"
+minify_assets "$ZS_OUTDIR" "js"
diff --git a/contrib/hooks/prehook b/contrib/hooks/prehook
new file mode 100755 (executable)
index 0000000..c52d3c2
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+exit 0
diff --git a/contrib/plugins/importmap b/contrib/plugins/importmap
new file mode 100755 (executable)
index 0000000..9deee6b
--- /dev/null
@@ -0,0 +1,25 @@
+#!/bin/bash
+
+if [ $# -ne 1 ]; then
+  printf "Usage: %s <path>\n" "$(basename "$0")"
+  exit 1
+fi
+
+modpath="$1"
+modpath="${modpath%"/"}"
+
+ext=".js"
+if [ -n "$ZS_PRODUCTION" ]; then
+  ext=".min.js"
+fi
+
+echo "<script type=\"importmap\">"
+{
+  find "$modpath" -type f -name '*.js' | while read -r file; do
+    name="${file#"$modpath"}"
+    name="${name#"/"}"
+    name="${name%.*}"
+    echo "${name}=./${modpath}/${name}${ext}"
+  done
+} | jq -Rs '{ imports: split("\n") | [.[] | capture("^(?<name>[^=]+)=(?<src>.*)$") | {(.name): .src}] | add }'
+echo "</script>"
diff --git a/contrib/plugins/include b/contrib/plugins/include
new file mode 100755 (executable)
index 0000000..3fd99f4
--- /dev/null
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+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/contrib/plugins/scripts b/contrib/plugins/scripts
new file mode 100755 (executable)
index 0000000..17eeaec
--- /dev/null
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+set -e
+
+SCRIPTS="page"
+MODULES="globe phenon"
+
+# Load live.js for non-production builds for faster development
+if [ -z "$ZS_PRODUCTION" ]; then
+  SCRIPTS="$SCRIPTS live"
+fi
+
+for script in $SCRIPTS; do
+  printf "<script type=\"application/javascript\" src=\"/js/%s.js\"></script>\n" "$script"
+done
+
+for module in $MODULES; do
+  printf "<script type=\"module\" src=\"/js/modules/%s.js\"></script>\n" "$module"
+done
+
+printf "<script defer type=\"module\" src=\"/js/main.js\">main();</script>\n"
diff --git a/contrib/plugins/styles b/contrib/plugins/styles
new file mode 100755 (executable)
index 0000000..899ba6f
--- /dev/null
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+set -e
+
+CSS="style triangles"
+
+for css in $CSS; do
+    printf "<link rel=\"stylesheet\" href=\"/css/%s.css\">\n" "$css"
+done