noxz-sites

A collection of a builder and various scripts creating the noxz.tech sites
git clone https://noxz.tech/git/noxz-sites.git
noxz-sites

commit: 9372c952c0a73afd0ba922f2a95b7b039c40b96e
parent: 909757cd9dd4d999818938042b669b9d3e074051
author: Chris Noxz <chris@noxz.tech>
date:   Fri, 7 Oct 2022 20:07:11 +0200
make it possible to have spaces in tags
Mbuild23+++++++++++---------
Mconfig/www.conf2+-
2 files changed, 14 insertions(+), 11 deletions(-)
diff --git a/build b/build
@@ -310,7 +310,8 @@ prerender() {
 	[ -f "${base_path}"/.tags ]                                             \
 		&& printf '\n.DIVS wrap-list\n.ULS\n'                               \
 		&& while read -r tag; do
-		printf '.LI\n.CLURL "../tags/%s" art-tag "%s"\n' "${tag}" "${tag}"
+		tag_safe="$(echo "${tag}" | tr \  _)"
+		printf '.LI\n.CLURL "../tags/%s" art-tag "%s"\n' "${tag_safe}" "${tag}"
 	done < "${base_path}"/.tags && printf '.ULE\n.DIVE\n'
 
 	[ -f "${base_path}"/.edit ] \
@@ -485,7 +486,7 @@ render_main() {
 	main_current=$(dirname "${main_current}/*")
 
 	[ -f "${main_current}/index.www" ] && SITE_WWW="${main_current}/index.www" || return
-	[ -f "${main_current}/.metadata" ] && SITE_TITLE="${SITE_TITLE}$(grep '\.ds\ TITLE' "${main_current}/.metadata" | sed 's/\.ds\ TITLE\s*//g')"
+	[ -f "${main_current}/.metadata" ] && SITE_TITLE="${SITE_TITLE}$(grep '\.ds TITLE' "${main_current}/.metadata" | sed 's/\.ds\ TITLE\s*//g')"
 	SITE_HTML="${SITE_WWW%.*}.html"
 
 	print_loading "Rendering ${main_current}"
@@ -994,16 +995,18 @@ main() {
 		# manage tags
 		find "${1}"/articles -name .tags -exec cat {} \; | sort -u | while read -r tag
 		do
-			mkdir -p "${1}"/articles/tags/${tag}
-			touch "${1}"/articles/tags/${tag}/.buildignore
-			printf '.URL ../.. Articles\ntagged "%s"\n' "${tag}" > "${1}"/articles/tags/${tag}/index.www
-			echo "{:articles#${tag}:}" >> "${1}"/articles/tags/${tag}/index.www
-			echo "index.html" > "${1}"/articles/tags/${tag}/.assemble
-			echo ".ds TITLE   #${tag}" > "${1}"/articles/tags/${tag}/.metadata
+			tag_safe="$(echo "${tag}" | tr \  _)"
+			mkdir -p "${1}"/articles/tags/"${tag_safe}"
+			touch "${1}"/articles/tags/"${tag_safe}"/.buildignore
+			printf '.URL ../.. Articles\ntagged "%s"\n' "${tag}" > "${1}"/articles/tags/"${tag_safe}"/index.www
+			echo "{:articles#${tag}:}" >> "${1}"/articles/tags/"${tag_safe}"/index.www
+			echo "index.html" > "${1}"/articles/tags/"${tag_safe}"/.assemble
+			echo ".ds TITLE   #${tag}" > "${1}"/articles/tags/"${tag_safe}"/.metadata
 
 			# append tag to tags page
-			printf '.LI\n.ARTTAG %s %s\n'                                           \
-				"${tag}" "$(grep ^${tag}$ "${1}"/articles/*/.tags | wc -l)" \
+			printf '.LI\n.ARTTAG "%s" "%s" "%s"\n'                          \
+				"${tag_safe}" "${tag}"                                      \
+				"$(grep "^${tag}$" "${1}"/articles/*/.tags | wc -l)"        \
 				>> "${1}"/articles/tags/index.www
 		done
 		printf '.ULE\n' >> "${1}"/articles/tags/index.www
diff --git a/config/www.conf b/config/www.conf
@@ -81,7 +81,7 @@
 ..
 .de ARTTAG
 .   ie \\n[www-html] \{\
-.       HTML <a class="art-tag" href="\\$1">\\$1 <span>\\$2</span></a>\\$3
+.       HTML <a class="art-tag" href="\\$1">\\$2 <span>\\$3</span></a>\\$4
 .   \}
 ..
 .\" --------------------------------------------------------------------------