diff --git a/outfgen b/outfgen deleted file mode 100755 index 9482083..0000000 --- a/outfgen +++ /dev/null @@ -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 . -# # - -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" diff --git a/processor b/processor index 943d88c..d8cf944 100755 --- a/processor +++ b/processor @@ -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 diff --git a/repo2html b/repo2html index c2895c9..0630b99 100755 --- a/repo2html +++ b/repo2html @@ -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)