about summary refs log tree commit diff homepage
path: root/atom.xslt
blob: 29d6ad501a5d807173fcc9acedf5b667c4a9f97e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="atom.xslt"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns="http://www.w3.org/2005/Atom">
  <xsl:output method="xml" indent="yes" encoding="UTF-8"/>
  <xsl:variable name="root">https://px.cnx.gdn/</xsl:variable>
  <xsl:template match="page">
    <xsl:variable name="base">
      <xsl:value-of select="$root"/>
      <xsl:value-of select="@curr"/>
      <xsl:text>/</xsl:text>
    </xsl:variable>
    <xsl:for-each select="post">
      <xsl:variable name="url">
        <xsl:value-of select="$base"/>
        <xsl:text>#</xsl:text>
        <xsl:value-of select="translate(@title, ' ', '-')"/>
      </xsl:variable>
      <entry xml:lang="{@lang}">
        <link rel="alternate" type="application/xhtml+xml" href="{$url}"/>
        <id><xsl:value-of select="$url"/></id>
        <title><xsl:value-of select="@title"/></title>
        <content type="xhtml">
          <div xmlns="http://www.w3.org/1999/xhtml">
            <xsl:for-each select="picture">
              <img alt="{@desc}" title="{@desc}"
                   src="{$base}{@filename}.jpg"/>
            </xsl:for-each>
          </div>
        </content>
        <updated><xsl:value-of select="time"/></updated>
      </entry>
    </xsl:for-each>
  </xsl:template>

  <xsl:template match="/">
    <feed xmlns="http://www.w3.org/2005/Atom">
      <link href="{$root}atom.xml" rel="self"/>
      <link href="{$root}"/>
      <id><xsl:value-of select="$root"/></id>
      <icon><xsl:value-of select="$root"/>favicon.png</icon>

      <title>pix by cnx</title>
      <author>
        <name>Nguyễn Gia Phong</name>
        <uri>https://cnx.gdn/</uri>
        <email>mcsinyx@disroot.org</email>
      </author>
      <rights>CC BY-SA 4.0</rights>
      <xsl:apply-templates select="document('00/index.xml')/page">
      </xsl:apply-templates>
      <xsl:apply-templates select="document('01/index.xml')/page">
      </xsl:apply-templates>
      <xsl:apply-templates select="document('02/index.xml')/page">
      </xsl:apply-templates>
      <xsl:apply-templates select="document('03/index.xml')/page">
      </xsl:apply-templates>
      <xsl:apply-templates select="document('04/index.xml')/page">
      </xsl:apply-templates>
      <xsl:apply-templates select="document('05/index.xml')/page">
      </xsl:apply-templates>
      <updated>2023-01-27T13:40:00Z</updated>
    </feed>
  </xsl:template>
</xsl:stylesheet>