60 lines
1.7 KiB
Diff
60 lines
1.7 KiB
Diff
|
From 638abbd35c41a4695ecaf7e569027c83a355d385 Mon Sep 17 00:00:00 2001
|
||
|
From: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
|
||
|
Date: Wed, 6 Dec 2023 21:29:31 +0100
|
||
|
Subject: [PATCH] Enable to deploy websites in subdirectories.
|
||
|
|
||
|
Sometimes people just have shell accounts on a server and the machine
|
||
|
is setup to serve web pages from their home directory. In that case
|
||
|
the domains typically looks like https://domain.org/~username/.
|
||
|
|
||
|
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
|
||
|
---
|
||
|
include/news.sh | 22 ++++++++++++++++++----
|
||
|
1 file changed, 18 insertions(+), 4 deletions(-)
|
||
|
|
||
|
diff --git a/include/news.sh b/include/news.sh
|
||
|
index 1886fcb..5d33987 100755
|
||
|
--- a/include/news.sh
|
||
|
+++ b/include/news.sh
|
||
|
@@ -51,7 +51,16 @@ mkarticle()
|
||
|
fi
|
||
|
while read -r f; do
|
||
|
_page="$(sanitizefilename "${f#"${_sitedir}/site/"}")"
|
||
|
- meta "${_page}" "${_sitedir}/site" \
|
||
|
+
|
||
|
+ _protocol="$(echo "${DOMAIN%/}" | sed 's#://.*##')"
|
||
|
+
|
||
|
+ _domain="$(echo "${DOMAIN%/}" | \
|
||
|
+ sed "s#${_protocol}://##" | sed 's#/.*##')"
|
||
|
+
|
||
|
+ _path="$(echo "${DOMAIN%/}" | \
|
||
|
+ sed "s#^${_protocol}://${_domain}/\?##")"
|
||
|
+
|
||
|
+ meta "${_page}" "${_sitedir}/site" "${_path}" \
|
||
|
>> "${_sitedir}/site/${_manifestdir}/index.md"
|
||
|
done < "${tmpdir}/xnews"
|
||
|
|
||
|
@@ -78,11 +87,16 @@ mkarticle()
|
||
|
mkhtml "$_sitedir/site/${_manifestdir}/index.md" "${_sitedir##*/}"
|
||
|
}
|
||
|
|
||
|
-# usage: meta file
|
||
|
+# usage: meta file filedir
|
||
|
meta()
|
||
|
{
|
||
|
- printf '%s\n' \
|
||
|
- "[$(mktitle "${2}/${1}")](/${1}){.title}"
|
||
|
+ if [ -n "${3}" ] ; then
|
||
|
+ printf '%s\n' \
|
||
|
+ "[$(mktitle "${2}/${1}")](/${3}/${1}){.title}"
|
||
|
+ else
|
||
|
+ printf '%s\n' \
|
||
|
+ "[$(mktitle "${2}/${1}")](/${1}){.title}"
|
||
|
+ fi
|
||
|
|
||
|
printf '%s\n' \
|
||
|
"[$(sed -n 3p "${2}/${1}" | sed -e s-^..--)]{.date}"
|
||
|
--
|
||
|
2.41.0
|
||
|
|