New build system

* Website is now built in build/ by default
* Build directory can be controlled via BUILDDIR environment variable
* Build files are no longer accessible from the web page
This commit is contained in:
David Bartley 2007-10-05 21:55:10 -04:00
parent 7481af1666
commit 1f5b375820
20 changed files with 125 additions and 89 deletions

2
.gitignore vendored
View File

@ -3,4 +3,4 @@
/members.xml
/events.ics
/books.xml
/default.mk
/common.mk

View File

@ -1,32 +1,20 @@
INPUTS = index.xml
SUBDIRS = about events office news services media
FILES = events.ics events.atom news.atom index.html \
favicon.ico default.css robots.txt csclub.der csclub.pem
SUBDIRS = about events office news services media buttons logos flash
include common.mk
first: noroot events.ics members.xml events.atom news.atom all
build: noroot mkoutdir common.mk $(OUTPUTS)
@for i in $(SUBDIRS) ; do ($(MAKE) -C $$i || exit 1); done
find ! -regex '.*/\..*' -type f ! -perm -0664 -print0 | xargs -r0 chmod u=rwX,g=rwX,o=rX || true
find ! -regex '.*/\..*' -type d ! -perm 2775 -print0 | xargs -r0 chmod 2775 || true
find ! -regex '.*/\..*' -type d ! -group www -print0 | xargs -r0 chgrp www || true
noroot:
if test $$UID = 0; then echo "don't build as root!"; exit 1; fi
members.xml:
test -e /usr/bin/ceoquery || (echo 'Erorr: ceoquery not found'; exit 1)
echo '<?xml version='\''1.0'\''?>' > $@
echo '<memberlist>' >> $@
ceoquery memberlist | sort | awk -F \| '{ name = $$1; program = $$2; userid = $$3; gsub(/&/, "\\&amp;", name); gsub(/&/, "\\&amp;", program); gsub(/"/, "\\&quot;", name); gsub(/"/, "\\&quot;", program); print "<member name=\"" name "\" program=\"" program "\" userid=\"" userid "\" />"; }' >> $@
echo '</memberlist>' >> $@
events.ics:
perl scripts/xml2ics.pl events.xml > events.ics
include default.mk
%.atom: %.xml xsl/atom.xsl
java -classpath $(CLASSPATH) net.sf.saxon.Transform -o $@ $< $(ROOT)/xsl/atom.xsl $(XSLTARGS)
sed -i 's| xmlns=""||' $@
default.mk: default.mk.in
common.mk: common.mk.in
echo 'ROOT = '`pwd` > $@
cat $< >> $@
make
exit $?
.PHONY: members.xml
.PHONY: noroot
noroot:
if test $$UID = 0; then echo "don't build as root!"; exit 1; fi

View File

@ -1,7 +1,13 @@
INPUTS = index.xml exec.xml members.xml constitution.xml \
constitution-change-20020920.xml constitution-change-20040205.xml
FILES = members.xml index.html exec.html members.html constitution.html \
constitution-change-20020920.html constitution-change-20040205.html
RELDIR = about/
include ../common.mk
include ../default.mk
members.html: ../members.xml
$(OUTDIR)members.html: $(OUTDIR)members.xml
$(OUTDIR)members.xml:
test -e /usr/bin/ceoquery || (echo 'Erorr: ceoquery not found'; exit 1)
echo '<?xml version='\''1.0'\''?>' > $@
echo '<memberlist>' >> $@
ceoquery memberlist | sort | awk -F \| '{ name = $$1; program = $$2; userid = $$3; gsub(/&/, "\\&amp;", name); gsub(/&/, "\\&amp;", program); gsub(/"/, "\\&quot;", name); gsub(/"/, "\\&quot;", program); print "<member name=\"" name "\" program=\"" program "\" userid=\"" userid "\" />"; }' >> $@
echo '</memberlist>' >> $@

5
buttons/Makefile Normal file
View File

@ -0,0 +1,5 @@
FILES = about.png events.png gitweb.png gopher.png home.png library.png \
mailman.png media.png office.png services.png stats.png webmail.png \
wiki.png
RELDIR = buttons/
include ../common.mk

50
common.mk.in Normal file
View File

@ -0,0 +1,50 @@
all: mkoutdir build
OUTDIR = $(ROOT)/build/$(RELDIR)
OUTPUTS = $(addprefix $(OUTDIR),$(FILES))
.PHONY += mkoutdir
mkoutdir:
mkdir -p $(OUTDIR)
.PHONY += build
build: $(OUTPUTS)
.PHONY += clean
clean:
rm -rf $(OUTDIR)
XSLTARGS = g_date=`date -I` g_time=`date +%H:%M:%S` \
g_pwd="$$(pwd)" g_root="$(ROOT)" g_outdir="$(OUTDIR)"
CLASSPATH = /users/www/saxon8/saxon8.jar
$(OUTDIR)%.html: %.xml $(ROOT)/csc.dtd $(ROOT)/xsl/*.xsl $(ROOT)/events.xml $(ROOT)/news.xml directory.xml
java -classpath $(CLASSPATH) net.sf.saxon.Transform -o $@ $< $(ROOT)/xsl/html.xsl $(XSLTARGS)
sed -i 's| xmlns=""||' $@
$(OUTDIR)%.atom: %.xml xsl/atom.xsl
java -classpath $(CLASSPATH) net.sf.saxon.Transform -o $@ $< $(ROOT)/xsl/atom.xsl $(XSLTARGS)
sed -i 's| xmlns=""||' $@
$(OUTDIR)%.ics: %.xml
perl scripts/xml2ics.pl $< > $@
$(OUTDIR)%.ico: %.ico
cp -f $< $@
$(OUTDIR)%.css: %.css
cp -f $< $@
$(OUTDIR)%.gif: %.gif
cp -f $< $@
$(OUTDIR)%.png: %.png
cp -f $< $@
$(OUTDIR)%.swf: %.swf
cp -f $< $@
$(OUTDIR)%.js: %.js
cp -f $< $@
$(OUTDIR)%.txt: %.txt
cp -f $< $@
$(OUTDIR)%.der: %.der
cp -f $< $@
$(OUTDIR)%.pem: %.pem
cp -f $< $@

View File

@ -1,16 +0,0 @@
OUTPUTS=$(INPUTS:.xml=.html)
XSLTARGS=g_date=`date -I` g_time=`date +%H:%M:%S` \
g_pwd="$$(pwd)" g_root="$(ROOT)"
CLASSPATH=/users/www/saxon8/saxon8.jar
all: $(OUTPUTS)
@for i in $(SUBDIRS) ; do cd $$i && ($(MAKE) || exit 1) && cd .. ; done
clean:
@for i in $(SUBDIRS) ; do cd $$i && ($(MAKE) clean || exit 1) && cd .. ; done
rm -f *.html events.ics
%.html: %.xml $(ROOT)/csc.dtd $(ROOT)/cscweb.xsl $(ROOT)/xsl/*.xsl $(ROOT)/events.xml $(ROOT)/news.xml $(ROOT)/default.mk directory.xml
java -classpath $(CLASSPATH) net.sf.saxon.Transform -o $@ $< $(ROOT)/cscweb.xsl $(XSLTARGS)
sed -i 's| xmlns=""||' $@

View File

@ -1,6 +1,6 @@
INPUTS = index.xml old.xml
FILES = index.html old.html
RELDIR = events/
include ../common.mk
include ../default.mk
all:
sed -i 's| xmlns=""||' *.html
build:
sed -i 's| xmlns=""||' $(OUTDIR)*.html

3
flash/Makefile Normal file
View File

@ -0,0 +1,3 @@
FILES = flvplayer.swf swfobject.js
RELDIR = flash/
include ../common.mk

3
logos/Makefile Normal file
View File

@ -0,0 +1,3 @@
FILES = acm_logo.gif csc_logo.gif csc_only.png csc_title.gif uw_logo.gif
RELDIR = logos/
include ../common.mk

View File

@ -1,7 +1,6 @@
INPUTS = index.xml
SUBDIRS =
FILES = index.html
RELDIR = media/
include ../common.mk
include ../default.mk
all:
sed -i 's| xmlns=""||' *.html
build:
sed -i 's| xmlns=""||' $(OUTDIR)*.html

View File

@ -1 +0,0 @@
Redirect /media/files/ http://www.csclub.uwaterloo.ca/files/

View File

@ -1 +0,0 @@
../flash/

View File

@ -1,6 +1,6 @@
INPUTS = index.xml
FILES = index.html
RELDIR = news/
include ../common.mk
include ../default.mk
all:
sed -i 's| xmlns=""||' *.html
build:
sed -i 's| xmlns=""||' $(OUTDIR)*.html

View File

@ -1,3 +1,3 @@
INPUTS = index.xml books.xml webcam.xml webcam-streaming.xml
include ../default.mk
FILES = index.html books.html webcam.html webcam-streaming.html
RELDIR = office/
include ../common.mk

View File

@ -1,5 +1,4 @@
INPUTS = index.xml clubs.xml machine_usage.xml machine_usage_summary.xml \
machine_usage-change-20070819.xml
SUBDIRS =
include ../default.mk
FILES = index.html clubs.html machine_usage.html machine_usage_summary.html \
machine_usage-change-20070819.html
RELDIR = services/
include ../common.mk

View File

@ -74,7 +74,7 @@
<xsl:result-document method="xml" encoding="ISO-8859-1"
doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
href="{translate(concat($g_root, '/events/', @room, '-', @date, '-', @time, '.html'), ' ', '_')}">
href="{translate(concat($g_outdir, @room, '-', @date, '-', @time, '.html'), ' ', '_')}">
<html>
<head>
<title><xsl:value-of select="@title" /></title>
@ -114,7 +114,7 @@
<xsl:result-document method="xml" encoding="ISO-8859-1"
doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
href="{translate(concat($g_root, '/events/old-', csc:term(@date), '.html'), ' ', '_')}">
href="{translate(concat($g_outdir, 'old-', csc:term(@date), '.html'), ' ', '_')}">
<html>
<head>
<title>Events for <xsl:value-of select="csc:term(@date)" /></title>

View File

@ -11,6 +11,7 @@
<xsl:param name="g_time" required="yes" />
<xsl:param name="g_pwd" required="yes" />
<xsl:param name="g_root" required="yes" />
<xsl:param name="g_outdir" required="yes" />
<!--
@ -33,15 +34,15 @@
<xsl:output method="xml" encoding="ISO-8859-1" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" />
<!-- include additional style sheets -->
<xsl:include href="./xsl/functions.xsl" />
<xsl:include href="./xsl/common.xsl" />
<xsl:include href="./xsl/directory.xsl" />
<xsl:include href="./xsl/menu.xsl" />
<xsl:include href="./xsl/exec.xsl" />
<xsl:include href="./xsl/members.xsl" />
<xsl:include href="./xsl/events.xsl" />
<xsl:include href="./xsl/news.xsl" />
<xsl:include href="./xsl/media.xsl" />
<xsl:include href="functions.xsl" />
<xsl:include href="common.xsl" />
<xsl:include href="directory.xsl" />
<xsl:include href="menu.xsl" />
<xsl:include href="exec.xsl" />
<xsl:include href="members.xsl" />
<xsl:include href="events.xsl" />
<xsl:include href="news.xsl" />
<xsl:include href="media.xsl" />
<xsl:template match="*">
<xsl:copy>

View File

@ -15,11 +15,11 @@
<xsl:template match="flvfile">
<xsl:param name="mirror" />
<script type="text/javascript" src="flash/swfobject.js"><xsl:text> </xsl:text></script>
<script type="text/javascript" src="../flash/swfobject.js"><xsl:text> </xsl:text></script>
<p id="player1"><a href="http://www.macromedia.com/go/getflashplayer">
Get the Flash Player</a> to see this video using Flash Player.</p>
<script type="text/javascript">
var s1 = new SWFObject("flash/flvplayer.swf","single","400","300","7");
var s1 = new SWFObject("../flash/flvplayer.swf","single","400","300","7");
s1.addParam("allowfullscreen","true");
s1.addVariable("file","<xsl:value-of select="$mirror" /><xsl:value-of select="@file" />");
<xsl:if test="@preview">
@ -58,7 +58,7 @@
<xsl:result-document method="xml" encoding="ISO-8859-1"
doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
href="{concat($g_root, '/media/', @title, $suffix, '.html')}">
href="{concat($g_outdir, @title, $suffix, '.html')}">
<html>
<head>
<title><xsl:value-of select="@title" /></title>

View File

@ -10,7 +10,7 @@
<xsl:template match="members-this-term">
<p>The members for <xsl:value-of select="csc:term($g_date)" /> are
listed here. We currently have
<xsl:value-of select="count(document(concat($g_root, '/members.xml'))/memberlist/member)" />
<xsl:value-of select="count(document(concat($g_outdir, 'members.xml'))/memberlist/member)" />
members.</p>
<table>
<tr>
@ -18,7 +18,7 @@
<th>Program</th>
<th>Userid</th>
</tr>
<xsl:for-each select="document(concat($g_root, '/members.xml'))/memberlist/member">
<xsl:for-each select="document(concat($g_outdir, 'members.xml'))/memberlist/member">
<xsl:variable name="class">
<xsl:choose>
<xsl:when test="position() mod 2 = 0">members1</xsl:when>

View File

@ -68,7 +68,7 @@
<xsl:result-document method="xml" encoding="ISO-8859-1"
doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
href="{translate(concat($g_root, '/news/old-', csc:term(@date), '.html'), ' ', '_')}">
href="{translate(concat($g_outdir, 'old-', csc:term(@date), '.html'), ' ', '_')}">
<html>
<head>
<title>News for <xsl:value-of select="csc:term(@date)" /></title>