From 52cf0a6d2568c6c45a677c1f9038ab42ac7801ac Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20H=C3=A4nsch?= Date: Tue, 19 Sep 2023 18:38:24 +0200 Subject: [PATCH] introduce tags and tag filtering --- macros/tag | 15 +++++++++++++++ tools.sh | 18 ++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100755 macros/tag diff --git a/macros/tag b/macros/tag new file mode 100755 index 0000000..2731ad9 --- /dev/null +++ b/macros/tag @@ -0,0 +1,15 @@ +#!/bin/sh + +. "$_EXEC/cgilite/storage.sh" + +_DATE="$(date +%s)" + +mkdir -p "$_DATA"/tags + +printf '\n' diff --git a/tools.sh b/tools.sh index 4f7bc25..57ae827 100755 --- a/tools.sh +++ b/tools.sh @@ -17,6 +17,8 @@ include_tools="$0" # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR # IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +. "${_EXEC}/cgilite/storage.sh" + md(){ local parser @@ -147,3 +149,19 @@ page_abs(){ *) PATH "${PATH_INFO%/*}/${1%/}/";; esac } + +has_tags() { + local page="$(page_abs "$1")"; shift 1; + local tdir="$_DATA/tags" tag dt df + + for tag in "$@"; do + tag="$(printf %s "$tag" |awk '{ sub(/^#/, ""); gsub(/[^[:alnum:]]/, "_"); print toupper($0); }')" + dt="$(DBM "${tdir}/${tag}" get "${page}")" || return 1 + df="$(stat -c %Y "$(mdfile "$page")")" || return 1 + if [ "$df" -gt "$dt" ]; then + DBM "${tdir}/${tag}" remove "${page}" + return 1 + fi + done + return 0 +} -- 2.39.2