1
0
Fork 0

Added support for custom HTML extension (or omission); adds -e and -E options

-E will create the effect of a URL rewriting scheme without having to actually use rewriting on the server
master
Mike Gerwitz 2013-05-21 17:20:58 -04:00
parent 73a462cfd2
commit 0f5561e893
No known key found for this signature in database
GPG Key ID: F22BB8158EE30EAB
3 changed files with 27 additions and 34 deletions

30
outfgen
View File

@ -1,30 +0,0 @@
#!/bin/bash
#
# Generates output filename for a given commit
#
# Copyright (C) 2012 Mike Gerwitz
#
# This file is part of repo2html.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
ts="${1?Missing timestamp}"
id="${2?Missing commit id}"
dateout="$( ./tsdate "$ts" %Y-%m-%d )"
month="$( ./tsdate "$ts" %m )"
year="${dateout%%-*}"
echo "$year/$month/$id.html"

View File

@ -54,6 +54,22 @@ resume-default()
exec "$path_default_tpl/$1"
}
# generates output filename
outfgen()
{
ts="${1?Missing timestamp}"
id="${2?Missing commit id}"
ext="${3:+.$3}"
dateout="$( ./tsdate "$ts" %Y-%m-%d )"
month="$( ./tsdate "$ts" %m )"
year="${dateout%%-*}"
echo "$year/$month/$id$ext"
}
# performs index generation; by separating this into a procedure, we allow the
# template to invoke it at any point and further process the output
do-index()
@ -86,7 +102,7 @@ do-index()
lastyear="${lastyear:-$year}"
firstyear="$year"
pagefile="$( ./outfgen "$ts" "$id" )"
pagefile="$( outfgen "$ts" "$id" "$html_ext" )"
fmtsubject="$( "$msgfmt" < <( echo "$subject"; echo ) )"
[ "$prevdate" == "$dategroup" ] || {
@ -122,5 +138,6 @@ do-index()
}
# let the template finish
export -f do-index resolv-template apply-template exec-template resume-default
export -f do-index resolv-template apply-template exec-template resume-default \
outfgen
exec-template index

View File

@ -84,17 +84,22 @@ cfgpath="$path_tpl/.config"
source "$cfgpath"
}
# some initial defaults
html_ext="${html_ext:-.html}"
# 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:f:C:R:T: opt; do
while getopts t:d:c:e:l:f:o:C:ER:T: opt; do
case "$opt" in
t) title="$OPTARG";;
d) desc="$OPTARG";;
c) copyright="$OPTARG";;
e) html_ext="$OPTARG";;
l) license="$OPTARG";;
f) msgfmt="$OPTARG";;
C) html_external_css="$OPTARG";;
E) html_ext=;;
R) rss_count="$OPTARG";;
T) ;; #already handled
?) exit 64;;
@ -119,7 +124,8 @@ msgfmt="${msgfmt:-./msgfmt}"
# make configuration available to all scripts
export title desc copyright license msgfmt url_root path_tpl \
html_external_css html_footer html_index_footer html_commit_footer
html_external_css html_footer html_index_footer html_commit_footer \
html_ext
# clear the cachefile (TODO: we could maintain cache files from previous runs if
# we offer a flag that opts out of reprocessing previously processed commits)