3 * StatusNet, the distributed open-source microblogging tool
5 * Plugin to add Echo/JS-Kit commenting to notice pages
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 Zach Copley <zach@status.net>
25 * @copyright 2010 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 use Echo (formerly JS-Kit)
37 * This plugin adds an Echo commenting widget to each notice page on
38 * your site. To get it to work, first you'll have to sign up for Echo
39 * (a commercial service) and register your site's URL.
41 * http://aboutecho.com/
43 * Once you've done that it's pretty straight forward to turn the
44 * plugin on, just add:
48 * to your config.php. The defaults should work OK with the default
49 * theme, but there are a lot of options to customize the look and
50 * feel of the comment widget. You can control both the CSS for the
51 * div that contains the widget, as well as the CSS for the widget
52 * itself via config parameters that can be passed into the plugin.
53 * See below for a more complex example:
55 * // Custom stylesheet for Echo commenting widget
56 * // See: http://wiki.js-kit.com/Skinning-Guide#UsingCSSnbsptocustomizefontsandcolors
57 * $stylesheet = <<<ENDOFCSS
58 * .js-CommentsArea { width: 400px; }
59 * .jsk-HeaderWrapper { display: none; }
60 * .jsk-ItemUserAvatar { display: none; }
61 * .jsk-ItemBody { margin-left: -48px; }
62 * .js-kit-avatars-wrapper { display: none; }
63 * .js-kit-nonLoggedUserInfo { margin-left: -75px; }
64 * .js-singleViaLinkWrapper { display: none; }
65 * .js-CommentsSkin-echo div.jsk-ThreadWrapper { padding: 0px; }
66 * .js-singleCommentAdminStar { display: none !important; }
67 * .js-singleCommentName { margin-right: 1em; }
68 * .js-kit-miniProfile { background-color:#FFFFFF; }
69 * .jskit-MenuContainer { background-color:#FFFFFF; }
70 * .jskit-MenuItemMO { background-color: #EDEDED; }
71 * .jsk-CommentFormButton { display: none; }
72 * .js-singleCommentReplyable { display: none; }
73 * .jsk-CommentFormSurface { display: none; }
74 * .js-kit-tab-follow { display: none; }
81 * // div_css is the css for the div containing the comment widget
82 * 'div_css' => 'width:675px; padding-top:10px; position:relative; float:left;',
83 * // stylesheet is the CSS for the comment widget itself
84 * 'stylesheet' => $stylesheet
90 * @author Zach Copley <zach@status.net>
91 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
92 * @link http://status.net/
97 class EchoPlugin extends Plugin
99 // NOTE: The Echo documentation says that this script will change on
100 // a per site basis, but I think that's incorrect. It always seems to
102 public $script = 'http://cdn.js-kit.com/scripts/comments.js';
104 function onEndShowScripts($action)
106 if (get_class($action) == 'ShownoticeAction') {
107 $action->script($this->script);
113 function onEndShowContentBlock($action)
115 if (get_class($action) == 'ShownoticeAction') {
118 $attrs['class'] = 'js-kit-comments';
119 $attrs['permalink'] = $action->notice->uri;
120 $attrs['uniq'] = $action->notice->id;
122 // NOTE: there are some other attributes that could be useful
123 // http://wiki.js-kit.com/Echo-Behavior
125 if (empty($this->div_css)) {
126 // This CSS seems to work OK with the default theme
127 $attrs['style'] = 'width:675px; padding-top:10px; position:relative; float:left;';
129 $attrs['style'] = $this->css;
132 $action->element('div', $attrs, null);
136 function onEndShowStyles($action)
138 if (get_class($action) == 'ShownoticeAction' && !empty($this->stylesheet)) {
139 $action->style($this->stylesheet);
143 function onPluginVersion(&$versions)
145 $versions[] = array('name' => 'Echo',
146 'version' => STATUSNET_VERSION,
147 'author' => 'Zach Copley',
148 'homepage' => 'http://status.net/wiki/Plugin:Echo',
150 _m('Use <a href="http://aboutecho.com/">Echo</a>'.
151 ' to add commenting to notice pages.'));