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:output method="xml" indent="yes"/>
28 <xsl:variable name="twitterBaseURL">
29 <xsl:text>https://twitter.com</xsl:text>
32 <xsl:variable name="screen-name" select="//div[@class='profile-card-inner']/@data-screen-name"/>
34 <!-- TODO: make URLs hyperlinked (http://www.dpawson.co.uk/xsl/rev2/regex2.html) -->
35 <xsl:template name="tweet" match="//p[@class='js-tweet-text tweet-text']">
36 <xsl:value-of select="$screen-name"/>: <xsl:value-of select=".//p[@class='js-tweet-text tweet-text']"/>
39 <xsl:template match="//div[@id='timeline']//ol[@id='stream-items-id']//li[@data-item-type='tweet']">
42 <xsl:call-template name="tweet"/>
45 <xsl:value-of select="$twitterBaseURL"/><xsl:value-of select=".//a[@class='details with-icn js-details']/@href"/>
48 <xsl:value-of select="php:functionString('formatDate', .//small[@class='time']//span/@data-time)"/>
51 <xsl:call-template name="tweet"/>
56 <xsl:template match="/">
60 <generator>Tweeper</generator>
62 <xsl:text>Twitter / </xsl:text><xsl:value-of select="$screen-name"/>
65 <xsl:value-of select="//link[@rel='canonical']/@href"/>
68 <xsl:value-of select="//meta[@name='description']/@content"/>
72 <xsl:value-of select="//a[@class='profile-picture media-thumbnail']/@href"/>
75 <xsl:apply-templates select="//div[@id='timeline']//ol[@id='stream-items-id']//li[@data-item-type='tweet']"/>