3 * StatusNet, the distributed open-source microblogging tool
5 * Plugin to support RSSCloud
9 * LICENCE: This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU Affero General Public License as published by
11 * the Free Software Foundation, either version 3 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Affero General Public License for more details.
19 * You should have received a copy of the GNU Affero General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 * @author Zach Copley <zach@status.net>
25 * @copyright 2009 StatusNet, Inc.
26 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
27 * @link http://status.net/
30 if (!defined('STATUSNET')) {
34 define('RSSCLOUDPLUGIN_VERSION', '0.1');
36 class RSSCloudPlugin extends Plugin
38 function __construct()
40 parent::__construct();
43 function onInitializePlugin()
45 $this->domain = common_config('rsscloud', 'domain');
46 $this->port = common_config('rsscloud', 'port');
47 $this->path = common_config('rsscloud', 'path');
48 $this->funct = common_config('rsscloud', 'function');
49 $this->protocol = common_config('rsscloud', 'protocol');
53 $local_server = parse_url(common_path('rsscloud/request_notify'));
55 if (empty($this->domain)) {
56 $this->domain = $local_server['host'];
59 if (empty($this->port)) {
63 if (empty($this->path)) {
64 $this->path = '/rsscloud/request_notify';
67 if (empty($this->funct)) {
71 if (empty($this->protocol)) {
72 $this->protocol = 'http-post';
77 * Add RSSCloud-related paths to the router table
79 * Hook for RouterInitialized event.
81 * @return boolean hook return
84 function onRouterInitialized(&$m)
86 $m->connect('rsscloud/request_notify', array('action' => 'RSSCloudRequestNotify'));
88 // XXX: This is just for end-to-end testing
89 $m->connect('rsscloud/notify', array('action' => 'LoggingAggregator'));
94 function onAutoload($cls)
99 case 'RSSCloudNotifier':
100 require_once(INSTALLDIR . '/plugins/RSSCloud/RSSCloudNotifier.php');
102 case 'RSSCloudRequestNotifyAction':
103 case 'LoggingAggregatorAction':
104 common_debug(mb_substr($cls, 0, -6) . '.php');
105 require_once(INSTALLDIR . '/plugins/RSSCloud/' . mb_substr($cls, 0, -6) . '.php');
112 function onStartApiRss($action){
114 if (get_class($action) == 'ApiTimelineUserAction') {
116 $attrs = array('domain' => $this->domain,
117 'port' => $this->port,
118 'path' => $this->path,
119 'registerProcedure' => $this->funct,
120 'protocol' => $this->protocol);
122 // Dipping into XMLWriter to avoid a full end element (</cloud>).
124 $action->xw->startElement('cloud');
125 foreach ($attrs as $name => $value) {
126 $action->xw->writeAttribute($name, $value);
128 $action->xw->endElement();
133 function onEndNoticeSave($notice){
135 common_debug("RSSCloudPlugin oneEndNoticeSave()");
137 $user = User::staticGet('id', $notice->profile_id);
138 $feed = common_local_url('api', array('apiaction' => 'statuses',
139 'method' => 'user_timeline',
140 'argument' => $user->nickname . '.rss'));
142 // XXX: Dave's hub for testing
143 // $endpoint = 'http://rpc.rsscloud.org:5337/rsscloud/ping';
145 // $notifier = new RSSCloudNotifier();
146 // $notifier->postUpdate($endpoint, $feed);