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: 507e2a0f1d9cf9daf2d4ab6ac3829668e8852a2c
parent: 958931c5177713f8d58f2b50b91e28eb809df997
author: Chris Noxz <chris@noxz.tech>
date:   Tue, 28 Dec 2021 12:59:10 +0100
merge git.noxz.tech into noxz.tech/git, and fix som bugs
M.gitignore1+
MMakefile5+-
Massemble2+-
Mbuild49++++++++++++--------
Mconfig/git_head.html4+-
Mconfig/git_repos.html5+-
Mconfig/main.html4+-
7 files changed, 42 insertions(+), 28 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -2,6 +2,7 @@
 !config/*.html
 web.tar
 git.noxz.tech/*
+noxz.tech/git
 !git.noxz.tech/pub
 logo.png
 sitemap.xml
diff --git a/Makefile b/Makefile
@@ -6,7 +6,7 @@ all: clean check
 	@
 	@echo creating icons
 	@convert -density 1200 -resize 256x256 ./noxz.tech/pub/logo.black.svg ./noxz.tech/pub/logo.png
-	@convert -density 1200 -resize 256x256 ./git.noxz.tech/pub/logo.svg ./git.noxz.tech/pub/logo.png
+	@convert -density 1200 -resize 256x256 ./git.noxz.tech/pub/logo.svg ./noxz.tech/git/pub/logo.png
 	@
 	@echo assembling tar archive '${ASSEMBLE_TAR}'
 	@./assemble ${ASSEMBLE_TAR}
@@ -26,6 +26,7 @@ clean:
 	@echo cleaning
 	@find ./noxz.tech/ -name '*.html' -type f -exec sh -ec 'rm "$$0"' {} \;
 	@find ./git.noxz.tech/ -name '*.html' -type f -exec sh -ec 'rm "$$0"' {} \;
+	@rm -rf ./noxz.tech/git
 	@rm -f noxz.tech/pub/logo.png
 	@rm -f noxz.tech/pub/sitemap.xml
 	@rm -f git.noxz.tech/pub/logo.png
@@ -33,4 +34,4 @@ clean:
 	@rm -f ${ASSEMBLE_TAR}
 
 clean-git:
-	@find ./git.noxz.tech -type d -prune ! -name "pub" -exec sh -ec 'rm -r "$$0"' {} \;
+	@find ./git.noxz.tech/* -type d -prune ! -name "pub" -exec sh -ec 'rm -rf "$$0"' {} \;
diff --git a/assemble b/assemble
@@ -2,7 +2,7 @@
 [ $# -eq 0 ] && return
 
 > assembly.list
-find -L ./git.noxz.tech -type f >> assembly.list
+find -L ./noxz.tech/git -type f >> assembly.list
 for a in $(find ./noxz.tech -name ".assemble"); do
 	cat "$a" | while read line; do echo ${a%.*}$line | tr ' ' '\n'; done
 done >> assembly.list
diff --git a/build b/build
@@ -193,7 +193,7 @@ render_main_menu() {
 
 render_main_menu_extra() {
 	printf '<li><a class="%s" href="%s">%s</a></li>\n'                      \
-		"twtxt" "twtxt.txt" "twtxt"                                         \
+		"twtxt" "//[site]/twtxt.txt" "twtxt"                                         \
 	| awk                                                                   \
 	'
 		BEGIN {
@@ -550,13 +550,13 @@ render_git() {
 		git_buffer=$(
 			printf '<tr><td><a href="%s">%s</a></td><td>%s</td><td>%s</td><td>%s</td></tr>' \
 				"//${1}/${repo##*/}"                                        \
-				"${git_pp}"                                                    \
-				"${git_description}"                                           \
-				"${git_owner}"                                                 \
+				"${git_pp}"                                                 \
+				"${git_description}"                                        \
+				"${git_owner}"                                              \
 				"$(git -C "${repo}" log -1 --date=format:"%Y-%m-%d %T" --format=%ad)")
 
 		[ -f "$repo/fork" ]                                                 \
-			&& git_forks="$(printf '%s%s' "${git_forks}" "${git_buffer}")"           \
+			&& git_forks="$(printf '%s%s' "${git_forks}" "${git_buffer}")"  \
 			|| git_repos="$(printf '%s%s' "${git_repos}" "${git_buffer}")"
 
 		render_git_repo "${1}" "${repo##*/}"
@@ -569,8 +569,8 @@ render_git() {
 		-v var_favicon="$(awk_safe "${SITE_ICON_PNG}")"                     \
 		-v var_stylesheet="$(awk_safe "${SITE_CSS}")"                       \
 		-v var_logo="$(awk_safe "${SITE_ICON_SVG}")"                        \
-		-v var_repos="$(awk_safe "${git_repos}" | sed 's/<tr>/\n\0/2g')"       \
-		-v var_forks="$(awk_safe "${git_forks}" | sed 's/<tr>/\n\0/2g')"       \
+		-v var_repos="$(awk_safe "${git_repos}" | sed 's/<tr>/\n\0/2g')"    \
+		-v var_forks="$(awk_safe "${git_forks}" | sed 's/<tr>/\n\0/2g')"    \
 	'
 		/\{:repos:\}/{
 			padding=$0
@@ -603,7 +603,7 @@ render_git() {
 			awk '1;/<body>/{exit}' "${git_index}"
 			cat "${file%/*}/head.html.tmp"
 			cat "${file}"
-			awk '/<\/body>/,0'
+			awk '/<\/body>/,0' "${git_index}"
 		} > "${file%.*}"
 	done
 
@@ -691,13 +691,16 @@ main() {
 	[ -n "$1" ] && [ ! -d "$1" ] && return
 	[ -n "$2" ] && [ ! -d "$2" ] && return
 
+	# make sure site/git is removed before rendering (to avoid it in menu)
+	rm -rf "${1}/git"
+
 	# main render
-	# TODO : FIX
 	[ -z "$2" ]                                                             \
 	&& find "$1" -type d                                                    \
 		-exec test -e '{}/index.www' \;                                     \
-		-exec "$0" "$1" {} \;                                               \
-	|| render_main "$1" "$2"
+		-exec "$0" "$1" {} \;
+	[ -n "$2" ]                                                             \
+	&& render_main "$1" "$2"
 
 	# post main render
 	if [ -z "$2" ]; then
@@ -709,22 +712,30 @@ main() {
 		# render git
 		[ "${SKIPGIT-SKIP}" = "SKIP" ] && render_git "git.${1}"
 
+		# move git.site to site/git
+		cp -r "git.${1}" "${1}/git"
+
+		# translate git.site to site/git
+		find "${1}/git" -type f -name "*.html" | while read -r line; do
+			sed -i "s,\"//\[site\]/,\"//[site]/git/,g" "$line"
+			sed -i "s,\"//git.${1}/,\"//${1}/git/,g" "$line"
+			sed -i "s,https://git.${1}/,https://${1}/git/,g" "$line"
+			sed -i "s,\"//\[root\]/,\"//[site]/,g" "$line"
+		done
+
 		# convert absolute paths to relative, so that they work with IPFS
 		print_loading "Converting absolute paths to relative"
-		for site in "$1" "git.${1}"; do
-			find "${site}" -type f -name "*.html" | while read -r line; do
-				count="$(echo "$line" | tr -cd '/' | wc -c)"
-				sed -i "s,\"//\(${site}\|\[site\]\)/,\"$(
-						seq -f "../%g" -s '' 2 "$count" | sed 's/[0-9]//g'
-					),g" "$line"
-			done
+		find "${1}" -type f -name "*.html" | while read -r line; do
+			count="$(echo "$line" | tr -cd '/' | wc -c)"
+			sed -i "s,\"//\(${1}\|\[site\]\)/,\"$(
+					seq -f "../%g" -s '' 2 "$count" | sed 's/[0-9]//g'
+				),g" "$line"
 		done
 		print_done
 
 		# generate sitemaps
 		print_loading "Generating sitemaps"
 		generate_sitemap "${1}"
-		generate_sitemap "git.${1}"
 		print_done
 
 	fi
diff --git a/config/git_head.html b/config/git_head.html
@@ -1,14 +1,12 @@
 	<table>
 		<tr>
-			<td><a href="//{:site:}/"><img src="{:logo:}" alt="" width="32" height="32" /></a></td>
+			<td rowspan="3" valign="top"><a href="//{:site:}/"><img src="{:logo:}" alt="" width="32" height="32" /></a></td>
 			<td><h1>{:name:}</h1><span class="desc">{:description:}</span></td>
 		</tr>
 		<tr>
-			<td></td>
 			<td>git clone <a href="https://{:site:}/{:repo:}">https://{:site:}/{:repo:}</a></td>
 		</tr>
 		<tr>
-			<td></td>
 			<td>{:menu:}</td>
 		</tr>
 	</table>
diff --git a/config/git_repos.html b/config/git_repos.html
@@ -13,9 +13,12 @@
 <body>
 	<table>
 		<tr>
-			<td><img src="{:logo:}" alt="" width="32" height="32" /></td>
+			<td rowspan="2" valign="top"><img src="{:logo:}" alt="" width="32" height="32" /></td>
 			<td><span class="desc">Repositories</span></td>
 		</tr>
+		<tr>
+			<td><a href="//[root]/">noxz.tech</a></td>
+		</tr>
 	</table>
 	<hr />
 	<div id="content">
diff --git a/config/main.html b/config/main.html
@@ -16,7 +16,7 @@
 		<a id="header-logo" href="//noxz.tech/"><img src="{:logo:}" alt="logo"/></a>
 		<a id="header-link" href="//noxz.tech/">{:main_title:}</a>
 		<span id="header-subtitle">{:sub_title:}</span>
-		<a id="header-source" href="//git.noxz.tech">source</a>
+		<a id="header-source" href="//noxz.tech/git">source</a>
 	</div>
 	<hr class="hidden-ruler"/>
 	<div id="content">
@@ -41,7 +41,7 @@
 		<span class="right">
 			Copyright &copy; 2006-{:year:} Chris Noxz
 			| <a href="//noxz.tech/about/copying-policy">copying policy</a>
-			| <a href="//git.noxz.tech">source</a>
+			| <a href="//noxz.tech/git">source</a>
 		</span>
 	</div>
 </body>