commit: 69592ea147221b02c07454242f7d5463fded0645
parent: f62d25b4e050a924128c5a7df8fa8b6729337883
author: Chris Noxz <chris@noxz.tech>
date: Sat, 25 Jun 2022 18:10:47 +0200
add tags page to git repos
2 files changed, 60 insertions(+), 8 deletions(-)
diff --git a/build b/build
@@ -421,8 +421,10 @@ render_git_repo() {
repo_path="${SITE_GIT_REPO_ROOT}/$2"
repo_path_head="$1/${2}/head.html.tmp"
repo_path_log="$1/${2}/log.html.tmp"
+ repo_path_tags="$1/${2}/tags.html.tmp"
repo_path_readme="$1/${2}/readme.html.tmp"
repo_path_license="$1/${2}/license.html.tmp"
+ repo_path_archive="$1/${2}/archive"
repo_name="${2%.*}"
repo_description=""
@@ -432,17 +434,26 @@ render_git_repo() {
repo_description="$(< "${1}/${2}"/description html_encode)"
+ # create archive files
+ mkdir "${repo_path_archive}"
+ git -C "$1/${2}" tag \
+ | xargs -I{} git -C "$1/${2}" archive \
+ --format=tar.gz --prefix="${repo_name}-{}/" \
+ -o "archive/${repo_name}-{}.tar.gz" "{}"
+
# render common html head
awk \
-v var_site="$(awk_safe "${1}")" \
-v var_repo="$(awk_safe "${2}")" \
-v var_logo="$(awk_safe "${SITE_ICON_SVG}")" \
- -v var_name="$(awk_safe "${repo_name}")" \
- -v var_description="$(awk_safe "${repo_description}")" \
+ -v var_name="$(awk_safe "${repo_name}")" \
+ -v var_description="$(awk_safe "${repo_description}")" \
-v var_menu="$(
git -C "$1/${2}" show HEAD:README >/dev/null 2>&1 || \
git -C "$1/${2}" show HEAD:LICENSE >/dev/null 2>&1 && \
printf '<a href="log.html">Log</a>'
+ git -C "$1/${2}" describe --tags >/dev/null 2>&1 &&
+ printf ' | <a href="tags.html">Tags</a>'
git -C "$1/${2}" show HEAD:README >/dev/null 2>&1 && \
printf ' | <a href="readme.html">README</a>'
git -C "$1/${2}" show HEAD:LICENSE >/dev/null 2>&1 && \
@@ -462,8 +473,7 @@ render_git_repo() {
# render log
git -C "$1/${2}" log \
- --date=format:"%Y-%m-%d %T" \
- --pretty="format:%ad%n%s%n%an%n%h" \
+ --pretty="format:%ai%n%s%n%an%n%h" \
| html_encode \
| awk '
BEGIN {
@@ -494,6 +504,43 @@ render_git_repo() {
}
' > "${repo_path_log}"
+ # render tags
+ git -C "$1/${2}" log \
+ --tags --pretty="format:%S%n%ai%n%an%n%h" \
+ | html_encode \
+ | awk '
+ BEGIN {
+ printf "\t<table id=\"tags\">\n"
+ printf "\t\t<tr class=\"nohi\">"
+ printf "<td>Name</td>"
+ printf "<td>Date</td>"
+ printf "<td>Author</td>"
+ printf "<td>Commit</td>"
+ printf "</tr>\n"
+ printf "\t\t<tbody>\n"
+ }
+
+ {
+ entry[(NR-1) % 4] = $0
+ if (NR % 4 == 0) {
+ printf "\t\t\t<tr>"
+ for (i = 0; i < 4; i++) {
+ if (i == 0) {
+ printf "<td><a href=\"./archive/__REPONAME__-%s.tar.gz\">%s</a></td>",entry[i],entry[i]
+ } else {
+ printf "<td>%s</td>",entry[i]
+ }
+ }
+ printf "</tr>\n"
+ }
+ }
+
+ END {
+ printf "\t\t</tbody>\n"
+ printf "\t</table>\n"
+ }
+ ' | sed "s/__REPONAME__/${repo_name}/g" > "${repo_path_tags}"
+
# render readme if existing
git -C "$1/${2}" show HEAD:README >/dev/null 2>&1 && \
git -C "$1/${2}" cat-file HEAD:README -p \
diff --git a/git.noxz.tech/pub/style.css b/git.noxz.tech/pub/style.css
@@ -36,20 +36,24 @@ table td {
#index,
#log,
+#tags,
#index td:nth-child(2),
-#log td:nth-child(2) {
+#log td:nth-child(2),
+#tags td:nth-child(2) {
width : 100%;
}
#index td,
-#log td {
+#log td,
+#tags td {
padding : 0.2em 0.4em;
vertical-align : top;
white-space : nowrap;
}
#index tr:hover td,
-#log tr:hover td {
+#log tr:hover td,
+#tags tr:hover td {
background-color : #f3f1f9;
}
@@ -59,7 +63,8 @@ tr.nohi:hover td {
}
#index tr td:nth-child(2),
-#log tr td:nth-child(2) {
+#log tr td:nth-child(2),
+#tags tr td:nth-child(2) {
white-space : normal;
}