From f0abc0fe15a54da468cf37e748041bba4f362e53 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Thu, 29 Oct 2009 13:18:51 +0100 Subject: [PATCH] Updated bookmarklet. Created its own action --- actions/bookmarklet.php | 75 +++++++++++++++++++++++++++++++++++++++++ doc-src/bookmarklet | 2 +- js/util.js | 3 ++ lib/router.php | 2 ++ 4 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 actions/bookmarklet.php diff --git a/actions/bookmarklet.php b/actions/bookmarklet.php new file mode 100644 index 0000000000..f253399e4b --- /dev/null +++ b/actions/bookmarklet.php @@ -0,0 +1,75 @@ +. + * + * @category Bookmarklet + * @package StatusNet + * @author Sarven Capadisli + * @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 + * @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() + { + } +} + diff --git a/doc-src/bookmarklet b/doc-src/bookmarklet index e5ded77023..0aa9e1e490 100644 --- a/doc-src/bookmarklet +++ b/doc-src/bookmarklet @@ -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. -Post to %%site.name%% +Post to %%site.name%% diff --git a/js/util.js b/js/util.js index 0a943512f2..b079388e47 100644 --- a/js/util.js +++ b/js/util.js @@ -241,6 +241,9 @@ $(document).ready(function(){ alert(result); } else { + if($('body')[0].id == 'bookmarklet') { + self.close(); + } if ($("#command_result", xml).length > 0) { var result = document._importNode($("p", xml).get(0), true); result = result.textContent || result.innerHTML; diff --git a/lib/router.php b/lib/router.php index dedf73c865..2fd255fe6f 100644 --- a/lib/router.php +++ b/lib/router.php @@ -179,6 +179,8 @@ class Router array('action' => 'deletenotice'), array('notice' => '[0-9]+')); + $m->connect('bookmarklet/new', array('action' => 'bookmarklet')); + // conversation $m->connect('conversation/:id',