From 4b74bd5a880a6cf5d148925392cfee50379f9615 Mon Sep 17 00:00:00 2001 From: Astro Date: Fri, 28 Mar 2014 22:29:10 +0100 Subject: [PATCH] don't publish news items with future @date --- documentation/conventions.md | 5 +++++ documentation/todo.md | 4 ---- xsl/atom.xsl | 4 ++-- xsl/calendar-summary.xsl | 3 ++- xsl/portal2items.xsl | 36 ++++++++++++++++-------------------- xsl/rss.xsl | 4 ++-- xsl/xhtml5.xsl | 21 +++++++++++++++++++-- 7 files changed, 46 insertions(+), 31 deletions(-) diff --git a/documentation/conventions.md b/documentation/conventions.md index 61b3254b1..b84a2716d 100644 --- a/documentation/conventions.md +++ b/documentation/conventions.md @@ -9,3 +9,8 @@ XSL-Stylesheet - Wird IMMER explizit als Parameter an xsltproc übergeben, nicht als Attribut in xml-stylesheet-Tag - Begründung: Ermöglicht Transformation in verschiedene Formate durch Angabe des entsprechenden XSL-Stylesheets (z.B. item-XML-Datei in HTML oder alternativ in RSS transformieren) + +== news pre-posting + +some news shall be written right now but published later, thats why the date next to author of the news/events item etc. should be compared and if greater than the current one not considered for publication yet. + diff --git a/documentation/todo.md b/documentation/todo.md index bd5de90a6..748f4b135 100644 --- a/documentation/todo.md +++ b/documentation/todo.md @@ -1,9 +1,5 @@ = was man noch machen könnte -== news pre-posting - -some news shall be written right now but published later, thats why the date next to author of the news/events item etc. should be compared and if greater than the current one not considered for publication yet. - == potal-mediagoblin eine option für das bekanntgeben eines neuen Bilcdes fehlt im Mediagobline. Derzeit werden alle Bilder von bestimmten Nutzern (john, astro, lachmoewe, bigalex) bekannt gegeben.. nuja. diff --git a/xsl/atom.xsl b/xsl/atom.xsl index 37098d652..dc06cc92a 100644 --- a/xsl/atom.xsl +++ b/xsl/atom.xsl @@ -41,8 +41,8 @@ - + starts-with(substring-after(substring-after($newsfile, '/'), '/'), $prefix) and + starts-with(date:difference(date:date-time(), document(.)/item/@date), '-')"> diff --git a/xsl/calendar-summary.xsl b/xsl/calendar-summary.xsl index 0235ba0de..02cab05c3 100644 --- a/xsl/calendar-summary.xsl +++ b/xsl/calendar-summary.xsl @@ -31,7 +31,8 @@ - + <xsl:choose> diff --git a/xsl/portal2items.xsl b/xsl/portal2items.xsl index c76d30564..3ec3419e1 100644 --- a/xsl/portal2items.xsl +++ b/xsl/portal2items.xsl @@ -1,6 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:atom="http://www.w3.org/2005/Atom" + xmlns:date="http://exslt.org/dates-and-times" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" encoding="utf-8" indent="yes"/> @@ -17,10 +18,13 @@ <!-- Extract from news --> <xsl:for-each select="document('../news.xml')//newsfile"> - <xsl:apply-templates select="document(concat('../', .))/item" mode="news"> - <xsl:with-param name="link" - select="concat(substring-before(substring-after(., 'content/'), '.xml'), '.html')"/> - </xsl:apply-templates> + <xsl:if test="starts-with(date:difference(date:date-time(), @date), '-')"> + <xsl:apply-templates select="document(concat('../', .))/item" + mode="news"> + <xsl:with-param name="link" + select="concat(substring-before(substring-after(., 'content/'), '.xml'), '.html')"/> + </xsl:apply-templates> + </xsl:if> </xsl:for-each> </portal> </xsl:template> @@ -85,23 +89,15 @@ </xsl:template> <xsl:template match="item" mode="news"> - <xsl:param name="link"/> + <xsl:param name="link"/> - <!-- date cannot be compared (to current date) in xslt 1.0 without a param handed over --> - <!-- current-date() as of XSLT 2.0 --> - <!-- - <xsl:if test="{@date}"> - --> - <item date="{@date}" class="news"> - <header>News</header> - <footer>by <xsl:value-of select="@author"/></footer> - <content-text><xsl:value-of select="@title"/></content-text> - <xsl:apply-templates select=".//image[1]" mode="news"/> - <link><xsl:value-of select="$link"/></link> - </item> - <!-- - </xsl:if> - --> + <item date="{@date}" class="news"> + <header>News</header> + <footer>by <xsl:value-of select="@author"/></footer> + <content-text><xsl:value-of select="@title"/></content-text> + <xsl:apply-templates select=".//image[1]" mode="news"/> + <link><xsl:value-of select="$link"/></link> + </item> </xsl:template> <xsl:template match="item/image[1]" mode="news"> diff --git a/xsl/rss.xsl b/xsl/rss.xsl index 3806e2d50..0c2529032 100644 --- a/xsl/rss.xsl +++ b/xsl/rss.xsl @@ -39,8 +39,8 @@ <xsl:sort select="date:seconds(document(.)/item/@date)" data-type="number" order="descending" /> <xsl:variable name="newsfile" select="."/> <xsl:if test="(position() <= $maxitems) and - starts-with(substring-after(substring-after($newsfile, '/'), '/'), $prefix)"> - + starts-with(substring-after(substring-after($newsfile, '/'), '/'), $prefix) and + starts-with(date:difference(date:date-time(), document(.)/item/@date), '-')"> <xsl:apply-templates select="document(.)/item"> <xsl:with-param name="newsfile" select="$newsfile"/> </xsl:apply-templates> diff --git a/xsl/xhtml5.xsl b/xsl/xhtml5.xsl index 8547de3cd..606fb7ed3 100644 --- a/xsl/xhtml5.xsl +++ b/xsl/xhtml5.xsl @@ -135,7 +135,14 @@ <xsl:for-each select="newsfile"> <xsl:sort select="date:seconds(document(concat('../', .))/item/@date)" data-type="number" order="descending" /> - <xsl:if test="position() <= 10"> + <xsl:if test="position() <= 10 and + not(starts-with( + date:difference( + document(concat('../', .))/item/@date, + date:date-time() + ), + '-' + ))"> <xsl:variable name="newsfile"><xsl:value-of select="."/></xsl:variable> <xsl:variable name="itemposition" select="position()"/> @@ -252,7 +259,17 @@ <xsl:variable name="newsfile" select="."/> <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) > 0))"> + <xsl:if test="((string-length($prefix) = 0) or + starts-with($newsfile, concat('content/news/', $prefix))) and + (($details != 'resources-only') or + (count(resource) > 0)) and + starts-with( + date:difference( + document(concat('../', .))/item/@date, + date:date-time() + ), + '-' + )"> <div> <xsl:if test="($details = 'event') and event">