Mike Gerwitz

Free Software Hacker+Activist

aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMike Gerwitz <mtg@gnu.org>2019-01-16 23:59:26 -0500
committerMike Gerwitz <mtg@gnu.org>2019-01-17 01:29:46 -0500
commit6d9defe292e3ade1be7fb87f576659e3cc10cc8e (patch)
treed91b68ddd90cf951a0066fbb3ff7b5d5f4f0c72f /src
parentf38aada7818e8c95e3ff0fcf7af812d96572ce0a (diff)
downloadthoughts-6d9defe292e3ade1be7fb87f576659e3cc10cc8e.zip
thoughts-6d9defe292e3ade1be7fb87f576659e3cc10cc8e.tar.gz
thoughts-6d9defe292e3ade1be7fb87f576659e3cc10cc8e.tar.bz2
Link to source code of post
Rather than displaying the hash separately, this just makes the date a link to the source code. Until I display a modification date, this will also make it easy to see the history of the file.
Diffstat (limited to 'src')
-rwxr-xr-xsrc/post2html14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/post2html b/src/post2html
index 1785541..803fef7 100755
--- a/src/post2html
+++ b/src/post2html
@@ -29,6 +29,8 @@
# the date, and we want to do all HTML processing now.
##
+declare -r srcref=/projects/thoughts/tree
+
set -euo pipefail
# Pandoc output format and extensions.
@@ -59,6 +61,7 @@ pexts()
hgroup-wrap()
{
local -r date=${1?Missing date}
+ local -r file=${2?Missing file}
# Abort if this is not a date prefix
[[ $date =~ [0-9]{4}-[0-9]{2}-[0-9]{2} ]] || {
@@ -66,9 +69,16 @@ hgroup-wrap()
return
}
+ local -r repo_href="$srcref/$file"
+
+ local anchor
+ printf -vanchor '<a class="muted" href="%s">%s</a>' \
+ "$repo_href" \
+ "$date"
+
sed '/^<h1/{
i<hgroup>
- a<h2 class="date">'"$date"'</h2></hgroup>
+ a<h2 class="date">'"$anchor"'</h2></hgroup>
}'
}
@@ -89,7 +99,7 @@ main()
-A src/footer.tpl.htm \
< "$file" \
| src/h12title @__PAGE_TITLE__@ \
- | hgroup-wrap "$date"
+ | hgroup-wrap "$date" "$file"
}