1
0
Fork 0

Title, description, copyright and license are now configurable

Warnings will be output to stderr if any are not provided.
master
Mike Gerwitz 2012-10-07 16:44:12 -04:00
parent dd6c1679e5
commit 5cb939fe0a
No known key found for this signature in database
GPG Key ID: F22BB8158EE30EAB
3 changed files with 40 additions and 7 deletions

View File

@ -27,10 +27,11 @@ cat <<EOH
<!DOCTYPE html>
<html>
<head>
<title>Mike Gerwitz's Thoughts and Ramblings</title>
<title>$title</title>
</head>
<body>
<h1>Mike Gerwitz's Thoughts and Ramblings</h1>
<h1>$title</h1>
<h2>$desc</h2>
EOH
@ -60,7 +61,7 @@ while read hash commit ts id subject; do
fmtsubject="$( ./msgfmt < <( echo "$subject"; echo ) )"
[ "$prevdate" == "$dategroup" ] || {
echo "<h2 id="$dategroup">$dategroup</h2>"
echo "<h3 id="$dategroup">$dategroup</h3>"
}
printf '<ul><li>(%02d) <a href="%s">%s</a></li></ul>' \
@ -91,7 +92,7 @@ fi
cat <<EOF
<hr />
<footer>
<div>Copyright &copy; $yearrange Mike Gerwitz</div>
<div>Copyright &copy; $yearrange $copyright</div>
<div>Last Updated: $( printf "%(%F %H:%M:%S)T" "$lastts" )</div>
<div>$lasthash</div>
</footer>

View File

@ -32,9 +32,42 @@ else
exit 128
fi
# store our cwd and enter our own (to make invoking relative scripts easier)
path_out="$( pwd )"
path="$( dirname "$0" )"
cd "$path"
# provides configuration warning and outputs a default
cwarn()
{
echo "Warning: no $1 provided; defaulting to: ${2:-(empty)}" >&2
echo "$2"
}
# configuration (note that this setup in conjunction with the below defaults
# imply that they can be passed in as environment variables as an alternative to
# options)
while getopts t:d:c:l: opt; do
case "$opt" in
t) title="$OPTARG";;
d) desc="$OPTARG";;
c) copyright="$OPTARG";;
l) license="$OPTARG";;
?) exit 64;;
esac
done
# default title to repository name (as taken from the directory)
title="${title:-$( cwarn title $( basename "$path_out" ) )}"
desc="${desc:-$( cwarn description )}"
# default to a restrictive copyright (unfortunately, that's the best we can do,
# since copyright is restrictive by default)
copyright="${copyright:-$( cwarn copyright 'Respective Authors' )}"
license="${license:-$( cwarn license )}"
# make configuration available to all scripts
export title desc copyright license
# pass commit list to the processor
"$repotype"/list | ./processor "$repotype" "$path_out"

View File

@ -19,9 +19,8 @@ cat <<EOF
<hr />
<footer>
Copyright &copy; $year Mike Gerwitz.
Verbatim redistribution of this document in its entirety is permitted so
long as this copyright notice is preserved.
Copyright &copy; $year $copyright.
$license
<div>$hash</div>
</footer>