Add a NEWS file
[tweeper.git] / rss_converter_twitter.com.xsl
index c7f03c2..09ba933 100644 (file)
     xmlns:php="http://php.net/xsl"
     xsl:extension-element-prefixes="php">
 
+    <xsl:param name="generateEnclosure"/>
+
     <xsl:output method="xml" indent="yes"/>
 
     <xsl:variable name="twitterBaseURL">
         <xsl:text>https://twitter.com</xsl:text>
     </xsl:variable>
 
+    <xsl:template match="a[@data-expanded-url]">
+        <xsl:value-of disable-output-escaping="yes" select="php:function('Tweeper::generate_enclosure', string(./@data-expanded-url))"/>
+    </xsl:template>
+
     <xsl:variable name="screen-name" select="//div[@class='profile-card-inner']/@data-screen-name"/>
 
     <xsl:template match="//div[@id='timeline']//ol[@id='stream-items-id']//li[@data-item-type='tweet']">
+        <xsl:variable name="user-name" select=".//span[@class='username js-action-profile-name']/b"/>
         <xsl:variable name="tweet-text" select=".//p[@class='js-tweet-text tweet-text']"/>
         <item>
             <title>
-                <xsl:value-of select="concat($screen-name, ': ', $tweet-text)"/>
+                <xsl:value-of select="concat($user-name, ': ', $tweet-text)"/>
             </title>
             <link>
                 <xsl:value-of select="concat($twitterBaseURL, .//a[@class='details with-icn js-details']/@href)"/>
             </link>
             <pubDate>
-                <xsl:value-of select="php:functionString('epoch_to_gmdate', .//small[@class='time']//span/@data-time)"/>
+                <xsl:value-of select="php:functionString('Tweeper::epoch_to_gmdate', .//small[@class='time']//span/@data-time)"/>
             </pubDate>
             <description>
-                <xsl:value-of select="concat($screen-name, ': ')"/>
+                <xsl:value-of select="concat($user-name, ': ')"/>
                 <xsl:text disable-output-escaping="yes">&lt;![CDATA[</xsl:text>
                 <xsl:copy-of select="$tweet-text/node()"/>
                 <xsl:text disable-output-escaping="yes">]]&gt;</xsl:text>
             </description>
-            <xsl:value-of disable-output-escaping="yes" select="php:function('generate_enclosure', string(.//a[@class='twitter-timeline-link']/@data-expanded-url))"/>
+            <xsl:if test="$generateEnclosure = 1">
+                <xsl:apply-templates select="$tweet-text//a[@data-expanded-url]"/>
+            </xsl:if>
         </item>
     </xsl:template>