rss_converter_facebook.com.xsl: fix the permalink
authorAntonio Ospite <ao2@ao2.it>
Sun, 15 May 2016 13:34:13 +0000 (15:34 +0200)
committerAntonio Ospite <ao2@ao2.it>
Sun, 15 May 2016 13:41:15 +0000 (15:41 +0200)
Use the page id and the story id to build a more robust permalink URL.

rss_converter_facebook.com.xsl

index 9fbc187..347f1e4 100644 (file)
         <xsl:text>https://facebook.com</xsl:text>
     </xsl:variable>
 
         <xsl:text>https://facebook.com</xsl:text>
     </xsl:variable>
 
+    <!--
+         Extract the page id from an element like:
+        <meta property="al:android:url" content="fb://page/793837197390834">
+
+        The page id will be used to build the permalink.
+    -->
+    <xsl:variable
+        name="page-id"
+        select="substring-after(//meta[@property='al:android:url']/@content, 'fb://page/')"/>
+
     <xsl:template match="//div[contains(@class, 'userContentWrapper')]">
     <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-content" select=".//div[contains(@class, 'userContent')]"/>
-        <xsl:variable name="item-permalink" select="concat($BaseURL, .//a[@target='']/@href)"/>
+        <xsl:variable
+            name="item-permalink"
+            select="concat($BaseURL, '/permalink.php?id=', $page-id, '&amp;story_fbid=', $story-id)"/>
+
         <item>
             <title>
                 <xsl:variable name="item-title" select="$item-content/p"/>
         <item>
             <title>
                 <xsl:variable name="item-title" select="$item-content/p"/>