From: Antonio Ospite Date: Sat, 27 Jul 2013 11:24:44 +0000 (+0200) Subject: Make stylesheet file name parametric X-Git-Tag: v0.1~29 X-Git-Url: https://git.ao2.it/tweeper.git/commitdiff_plain/ef4f6c6fb10b121fa79a0d8b6ccd7930fec48591?hp=d8950b148c6396251ac2fbc6ff3caab3e32b56e3 Make stylesheet file name parametric The host is encoded in the file name, this is in order to support more sites with no changes to the code, all that is needed is just new stylesheets with the host in their filename following the scheme will: rss_converter_HOST.xsl Where HOST has the meaning of the "host" field in the return value of the PHP parse_url() function. --- diff --git a/rss_converter_twitter.com.xsl b/rss_converter_twitter.com.xsl new file mode 100644 index 0000000..6d72ceb --- /dev/null +++ b/rss_converter_twitter.com.xsl @@ -0,0 +1,79 @@ + + + + + + + https://twitter.com + + + + + + + + + <xsl:value-of select="concat($screen-name, ': ')"/> + <xsl:value-of select="$tweet-text"/> + + + + + + + + + + <![CDATA[ + + ]]> + + + + + + + + + Tweeper + + <xsl:text>Twitter / </xsl:text><xsl:value-of select="$screen-name"/> + + + + + + + + + + + + + + + + + diff --git a/tweeper.php b/tweeper.php index a275a64..4050100 100755 --- a/tweeper.php +++ b/tweeper.php @@ -95,14 +95,9 @@ $url = parse_url($src_url); if (FALSE === $url || empty($url["host"])) die("Invalid url\n"); -$stylesheets = array( - "twitter.com" => "twitter_user_timeline2rss.xsl", -); - -if (FALSE === array_key_exists($url["host"], $stylesheets)) +$stylesheet = "rss_converter_" . $url["host"] . ".xsl"; +if (FALSE === file_exists($stylesheet)) die("Unsupported host\n"); -$stylesheet = $stylesheets[$url["host"]]; - $tweeper = new Tweeper($stylesheet); echo $tweeper->tweep($src_url); diff --git a/twitter_user_timeline2rss.xsl b/twitter_user_timeline2rss.xsl deleted file mode 100644 index 6d72ceb..0000000 --- a/twitter_user_timeline2rss.xsl +++ /dev/null @@ -1,79 +0,0 @@ - - - - - - - https://twitter.com - - - - - - - - - <xsl:value-of select="concat($screen-name, ': ')"/> - <xsl:value-of select="$tweet-text"/> - - - - - - - - - - <![CDATA[ - - ]]> - - - - - - - - - Tweeper - - <xsl:text>Twitter / </xsl:text><xsl:value-of select="$screen-name"/> - - - - - - - - - - - - - - - - -