X-Git-Url: https://git.ao2.it/tweeper.git/blobdiff_plain/481f2d015d14180be9982ced2f281494e0ec3855..2eb4e1d36fcc9c6a251b3ec33ef46920d18cb7f8:/rss_converter_facebook.com.xsl diff --git a/rss_converter_facebook.com.xsl b/rss_converter_facebook.com.xsl index b50be3d..418b3d2 100644 --- a/rss_converter_facebook.com.xsl +++ b/rss_converter_facebook.com.xsl @@ -42,12 +42,28 @@ <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:variable name="item-content" select=".//div[contains(@class, 'userContent')]"/> - <xsl:variable name="item-permalink" select="concat($BaseURL, .//a[@target='']/@href)"/> + <xsl:variable name="story-id" select=".//input[@name='ft_ent_identifier']/@value"/> + <xsl:variable + name="item-permalink" + select="concat($BaseURL, '/permalink.php?id=', $page-id, '&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> - <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> @@ -69,20 +85,28 @@ </guid> <pubDate> <xsl:variable name="timestamp" select=".//abbr[@data-shorten]/@data-utime"/> - <xsl:value-of select="php:functionString('Tweeper::epoch_to_gmdate', number($timestamp))"/> + <xsl:value-of select="php:functionString('Tweeper::epochToRssDate', $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"><![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">]]></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="//meta[@property='og:url']/@content"/> + <xsl:variable name="channel-title" select="//title"/> + <xsl:variable name="channel-link" select="//div[contains(@class, 'userContentWrapper')][1]//a[1]/@href"/> <rss version="2.0"> <xsl:attribute name="xml:base"><xsl:value-of select="$BaseURL" /></xsl:attribute> @@ -95,7 +119,9 @@ <xsl:value-of select="$channel-link"/> </link> <description> - <xsl:value-of select="normalize-space(//meta[@property='og:description']/@content)"/> + <xsl:text disable-output-escaping="yes"><![CDATA[</xsl:text> + <xsl:copy-of select="//div[@data-id='1']/node()"/> + <xsl:text disable-output-escaping="yes">]]></xsl:text> </description> <image> <title>