Updated bookmarklet. Created its own action
This commit is contained in:
parent
2b5a5e02a4
commit
f0abc0fe15
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()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -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://localhost/dev/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=650,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;
|
||||||
|
|
|
@ -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',
|
||||||
|
|
Loading…
Reference in New Issue
Block a user