From: Antonio Ospite Date: Sat, 27 Jul 2013 14:51:38 +0000 (+0200) Subject: Add initial support for scraping Pump.io activity streams X-Git-Tag: v0.1~20 X-Git-Url: https://git.ao2.it/tweeper.git/commitdiff_plain/5bf4c1bdaf068d58e3141c0015d1b9341965b43b?ds=inline;hp=-c Add initial support for scraping Pump.io activity streams Use symlinks to represent alternate sites with the same structure (i.e. same server software). Symlinks are handy and concise, an alternative way would be to introduce some equivalence mapping, like in the patch below, but I don't really like that: diff --git a/tweeper.php b/tweeper.php index a019684..eb12af2 100755 --- a/tweeper.php +++ b/tweeper.php @@ -101,9 +101,18 @@ $url = parse_url($src_url); if (FALSE === $url || empty($url["host"])) die("Invalid url: $url\n"); -$stylesheet = __DIR__ . "/rss_converter_" . $url["host"] . ".xsl"; +$equivalence_map = array( + "identi.ca" => "pump.io" +); + +if (array_key_exists($url["host"], $equivalence_map)) + $host = $equivalence_map[$url["host"]]; +else + $host = $url["host"]; + +$stylesheet = __DIR__ . "/rss_converter_" . $host . ".xsl"; if (FALSE === file_exists($stylesheet)) - die("Conversion to RSS not supported: {$url["host"]}\n"); + die("Conversion to RSS not supported: {$host}\n"); $tweeper = new Tweeper($stylesheet); echo $tweeper->tweep($src_url); --- 5bf4c1bdaf068d58e3141c0015d1b9341965b43b diff --git a/rss_converter_identi.ca.xsl b/rss_converter_identi.ca.xsl new file mode 120000 index 0000000..d8042a1 --- /dev/null +++ b/rss_converter_identi.ca.xsl @@ -0,0 +1 @@ +rss_converter_pump.io.xsl \ No newline at end of file diff --git a/rss_converter_pump.io.xsl b/rss_converter_pump.io.xsl new file mode 100644 index 0000000..ef4b6e8 --- /dev/null +++ b/rss_converter_pump.io.xsl @@ -0,0 +1,75 @@ + + + + + + + + + + + + + <xsl:value-of select="concat($user-name, ': ', normalize-space($activity-text))"/> + + + + + + + + + + <![CDATA[ + + ]]> + + + + + + + + + Tweeper + + <xsl:value-of select="concat(substring-after($user-name, '@'), ' / ', substring-before($user-name, '@'))"/> + + + + + + + + + + + + + + + + +