diff --git a/Makefile b/Makefile index a87e88b..a13fc4c 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,7 @@ INPUTS = index.xml footer.xml SUBDIRS = about events docs office news users clubs media -# the following two rules are there so cow gets built first. -cow-first: noroot events.ics recurse-cow books.xml members.xml menu.xml all +first: noroot events.ics books.xml members.xml menu.xml all 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 @@ -10,9 +9,6 @@ cow-first: noroot events.ics recurse-cow books.xml members.xml menu.xml all noroot: if test $$UID = 0; then echo "don't build as root!"; exit 1; fi -recurse-cow: - cd cow && $(MAKE) && cd .. - members.xml: echo '' > $@ echo '' >> $@ diff --git a/cow/.gitignore b/cow/.gitignore deleted file mode 100644 index 50fd5e2..0000000 --- a/cow/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -*.o -/i686 -/x86_64 -/alpha diff --git a/cow/Makefile b/cow/Makefile deleted file mode 100644 index 8db51e4..0000000 --- a/cow/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -ARCH=$(shell uname -m) -MAIN = $(ARCH)/cow -CFLAGS = -I/usr/include/libxml2 -DDEBUG -pedantic -ansi -Wall -LDFLAGS = $(CFLAGS) -lxml2 -lxslt -SOURCES = $(wildcard *.c) -OBJECTS = $(addprefix $(ARCH)/,$(SOURCES:.c=.o)) - -all: $(MAIN) - -$(ARCH): - mkdir -p $(ARCH) - -$(MAIN): $(OBJECTS) - $(CC) $(LDFLAGS) -o $@ $(OBJECTS) - -$(ARCH)/%.o: %.c $(ARCH) - $(CC) -c $(CFLAGS) -o $@ $< diff --git a/cow/README b/cow/README deleted file mode 100644 index 5ccc4b7..0000000 --- a/cow/README +++ /dev/null @@ -1 +0,0 @@ -requires libxslt to build diff --git a/cow/cow b/cow/cow deleted file mode 100755 index 2cfccc3..0000000 --- a/cow/cow +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -exec "$(dirname $0)/$(uname -m)/$(basename $0)" "$@" diff --git a/cow/debug.h b/cow/debug.h deleted file mode 100644 index 39d239b..0000000 --- a/cow/debug.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef CSC_COW_DEBUG_H -#define CSC_COW_DEBUG_H - -#include - -#ifdef DEBUG -#define DEBUG_PRINT(x) do { fprintf(stderr, "%s:%d (%s): %s\n", __FILE__, \ - __LINE__, __FUNCTION__, x); } while (0) -#else -#define DEBUG_PRINT(x) do { } while (0) -#endif - -#endif diff --git a/cow/functions.c b/cow/functions.c deleted file mode 100644 index 9b11b81..0000000 --- a/cow/functions.c +++ /dev/null @@ -1,49 +0,0 @@ -#include "debug.h" -#include -#include -#include - -#define COW_URI ((const xmlChar *)"http://www.csclub.uwaterloo.ca/cow") - -/* return the term ({Winter,Summer,Fall} YYYY) for a date in - * YYYY-MM-DD format. - */ -void extension_cow_term(xmlXPathParserContextPtr ctxt, - int nargs) -{ - xmlChar *str, *ret; - int month; - - if (nargs != 1) { - xmlXPathSetArityError(ctxt); - } - str = xmlXPathPopString(ctxt); - - month = (str[5] - '0')*10 + (str[6] - '0'); - - ret = xmlUTF8Strndup((const xmlChar*)(month < 9 ? (month < 5 ? "Winter " : "Spring ") : "Fall "), 7); - ret = xmlStrcat(ret, xmlUTF8Strsub(str, 0, 4)); - - xmlXPathReturnString(ctxt, ret); - xmlFree(str); -} - -void *extension_init_func(xsltTransformContextPtr ctxt, - const xmlChar *URI) -{ - return 0; -} - -void extension_shutdown_func(xsltTransformContextPtr ctxt, - const xmlChar *URI, - void *data) -{ -} - -void init_extensions() -{ - xsltRegisterExtModule(COW_URI, - extension_init_func, extension_shutdown_func); - xsltRegisterExtModuleFunction((const xmlChar*)"term", COW_URI, - extension_cow_term); -} diff --git a/cow/main.c b/cow/main.c deleted file mode 100644 index 077ffb2..0000000 --- a/cow/main.c +++ /dev/null @@ -1,100 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "debug.h" - -extern int xmlLoadExtDtdDefaultValue; - -void init_extensions(); - -/* TODO: check for parse errors */ -static int error = 0; - -/* output usage message. progname is the name of the executable. */ -static void usage(const char* progname) -{ - printf("Usage: %s [options] stylesheet input output\n", progname); - printf(" --param name value : pass a parameter to the stylesheet\n"); -} - -int main(int argc, char** argv) -{ - int argNum; - const char **params = 0; - int maxparams = 0; - int nbparams = 0; - xsltStylesheetPtr cur = NULL; - xmlDocPtr doc, res; - FILE *out; - - maxparams = 16; - params = (const char**)malloc(sizeof(char*) * maxparams * 2); - - if (argc <= 1) { - usage(argv[0]); - return 1; - } - - for (argNum = 1; argNum < argc; argNum++) { - if (argv[argNum][0] != '-') - break; - if ((!strcmp(argv[argNum], "-param")) || - (!strcmp(argv[argNum], "--param"))) { - argNum++; - params[nbparams++] = argv[argNum++]; - params[nbparams++] = argv[argNum]; - if (nbparams >= maxparams * 2) { - maxparams *= 2; - params = realloc(params, sizeof(char*) * maxparams * 2); - } - } else { - fprintf(stderr, "Unknown option %s\n", argv[argNum]); - usage(argv[0]); - return 1; - } - } - if ((argc - argNum) != 3) { - usage(argv[0]); - return 1; - } - - params[nbparams] = NULL; - xmlSubstituteEntitiesDefault(1); - xmlLoadExtDtdDefaultValue = XML_DETECT_IDS | XML_COMPLETE_ATTRS; - - init_extensions(); - - cur = xsltParseStylesheetFile((const xmlChar *)argv[argNum]); - argNum++; - doc = xmlParseFile(argv[argNum]); - argNum++; - if(!doc) - return 1; - res = xsltApplyStylesheet(cur, doc, params); - if(!res || error) - return 1; - out = fopen(argv[argNum], "w"); - if(!out) - return 1; - xsltSaveResultToFile(out, res, cur); - - fclose(out); - xsltFreeStylesheet(cur); - xmlFreeDoc(res); - xmlFreeDoc(doc); - - xsltCleanupGlobals(); - xmlCleanupParser(); - return 0; -} diff --git a/cscweb.xsl b/cscweb.xsl index 6a9abcb..5a9ddbe 100644 --- a/cscweb.xsl +++ b/cscweb.xsl @@ -1,8 +1,14 @@ - + + + + + + + diff --git a/default.mk.in b/default.mk.in index 2fc755c..def8502 100644 --- a/default.mk.in +++ b/default.mk.in @@ -1,12 +1,8 @@ -#DEBUG = 1 OUTPUTS=$(INPUTS:.xml=.html) -XSLTARGS=--param date "'`date -I`'" --param time "'`date +%H:%M:%S`'" \ - --param pwd "'`pwd`'" --param root "'$(ROOT)'" - -ifdef DEBUG - XSLTARGS += -v -endif +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 @@ -16,5 +12,5 @@ clean-recurse: clean clean: rm -f *.html events.ics -%.html: %.xml $(ROOT)/csc.dtd $(ROOT)/cscweb.xsl $(ROOT)/xsl/*.xsl $(ROOT)/events.xml $(ROOT)/news.xml $(ROOT)/menu.xml $(ROOT)/default.mk directory.xml $(ROOT)/cow/cow - $(ROOT)/cow/cow $(XSLTARGS) $(ROOT)/cscweb.xsl $< $@ || exit 1; +%.html: %.xml $(ROOT)/csc.dtd $(ROOT)/cscweb.xsl $(ROOT)/xsl/*.xsl $(ROOT)/events.xml $(ROOT)/news.xml $(ROOT)/menu.xml $(ROOT)/default.mk directory.xml + java -classpath $(CLASSPATH) net.sf.saxon.Transform $< $(ROOT)/cscweb.xsl $(XSLTARGS) > $@ || exit 1; diff --git a/xsl/books.xsl b/xsl/books.xsl index 435043d..6d4ec81 100644 --- a/xsl/books.xsl +++ b/xsl/books.xsl @@ -1,8 +1,9 @@ - +

The books we currently own include:

@@ -11,7 +12,7 @@ Title Author - + books1 @@ -31,21 +32,17 @@ - + href="{translate(concat($g_root, '/office/books/', @isbn, '.html'), ' ', '_')}"> Book: <xsl:value-of select="@title" />
- - - - - +

Title:
Edition:
@@ -56,7 +53,7 @@

-
+
diff --git a/xsl/common.xsl b/xsl/common.xsl index 4d5ceec..6c1a764 100644 --- a/xsl/common.xsl +++ b/xsl/common.xsl @@ -1,8 +1,9 @@ - + @@ -57,7 +58,7 @@
+ select="document(concat($g_pwd, '/directory.xml'))/directory"/>
@@ -65,8 +66,8 @@ Go to top