summaryrefslogtreecommitdiff
path: root/plugins/SimpleUrl
diff options
context:
space:
mode:
authorEvan Prodromou <evan@status.net>2009-11-14 17:14:35 +0100
committerEvan Prodromou <evan@status.net>2009-11-14 17:14:35 +0100
commit959d278c347fdf90e0227adc57c0215f5d82404a (patch)
tree16eb3b0155b446ada520566e187b4c47b0b9e76b /plugins/SimpleUrl
parent093857c582a68b39e0d65523d27f25ede7b7fed6 (diff)
parent2147ac510f5489c860a4bebf3ab48a069b89ecfb (diff)
Merge branch '0.9.x' of git@gitorious.org:statusnet/mainline into 0.9.x
Diffstat (limited to 'plugins/SimpleUrl')
-rw-r--r--plugins/SimpleUrl/SimpleUrlPlugin.php41
1 files changed, 11 insertions, 30 deletions
diff --git a/plugins/SimpleUrl/SimpleUrlPlugin.php b/plugins/SimpleUrl/SimpleUrlPlugin.php
index d59d63e47..45b745b07 100644
--- a/plugins/SimpleUrl/SimpleUrlPlugin.php
+++ b/plugins/SimpleUrl/SimpleUrlPlugin.php
@@ -31,40 +31,21 @@ if (!defined('STATUSNET')) {
exit(1);
}
-class SimpleUrlPlugin extends Plugin
+require_once INSTALLDIR.'/plugins/UrlShortener/UrlShortenerPlugin.php';
+
+class SimpleUrlPlugin extends UrlShortenerPlugin
{
- function __construct()
- {
- parent::__construct();
- }
+ public $serviceUrl;
function onInitializePlugin(){
- $this->registerUrlShortener(
- 'is.gd',
- array(),
- array('SimpleUrl',array('http://is.gd/api.php?longurl='))
- );
- $this->registerUrlShortener(
- 'snipr.com',
- array(),
- array('SimpleUrl',array('http://snipr.com/site/snip?r=simple&link='))
- );
- $this->registerUrlShortener(
- 'metamark.net',
- array(),
- array('SimpleUrl',array('http://metamark.net/api/rest/simple?long_url='))
- );
- $this->registerUrlShortener(
- 'tinyurl.com',
- array(),
- array('SimpleUrl',array('http://tinyurl.com/api-create.php?url='))
- );
+ parent::onInitializePlugin();
+ if(!isset($this->serviceUrl)){
+ throw new Exception("must specify a serviceUrl");
+ }
}
-}
-class SimpleUrl extends ShortUrlApi
-{
- protected function shorten_imp($url) {
- return $this->http_get($url);
+ protected function shorten($url) {
+ return $this->http_get(sprintf($this->serviceUrl,urlencode($url)));
}
}
+