summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2014-09-22 16:22:38 +0200
committerNatanael Copa <ncopa@alpinelinux.org>2014-09-22 16:22:38 +0200
commit9fd9c75ecdfdcbcadd82c5b757ea94f8b00fabb7 (patch)
tree81528ee12ac8884af0c11ac1f2bcec2489f095b2
parentce5059939a5ec3ce7e898d5cb928be666ef68828 (diff)
downloadmksite-alpine-9fd9c75ecdfdcbcadd82c5b757ea94f8b00fabb7.tar.bz2
mksite-alpine-9fd9c75ecdfdcbcadd82c5b757ea94f8b00fabb7.tar.xz
fetch last git commits from atom feed
It might be nice to have a general RSS atom feed importer since it can be reused for bugs and other things
-rw-r--r--Makefile15
-rw-r--r--_scripts/atom-to-yaml.xsl54
-rw-r--r--index.md8
3 files changed, 71 insertions, 6 deletions
diff --git a/Makefile b/Makefile
index 09ffb9e..35e05e0 100644
--- a/Makefile
+++ b/Makefile
@@ -6,9 +6,11 @@ pages := $(patsubst %.md,$(out)/%.html, $(md_sources))
static_sources := $(shell find _static -type f)
static_out := $(patsubst _static/%,$(out)/%,$(static_sources))
+git_atom_url := http://git.alpinelinux.org/cgit/aports/atom
+
all: $(pages) $(static_out)
-$(out)/index.html: release.yaml last5.yaml
+$(out)/index.html: release.yaml git-commits.yaml
$(out)/%.html: %.md _default.template.html
mkdir -p $(dir $@)
@@ -34,4 +36,13 @@ release.yaml: latest-releases.yaml
update-release:
rm -f latest-releases.yaml
- $(MAKE) release.yaml
+ $(MAKE)
+
+git-commits.yaml: _scripts/atom-to-yaml.xsl
+ curl $(git_atom_url) | xsltproc _scripts/atom-to-yaml.xsl - > $@.tmp
+ mv $@.tmp $@
+
+update-git-commits:
+ rm -f git-commits.yaml
+ $(MAKE)
+
diff --git a/_scripts/atom-to-yaml.xsl b/_scripts/atom-to-yaml.xsl
new file mode 100644
index 0000000..6c9a5e7
--- /dev/null
+++ b/_scripts/atom-to-yaml.xsl
@@ -0,0 +1,54 @@
+<xsl:stylesheet
+ version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:atom="http://www.w3.org/2005/Atom"
+ exclude-result-prefixes="atom"
+>
+<xsl:output omit-xml-declaration="yes"/>
+<xsl:template match="/">
+---
+<xsl:apply-templates select="atom:feed/atom:entry" />
+---
+</xsl:template>
+ <xsl:template name="escapeQuotes">
+ <xsl:param name="txt"/>
+ <xsl:variable name="backSlashQuote">&#92;&#39;</xsl:variable>
+ <xsl:variable name="singleQuote">&#39;</xsl:variable>
+
+ <xsl:choose>
+ <xsl:when test="string-length($txt) = 0">
+ <!-- ... -->
+ </xsl:when>
+
+ <xsl:when test="contains($txt, $singleQuote)">
+ <xsl:value-of disable-output-escaping="yes" select="concat(substring-before($txt, $singleQuote), $backSlashQuote)"/>
+
+ <xsl:call-template name="escapeQuotes">
+ <xsl:with-param name="txt" select="substring-after($txt, $singleQuote)"/>
+ </xsl:call-template>
+ </xsl:when>
+
+ <xsl:otherwise>
+ <xsl:value-of disable-output-escaping="yes" select="$txt"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+<xsl:template match="atom:entry">
+-
+ title: '<xsl:call-template name="escapeQuotes">
+ <xsl:with-param name="txt" select="atom:title"/>
+ </xsl:call-template>'
+ id: '<xsl:call-template name="escapeQuotes">
+ <xsl:with-param name="txt" select="atom:id"/>
+ </xsl:call-template>'
+ author_name: '<xsl:call-template name="escapeQuotes">
+ <xsl:with-param name="txt" select="atom:author/atom:name"/>
+ </xsl:call-template>'
+ author_email: '<xsl:value-of select="atom:author/atom:email"/>'
+ published: <xsl:value-of select="atom:published"/>
+ updated: <xsl:value-of select="atom:updated"/>
+ link: <xsl:value-of select="atom:link/@href"/>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/index.md b/index.md
index a88752d..c693d20 100644
--- a/index.md
+++ b/index.md
@@ -46,12 +46,12 @@ This site is under [development](http://git.alpinelinux.org/cgit/ncopa/mksite-al
<div class="block2">
<h3><span class="icon-archive"></span> Latest Development</h3>
<table>
-{{#last5}}
+{{#git-commits}}
<tr>
- <td>{{commitdate}}</td>
- <td><a href="http://git.alpinelinux.org/cgit/ncopa/mksite-alpine/commit/?id={{commit}}">{{subject}}</a></td>
+ <td><time datetime="{{updated}}">{{updated}}</time></td>
+ <td><a href="{{link}}">{{title}}</a></td>
</tr>
-{{/last5}}
+{{/git-commits}}
</table>
</div>
</div>