summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/LilUrl/LilUrlPlugin.php64
-rw-r--r--plugins/LinkbackPlugin.php15
-rw-r--r--plugins/OpenID/openidlogin.php6
-rw-r--r--plugins/OpenID/openidsettings.php6
-rw-r--r--plugins/PtitUrl/PtitUrlPlugin.php62
-rw-r--r--plugins/PubSubHubBub/PubSubHubBubPlugin.php122
-rw-r--r--plugins/PubSubHubBub/publisher.php86
-rw-r--r--plugins/SimpleUrl/SimpleUrlPlugin.php79
-rw-r--r--plugins/TightUrl/TightUrlPlugin.php62
9 files changed, 498 insertions, 4 deletions
diff --git a/plugins/LilUrl/LilUrlPlugin.php b/plugins/LilUrl/LilUrlPlugin.php
new file mode 100644
index 000000000..7665b6c1e
--- /dev/null
+++ b/plugins/LilUrl/LilUrlPlugin.php
@@ -0,0 +1,64 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Plugin to push RSS/Atom updates to a PubSubHubBub hub
+ *
+ * PHP version 5
+ *
+ * LICENCE: This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @category Plugin
+ * @package StatusNet
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @copyright 2009 Craig Andrews http://candrews.integralblue.com
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://status.net/
+ */
+
+if (!defined('STATUSNET')) {
+ exit(1);
+}
+
+require_once(INSTALLDIR.'/lib/Shorturl_api.php');
+
+class LilUrlPlugin extends Plugin
+{
+ function __construct()
+ {
+ parent::__construct();
+ }
+
+ function onInitializePlugin(){
+ $this->registerUrlShortener(
+ 'ur1.ca',
+ array('freeService'=>true),
+ array('LilUrl',array('http://ur1.ca/'))
+ );
+ }
+}
+
+class LilUrl extends ShortUrlApi
+{
+ protected function shorten_imp($url) {
+ $data['longurl'] = $url;
+ $response = $this->http_post($data);
+ if (!$response) return $url;
+ $y = @simplexml_load_string($response);
+ if (!isset($y->body)) return $url;
+ $x = $y->body->p[0]->a->attributes();
+ if (isset($x['href'])) return $x['href'];
+ return $url;
+ }
+}
diff --git a/plugins/LinkbackPlugin.php b/plugins/LinkbackPlugin.php
index c49f70de0..60f7a60c7 100644
--- a/plugins/LinkbackPlugin.php
+++ b/plugins/LinkbackPlugin.php
@@ -75,6 +75,8 @@ class LinkbackPlugin extends Plugin
function linkbackUrl($url)
{
+ common_log(LOG_DEBUG,"Attempting linkback for " . $url);
+
$orig = $url;
$url = htmlspecialchars_decode($orig);
$scheme = parse_url($url, PHP_URL_SCHEME);
@@ -134,15 +136,20 @@ class LinkbackPlugin extends Plugin
"User-Agent: " . $this->userAgent(),
'content' => $request)));
$file = file_get_contents($endpoint, false, $context);
- $response = xmlrpc_decode($file);
- if (xmlrpc_is_fault($response)) {
+ if (!$file) {
common_log(LOG_WARNING,
+ "Pingback request failed for '$url' ($endpoint)");
+ } else {
+ $response = xmlrpc_decode($file);
+ if (xmlrpc_is_fault($response)) {
+ common_log(LOG_WARNING,
"Pingback error for '$url' ($endpoint): ".
"$response[faultString] ($response[faultCode])");
- } else {
- common_log(LOG_INFO,
+ } else {
+ common_log(LOG_INFO,
"Pingback success for '$url' ($endpoint): ".
"'$response'");
+ }
}
}
diff --git a/plugins/OpenID/openidlogin.php b/plugins/OpenID/openidlogin.php
index 07c82db3e..29e89234e 100644
--- a/plugins/OpenID/openidlogin.php
+++ b/plugins/OpenID/openidlogin.php
@@ -84,6 +84,12 @@ class OpenidloginAction extends Action
}
}
+ function showScripts()
+ {
+ parent::showScripts();
+ $this->autofocus('openid_url');
+ }
+
function title()
{
return _('OpenID Login');
diff --git a/plugins/OpenID/openidsettings.php b/plugins/OpenID/openidsettings.php
index 104ea8d88..3ad46f5f5 100644
--- a/plugins/OpenID/openidsettings.php
+++ b/plugins/OpenID/openidsettings.php
@@ -72,6 +72,12 @@ class OpenidsettingsAction extends AccountSettingsAction
' Manage your associated OpenIDs from here.');
}
+ function showScripts()
+ {
+ parent::showScripts();
+ $this->autofocus('openid_url');
+ }
+
/**
* Show the form for OpenID management
*
diff --git a/plugins/PtitUrl/PtitUrlPlugin.php b/plugins/PtitUrl/PtitUrlPlugin.php
new file mode 100644
index 000000000..f00d3e2f2
--- /dev/null
+++ b/plugins/PtitUrl/PtitUrlPlugin.php
@@ -0,0 +1,62 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Plugin to push RSS/Atom updates to a PubSubHubBub hub
+ *
+ * PHP version 5
+ *
+ * LICENCE: This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @category Plugin
+ * @package StatusNet
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @copyright 2009 Craig Andrews http://candrews.integralblue.com
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://status.net/
+ */
+
+if (!defined('STATUSNET')) {
+ exit(1);
+}
+
+class PtitUrlPlugin extends Plugin
+{
+ function __construct()
+ {
+ parent::__construct();
+ }
+
+ function onInitializePlugin(){
+ $this->registerUrlShortener(
+ 'ptiturl.com',
+ array(),
+ array('PtitUrl',array('http://ptiturl.com/?creer=oui&action=Reduire&url='))
+ );
+ }
+}
+
+class PtitUrl extends ShortUrlApi
+{
+ protected function shorten_imp($url) {
+ $response = $this->http_get($url);
+ if (!$response) return $url;
+ $response = $this->tidy($response);
+ $y = @simplexml_load_string($response);
+ if (!isset($y->body)) return $url;
+ $xml = $y->body->center->table->tr->td->pre->a->attributes();
+ if (isset($xml['href'])) return $xml['href'];
+ return $url;
+ }
+}
diff --git a/plugins/PubSubHubBub/PubSubHubBubPlugin.php b/plugins/PubSubHubBub/PubSubHubBubPlugin.php
new file mode 100644
index 000000000..013a234d7
--- /dev/null
+++ b/plugins/PubSubHubBub/PubSubHubBubPlugin.php
@@ -0,0 +1,122 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Plugin to push RSS/Atom updates to a PubSubHubBub hub
+ *
+ * PHP version 5
+ *
+ * LICENCE: This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @category Plugin
+ * @package StatusNet
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @copyright 2009 Craig Andrews http://candrews.integralblue.com
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://status.net/
+ */
+
+if (!defined('STATUSNET')) {
+ exit(1);
+}
+
+define('DEFAULT_HUB','http://2pubsubhubbub.appspot.com');
+
+require_once(INSTALLDIR.'/plugins/PubSubHubBub/publisher.php');
+
+class PubSubHubBubPlugin extends Plugin
+{
+ private $hub;
+
+ function __construct()
+ {
+ parent::__construct();
+ }
+
+ function onInitializePlugin(){
+ $this->hub = common_config('PubSubHubBub', 'hub');
+ if(empty($this->hub)){
+ $this->hub = DEFAULT_HUB;
+ }
+ }
+
+ function onStartApiAtom($action){
+ $action->element('link',array('rel'=>'hub','href'=>$this->hub),null);
+ }
+
+ function onStartApiRss($action){
+ $action->element('atom:link',array('rel'=>'hub','href'=>$this->hub),null);
+ }
+
+ function onEndNoticeSave($notice){
+ $publisher = new Publisher($this->hub);
+
+ $feeds = array();
+
+ //public timeline feeds
+ $feeds[]=common_local_url('api',array('apiaction' => 'statuses','method' => 'public_timeline.rss'));
+ $feeds[]=common_local_url('api',array('apiaction' => 'statuses','method' => 'public_timeline.atom'));
+
+ //author's own feeds
+ $user = User::staticGet('id',$notice->profile_id);
+ $feeds[]=common_local_url('api',array('apiaction' => 'statuses','method' => 'user_timeline','argument' => $user->nickname.'.rss'));
+ $feeds[]=common_local_url('api',array('apiaction' => 'statuses','method' => 'user_timeline','argument' => $user->nickname.'.atom'));
+
+ //tag feeds
+ $tag = new Notice_tag();
+ $tag->notice_id = $notice->id;
+ if ($tag->find()) {
+ while ($tag->fetch()) {
+ $feeds[]=common_local_url('api',array('apiaction' => 'tags','method' => 'timeline', 'argument'=>$tag->tag.'.atom'));
+ $feeds[]=common_local_url('api',array('apiaction' => 'tags','method' => 'timeline', 'argument'=>$tag->tag.'.rss'));
+ }
+ }
+
+ //group feeds
+ $group_inbox = new Group_inbox();
+ $group_inbox->notice_id = $notice->id;
+ if ($group_inbox->find()) {
+ while ($group_inbox->fetch()) {
+ $group = User_group::staticGet('id',$group_inbox->group_id);
+ $feeds[]=common_local_url('api',array('apiaction' => 'groups','method' => 'timeline','argument' => $group->nickname.'.rss'));
+ $feeds[]=common_local_url('api',array('apiaction' => 'groups','method' => 'timeline','argument' => $group->nickname.'.atom'));
+ }
+ }
+
+ //feed of each user that subscribes to the notice's author
+ $notice_inbox = new Notice_inbox();
+ $notice_inbox->notice_id = $notice->id;
+ if ($notice_inbox->find()) {
+ while ($notice_inbox->fetch()) {
+ $user = User::staticGet('id',$notice_inbox->user_id);
+ $feeds[]=common_local_url('api',array('apiaction' => 'statuses','method' => 'user_timeline','argument' => $user->nickname.'.rss'));
+ $feeds[]=common_local_url('api',array('apiaction' => 'statuses','method' => 'user_timeline','argument' => $user->nickname.'.atom'));
+ }
+ }
+
+ /* TODO: when the reply page gets RSS and ATOM feeds, implement this
+ //feed of user replied to
+ if($notice->reply_to){
+ $user = User::staticGet('id',$notice->reply_to);
+ $feeds[]=common_local_url('api',array('apiaction' => 'statuses','method' => 'user_timeline','argument' => $user->nickname.'.rss'));
+ $feeds[]=common_local_url('api',array('apiaction' => 'statuses','method' => 'user_timeline','argument' => $user->nickname.'.atom'));
+ }*/
+
+ foreach(array_unique($feeds) as $feed){
+ if(! $publisher->publish_update($feed)){
+ common_log_line(LOG_WARNING,$feed.' was not published to hub at '.$this->hub.':'.$publisher->last_response());
+ }
+ }
+ }
+}
diff --git a/plugins/PubSubHubBub/publisher.php b/plugins/PubSubHubBub/publisher.php
new file mode 100644
index 000000000..f176a9b8a
--- /dev/null
+++ b/plugins/PubSubHubBub/publisher.php
@@ -0,0 +1,86 @@
+<?php
+
+// a PHP client library for pubsubhubbub
+// as defined at http://code.google.com/p/pubsubhubbub/
+// written by Josh Fraser | joshfraser.com | josh@eventvue.com
+// Released under Apache License 2.0
+
+class Publisher {
+
+ protected $hub_url;
+ protected $last_response;
+
+ // create a new Publisher
+ public function __construct($hub_url) {
+
+ if (!isset($hub_url))
+ throw new Exception('Please specify a hub url');
+
+ if (!preg_match("|^https?://|i",$hub_url))
+ throw new Exception('The specified hub url does not appear to be valid: '.$hub_url);
+
+ $this->hub_url = $hub_url;
+ }
+
+ // accepts either a single url or an array of urls
+ public function publish_update($topic_urls, $http_function = false) {
+ if (!isset($topic_urls))
+ throw new Exception('Please specify a topic url');
+
+ // check that we're working with an array
+ if (!is_array($topic_urls)) {
+ $topic_urls = array($topic_urls);
+ }
+
+ // set the mode to publish
+ $post_string = "hub.mode=publish";
+ // loop through each topic url
+ foreach ($topic_urls as $topic_url) {
+
+ // lightweight check that we're actually working w/ a valid url
+ if (!preg_match("|^https?://|i",$topic_url))
+ throw new Exception('The specified topic url does not appear to be valid: '.$topic_url);
+
+ // append the topic url parameters
+ $post_string .= "&hub.url=".urlencode($topic_url);
+ }
+
+ // make the http post request and return true/false
+ // easy to over-write to use your own http function
+ if ($http_function)
+ return $http_function($this->hub_url,$post_string);
+ else
+ return $this->http_post($this->hub_url,$post_string);
+ }
+
+ // returns any error message from the latest request
+ public function last_response() {
+ return $this->last_response;
+ }
+
+ // default http function that uses curl to post to the hub endpoint
+ private function http_post($url, $post_string) {
+
+ // add any additional curl options here
+ $options = array(CURLOPT_URL => $url,
+ CURLOPT_POST => true,
+ CURLOPT_POSTFIELDS => $post_string,
+ CURLOPT_USERAGENT => "PubSubHubbub-Publisher-PHP/1.0");
+
+ $ch = curl_init();
+ curl_setopt_array($ch, $options);
+
+ $response = curl_exec($ch);
+ $this->last_response = $response;
+ $info = curl_getinfo($ch);
+
+ curl_close($ch);
+
+ // all good
+ if ($info['http_code'] == 204)
+ return true;
+ return false;
+ }
+}
+
+?> \ No newline at end of file
diff --git a/plugins/SimpleUrl/SimpleUrlPlugin.php b/plugins/SimpleUrl/SimpleUrlPlugin.php
new file mode 100644
index 000000000..82d772048
--- /dev/null
+++ b/plugins/SimpleUrl/SimpleUrlPlugin.php
@@ -0,0 +1,79 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Plugin to push RSS/Atom updates to a PubSubHubBub hub
+ *
+ * PHP version 5
+ *
+ * LICENCE: This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @category Plugin
+ * @package StatusNet
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @copyright 2009 Craig Andrews http://candrews.integralblue.com
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://status.net/
+ */
+
+if (!defined('STATUSNET')) {
+ exit(1);
+}
+
+class SimpleUrlPlugin extends Plugin
+{
+ function __construct()
+ {
+ parent::__construct();
+ }
+
+ 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='))
+ );
+ }
+}
+
+class SimpleUrl extends ShortUrlApi
+{
+ protected function shorten_imp($url) {
+ $curlh = curl_init();
+ curl_setopt($curlh, CURLOPT_CONNECTTIMEOUT, 20); // # seconds to wait
+ curl_setopt($curlh, CURLOPT_USERAGENT, 'StatusNet');
+ curl_setopt($curlh, CURLOPT_RETURNTRANSFER, true);
+
+ curl_setopt($curlh, CURLOPT_URL, $this->service_url.urlencode($url));
+ $short_url = curl_exec($curlh);
+
+ curl_close($curlh);
+ return $short_url;
+ }
+}
diff --git a/plugins/TightUrl/TightUrlPlugin.php b/plugins/TightUrl/TightUrlPlugin.php
new file mode 100644
index 000000000..48efb355f
--- /dev/null
+++ b/plugins/TightUrl/TightUrlPlugin.php
@@ -0,0 +1,62 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Plugin to push RSS/Atom updates to a PubSubHubBub hub
+ *
+ * PHP version 5
+ *
+ * LICENCE: This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @category Plugin
+ * @package StatusNet
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @copyright 2009 Craig Andrews http://candrews.integralblue.com
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://status.net/
+ */
+
+if (!defined('STATUSNET')) {
+ exit(1);
+}
+
+class TightUrlPlugin extends Plugin
+{
+ function __construct()
+ {
+ parent::__construct();
+ }
+
+ function onInitializePlugin(){
+ $this->registerUrlShortener(
+ '2tu.us',
+ array('freeService'=>true),
+ array('TightUrl',array('http://2tu.us/?save=y&url='))
+ );
+ }
+}
+
+class TightUrl extends ShortUrlApi
+{
+ protected function shorten_imp($url) {
+ $response = $this->http_get($url);
+ if (!$response) return $url;
+ $response = $this->tidy($response);
+ $y = @simplexml_load_string($response);
+ if (!isset($y->body)) return $url;
+ $xml = $y->body->p[0]->code[0]->a->attributes();
+ if (isset($xml['href'])) return $xml['href'];
+ return $url;
+ }
+}