rss_converter_dilbert.com.xsl: fixes for the new dilbert.com
authorAntonio Ospite <ao2@ao2.it>
Fri, 27 Feb 2015 12:58:33 +0000 (13:58 +0100)
committerAntonio Ospite <ao2@ao2.it>
Fri, 27 Feb 2015 13:01:01 +0000 (14:01 +0100)
Make the stylesheet work again with the new dilbert.com website.

rss_converter_dilbert.com.xsl

index 82c33f2..a12c44e 100644 (file)
 
     <xsl:output method="xml" indent="yes"/>
 
 
     <xsl:output method="xml" indent="yes"/>
 
-    <xsl:variable name="BaseURL" select="concat('http://', //meta[@property='og:site_name']/@content)"/>
+    <xsl:variable name="BaseURL" select="//meta[@property='og:url']/@content"/>
 
 
-    <xsl:template match="//a[@id='strip_zoom']">
-        <xsl:variable name="picture-id" select="substring-after(./@href, '#')"/>
-        <xsl:variable name="picture-element" select="//div[@id=$picture-id]/img"/>
-        <xsl:variable name="picture-print-url" select="php:functionString('str_replace', 'zoom', 'print', $picture-element/@src)"/>
+    <xsl:template match="//section[@class='comic-item']">
+        <xsl:variable name="item-permalink" select=".//a[@class='img-comic-link']/@href"/>
+        <xsl:variable name="picture-url" select=".//img[@class='img-responsive img-comic']/@src"/>
+        <xsl:variable name="picture-title" select=".//img[@class='img-responsive img-comic']/@alt"/>
         <item>
             <title>
         <item>
             <title>
-                <xsl:value-of select="$picture-element/@title"/>
+                <xsl:value-of select="$picture-title"/>
             </title>
             <link>
             </title>
             <link>
-                <xsl:value-of select="concat($BaseURL, $picture-element/@src)"/>
+                <xsl:value-of select="$item-permalink"/>
             </link>
             <pubDate>
             </link>
             <pubDate>
-                <xsl:value-of select="php:functionString('Tweeper::str_to_gmdate', substring-after($picture-id, 'strip_enlarged_'))"/>
+                <xsl:value-of select="php:functionString('Tweeper::str_to_gmdate', normalize-space(.//date))"/>
             </pubDate>
             <description>
                 <xsl:text disable-output-escaping="yes">&lt;![CDATA[</xsl:text>
             </pubDate>
             <description>
                 <xsl:text disable-output-escaping="yes">&lt;![CDATA[</xsl:text>
-                <img src="{$picture-print-url}" />
+                <img src="{$picture-url}" />
                 <xsl:text disable-output-escaping="yes">]]&gt;</xsl:text>
             </description>
         </item>
     </xsl:template>
 
     <xsl:template match="/">
                 <xsl:text disable-output-escaping="yes">]]&gt;</xsl:text>
             </description>
         </item>
     </xsl:template>
 
     <xsl:template match="/">
+        <xsl:variable name="channel-title" select="//meta[@property='og:title']/@content"/>
+        <xsl:variable name="channel-link" select="$BaseURL"/>
 
         <rss version="2.0">
             <xsl:attribute name="xml:base"><xsl:value-of select="$BaseURL" /></xsl:attribute>
             <channel>
                 <generator>Tweeper</generator>
                 <title>
 
         <rss version="2.0">
             <xsl:attribute name="xml:base"><xsl:value-of select="$BaseURL" /></xsl:attribute>
             <channel>
                 <generator>Tweeper</generator>
                 <title>
-                    <xsl:value-of select="//meta[@property='og:title']/@content"/>
+                    <xsl:value-of select="$channel-title"/>
                 </title>
                 <link>
                 </title>
                 <link>
-                    <xsl:value-of select="$BaseURL"/>
+                    <xsl:value-of select="$channel-link"/>
                 </link>
                 <description>
                     <xsl:value-of select="//meta[@property='og:description']/@content"/>
                 </description>
                 <image>
                     <url>
                 </link>
                 <description>
                     <xsl:value-of select="//meta[@property='og:description']/@content"/>
                 </description>
                 <image>
                     <url>
-                        <xsl:value-of select="//meta[@property='og:image']/@content"/>
+                        <xsl:value-of select="concat($BaseURL, //img[@alt='Dilbert logo']/@src)"/>
                     </url>
                 </image>
                     </url>
                 </image>
-                <xsl:apply-templates select="//a[@id='strip_zoom']"/>
+                <xsl:apply-templates select="//section[@class='comic-item']"/>
             </channel>
         </rss>
     </xsl:template>
             </channel>
         </rss>
     </xsl:template>