Merge commit 'mainline/0.9.x' into 0.9.x
This commit is contained in:
commit
c0f8c0178a
75
actions/bookmarklet.php
Normal file
75
actions/bookmarklet.php
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* StatusNet, the distributed open-source microblogging tool
|
||||||
|
*
|
||||||
|
* Handler for posting new notices
|
||||||
|
*
|
||||||
|
* 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 Bookmarklet
|
||||||
|
* @package StatusNet
|
||||||
|
* @author Sarven Capadisli <csarven@status.net>
|
||||||
|
* @copyright 2008-2009 StatusNet, Inc.
|
||||||
|
* @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') && !defined('LACONICA')) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once INSTALLDIR . '/actions/newnotice.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action for posting a notice
|
||||||
|
*
|
||||||
|
* @category Bookmarklet
|
||||||
|
* @package StatusNet
|
||||||
|
* @author Sarven Capadisli <csarven@status.net>
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://status.net/
|
||||||
|
*/
|
||||||
|
|
||||||
|
class BookmarkletAction extends NewnoticeAction
|
||||||
|
{
|
||||||
|
function showTitle()
|
||||||
|
{
|
||||||
|
$this->element('title', null, _('Post to ').common_config('site', 'name'));
|
||||||
|
}
|
||||||
|
|
||||||
|
function showHeader()
|
||||||
|
{
|
||||||
|
$this->elementStart('div', array('id' => 'header'));
|
||||||
|
$this->elementStart('address');
|
||||||
|
$this->element('a', array('class' => 'url',
|
||||||
|
'href' => common_local_url('public')),
|
||||||
|
'');
|
||||||
|
$this->elementEnd('address');
|
||||||
|
if (common_logged_in()) {
|
||||||
|
$this->showNoticeForm();
|
||||||
|
}
|
||||||
|
$this->elementEnd('div');
|
||||||
|
}
|
||||||
|
|
||||||
|
function showCore()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
function showFooter()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -103,7 +103,7 @@ class OthersettingsAction extends AccountSettingsAction
|
|||||||
foreach($_shorteners as $name=>$value)
|
foreach($_shorteners as $name=>$value)
|
||||||
{
|
{
|
||||||
$services[$name]=$name;
|
$services[$name]=$name;
|
||||||
if($value['info']['freeService']){
|
if(!empty($value['info']['freeService'])){
|
||||||
// I18N
|
// I18N
|
||||||
$services[$name].=' (free service)';
|
$services[$name].=' (free service)';
|
||||||
}
|
}
|
||||||
|
@ -348,6 +348,8 @@ class ShowstreamAction extends ProfileAction
|
|||||||
{
|
{
|
||||||
if (Event::handle('StartProfilePageActionsSection', array(&$this, $this->profile))) {
|
if (Event::handle('StartProfilePageActionsSection', array(&$this, $this->profile))) {
|
||||||
|
|
||||||
|
$cur = common_current_user();
|
||||||
|
|
||||||
$this->elementStart('div', 'entity_actions');
|
$this->elementStart('div', 'entity_actions');
|
||||||
$this->element('h2', null, _('User actions'));
|
$this->element('h2', null, _('User actions'));
|
||||||
$this->elementStart('ul');
|
$this->elementStart('ul');
|
||||||
@ -379,21 +381,21 @@ class ShowstreamAction extends ProfileAction
|
|||||||
}
|
}
|
||||||
$this->elementEnd('li');
|
$this->elementEnd('li');
|
||||||
|
|
||||||
if ($cur->mutuallySubscribed($user)) {
|
if ($cur->mutuallySubscribed($this->user)) {
|
||||||
|
|
||||||
// message
|
// message
|
||||||
|
|
||||||
$this->elementStart('li', 'entity_send-a-message');
|
$this->elementStart('li', 'entity_send-a-message');
|
||||||
$this->element('a', array('href' => common_local_url('newmessage', array('to' => $user->id)),
|
$this->element('a', array('href' => common_local_url('newmessage', array('to' => $this->user->id)),
|
||||||
'title' => _('Send a direct message to this user')),
|
'title' => _('Send a direct message to this user')),
|
||||||
_('Message'));
|
_('Message'));
|
||||||
$this->elementEnd('li');
|
$this->elementEnd('li');
|
||||||
|
|
||||||
// nudge
|
// nudge
|
||||||
|
|
||||||
if ($user->email && $user->emailnotifynudge) {
|
if ($this->user->email && $this->user->emailnotifynudge) {
|
||||||
$this->elementStart('li', 'entity_nudge');
|
$this->elementStart('li', 'entity_nudge');
|
||||||
$nf = new NudgeForm($this, $user);
|
$nf = new NudgeForm($this, $this->user);
|
||||||
$nf->show();
|
$nf->show();
|
||||||
$this->elementEnd('li');
|
$this->elementEnd('li');
|
||||||
}
|
}
|
||||||
|
@ -1412,4 +1412,21 @@ class Notice extends Memcached_DataObject
|
|||||||
$contentlimit = self::maxContent();
|
$contentlimit = self::maxContent();
|
||||||
return ($contentlimit > 0 && !empty($content) && (mb_strlen($content) > $contentlimit));
|
return ($contentlimit > 0 && !empty($content) && (mb_strlen($content) > $contentlimit));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getLocation()
|
||||||
|
{
|
||||||
|
$location = null;
|
||||||
|
|
||||||
|
if (!empty($this->location_id) && !empty($this->location_ns)) {
|
||||||
|
$location = Location::fromId($this->location_id, $this->location_ns);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_null($location)) { // no ID, or Location::fromId() failed
|
||||||
|
if (!empty($this->lat) && !empty($this->lon)) {
|
||||||
|
$location = Location::fromLatLon($this->lat, $this->lon);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $location;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -562,4 +562,29 @@ class Profile extends Memcached_DataObject
|
|||||||
$block->blocked = $this->id;
|
$block->blocked = $this->id;
|
||||||
$block->delete();
|
$block->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// XXX: identical to Notice::getLocation.
|
||||||
|
|
||||||
|
function getLocation()
|
||||||
|
{
|
||||||
|
$location = null;
|
||||||
|
|
||||||
|
if (!empty($this->location_id) && !empty($this->location_ns)) {
|
||||||
|
$location = Location::fromId($this->location_id, $this->location_ns);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_null($location)) { // no ID, or Location::fromId() failed
|
||||||
|
if (!empty($this->lat) && !empty($this->lon)) {
|
||||||
|
$location = Location::fromLatLon($this->lat, $this->lon);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_null($location)) { // still haven't found it!
|
||||||
|
if (!empty($this->location)) {
|
||||||
|
$location = Location::fromName($this->location);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $location;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,4 +2,4 @@ A bookmarklet is a small piece of javascript code used as a bookmark. This one w
|
|||||||
|
|
||||||
Drag-and-drop the following link to your bookmarks bar or right-click it and add it to your browser favorites to keep it handy.
|
Drag-and-drop the following link to your bookmarks bar or right-click it and add it to your browser favorites to keep it handy.
|
||||||
|
|
||||||
<a href="javascript:var%20d=document,w=window,e=w.getSelection,k=d.getSelection,x=d.selection,s=(e?e():(k)?k():(x?x.createRange().text:0)),f='http://%%site.server%%/%%site.path%%/index.php?action=newnotice',l=d.location,e=encodeURIComponent,g=f+'&status_textarea=%22'+((e(s))?e(s):e(document.title))+'%22 from '+l.href;function%20a(){if(!w.open(g,'t','toolbar=0,resizable=0,scrollbars=1,status=1,width=800,height=570')){l.href=g;}}a();void(0);">Post to %%site.name%%</a>
|
<a href="javascript:(function(){var%20d=document,w=window,e=w.getSelection,k=d.getSelection,x=d.selection,s=(e?e():(k)?k():(x?x.createRange().text:0)),f='http://%%site.server%%/%%site.path%%/index.php?action=bookmarklet',l=d.location,e=encodeURIComponent,g=f+'&status_textarea=%22'+((e(s))?e(s):e(document.title))+'%22%20%E2%80%94%20'+l.href;function%20a(){if(!w.open(g,'t','toolbar=0,resizable=0,scrollbars=1,status=1,width=450,height=200')){l.href=g;}}a();})()">Post to %%site.name%%</a>
|
||||||
|
@ -241,6 +241,9 @@ $(document).ready(function(){
|
|||||||
alert(result);
|
alert(result);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
if($('body')[0].id == 'bookmarklet') {
|
||||||
|
self.close();
|
||||||
|
}
|
||||||
if ($("#command_result", xml).length > 0) {
|
if ($("#command_result", xml).length > 0) {
|
||||||
var result = document._importNode($("p", xml).get(0), true);
|
var result = document._importNode($("p", xml).get(0), true);
|
||||||
result = result.textContent || result.innerHTML;
|
result = result.textContent || result.innerHTML;
|
||||||
|
@ -47,10 +47,11 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
|
|||||||
|
|
||||||
class Location
|
class Location
|
||||||
{
|
{
|
||||||
public $lat;
|
public $lat;
|
||||||
public $lon;
|
public $lon;
|
||||||
public $location_id;
|
public $location_id;
|
||||||
public $location_ns;
|
public $location_ns;
|
||||||
|
private $_url;
|
||||||
|
|
||||||
var $names = array();
|
var $names = array();
|
||||||
|
|
||||||
@ -90,6 +91,10 @@ class Location
|
|||||||
|
|
||||||
static function fromId($id, $ns, $language=null)
|
static function fromId($id, $ns, $language=null)
|
||||||
{
|
{
|
||||||
|
if (is_null($language)) {
|
||||||
|
$language = common_language();
|
||||||
|
}
|
||||||
|
|
||||||
$location = null;
|
$location = null;
|
||||||
|
|
||||||
// Let a third-party handle it
|
// Let a third-party handle it
|
||||||
@ -157,4 +162,27 @@ class Location
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get an URL suitable for this location
|
||||||
|
*
|
||||||
|
* @return string URL for this location or NULL
|
||||||
|
*/
|
||||||
|
|
||||||
|
function getURL()
|
||||||
|
{
|
||||||
|
// Keep one cached
|
||||||
|
|
||||||
|
if (is_string($this->_url)) {
|
||||||
|
return $this->_url;
|
||||||
|
}
|
||||||
|
|
||||||
|
$url = null;
|
||||||
|
|
||||||
|
Event::handle('LocationUrl', array($this, &$url));
|
||||||
|
|
||||||
|
$this->_url = $url;
|
||||||
|
|
||||||
|
return $url;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -199,6 +199,7 @@ class NoticeListItem extends Widget
|
|||||||
{
|
{
|
||||||
$this->out->elementStart('div', 'entry-content');
|
$this->out->elementStart('div', 'entry-content');
|
||||||
$this->showNoticeLink();
|
$this->showNoticeLink();
|
||||||
|
$this->showNoticeLocation();
|
||||||
$this->showNoticeSource();
|
$this->showNoticeSource();
|
||||||
$this->showContext();
|
$this->showContext();
|
||||||
$this->out->elementEnd('div');
|
$this->out->elementEnd('div');
|
||||||
@ -369,6 +370,44 @@ class NoticeListItem extends Widget
|
|||||||
$this->out->elementEnd('a');
|
$this->out->elementEnd('a');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* show the notice location
|
||||||
|
*
|
||||||
|
* shows the notice location in the correct language.
|
||||||
|
*
|
||||||
|
* If an URL is available, makes a link. Otherwise, just a span.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function showNoticeLocation()
|
||||||
|
{
|
||||||
|
$id = $this->notice->id;
|
||||||
|
|
||||||
|
$location = $this->notice->getLocation();
|
||||||
|
|
||||||
|
if (empty($location)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$name = $location->getName();
|
||||||
|
|
||||||
|
if (empty($name)) {
|
||||||
|
// XXX: Could be a translation issue. Fall back to... something?
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$url = $location->getUrl();
|
||||||
|
|
||||||
|
if (empty($url)) {
|
||||||
|
$this->out->element('span', array('class' => 'location'), $name);
|
||||||
|
} else {
|
||||||
|
$this->out->element('a', array('class' => 'location',
|
||||||
|
'href' => $url),
|
||||||
|
$name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show the source of the notice
|
* Show the source of the notice
|
||||||
*
|
*
|
||||||
|
@ -179,6 +179,8 @@ class Router
|
|||||||
array('action' => 'deletenotice'),
|
array('action' => 'deletenotice'),
|
||||||
array('notice' => '[0-9]+'));
|
array('notice' => '[0-9]+'));
|
||||||
|
|
||||||
|
$m->connect('bookmarklet/new', array('action' => 'bookmarklet'));
|
||||||
|
|
||||||
// conversation
|
// conversation
|
||||||
|
|
||||||
$m->connect('conversation/:id',
|
$m->connect('conversation/:id',
|
||||||
|
@ -58,7 +58,7 @@ class FacebookPlugin extends Plugin
|
|||||||
* @return boolean hook return
|
* @return boolean hook return
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function onRouterInitialized(&$m)
|
function onRouterInitialized($m)
|
||||||
{
|
{
|
||||||
|
|
||||||
// Facebook App stuff
|
// Facebook App stuff
|
||||||
|
@ -278,4 +278,28 @@ class GeonamesPlugin extends Plugin
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Human-readable name for a location
|
||||||
|
*
|
||||||
|
* Given a location, we try to retrieve a geonames.org URL.
|
||||||
|
*
|
||||||
|
* @param Location $location Location to get the url for
|
||||||
|
* @param string &$url Place to put the url
|
||||||
|
*
|
||||||
|
* @return boolean whether to continue
|
||||||
|
*/
|
||||||
|
|
||||||
|
function onLocationUrl($location, &$url)
|
||||||
|
{
|
||||||
|
if ($location->location_ns != self::NAMESPACE) {
|
||||||
|
// It's not one of our IDs... keep processing
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$url = 'http://www.geonames.org/' . $location->location_id;
|
||||||
|
|
||||||
|
// it's been filled, so don't process further.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ class OpenIDPlugin extends Plugin
|
|||||||
* @return boolean hook return
|
* @return boolean hook return
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function onRouterInitialized(&$m)
|
function onRouterInitialized($m)
|
||||||
{
|
{
|
||||||
$m->connect('main/openid', array('action' => 'openidlogin'));
|
$m->connect('main/openid', array('action' => 'openidlogin'));
|
||||||
$m->connect('settings/openid', array('action' => 'openidsettings'));
|
$m->connect('settings/openid', array('action' => 'openidsettings'));
|
||||||
|
@ -32,7 +32,7 @@ class TemplatePlugin extends Plugin {
|
|||||||
// capture the RouterInitialized event
|
// capture the RouterInitialized event
|
||||||
// and connect a new API method
|
// and connect a new API method
|
||||||
// for updating the template
|
// for updating the template
|
||||||
function onRouterInitialized( &$m ) {
|
function onRouterInitialized( $m ) {
|
||||||
$m->connect( 'template/update', array(
|
$m->connect( 'template/update', array(
|
||||||
'action' => 'template',
|
'action' => 'template',
|
||||||
));
|
));
|
||||||
|
@ -11,8 +11,7 @@ Installation
|
|||||||
|
|
||||||
To enable the plugin, add the following to your config.php:
|
To enable the plugin, add the following to your config.php:
|
||||||
|
|
||||||
require_once(INSTALLDIR . '/plugins/TwitterBridge/TwitterBridgePlugin.php');
|
addPlugin("TwitterBridge");
|
||||||
$tb = new TwitterBridgePlugin();
|
|
||||||
|
|
||||||
OAuth is used to to access protected resources on Twitter (as opposed to
|
OAuth is used to to access protected resources on Twitter (as opposed to
|
||||||
HTTP Basic Auth)*. To use Twitter bridging you will need to register
|
HTTP Basic Auth)*. To use Twitter bridging you will need to register
|
||||||
|
@ -60,12 +60,12 @@ class TwitterBridgePlugin extends Plugin
|
|||||||
*
|
*
|
||||||
* Hook for RouterInitialized event.
|
* Hook for RouterInitialized event.
|
||||||
*
|
*
|
||||||
* @param Net_URL_Mapper &$m path-to-action mapper
|
* @param Net_URL_Mapper $m path-to-action mapper
|
||||||
*
|
*
|
||||||
* @return boolean hook return
|
* @return boolean hook return
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function onRouterInitialized(&$m)
|
function onRouterInitialized($m)
|
||||||
{
|
{
|
||||||
$m->connect('twitter/authorization',
|
$m->connect('twitter/authorization',
|
||||||
array('action' => 'twitterauthorization'));
|
array('action' => 'twitterauthorization'));
|
||||||
|
@ -1295,3 +1295,13 @@ display:none;
|
|||||||
.guide {
|
.guide {
|
||||||
clear:both;
|
clear:both;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#bookmarklet address {
|
||||||
|
display:none;
|
||||||
|
}
|
||||||
|
#bookmarklet #form_notice {
|
||||||
|
width:auto;
|
||||||
|
}
|
||||||
|
#bookmarklet #wrap {
|
||||||
|
min-width:0;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user