@category aus qemud-0.1.0 news raus

präparationen für events.xml für Events zu der wir keine extra News wollen
calendar.html-Logik


git-svn-id: svn://svn.c3d2.de/c3d2-web/trunk@540 31f61c52-7bfb-0310-b897-fc00f8a278f0
This commit is contained in:
astro 2006-10-28 18:33:31 +00:00
parent e07a541408
commit 04ef134d88
6 changed files with 195 additions and 2 deletions

View File

@ -39,7 +39,7 @@ WWW_CCC_DE_UPDATES=chaosupdates.rdf
### Ziele ###
# Dateinamen der zu erzeugenden html-Dateien:
CONTENT=$(PAGES) $(NEWS_PAGES) $(DS_PAGES) $(NEWSFILES) $(SEARCH_TMPL)
CONTENT=$(PAGES) $(NEWS_PAGES) $(DS_PAGES) $(NEWSFILES) $(SEARCH_TMPL) build/calendar.html
# 'normale' Seiten:
PAGES:=$(patsubst content/pages/%.xml, build/%.html, $(wildcard content/pages/*.xml))
@ -61,6 +61,7 @@ NOVALID_IGNORE:=false
define xml_process
$(VALIDATOR) $(VFLAGS_IN) $<
$(PROCESSOR) $(PFLAGS) -o $@ $(STYLE) $<
# TODO: touch erklären!
$(VALIDATOR) $(VFLAGS_OUT) $@ || $(NOVALID_IGNORE) || \
{ touch -m -t 197001010000 Makefile $@ ; exit 1 ; }
endef
@ -95,6 +96,17 @@ news.xml: $(NEWSITEMS)
$(NEWSFILES): news.xml $(NAVIGATION) $(STYLE)
$(call xml_process)
# Calendar
calendar-summary.xml : STYLE=xsl/calendar-summary.xsl
calendar-summary.xml : NOVALID_IGNORE:=true
calendar-summary.xml : VFLAGS_IN=--noout
calendar-summary.xml: content/events.xml news.xml
$(call xml_process)
build/calendar.html : VFLAGS_IN=--noout
build/calendar.html: calendar-summary.xml $(STYLE) $(NAVIGATION) $(WWW_CCC_DE_UPDATES)
$(call xml_process)
# Pages:
build/%.html: content/pages/%.xml $(STYLE) $(NAVIGATION) $(WWW_CCC_DE_UPDATES) news.xml
$(call xml_process)

11
content/events.xml Normal file
View File

@ -0,0 +1,11 @@
<?xml version="1.0"?>
<calendar>
<event title="Chaosdienstag">
<start>2006-10-17T19:00:00</start>
<location>Dresden</location>
</event>
<event title="Chaosdienstag">
<start>2006-10-24T19:00:00</start>
<location>Dresden</location>
</event>
</calendar>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE item SYSTEM "http://www.c3d2.de/dtd/c3d2web.dtd">
<?xml-stylesheet type="text/xsl" href="../../xsl/html.xsl" ?>
<item title="qemud-0.1.0" date="2006-10-28T23:42:05" author="toidinamai" category="Projekte">
<item title="qemud-0.1.0" date="2006-10-28T23:42:05" author="toidinamai">
<p>
<link href="http://cthulhu.c3d2.de/~toidinamai/qemud/">qemud</link> ist ein Daemon
zum Verwalten von virtuellen Maschinen. Die Bedienung ist an die von Xens

45
xsl/calendar-summary.xsl Normal file
View File

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:date="http://exslt.org/dates-and-times"
exclude-result-prefixes="xsl date">
<xsl:output method="xml"
version="1.0"
encoding="utf-8"
doctype-system="http://www.c3d2.de/dtd/c3d2web.dtd"
indent="yes"/>
<xsl:template match="/calendar">
<page>
<calendar-summary>
<!-- Events aus events.xml ziehen -->
<xsl:apply-templates select="event"/>
<!-- Events aus den News ziehen -->
<xsl:for-each select="document('../news.xml')/page/news/newsfile">
<xsl:message>newsfile: <xsl:value-of select="."/></xsl:message>
<xsl:apply-templates select="document(concat('../', .))/item/event"/>
</xsl:for-each>
</calendar-summary>
</page>
</xsl:template>
<xsl:template match="event">
<event>
<title>
<xsl:choose>
<xsl:when test="@title"><xsl:value-of select="@title"/></xsl:when>
<xsl:when test="../@title"><xsl:value-of select="../@title"/></xsl:when>
<xsl:otherwise>
<xsl:message terminate="yes">Event with no title!</xsl:message>
</xsl:otherwise>
</xsl:choose>
</title>
<date><xsl:value-of select="start"/></date>
<location><xsl:value-of select="start"/></location>
<!-- TODO: Link -->
</event>
</xsl:template>
</xsl:stylesheet>

121
xsl/calendar.xsl Normal file
View File

@ -0,0 +1,121 @@
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:date="http://exslt.org/dates-and-times"
exclude-result-prefixes="xsl date">
<xsl:template match="/page/calendar-summary">
<table border="0" class="calendar">
<tr>
<th>Montag</th>
<th>Dienstag</th>
<th>Mittwoch</th>
<th>Donnerstag</th>
<th>Freitag</th>
<th>Samstag</th>
<th>Sonntag</th>
</tr>
<xsl:call-template name="output-week">
<xsl:with-param name="date">
<xsl:call-template name="get-past-monday">
<xsl:with-param name="date" select="concat(date:year(date:date()), '-', date:month-in-year(date:date()), '-01')"/>
</xsl:call-template>
</xsl:with-param>
<xsl:with-param name="stopmonth" select="date:month-in-year(date:add(date:date(), 'P2M'))"/>
</xsl:call-template>
</table>
</xsl:template>
<xsl:template name="output-week">
<xsl:param name="date"/>
<xsl:param name="stopmonth"/>
<tr>
<xsl:call-template name="output-day">
<xsl:with-param name="date" select="$date"/>
</xsl:call-template>
</tr>
<xsl:variable name="nextweek" select="date:add($date, 'P7D')"/>
<xsl:message>nextweek: <xsl:value-of select="$nextweek"/></xsl:message>
<xsl:if test="date:month-in-year($nextweek) != $stopmonth">
<xsl:call-template name="output-week">
<xsl:with-param name="date" select="$nextweek"/>
<xsl:with-param name="stopmonth" select="$stopmonth"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
<!--
td/@class ist wie folgend aufgebaut:
* Beginnt immer mit 'cal'
* Dann 'week' für Wochentage, 'sun' für Sonntage
* '1' für aktuellen Monat, '2' für folgenden Monat, '3' für sonstige Monate
-->
<xsl:template name="output-day">
<xsl:param name="date"/>
<td>
<xsl:attribute name="class">
<xsl:text>cal</xsl:text>
<xsl:choose>
<xsl:when test="date:day-in-week($date) = 1">sun</xsl:when>
<xsl:otherwise>week</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="date:month-in-year($date) = date:month-in-year(date:date())">1</xsl:when>
<xsl:when test="date:month-in-year($date) = date:month-in-year(date:add(date:date(), 'P1M'))">2</xsl:when>
<xsl:otherwise>3</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:value-of select="date:day-in-month($date)"/>
</td>
<xsl:if test="date:day-in-week($date) != 1"> <!-- Sunday? Break and return to output-week... -->
<xsl:call-template name="output-day">
<xsl:with-param name="date" select="date:add($date, 'P1D')"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
<xsl:template name="calendar-title">
<xsl:variable name="d1" select="date:date()"/>
<xsl:variable name="d2" select="date:add(date:date(), 'P1M')"/>
<xsl:text>Kalender: </xsl:text>
<xsl:call-template name="get-monthstring">
<xsl:with-param name="date" select="$d1"/>
</xsl:call-template>
<xsl:if test="date:year($d1) != date:year($d2)">
<xsl:text> </xsl:text>
<xsl:value-of select="date:year($d1)"/>
</xsl:if>
<xsl:text> &amp; </xsl:text>
<xsl:call-template name="get-monthstring">
<xsl:with-param name="date" select="$d2"/>
</xsl:call-template>
<xsl:text> </xsl:text>
<xsl:value-of select="date:year($d2)"/>
</xsl:template>
<xsl:template name="get-past-monday">
<xsl:param name="date"/>
<xsl:choose>
<xsl:when test="date:day-in-week($date) = 2">
<xsl:value-of select="$date"/>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="get-past-monday">
<xsl:with-param name="date" select="date:add($date, '-P1D')"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>

View File

@ -11,6 +11,7 @@
<xsl:include href="common.xsl" />
<xsl:include href="header.xsl" />
<xsl:include href="footer.xsl" />
<xsl:include href="calendar.xsl" />
<xsl:output method="xml"
version="1.0"
@ -28,6 +29,9 @@
<xsl:when test="/page/@title">
<xsl:value-of select="/page/@title"/>
</xsl:when>
<xsl:when test="/page/calendar-summary">
<xsl:call-template name="calendar-title"/>
</xsl:when>
<xsl:otherwise>
<xsl:comment><xsl:text> missing title </xsl:text></xsl:comment>
</xsl:otherwise>