rss_converter_twitter.com.xsl: add a mode attribute to the enclosure template
[tweeper.git] / rss_converter_twitter.com.xsl
index 6ef86dd..1903607 100644 (file)
@@ -32,7 +32,7 @@
         <xsl:text>https://twitter.com</xsl:text>
     </xsl:variable>
 
-    <xsl:template match="a[@data-expanded-url]">
+    <xsl:template match="a[@data-expanded-url]" mode="enclosure">
         <xsl:copy-of select="php:function('Tweeper::generateEnclosure', string(./@data-expanded-url))"/>
     </xsl:template>
 
         <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"/>
@@ -63,7 +73,7 @@
                 <xsl:text disable-output-escaping="yes">]]&gt;</xsl:text>
             </description>
             <xsl:if test="$generate-enclosure = 1">
-                <xsl:apply-templates select="$item-content//a[@data-expanded-url]"/>
+                <xsl:apply-templates select="$item-content//a[@data-expanded-url]" mode="enclosure"/>
             </xsl:if>
         </item>
     </xsl:template>