Use templates to generate enclosures
authorAntonio Ospite <ospite@studenti.unina.it>
Sun, 11 Aug 2013 11:43:05 +0000 (13:43 +0200)
committerAntonio Ospite <ospite@studenti.unina.it>
Sun, 11 Aug 2013 23:21:23 +0000 (01:21 +0200)
This has two benefits:
  - make it possible to handle multiple enclosures;
  - handle _only_ the anchors with the 'data-expanded-url' attribute,
    before the change every anchor with the 'twitter-timeline-link'
    attribute was handled.

The change also makes the DOM navigation a little lighter because now
only $tweet-text is searched for the 'data-expanded-url' attribute.

rss_converter_twitter.com.xsl

index c7f03c2..280342e 100644 (file)
         <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('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']">
@@ -49,7 +53,7 @@
                 <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:apply-templates select="$tweet-text//a[@data-expanded-url]"/>
         </item>
     </xsl:template>