3 * StatusNet, the distributed open-source microblogging tool
5 * Plugin to add ICBM metadata to HTML pages and report data to GeoURL.org
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 Evan Prodromou <evan@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')) {
35 * Plugin to add ICBM metadata to HTML pages and report data to GeoURL.org
37 * Adds metadata to notice and profile pages that geourl.org and others
38 * understand. Also, pings geourl.org when a new notice is saved or
39 * a profile is changed.
43 * @author Evan Prodromou <evan@status.net>
44 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
45 * @link http://status.net/
49 class GeoURLPlugin extends Plugin
51 public $ping = 'http://geourl.org/ping/';
54 * Add extra <meta> headers for certain pages that geourl.org understands
56 * @param Action $action page being shown
58 * @return boolean event handler flag
60 function onEndShowHeadElements($action)
62 $name = $action->trimmed('action');
66 if ($name == 'showstream') {
67 $profile = $action->profile;
68 if (!empty($profile) && !empty($profile->lat) && !empty($profile->lon)) {
69 $location = $profile->lat . ', ' . $profile->lon;
71 } else if ($name == 'shownotice') {
72 $notice = $action->profile;
73 if (!empty($notice) && !empty($notice->lat) && !empty($notice->lon)) {
74 $location = $notice->lat . ', ' . $notice->lon;
78 if (!empty($location)) {
79 $action->element('meta', array('name' => 'ICBM',
80 'content' => $location));
81 $action->element('meta', array('name' => 'DC.title',
82 'content' => $action->title()));
89 * Report local notices to GeoURL.org when they're created
91 * @param Notice &$notice queued notice
93 * @return boolean event handler flag
95 function onHandleQueuedNotice(&$notice)
97 if ($notice->is_local == 1) {
99 $request = HTTPClient::start();
101 $url = common_local_url('shownotice',
102 array('notice' => $notice->id));
105 $request->post($this->ping,
108 } catch (HTTP_Request2_Exception $e) {
109 common_log(LOG_WARNING,
110 "GeoURL.org ping failed for '$url' ($this->ping)");
117 function onPluginVersion(&$versions)
119 $versions[] = array('name' => 'GeoURL',
120 'version' => STATUSNET_VERSION,
121 'author' => 'Evan Prodromou',
122 'homepage' => 'http://status.net/wiki/Plugin:GeoURL',
124 _m('Ping <a href="http://geourl.org/">GeoURL</a> when '.
125 'new geolocation-enhanced notices are posted.'));