rss_converter_twitter.com.xsl: cleanup titles
[tweeper.git] / rss_converter_twitter.com.xsl
index 59c29bb..b7c7124 100644 (file)
@@ -33,7 +33,7 @@
     </xsl:variable>
 
     <xsl:template match="a[@data-expanded-url]">
-        <xsl:value-of disable-output-escaping="yes" select="php:function('Tweeper::generateEnclosure', string(./@data-expanded-url))"/>
+        <xsl:copy-of select="php:function('Tweeper::generateEnclosure', string(./@data-expanded-url))"/>
     </xsl:template>
 
     <xsl:variable name="screen-name" select="//div[@class='user-actions btn-group not-following ']/@data-screen-name"/>
         <xsl:variable name="item-permalink" select="concat($BaseURL, .//div[@data-permalink-path]/@data-permalink-path)"/>
         <item>
             <title>
-                <xsl:value-of select="concat($user-name, ': ', $item-content)"/>
+                <xsl:value-of select="concat($user-name, ': ')"/>
+                <!--
+                     Prepend a space in front of the URLs which are not
+                     preceded by an open parenthesis, for aestethic reasons.
+                     Also, regex, I know: http://xkcd.com/1171/
+                -->
+                <xsl:variable
+                    name="processed-title"
+                    select="php:function('preg_replace', '@((?&lt;!\()(?:http[s]?://|pic.twitter.com))@', ' \1', string($item-content))"/>
+                <!-- Also strip &nbsp; and &hellip; -->
+                <xsl:value-of select="normalize-space(translate($processed-title, '&#xA0;&#x2026;', ''))"/>
             </title>
             <link>
                 <xsl:value-of select="$item-permalink"/>
@@ -54,7 +64,7 @@
             </guid>
             <pubDate>
                 <xsl:variable name="timestamp" select=".//span[contains(@class, 'js-short-timestamp')]/@data-time"/>
-                <xsl:value-of select="php:functionString('Tweeper::epochToGmdate', number($timestamp))"/>
+                <xsl:value-of select="php:functionString('Tweeper::epochToRssDate', number($timestamp))"/>
             </pubDate>
             <description>
                 <xsl:value-of select="concat($user-name, ': ')"/>