From: Antonio Ospite <ao2@ao2.it> Date: Fri, 27 Feb 2015 12:10:20 +0000 (+0100) Subject: rss_converter_twitter.com.xsl: make the feed validate with feedvalidator.org X-Git-Tag: v0.4~46 X-Git-Url: https://git.ao2.it/tweeper.git/commitdiff_plain/72485ebd9b564be20255a3377d381dc1b94c0359?hp=19d2c915502213e887ba7fd75c2e6b52400cd6d1 rss_converter_twitter.com.xsl: make the feed validate with feedvalidator.org Make the Twitter feed validate with http://feedvalidator.org and also improve compatibility by providing a guid and by excluding the weird xmlns:php namespace in the output. --- diff --git a/rss_converter_twitter.com.xsl b/rss_converter_twitter.com.xsl index a5f3c4b..76937e4 100644 --- a/rss_converter_twitter.com.xsl +++ b/rss_converter_twitter.com.xsl @@ -21,7 +21,8 @@ <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:php="http://php.net/xsl" - xsl:extension-element-prefixes="php"> + xsl:extension-element-prefixes="php" + exclude-result-prefixes="php"> <xsl:param name="generateEnclosure"/> @@ -40,13 +41,17 @@ <xsl:template match="//*[@data-item-type='tweet']"> <xsl:variable name="user-name" select=".//div[contains(@class, 'js-stream-tweet')]/@data-screen-name"/> <xsl:variable name="tweet-text" select=".//p[contains(@class, 'js-tweet-text')]"/> + <xsl:variable name="tweet-permalink" select="concat($twitterBaseURL, .//a[contains(@class, 'js-permalink')]/@href)"/> <item> <title> <xsl:value-of select="concat($user-name, ': ', $tweet-text)"/> </title> <link> - <xsl:value-of select="concat($twitterBaseURL, .//a[contains(@class, 'js-permalink')]/@href)"/> + <xsl:value-of select="$tweet-permalink"/> </link> + <guid> + <xsl:value-of select="$tweet-permalink"/> + </guid> <pubDate> <xsl:variable name="timestamp" select=".//span[contains(@class, 'js-short-timestamp')]/@data-time"/> <xsl:value-of select="php:functionString('Tweeper::epoch_to_gmdate', number($timestamp))"/> @@ -64,21 +69,29 @@ </xsl:template> <xsl:template match="/"> + <xsl:variable name="channel-title" select="concat('Twitter / ', $screen-name)"/> + <xsl:variable name="channel-link" select="//link[@rel='canonical']/@href"/> <rss version="2.0"> <xsl:attribute name="xml:base"><xsl:value-of select="$twitterBaseURL" /></xsl:attribute> <channel> <generator>Tweeper</generator> <title> - <xsl:text>Twitter / </xsl:text><xsl:value-of select="$screen-name"/> + <xsl:value-of select="$channel-title"/> </title> <link> - <xsl:value-of select="//link[@rel='canonical']/@href"/> + <xsl:value-of select="$channel-link"/> </link> <description> <xsl:value-of select="//meta[@name='description']/@content"/> </description> <image> + <title> + <xsl:value-of select="$channel-title"/> + </title> + <link> + <xsl:value-of select="$channel-link"/> + </link> <url> <xsl:value-of select="//a[contains(@class, 'profile-picture media-thumbnail')]/@href"/> </url>