commit 76653168e67c9855a0924edf892a42cc5933440e
parent c31f567b63fd302d3d55b06ef7ecd74b409a7ed0
Author: JayVii <jayvii[AT]posteo[DOT]de>
Date: Mon, 10 Jun 2024 22:02:53 +0200
feat: create designated list for file exports
Diffstat:
1 file changed, 62 insertions(+), 12 deletions(-)
diff --git a/bin/git_update_repo_html.sh b/bin/git_update_repo_html.sh
@@ -81,17 +81,6 @@ TMENU=$(
-e "s/<\!--MENU-->/${RMENU}/g"
)
-## generate summary injection content
-SUMR="
- ${ACTIVITY_HTML}
- <pre id=\"description\">${RDESCF}</pre>
- <hr>
- <span>Clone this repository via:</span><br>
- <pre>git clone <a href=\"$RURL\">$RURL</a></pre>
- </a>
- </div>
-"
-
## Write template
echo "<!DOCTYPE html>
<html>
@@ -110,6 +99,67 @@ ${ACTIVITY_HTML}
</html>
" > "${1}/${2}/${3}/index.html"
+# Exports Page -----------------------------------------------------------------
+
+## fetch repo description, URL and menu-line
+RDESCS=$(
+ cat "${1}/${2}/${3}.git/description" 2>/dev/null | \
+ sed -e 's/\//\\\//g'
+)
+RURL=$(
+ cat "${1}/${2}/${3}.git/url" 2>/dev/null | \
+ sed -e 's/\//\\\//g')
+RMENU=$(
+ grep -E "^.*<a\ href=\"log.html\">.*$" \
+ --only-matching "${1}/${2}/${3}/log.html" | \
+ sed -e 's/\//\\\//g'
+)
+
+# read template sections
+THEAD=$(
+ cat "${1}/templates/head.html" | \
+ sed \
+ -e "s/<\!--TITLE-->/Exports\ -\ ${3}/g" \
+ -e "s/<\!--DESC-->/${RDESCS}/g" \
+ -e "s/<\!--DIR-->/\./g" \
+ -e "s/<\!--REPO-->/${RURL}/g"
+)
+TMENU=$(
+ cat "${1}/templates/menu.html" | \
+ sed \
+ -e "s/<\!--TITLE-->/${3}/g" \
+ -e "s/<\!--DESC-->/${RDESCS}/g" \
+ -e "s/<\!--REPO-->/${RURL}/g" \
+ -e "s/<\!--MENU-->/${RMENU}/g"
+)
+
+# list exports
+EXPTS=$(
+ ls "${1}/${2}/${3}/exports/" -lht \
+ --time-style="+%Y-%m-%d %H:%m" | \
+ awk '{ print "<tr><td><a href=\"exports/" $8 "\">" $8 "</a></td><td>" $6 " " $7 "</td><td>" $5 "</td><tr>" }'
+)
+
+## Write template
+echo "<!DOCTYPE html>
+<html>
+${THEAD}
+<body>
+${TMENU}
+<div id=\"content\">
+<table id=\"exports\">
+<thead>
+<tr><td><b>Name</b></td><td><b>Date</b></td><td class=\"num\" align=\"right\"><b>Size</b></td></tr>
+</thead>
+<tbody>
+${EXPTS}
+</tbody>
+</table>
+</div>
+</body>
+</html>
+" > "${1}/${2}/${3}/exports.html"
+
# Replacements -----------------------------------------------------------------
# Protect Mail-Adresses in HTML
@@ -117,7 +167,7 @@ MAILEXP='s/([a-zA-Z0-9\.]+)\@([a-zA-Z0-9\-]+)\.([a-z]+)/\1\[AT\]\2\[DOT\]\3/g'
find "${1}/${2}/${3}/" -type f -exec sed -E -e ${MAILEXP} -i {} \;
# Add Exports to menu (behind Files)
-INJEXP="s/(>Files<\/a>\ \|)/\1 <a href=\"\/${2}\/${3}\/exports\/\">Exports<\/a> \|/"
+INJEXP="s/(>Files<\/a>\ \|)/\1 <a href=\"\/${2}\/${3}\/exports.html\">Exports<\/a> \|/"
find "${1}/${2}/${3}/" -type f -name "*.html" -exec sed -E "${INJEXP}" -i {} \;
# Add Back-Button and Summary page (within title)