2 Stylesheet to convert Twitter user timelines to RSS.
4 Copyright (C) 2013 Antonio Ospite <ospite@studenti.unina.it>
6 This file is part of tweeper.
8 This program is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
21 <xsl:stylesheet version="1.0"
22 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
23 xmlns:php="http://php.net/xsl"
24 xsl:extension-element-prefixes="php">
26 <xsl:param name="generateEnclosure"/>
28 <xsl:output method="xml" indent="yes"/>
30 <xsl:variable name="twitterBaseURL">
31 <xsl:text>https://twitter.com</xsl:text>
34 <xsl:template match="a[@data-expanded-url]">
35 <xsl:value-of disable-output-escaping="yes" select="php:function('Tweeper::generate_enclosure', string(./@data-expanded-url))"/>
38 <xsl:variable name="screen-name" select="//div[@class='profile-card-inner']/@data-screen-name"/>
40 <xsl:template match="//div[@id='timeline']//ol[@id='stream-items-id']//li[@data-item-type='tweet']">
41 <xsl:variable name="user-name" select=".//span[@class='username js-action-profile-name']/b"/>
42 <xsl:variable name="tweet-text" select=".//p[@class='js-tweet-text tweet-text']"/>
45 <xsl:value-of select="concat($user-name, ': ', $tweet-text)"/>
48 <xsl:value-of select="concat($twitterBaseURL, .//a[@class='details with-icn js-details']/@href)"/>
51 <xsl:value-of select="php:functionString('Tweeper::epoch_to_gmdate', .//small[@class='time']//span/@data-time)"/>
54 <xsl:value-of select="concat($user-name, ': ')"/>
55 <xsl:text disable-output-escaping="yes"><![CDATA[</xsl:text>
56 <xsl:copy-of select="$tweet-text/node()"/>
57 <xsl:text disable-output-escaping="yes">]]></xsl:text>
59 <xsl:if test="$generateEnclosure = 1">
60 <xsl:apply-templates select="$tweet-text//a[@data-expanded-url]"/>
65 <xsl:template match="/">
68 <xsl:attribute name="xml:base"><xsl:value-of select="$twitterBaseURL" /></xsl:attribute>
70 <generator>Tweeper</generator>
72 <xsl:text>Twitter / </xsl:text><xsl:value-of select="$screen-name"/>
75 <xsl:value-of select="//link[@rel='canonical']/@href"/>
78 <xsl:value-of select="//meta[@name='description']/@content"/>
82 <xsl:value-of select="//a[@class='profile-picture media-thumbnail']/@href"/>
85 <xsl:apply-templates select="//div[@id='timeline']//ol[@id='stream-items-id']//li[@data-item-type='tweet']"/>