Worked on news redesign

This commit is contained in:
Martin Byrenheid 2014-01-29 20:34:33 +01:00
parent 7babd5152d
commit fb463e95e8
9 changed files with 209 additions and 108 deletions

View File

@ -1,7 +1,6 @@
PROCESSOR=xsltproc
PFLAGS=--novalid
# The root directory of every transformation
# used in the following makefile
TRANSFORMATION_ROOT=transformation
@ -11,11 +10,48 @@ TRANSFORMATION_ROOT=transformation
HTML_OUTPUT=output/html
PAGE_OUTPUT=output/page
NEWS_OUTPUT=output/news
#
# C3D2-specific configuration
#
TITLE_PREFIX="C3D2 Blub"
BASEURL=""
#
# Predefined functions
#
# news2page (target, pathinclude) where
# "target" - the path of the xml file to be transformed
# "pathinclude" - additional paths (separated by whitespace) for inclusion of news items
news2page = $(PROCESSOR) $(PFLAGS) --path "$(NEWS_OUTPUT) $(2)" $(TRANSFORMATION_ROOT)/news2page/news.xsl $(1)
# page2html (target, pathincluce) where
# "target" - the path of the xml file to be transformed
# "pathinclude" - additional paths (separated by whitespace) for inclusion of news items
page2html = $(PROCESSOR) $(PFLAGS) --path "$(PAGE_OUTPUT) $(TRANSFORMATION_ROOT)/page2html $(2)" --stringparam baseurl $(BASEURL) --stringparam common_title_prefix $(TITLE_PREFIX) $(TRANSFORMATION_ROOT)/page2html/page2html.xsl $(1)
all: prepare_output $(HTML_OUTPUT)/news.html $(HTML_OUTPUT)/unterstuetzen.html $(HTML_OUTPUT)/schule.html
prepare_output:
mkdir -p $(HTML_OUTPUT) $(PAGE_OUTPUT) $(NEWS_OUTPUT)
cp -rf content/c3d2/static/* $(HTML_OUTPUT)
#
# Static pages
#
$(HTML_OUTPUT)/schule.html:
$(call page2html, content/c3d2/pages/schule.xml , content/c3d2 content/c3d2/pages) > $(HTML_OUTPUT)/schule.html
$(HTML_OUTPUT)/unterstuetzen.html:
$(call page2html, content/c3d2/pages/unterstuetzen.xml , content/c3d2 content/c3d2/pages) > $(HTML_OUTPUT)/unterstuetzen.html
#
# NEWS
#
NEWS_OUTPUT=output/news
ITEMS_DIR=content/c3d2/items
@ -27,10 +63,17 @@ LIST_GENERATOR=scripts/generate-news-list.sh
# 1. Generate a list of all news items
# stored within $(ITEMS_DIR).
$(NEWS_OUTPUT)/news-list.xml:
$(NEWS_OUTPUT)/news-list.xml:
$(LIST_GENERATOR) $(ITEMS_DIR) > $(NEWS_OUTPUT)/news-list.xml
# 2. Transform the news.xml-file into a page
# TODO: Replace PROCESSOR-call with a predefined procedure for news2page-transformation.
$(PAGE_OUTPUT)/news.xml:
$(PROCESSOR) $(TRANSFORMATION_ROOT)/news2page/news.xsl content/c3d2/news/overview.xml
$(PAGE_OUTPUT)/news.xml: $(NEWS_OUTPUT)/news-list.xml
$(call news2page, content/c3d2/news/overview.xml, content/c3d2/items) > $(PAGE_OUTPUT)/news.xml
# 3. Transform the news page into HTML
$(HTML_OUTPUT)/news.html: $(PAGE_OUTPUT)/news.xml
$(call page2html, output/page/news.xml , $(PAGE_OUTPUT) content/c3d2 content/c3d2/pages) > $(HTML_OUTPUT)/news.html
clean:
rm -rf $(NEWS_OUTPUT)/* $(PAGE_OUTPUT)/* $(HTML_OUTPUT)/*

View File

@ -1,16 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<news>
<news-list src="news-files.xml" newsdir="../news" title="News" id="news" count="10" />
<news title="News" id="news">
<item-list src="news-list.xml" sdir="../news" display="event" count="10" />
<aside>
<p>
Die Neuigkeiten des C3D2 sind auch
als <a href="{$baseurl}news-atom.xml">ATOM</a>
und <a href="{$baseurl}news-rss.xml">RSS</a>, die
als <a href="./news-atom.xml">ATOM</a>
und <a href="./news-rss.xml">RSS</a>, die
Veranstaltungen
im <a href="{$baseurl}ical.ics">iCal-</a>, <a href="{$baseurl}xcal.xml">XCal-</a>
und <a href="{$baseurl}reminders">remind-Format</a> abrufbar.
im <a href="./ical.ics">iCal-</a>, <a href="{$baseurl}xcal.xml">XCal-</a>
und <a href="./reminders">remind-Format</a> abrufbar.
Mehr News gibts im <a href="{$baseurl}news-archiv.html" rel="archives">Archiv</a>.
</p>
</aside>

View File

@ -1,6 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE page SYSTEM "http://www.c3d2.de/dtd/c3d2web.dtd">
<?xml-stylesheet type="text/xsl" href="../xsl/html.xsl" ?>
<page id="schule" title="Schule">
<p>

View File

@ -1,6 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE page SYSTEM "http://www.c3d2.de/dtd/c3d2web.dtd">
<?xml-stylesheet type="text/xsl" href="../xsl/html.xsl" ?>
<page id="unterstuetzen" title="Unterstützen">
<p title="Spenden">

View File

@ -6,6 +6,67 @@
xmlns:crypto="http://exslt.org/crypto"
exclude-result-prefixes="xsl date crypto">
<!-- Support für <event/> bzw. Microformats -->
<xsl:include href="date.xsl" />
<xsl:template match="item/event">
<dl>
<xsl:apply-templates/>
</dl>
</xsl:template>
<xsl:template match="item/event/start">
<xsl:variable name="start" select="."/>
<xsl:variable name="end" select="../end"/>
<dt>Datum</dt>
<dd>
<abbr class="dtstart">
<xsl:attribute name="title">
<xsl:call-template name="date-to-hevent">
<xsl:with-param name="date" select="$start"/>
</xsl:call-template>
</xsl:attribute>
<xsl:call-template name="get-datestring">
<xsl:with-param name="date" select="$start"/>
</xsl:call-template>
</abbr>
<xsl:if test="$end">
bis
<abbr class="dtend">
<xsl:attribute name="title">
<xsl:call-template name="date-to-hevent">
<xsl:with-param name="date" select="$end"/>
</xsl:call-template>
</xsl:attribute>
<xsl:choose>
<!-- Ends on same day it starts? -->
<xsl:when test="date:date($start) = date:date($end)">
<xsl:call-template name="get-timestring">
<xsl:with-param name="date" select="$end"/>
</xsl:call-template>
</xsl:when>
<!-- Event spans days -->
<xsl:otherwise>
<xsl:call-template name="get-datestring">
<xsl:with-param name="date" select="$end"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</abbr>
</xsl:if>
</dd>
</xsl:template>
<xsl:template match="item/event/end">
<!-- Output already for item/event/start above -->
</xsl:template>
<xsl:template match="item/event/location">
<dt>Ort</dt>
<dd class="location"><xsl:apply-templates/></dd>
</xsl:template>
<xsl:template match="item/image[1]">
<xsl:variable name="path">
<xsl:call-template name="normalize-path">

View File

@ -1,43 +1,78 @@
<?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"
xmlns:crypto="http://exslt.org/crypto"
exclude-result-prefixes="xsl date crypto">
<xsl:template match="news-list">
<xsl:variable name="prefix" select="@prefix"/>
<xsl:variable name="details" select="@details"/>
<xsl:output method="xml"
version="1.0"
encoding="utf-8"
indent="yes"/>
<xsl:for-each select="document('../news.xml')/page/news/newsfile">
<xsl:sort select="date:seconds(document(concat('../', .))/item/@date)" data-type="number" order="descending" />
<xsl:variable name="newsfile" select="."/>
<xsl:include href="include/date.xsl" />
<xsl:for-each select="document(concat('../', $newsfile))/item">
<xsl:if test="((string-length($prefix) = 0) or starts-with($newsfile, concat('content/news/', $prefix))) and (($details != 'resources-only') or (count(resource) &gt; 0))">
<xsl:template match="news">
<page title="@title" id="@id">
<xsl:attribute name="title">
<xsl:value-of select="@title" />
</xsl:attribute>
<xsl:attribute name="id">
<xsl:value-of select="@id" />
</xsl:attribute>
<xsl:apply-templates select="*" />
</page>
</xsl:template>
<xsl:template name="item-meta">
<small class="news_author">
<xsl:value-of select="@author"/>
</small>
<small class="news_date">
@
<time datetime="{@date}" pubdate="pubdate">
<xsl:call-template name="get-datestring">
<xsl:with-param name="date" select="@date" />
</xsl:call-template>
</time>
</small>
</xsl:template>
<xsl:template match="item-summary">
<xsl:variable name="list" select="@src" />
<xsl:variable name="dir" select="@dir" />
<xsl:variable name="display" select="@display" />
<xsl:variable name="count" select="@count" />
<!--
# Iterate over all files listed in the file under $src.
-->
<xsl:for-each select="document($list)/newsfiles/file">
<xsl:sort select="date:seconds(document(concat($dir , .))/item/@date)" data-type="number" order="descending" />
<xsl:variable name="itemfile" select="."/>
<xsl:if test="position() &lt;= number($count)">
<xsl:for-each select="document(concat($dir, $itemfile))/item">
<div>
<xsl:if test="($details = 'event') and event">
<xsl:attribute name="class">vevent</xsl:attribute>
</xsl:if>
<h3 class="summary">
<a href="{substring-before(substring-after($newsfile, 'content/'), '.xml')}.html" class="url">
<a href="{substring-before($itemfile, '.xml')}.html" class="url">
<xsl:value-of select="@title"/>
</a>
</h3>
<xsl:choose>
<xsl:when test="$details = 'news'">
<xsl:call-template name="news-meta"/>
<xsl:when test="$display = 'news'">
<xsl:call-template name="item-meta"/>
</xsl:when>
<xsl:when test="$details = 'resources-only'">
<xsl:when test="$display = 'resources-only'">
<xsl:apply-templates select=".//resource"/>
</xsl:when>
<xsl:when test="($details = 'event') and event">
<xsl:when test="($display = 'event') and event">
<ul class="details_event">
<li>
<abbr class="dtstart">
@ -59,24 +94,27 @@
</ul>
</xsl:when>
</xsl:choose>
</div>
</xsl:if>
</xsl:for-each>
</xsl:if>
</xsl:for-each>
</xsl:template>
<xsl:template match="/page/news">
<xsl:template match="item-list">
<xsl:variable name="list" select="@src" />
<xsl:variable name="dir" select="@dir" />
<xsl:variable name="display" select="@display" />
<xsl:variable name="count" select="@count" />
<xsl:for-each select="newsfile">
<xsl:sort select="date:seconds(document(concat('../', .))/item/@date)" data-type="number" order="descending" />
<xsl:if test="position() &lt;= 10">
<xsl:for-each select="document($list)/newsfiles/file">
<xsl:sort select="date:seconds(document(concat($dir, .))/item/@date)" data-type="number" order="descending" />
<xsl:if test="position() &lt;= number($count)">
<xsl:variable name="newsfile"><xsl:value-of select="."/></xsl:variable>
<xsl:variable name="itemposition" select="position()"/>
<xsl:for-each select="document(concat('../', $newsfile))/item">
<xsl:for-each select="document(concat($dir, $newsfile))/item">
<article><div>
<xsl:if test="event">
@ -85,12 +123,12 @@
<header>
<h3 class="news summary">
<a href="{substring-before(substring-after($newsfile, 'content/'), '.xml')}.html" class="url">
<a href="{substring-before($newsfile, '.xml')}.html" class="url">
<xsl:value-of select="@title"/>
</a>
</h3>
<xsl:call-template name="news-meta"/>
<xsl:call-template name="item-meta"/>
</header>
<div class="news">
@ -100,7 +138,7 @@
<xsl:if test="//addendum or //resource[@hide='yes']">
<footer><p class="more">
<a href="{substring-before(substring-after($newsfile, 'content/'), '.xml')}.html">
<a href="{substring-before($newsfile, '.xml')}.html">
Weiterlesen…
</a>
</p></footer>
@ -116,5 +154,16 @@
</xsl:for-each>
</xsl:template>
<!--
# Identity transformation for all elements
# not handled by the templates within this file.
# Taken from
# http://stackoverflow.com/questions/10454114/xslt-template-for-any-node-not-already-handled
-->
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>

View File

@ -210,67 +210,6 @@
</ul>
</xsl:template>
<!-- Support für <event/> bzw. Microformats -->
<xsl:include href="date.xsl" />
<xsl:template match="item/event">
<dl>
<xsl:apply-templates/>
</dl>
</xsl:template>
<xsl:template match="item/event/start">
<xsl:variable name="start" select="."/>
<xsl:variable name="end" select="../end"/>
<dt>Datum</dt>
<dd>
<abbr class="dtstart">
<xsl:attribute name="title">
<xsl:call-template name="date-to-hevent">
<xsl:with-param name="date" select="$start"/>
</xsl:call-template>
</xsl:attribute>
<xsl:call-template name="get-datestring">
<xsl:with-param name="date" select="$start"/>
</xsl:call-template>
</abbr>
<xsl:if test="$end">
bis
<abbr class="dtend">
<xsl:attribute name="title">
<xsl:call-template name="date-to-hevent">
<xsl:with-param name="date" select="$end"/>
</xsl:call-template>
</xsl:attribute>
<xsl:choose>
<!-- Ends on same day it starts? -->
<xsl:when test="date:date($start) = date:date($end)">
<xsl:call-template name="get-timestring">
<xsl:with-param name="date" select="$end"/>
</xsl:call-template>
</xsl:when>
<!-- Event spans days -->
<xsl:otherwise>
<xsl:call-template name="get-datestring">
<xsl:with-param name="date" select="$end"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</abbr>
</xsl:if>
</dd>
</xsl:template>
<xsl:template match="item/event/end">
<!-- Output already for item/event/start above -->
</xsl:template>
<xsl:template match="item/event/location">
<dt>Ort</dt>
<dd class="location"><xsl:apply-templates/></dd>
</xsl:template>
<!-- Resources/alternatives in HTML -->
<xsl:template match="resource">

View File

@ -1,12 +1,12 @@
<?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"
xmlns:crypto="http://exslt.org/crypto"
exclude-result-prefixes="xsl date crypto">
<xsl:param name="common_title_prefix" />
<xsl:param name="baseurl" />
<xsl:include href="common.xsl" />
<xsl:include href="include/entities.xsl" />
@ -93,7 +93,7 @@
</xsl:if>
<!-- # PAGE BODY # -->
<xsl:apply-templates />
<xsl:apply-templates select="*" />
</section>
<!-- # PAGE FOOTER # -->
@ -155,4 +155,17 @@
</body> <!-- ## END OF HTML BODY ## -->
</html>
</xsl:template>
<!--
# Identity transformation for all elements
# not handled by the templates within this file.
# Taken from
# http://stackoverflow.com/questions/10454114/xslt-template-for-any-node-not-already-handled
-->
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>