start aggregating feeds for portal

This commit is contained in:
Astro 2013-10-29 02:42:40 +01:00
parent bfa9b0f147
commit decbdfc67b
5 changed files with 119 additions and 3 deletions

1
.gitignore vendored
View File

@ -7,6 +7,7 @@
/chaosupdates.xml
/chaosupdates.xml.orig
/calendar-summary.xml
/portal-*.xml
/content/datenspuren/schedule.xml
/content/static/datenspuren/2008/fahrplan/track/V*
/content/static/datenspuren/2007/fahrplan/track/V*

View File

@ -65,7 +65,8 @@ NEWSFILES:=build/news.html build/news-rss.xml build/news-atom.xml \
build/pentamusic-archiv.xml build/pentamedia-archiv.xml \
build/ical.ics build/xcal.xml build/reminders \
build/datenspuren/$(DS_YEAR)/news-rss.xml build/datenspuren/$(DS_YEAR)/news-atom.xml \
build/pentacast-ogg.xml build/pentacast-ogg-archiv.xml
build/pentacast-ogg.xml build/pentacast-ogg-archiv.xml \
build/portal.html
PLAYLISTS:=$(patsubst content/news/pentaradio%.xml, build/news/pentaradio%.xspf, $(wildcard content/news/pentaradio*.xml)) \
$(patsubst content/news/pentaradio%.xml, build/news/pentaradio%.pls, $(wildcard content/news/pentaradio*.xml)) \
$(patsubst content/news/pentaradio%.xml, build/news/pentaradio%.m3u, $(wildcard content/news/pentaradio*.xml))
@ -116,7 +117,6 @@ $(DATESTAMP):
build/%.html : NOVALID:=true
build/news.html: $(WWW_CCC_DE_UPDATES) $(CALENDAR_SUMMARY) $(DATESTAMP)
## Feedgrößen begrenzen
build/%.xml : MAX_ITEMS=23
build/%-archiv.xml build/news-archiv-%.xml : MAX_ITEMS=9999999
@ -214,6 +214,22 @@ build/%.xspf : VFLAGS_OUT=$(VFLAGS) --relaxng xsd/xspf-1_0.5.rng
build/%.m3u : NOVALID:=true
build/%.pls : NOVALID:=true
# Portal
portal:
mkdir $@
portal/fetch.sh : STYLE=xsl/portal2fetch.xsl
portal/fetch.sh : NOVALID:=true
portal/fetch.sh: content/portal-config.xml $(STYLE)
$(PROCESSOR) $(PFLAGS) -o $@ $(STYLE) $<
chmod a+x $@
portal/items.xml : STYLE=xsl/portal2items.xsl
portal/items.xml : NOVALID:=true
portal/items.xml: content/portal-config.xml $(STYLE) portal/fetch.sh news.xml
( cd portal && ./fetch.sh )
$(PROCESSOR) $(PFLAGS) -o $@ $(STYLE) $<
# Pages:
build/%.html: content/pages/%.xml $(STYLE) $(NAVIGATION) $(WWW_CCC_DE_UPDATES) $(CALENDAR_SUMMARY) $(DATESTAMP) news.xml
$(call xml_process)
@ -274,4 +290,4 @@ $(WWW_CCC_DE_UPDATES): $(WWW_CCC_DE_UPDATES).orig
.PHONY: clean
clean:
$(RM) $(CLEAN) news.xml
$(RM) -r portal

View File

@ -0,0 +1,6 @@
<config>
<gallery id="media-lachmoewe">https://media.c3d2.de/u/lachmoewe/atom/</gallery>
<gallery id="media-bigalex">https://media.c3d2.de/u/bigalex/atom/</gallery>
<gallery id="media-joerg">https://media.c3d2.de/u/joerg/atom/</gallery>
<wiki id="wiki">https://wiki.c3d2.de/w/index.php?title=Spezial:Letzte_%C3%84nderungen&amp;feed=atom&amp;days=60&amp;limit=30</wiki>
</config>

20
xsl/portal2fetch.xsl Normal file
View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" encoding="utf-8"/>
<xsl:template match="/config">
<xsl:text>#!/bin/sh&#10;</xsl:text>
<xsl:apply-templates select="*[@id]"/>
</xsl:template>
<xsl:template match="/config/*">
<xsl:text>wget -O portal-</xsl:text>
<xsl:value-of select="@id"/>
<xsl:text>.xml '</xsl:text>
<xsl:value-of select="string(.)"/>
<xsl:text>'&#10;</xsl:text>
</xsl:template>
</xsl:stylesheet>

73
xsl/portal2items.xsl Normal file
View File

@ -0,0 +1,73 @@
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="utf-8" indent="yes"/>
<xsl:template match="/config">
<portal>
<xsl:apply-templates select="*[@id]"/>
<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(., '.xml'), '.html')"/>
</xsl:apply-templates>
</xsl:for-each>
</portal>
</xsl:template>
<xsl:template match="/config/gallery">
<xsl:apply-templates select="document(concat('../portal/portal-', @id, '.xml'))/atom:feed/atom:entry" mode="gallery"/>
</xsl:template>
<xsl:template match="/config/wiki">
<xsl:apply-templates select="document(concat('../portal/portal-', @id, '.xml'))/atom:feed/atom:entry" mode="wiki"/>
</xsl:template>
<xsl:template match="*">
</xsl:template>
<xsl:template match="atom:entry" mode="gallery">
<item>
<header><xsl:value-of select="atom:title"/></header>
<footer><xsl:value-of select="atom:content[@type='html']" disable-output-escaping="yes"/></footer>
<date><xsl:value-of select="atom:updated"/></date>
<content-image><xsl:value-of select="atom:link[@rel='enclosure'][1]/@href"/></content-image>
<link><xsl:value-of select="atom:link[@rel='alternate'][1]/@href"/></link>
</item>
</xsl:template>
<xsl:template match="atom:entry" mode="wiki">
<item>
<header>C3D2 Wiki</header>
<footer>by <xsl:value-of select="atom:author/atom:name"/></footer>
<date><xsl:value-of select="atom:updated"/></date>
<content-text>[[<xsl:value-of select="atom:title"/>]]</content-text>
<link><xsl:value-of select="atom:link[@rel='alternate'][1]/@href"/></link>
</item>
</xsl:template>
<xsl:template match="item" mode="news">
<xsl:param name="link"/>
<item>
<header>News</header>
<footer>by <xsl:value-of select="@author"/></footer>
<date><xsl:value-of select="@date"/></date>
<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="image" mode="news">
<content-image>
<xsl:choose>
<xsl:when test="contains(., '//')"></xsl:when>
<xsl:otherwise>images/news/</xsl:otherwise>
</xsl:choose>
<xsl:value-of select="."/>
</content-image>
</xsl:template>
</xsl:stylesheet>