rss_converter_facebook.com.xsl: fix getting the item description
authorAntonio Ospite <ao2@ao2.it>
Sun, 15 May 2016 13:52:10 +0000 (15:52 +0200)
committerAntonio Ospite <ao2@ao2.it>
Sun, 15 May 2016 13:52:10 +0000 (15:52 +0200)
Hopefully this is a more stable way to get just the useful content of
a story skipping the header and the footer.

rss_converter_facebook.com.xsl

index 347f1e4..984d12c 100644 (file)
 
     <xsl:template match="//div[contains(@class, 'userContentWrapper')]">
         <xsl:variable name="story-id" select=".//input[@name='ft_ent_identifier']/@value"/>
 
     <xsl:template match="//div[contains(@class, 'userContentWrapper')]">
         <xsl:variable name="story-id" select=".//input[@name='ft_ent_identifier']/@value"/>
-        <xsl:variable name="item-content" select=".//div[contains(@class, 'userContent')]"/>
         <xsl:variable
             name="item-permalink"
             select="concat($BaseURL, '/permalink.php?id=', $page-id, '&amp;story_fbid=', $story-id)"/>
 
         <xsl:variable
             name="item-permalink"
             select="concat($BaseURL, '/permalink.php?id=', $page-id, '&amp;story_fbid=', $story-id)"/>
 
+        <!-- Get only the first child in order to skip the footer of the content -->
+        <xsl:variable name="item-content" select="div[1]"/>
+
         <item>
             <title>
         <item>
             <title>
-                <xsl:variable name="item-title" select="$item-content/p"/>
+                <xsl:variable name="item-title" select="$item-content//p"/>
                 <xsl:variable name="title-length" select="140"/>
                 <!-- ellipsize, inspired from http://stackoverflow.com/questions/13622338 -->
                 <xsl:choose>
                 <xsl:variable name="title-length" select="140"/>
                 <!-- ellipsize, inspired from http://stackoverflow.com/questions/13622338 -->
                 <xsl:choose>
                 <xsl:value-of select="php:functionString('Tweeper::epoch_to_gmdate', number($timestamp))"/>
             </pubDate>
             <description>
                 <xsl:value-of select="php:functionString('Tweeper::epoch_to_gmdate', number($timestamp))"/>
             </pubDate>
             <description>
+
+                <!--
+                     Get only the children starting from the one with class="userContent",
+                     this way the content header is skipped
+                -->
+                <xsl:variable
+                    name="usercontent-position"
+                    select="count($item-content/div[contains(@class, 'userContent')]/preceding-sibling::*) + 1"/>
+
                 <xsl:text disable-output-escaping="yes">&lt;![CDATA[</xsl:text>
                 <xsl:text disable-output-escaping="yes">&lt;![CDATA[</xsl:text>
-                <xsl:copy-of select="$item-content/node()"/>
-                <xsl:copy-of select=".//div[@class='mtm']/node()"/>
+                <xsl:copy-of select="$item-content/div[position() >= $usercontent-position]"/>
                 <xsl:text disable-output-escaping="yes">]]&gt;</xsl:text>
             </description>
         </item>
                 <xsl:text disable-output-escaping="yes">]]&gt;</xsl:text>
             </description>
         </item>