From: James Mills <1290234+prologic@users.noreply.github.com> Date: Thu, 30 Mar 2023 12:53:03 +0000 (+1000) Subject: Add list plugin to contrib X-Git-Tag: 0.4.0~3 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=3c1f7fdf563b6b550d902f4ef6f77e2f336d3e62;p=aya.git Add list plugin to contrib --- diff --git a/contrib/plugins/list b/contrib/plugins/list new file mode 100755 index 0000000..ace7f3d --- /dev/null +++ b/contrib/plugins/list @@ -0,0 +1,27 @@ +#!/bin/sh + +if [ ! $# = 1 ]; then + printf >&2 "Usage: %s [ext]\n" "$(basename "$0")" + exit 0 +fi + +p="$1" +t="${2:-md}" + +if [ ! -d "$p" ]; then + printf >&2 "error: path %s not found\n" "$p" + exit 1 +fi + +find "$p" -type f -name "*.$t" | while read -r file; do + name="${file#"$p"}" + name="${name#"/"}" + name="${name%.*}" + + title="$(zs vars "$file" title)" + if [ -z "$title" ]; then + title="$name" + fi + + echo "- [$title](${p}/${name}.html)" +done