diff --git a/plugins/Bookmark/BookmarkPlugin.php b/plugins/Bookmark/BookmarkPlugin.php index 6bd38a8c12..ae0f493abb 100644 --- a/plugins/Bookmark/BookmarkPlugin.php +++ b/plugins/Bookmark/BookmarkPlugin.php @@ -127,7 +127,8 @@ class BookmarkPlugin extends Plugin switch ($cls) { case 'NewbookmarkAction': - include_once $dir.'/newbookmark.php'; + case 'BookmarkpopupAction': + include_once $dir . '/' . strtolower(mb_substr($cls, 0, -6)) . '.php'; return false; case 'Notice_bookmark': include_once $dir.'/'.$cls.'.php'; @@ -156,6 +157,8 @@ class BookmarkPlugin extends Plugin array('action' => 'newbookmark'), array('id' => '[0-9]+')); + $m->connect('main/bookmark/popup', array('action' => 'bookmarkpopup')); + return true; } @@ -312,5 +315,27 @@ class BookmarkPlugin extends Plugin _m('Simple extension for supporting bookmarks.')); return true; } + + /** + * Load our document if requested + * + * @param string &$title Title to fetch + * @param string &$output HTML to output + * + * @return boolean hook value + */ + + function onStartLoadDoc(&$title, &$output) + { + if ($title == 'bookmarklet') { + $filename = INSTALLDIR.'/plugins/Bookmark/bookmarklet'; + + $c = file_get_contents($filename); + $output = common_markup_to_html($c); + return false; // success! + } + + return true; + } } diff --git a/plugins/Bookmark/bookmarklet b/plugins/Bookmark/bookmarklet new file mode 100644 index 0000000000..fc1f8b9d05 --- /dev/null +++ b/plugins/Bookmark/bookmarklet @@ -0,0 +1,9 @@ + + + + +A bookmarklet is a small piece of javascript code used as a bookmark. This one will let you post to %%site.name%% simply by selecting some text on a page and pressing the bookmarklet. + +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. + +Bookmark on %%site.name%% diff --git a/plugins/Bookmark/bookmarkpopup.php b/plugins/Bookmark/bookmarkpopup.php new file mode 100644 index 0000000000..52a40de921 --- /dev/null +++ b/plugins/Bookmark/bookmarkpopup.php @@ -0,0 +1,87 @@ +. + * + * @category Bookmark + * @package StatusNet + * @author Sarven Capadisli + * @author Evan Prodromou + * @copyright 2008-2010 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET')) { + exit(1); +} + +/** + * Action for posting a new bookmark + * + * @category Bookmark + * @package StatusNet + * @author Sarven Capadisli + * @author Evan Prodromou + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 + * @link http://status.net/ + */ +class BookmarkpopupAction extends NewbookmarkAction +{ + function prepare($args) + { + $result = parent::prepare($args); + common_debug('Values: ' . $this->_title . ' ' . $this->_url); + return $result; + } + + function showTitle() + { + // TRANS: Title for mini-posting window loaded from bookmarklet. + // TRANS: %s is the StatusNet site name. + $this->element('title', + null, sprintf(_('Bookmark on %s'), + 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()) { + $form = new BookmarkForm($this, + $this->_title, + $this->_url); + $form->show(); + } + $this->elementEnd('div'); + } + + function showCore() + { + } + + function showFooter() + { + } +} diff --git a/plugins/Bookmark/newbookmark.php b/plugins/Bookmark/newbookmark.php index efc664e7b6..7a11b08ad3 100644 --- a/plugins/Bookmark/newbookmark.php +++ b/plugins/Bookmark/newbookmark.php @@ -47,13 +47,13 @@ if (!defined('STATUSNET')) { class NewbookmarkAction extends Action { - private $_user = null; - private $_error = null; - private $_complete = null; - private $_title = null; - private $_url = null; - private $_tags = null; - private $_description = null; + protected $_user = null; + protected $_error = null; + protected $_complete = null; + protected $_title = null; + protected $_url = null; + protected $_tags = null; + protected $_description = null; /** * Returns the title of the action