merge in support for nightly triggers and local menus

svn path=/trunk/; revision=32215
This commit is contained in:
paul 2015-10-28 21:28:21 +00:00
parent 0fb46dfccd
commit 16e7ff8d93
27 changed files with 125 additions and 97 deletions

View File

@ -30,18 +30,11 @@ sources := $(shell grep -l -R --include='*.xhtml' $(SELECT) . )
.PHONY: localmenus
localmenus: localmenuinfo.xml
localmenus: localmenuinfo.en.xml
$(HELPERFILE) :
rm -f $(HELPERFILE)
localmenuinfo.en.xml: $(sources)
echo \<localmenuset\> > $(HELPERFILE)
grep -R --include='*.xhtml' $(SELECT) .| sed -e 's,$(FIND),$(REPLACE),' >> $(HELPERFILE)
echo \</localmenuset\> >> $(HELPERFILE)
localmenuinfo.xml: $(HELPERFILE) $(sources)
xsltproc -o $@ $(STYLESHEET) $(HELPERFILE)
rm -f $(HELPERFILE)
%.html : %.xhtml $(HELPERFILE)
perl tools/bogus-build.pl $< | xsltproc -o $@ fsfeurope.xsl -
rm $(HELPERFILE)

View File

@ -3,8 +3,8 @@ Usage:
------------------------------------------------------------------------------
build_main.sh [options] build_into "destination_dir"
Perform the page build. Write output to destination_dir. The source directory
is determined from the build scripts own location.
Perform the page build. Write output to destination_dir. The source
directory is determined from the build scripts own location.
build_main.sh [options] build_xmlstream "file.xhtml"
Compile an xml stream from the specified file, additional sources will be
@ -24,6 +24,15 @@ build_main.sh [options] tree_maker [input_dir] "destination_dir"
Note: if destination_dir is set via previous options, and only one paramter
is given, then this parameter will be interpreted as input_dir
build_main.sh [options] wakeup_news [date]
News items that are in the future at the time of their commit are not
considered for the content of dependent files (e.g. news.html, index.html).
This function performs a `touch` on all files which are to be released at
the presented date, thus forcing a subsequent buildrun to rebuild dependent
files even though the input files may not have changed their content.
The date option defaults to the present date, if given it must adhere to
the form YYYY-MM-DD.
OPTIONS
-------

View File

@ -4,7 +4,7 @@
if [ -z "$inc_arguments" ]; then
inc_arguments=true
basedir="$(realpath "$(dirname "$0")/..")"
basedir="$(realpath "${0%/*}/..")"
while [ "$#" -gt 0 ]; do
case "$1" in
@ -72,6 +72,10 @@ if [ -z "$inc_arguments" ]; then
[ "$#" -gt 0 ] && shift 1 && globfile="$1"
[ "$#" -gt 0 ] && shift 1 && reffile="$1"
;;
wakeup_news)
command="$1$command"
[ "$#" -gt 0 ] && shift 1 && today="$1"
;;
*)
print_error "Unknown option: $1"
exit 1
@ -82,7 +86,8 @@ if [ -z "$inc_arguments" ]; then
olang="${olang:-en}"
tree="${tree:-$basedir}"
stagedir=${stagedir:-$target}
stagedir="${stagedir:-$target}"
today="${today:-$(date +%F)}"
readonly tree="${tree:+$(realpath "$tree")}"
readonly stagedir="${stagedir:+$(realpath "$stagedir")}"
readonly basedir="${basedir:+$(realpath "$basedir")}"
@ -98,8 +103,9 @@ if [ -z "$inc_arguments" ]; then
tree_maker) [ -z "$target" ] && die "Missing target location" ;;
sourceglobs) [ -z "$sourcesfile" ] && die "Missing .sources file" ;;
lang_sources) [ -z "$sourceglobfile" -o -z "$lang" ] && die "Need source globfile and language" ;;
cast_refglobs) [ -z "$globfile" -o -z "$reffile" ] && die "Need globfile and reffile" ;;
cast_refglobs) [ -z "$globfile" -o -z "$reffile" ] && die "Need globfile and reffile" ;;
map_tags) true;;
wakeup_news) true;;
*help*) print_help; exit 0 ;;
*) die "Urecognised command or no command given" ;;
esac

View File

@ -1,6 +1,6 @@
#!/bin/sh
basedir="$(dirname "$0")/.."
basedir="${0%/*}/.."
[ -z "$inc_misc" ] && . "$basedir/build/misc.sh"
readonly start_time="$(date +%s)"
@ -32,6 +32,7 @@ fi
[ -z "$inc_processor" ] && . "$basedir/build/processor.sh"
[ -z "$inc_scaffold" ] && . "$basedir/build/scaffold.sh"
[ -z "$inc_sources" ] && . "$basedir/build/sources.sh"
[ -z "$inc_stirrups" ] && . "$basedir/build/stirrups.sh"
case "$command" in
map_tags) map_tags "$@";;
@ -43,4 +44,5 @@ case "$command" in
sourceglobs) sourceglobs "$sourcesfile" ;;
lang_sources) lang_sources "$sourceglobfile" "$lang" ;;
cast_refglobs) cast_refglobs "$globfile" "$reffile" ;;
wakeup_news) wakeup_news "$today" ;;
esac

View File

@ -36,15 +36,14 @@ get_processor(){
# a given xhtml file.
# expects the shortname of the file as input (i.e. the
# the file path without language and file endings)
shortname="$1"
if [ -f "${shortname}.xsl" ]; then
echo "${shortname}.xsl"
else
location="$(dirname "$shortname")"
location="${shortname%/*}"
until [ -f "$location/default.xsl" -o "$location" = . -o "$location" = / ]; do
location="$(dirname "$location")"
location="${location%/*}"
done
echo "$location/default.xsl"
fi

View File

@ -36,12 +36,14 @@ glob_maker(){
# issue make rules for preglobbed sources files
sourcesfile="$1"
filedir="\${INPUTDIR}/$(dirname "$sourcesfile")"
shortbase="$(basename "$sourcesfile" |sed -r 's;\.sources$;;')"
filedir="\${INPUTDIR}/${sourcesfile}"
filedir="${filedir%/*}"
shortbase="${sourcesfile##*/}"
shortbase="${shortbase%.sources}"
for lang in $(get_languages); do
globfile="${filedir%/.}/._._${shortbase}.${lang}.sourceglobs"
refglobs="${filedir%/.}/._._${shortbase}.${lang}.refglobs"
globfile="${filedir}/._._${shortbase}.${lang}.sourceglobs"
refglobs="${filedir}/._._${shortbase}.${lang}.refglobs"
cat <<MakeEND
$(mes "$globfile"): $(mes "\${INPUTDIR}/tagmap" "\${INPUTDIR}/$sourcesfile")
\${PGLOBBER} \${PROCFLAGS} lang_sources "\${INPUTDIR}/$sourcesfile" "$lang" >"$globfile"
@ -75,12 +77,12 @@ xhtml_maker(){
shortname="$input/$1"
outpath="\${OUTPUTDIR}/${2}"
outpath="${outpath%/.}"
outpath="${outpath%/*}"
textsen="$(get_textsfile "en")"
menufile="$basedir/tools/menu-global.xml"
filedir="$(dirname "$shortname")"
shortbase="$(basename "$shortname")"
filedir="${shortname%/*}"
shortbase="${shortname##*/}"
processor="$(get_processor "$shortname")"
langglob="$filedir/._._${shortbase}.langglob"
@ -91,7 +93,7 @@ xhtml_maker(){
olang="$(echo "${shortname}".[a-z][a-z].xhtml "${shortname}".[e]n.xhtml |sed -rn 's;^.*\.([a-z]{2})\.xhtml.*$;\1;p')"
if [ "${shortbase}" = "$(basename "$filedir")" ] && \
if [ "${shortbase}" = "${filedir##*/}" ] && \
[ ! -f "${filedir}/index.${olang}.xhtml" ]; then
bool_indexname=true
else
@ -149,7 +151,7 @@ xhtml_makers(){
| sed -r 's;\.[a-z][a-z]\.xhtml$;;' \
| sort -u \
| while read shortpath; do
xhtml_maker "$shortpath" "$(dirname "$shortpath")"
xhtml_maker "$shortpath" "${shortpath}"
done
}
@ -159,16 +161,14 @@ xhtml_additions(){
| sort -u \
| xargs realpath \
| while read addition; do
xhtml_maker "${addition#$input/}" "$(dirname "${addition#$input/}")"
xhtml_maker "${addition#$input/}" "${addition#$input/}"
done
}
copy_maker(){
# generate make rule for copying a plain file
infile="\${INPUTDIR}/$1"
outpath="\${OUTPUTDIR}/${2}"
outpath="${outpath%/.}"
outfile="$outpath/$(basename "$infile")"
outfile="\${OUTPUTDIR}/$2"
cat <<MakeEND
all: $(mes "$outfile")
@ -183,7 +183,7 @@ copy_makers(){
\! -name '*.sources' \! -name '*.xhtml' \! -name '*.xml' \
\! -name '*.xsl' \! -name 'tagmap' \! -name '*.langglob' \
| while read filepath; do
copy_maker "$filepath" "$(dirname "$filepath")"
copy_maker "$filepath" "$filepath"
done
}
@ -192,7 +192,7 @@ copy_additions(){
| egrep -v '.+(\.sources|\.sourceglobs|\.refglobs|\.xhtml|\.xml|\.xsl|/Makefile|/)$' \
| xargs realpath \
| while read addition; do
copy_maker "${addition#$input/}" "$(dirname "${addition#$input/}")"
copy_maker "${addition#$input/}" "${addition#$input/}"
done
}
@ -213,7 +213,7 @@ xslt_maker(){
# Make dependencies accordingly
file="$input/$1"
dir="$(dirname "$file")"
dir="${file%/*}"
deps="$( xslt_dependencies "$file" |xargs -I'{}' realpath "$dir/{}" )"
cat <<MakeEND
@ -244,7 +244,7 @@ copy_sources(){
# the public source directory
sourcefind -name '*.xhtml' \
| while read filepath; do
copy_maker "$filepath" "source/$(dirname "$filepath")"
copy_maker "$filepath" "source/$filepath"
done
}
@ -253,7 +253,7 @@ copy_sourceadditions(){
| egrep '.+\.xhtml$' \
| xargs realpath \
| while read addition; do
copy_maker "${addition#$input/}" "source/$(dirname "${addition#$input/}")"
copy_maker "${addition#$input/}" "source/${addition#$input/}"
done
}
@ -285,7 +285,7 @@ MakeHead
forcelog Make_sourcecopy; Make_sourcecopy="$(logname Make_sourcecopy)"
Make_xhtml="$(logname Make_xhtml)"
trap "trap - 0 2 3 6 9 15; killall \"$(basename "$0")\"" 0 2 3 6 9 15
trap "trap - 0 2 3 6 9 15; killall \"${0##*/}\"" 0 2 3 6 9 15
[ "$regen_globs" = false -a -s "$Make_globs" ] && \
glob_additions "$@" >>"$Make_globs" \

View File

@ -1,6 +1,6 @@
#!/bin/sh
basedir="$(dirname $0)/.."
basedir="${0%/*}/.."
[ -z "$inc_processor" ] && . "$basedir/build/processor.sh"
. "$basedir/build/arguments.sh"

View File

@ -15,7 +15,7 @@ build_xmlstream(){
lang="$2"
olang="$3"
dirname="$(dirname "$shortname")"
dirname="${shortname%/*}/"
texts_xml=$(get_textsfile $lang)
fundraising_xml=$(get_fundraisingfile $lang)
date="$(date +%Y-%m-%d)"
@ -35,8 +35,8 @@ build_xmlstream(){
<buildinfo
date="$date"
original="$olang"
filename="${shortname#$basedir}"
dirname="${dirname#$basedir}"
filename="${shortname#$basedir/}"
dirname="${dirname#$basedir/}"
language="$lang"
outdated="$outdated"
>

View File

@ -1,6 +1,6 @@
#!/bin/sh
basedir="$(dirname $0)/.."
basedir="${0%/*}/.."
[ -z "$inc_sources" ] && . "$basedir/build/sources.sh"
. "$basedir/build/arguments.sh"

View File

@ -59,3 +59,13 @@ remove_orphans(){
rm -v "$dtree/$file"
done
}
wakeup_news(){
# Performs a `touch` on all files which are to be released at the
# presented date.
today="$1"
find "$basedir" -name '*.xml' \
| xargs egrep -l "<[^>]+ date=[\"']${today}[\"'][^>]*>" \
| xargs touch -c 2>&- || true
}

View File

@ -4,71 +4,64 @@
<!-- Insert local menu -->
<xsl:template match="localmenu">
<xsl:variable name="set">
<xsl:choose>
<xsl:when test="@set">
<xsl:value-of select="@set"/>
</xsl:when>
<xsl:otherwise>
<xsl:text>0</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:choose><xsl:when test="@set">
<xsl:value-of select="@set"/>
</xsl:when><xsl:otherwise>
<xsl:text>0</xsl:text>
</xsl:otherwise></xsl:choose>
</xsl:variable>
<xsl:variable name="dir">
<xsl:value-of select="/buildinfo/@dirname"/>
</xsl:variable>
<xsl:variable name="language">
<xsl:value-of select="/buildinfo/@language"/>
</xsl:variable>
<xsl:element name="div">
<xsl:attribute name="class">localmenu</xsl:attribute>
<xsl:element name="p">
<xsl:text>[ </xsl:text>
<xsl:for-each select="/buildinfo/localmenuset/localmenuitems/menu[@dir=$dir and @set=$set]">
<xsl:sort select="@id"/>
<xsl:variable name="style"><xsl:value-of select="@style"/></xsl:variable>
<xsl:variable name="id"><xsl:value-of select="@id"/></xsl:variable>
<xsl:variable name="localmenutext">
<xsl:choose>
<xsl:when
test="/buildinfo/localmenuset/translate/lang_part[@dir=$dir and @id=$id and @language=$language]">
<xsl:value-of
select="/buildinfo/localmenuset/translate/lang_part[@dir=$dir and @id=$id and @language=$language]"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of
select="/buildinfo/localmenuset/translate/lang_part[@dir=$dir and @id=$id and @language='en']"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:element name="span">
<xsl:attribute name="class">local_menu_item</xsl:attribute>
<xsl:choose>
<xsl:when test="not(substring-before(concat(/buildinfo/@filename ,'.html'), string(.)))">
<xsl:element name="a">
<xsl:attribute name="href"><xsl:value-of select="."/></xsl:attribute>
<xsl:value-of select="$localmenutext"/>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="href">bamboo</xsl:attribute>
<xsl:value-of select="$localmenutext"/>
</xsl:otherwise>
</xsl:choose>
</xsl:element>
<xsl:if test="position()!=last()">
<xsl:choose>
<xsl:when test="$style='number'">
<xsl:text> | </xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text> ] [ </xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:for-each>
<xsl:text> ]</xsl:text>
<xsl:text>[ </xsl:text>
<xsl:for-each select="/buildinfo/document/set/localmenuitems/menu[@dir=$dir and @set=$set]">
<xsl:sort select="@id"/>
<xsl:variable name="style"><xsl:value-of select="@style"/></xsl:variable>
<xsl:variable name="id"><xsl:value-of select="@id"/></xsl:variable>
<xsl:variable name="localmenutext">
<xsl:choose><xsl:when test="/buildinfo/document/set/translate/lang_part[@dir=$dir and @id=$id and @language=$language]">
<xsl:value-of select="/buildinfo/document/set/translate/lang_part[@dir=$dir and @id=$id and @language=$language]"/>
</xsl:when><xsl:otherwise>
<xsl:value-of select="/buildinfo/document/set/translate/lang_part[@dir=$dir and @id=$id and @language='en']"/>
</xsl:otherwise></xsl:choose>
</xsl:variable>
<xsl:element name="span">
<xsl:attribute name="class">local_menu_item</xsl:attribute>
<xsl:choose> <xsl:when test="not(substring-before(concat(/buildinfo/@filename ,'.html'), string(.)))">
<xsl:element name="a">
<xsl:attribute name="href"><xsl:value-of select="."/></xsl:attribute>
<xsl:value-of select="$localmenutext"/>
</xsl:element>
</xsl:when><xsl:otherwise>
<xsl:attribute name="href">bamboo</xsl:attribute>
<xsl:value-of select="$localmenutext"/>
</xsl:otherwise></xsl:choose>
</xsl:element>
<xsl:if test="position()!=last()">
<xsl:choose><xsl:when test="$style='number'">
<xsl:text> | </xsl:text>
</xsl:when><xsl:otherwise>
<xsl:text> ] [ </xsl:text>
</xsl:otherwise></xsl:choose>
</xsl:if>
</xsl:for-each>
<xsl:text> ]</xsl:text>
</xsl:element><!--end wrapper-->
</xsl:element>
</xsl:template>

View File

@ -1 +1,2 @@
donate/donors/donors-2001:[]
localmenuinfo:[]

View File

@ -1 +1,2 @@
donate/donors/donors-2002:[]
localmenuinfo:[]

View File

@ -1 +1,2 @@
donate/donors/donors-2003:[]
localmenuinfo:[]

View File

@ -1 +1,2 @@
donate/donors/donors-2004:[]
localmenuinfo:[]

View File

@ -1 +1,2 @@
donate/donors/donors-2005:[]
localmenuinfo:[]

View File

@ -1 +1,2 @@
donate/donors/donors-2006:[]
localmenuinfo:[]

View File

@ -1 +1,2 @@
donate/donors/donors-2007:[]
localmenuinfo:[]

View File

@ -1 +1,2 @@
donate/donors/donors-2008:[]
localmenuinfo:[]

View File

@ -1 +1,2 @@
donate/donors/donors-2009:[]
localmenuinfo:[]

View File

@ -1 +1,2 @@
donate/donors/donors-2010:[]
localmenuinfo:[]

View File

@ -1 +1,2 @@
donate/donors/donors-2011:[]
localmenuinfo:[]

View File

@ -1 +1,2 @@
donate/donors/donors-2012:[]
localmenuinfo:[]

View File

@ -1 +1,2 @@
donate/donors/donors-2013:[]
localmenuinfo:[]

View File

@ -1 +1,2 @@
donate/donors/donors-2014:[]
localmenuinfo:[]

View File

@ -1 +1,2 @@
donate/donors/donors-2015:[]
localmenuinfo:[]

View File

@ -1,2 +1,3 @@
donate/donors/donors-2014:[]
donate/donors/donors-2015:[]
localmenuinfo:[]