diff options
author | Brion Vibber <brion@pobox.com> | 2010-12-07 10:50:05 -0800 |
---|---|---|
committer | Brion Vibber <brion@pobox.com> | 2010-12-07 10:50:05 -0800 |
commit | 9df856e667a12cd217576263efbc72fff12692d9 (patch) | |
tree | dc8d588e8b01d1ec788c78d6aec10a9b9d26bec6 /plugins/Autocomplete | |
parent | 01f32e3998b8d031d2a39e2d0506253142b6632e (diff) | |
parent | 4b4b763255ad3b2bff8f18da2bd3927b52a54e55 (diff) |
Merge branch '0.9.x' into merge
Conflicts:
README
actions/hostmeta.php
classes/File_redirection.php
lib/common.php
lib/designsettings.php
lib/router.php
lib/util.php
lib/xmppmanager.php
plugins/OStatus/OStatusPlugin.php
Diffstat (limited to 'plugins/Autocomplete')
-rw-r--r-- | plugins/Autocomplete/Autocomplete.js | 71 | ||||
-rw-r--r-- | plugins/Autocomplete/AutocompletePlugin.php | 2 | ||||
-rw-r--r-- | plugins/Autocomplete/README | 11 | ||||
-rw-r--r-- | plugins/Autocomplete/autocomplete.php | 36 | ||||
-rw-r--r-- | plugins/Autocomplete/locale/be-tarask/LC_MESSAGES/Autocomplete.po | 33 |
5 files changed, 112 insertions, 41 deletions
diff --git a/plugins/Autocomplete/Autocomplete.js b/plugins/Autocomplete/Autocomplete.js index 3eff685a8..c3f022702 100644 --- a/plugins/Autocomplete/Autocomplete.js +++ b/plugins/Autocomplete/Autocomplete.js @@ -1,37 +1,38 @@ $(document).ready(function(){ - $('#notice_data-text').autocomplete($('address .url')[0].href+'/plugins/Autocomplete/autocomplete.json', { - multiple: true, - multipleSeparator: " ", - minChars: 1, - formatItem: function(row, i, max){ - row = eval("(" + row + ")"); - switch(row.type) - { - case 'user': - return row.nickname + ' (' + row.fullname + ')'; - case 'group': - return row.nickname + ' (' + row.fullname + ')'; - } - }, - formatMatch: function(row, i, max){ - row = eval("(" + row + ")"); - switch(row.type) - { - case 'user': - return row.nickname; - case 'group': - return row.nickname; - } - }, - formatResult: function(row){ - row = eval("(" + row + ")"); - switch(row.type) - { - case 'user': - return '@' + row.nickname; - case 'group': - return '!' + row.nickname; - } - } - }); + function fullName(row) { + if (typeof row.fullname == "string" && row.fullname != '') { + return row.nickname + ' (' + row.fullname + ')'; + } else { + return row.nickname; + } + } + $('#notice_data-text').autocomplete($('address .url')[0].href+'main/autocomplete/suggest', { + multiple: true, + multipleSeparator: " ", + minChars: 1, + formatItem: function(row, i, max){ + row = eval("(" + row + ")"); + // the display:inline is because our INSANE stylesheets + // override the standard display of all img tags for no + // good reason. + var div = $('<div><img style="display:inline; vertical-align: middle"> <span></span></div>') + .find('img').attr('src', row.avatar).end() + .find('span').text(fullName(row)).end() + return div.html(); + }, + formatMatch: function(row, i, max){ + row = eval("(" + row + ")"); + return row.nickname; + }, + formatResult: function(row){ + row = eval("(" + row + ")"); + switch(row.type) + { + case 'user': + return '@' + row.nickname; + case 'group': + return '!' + row.nickname; + } + } + }); }); diff --git a/plugins/Autocomplete/AutocompletePlugin.php b/plugins/Autocomplete/AutocompletePlugin.php index 620b5e7b0..230ba089d 100644 --- a/plugins/Autocomplete/AutocompletePlugin.php +++ b/plugins/Autocomplete/AutocompletePlugin.php @@ -66,7 +66,7 @@ class AutocompletePlugin extends Plugin function onRouterInitialized($m) { if (common_logged_in()) { - $m->connect('plugins/Autocomplete/autocomplete.json', array('action'=>'autocomplete')); + $m->connect('main/autocomplete/suggest', array('action'=>'autocomplete')); } } diff --git a/plugins/Autocomplete/README b/plugins/Autocomplete/README index 1db4c6565..f5feb94a7 100644 --- a/plugins/Autocomplete/README +++ b/plugins/Autocomplete/README @@ -1,6 +1,13 @@ -Autocomplete allows users to autocomplete screen names in @ replies. When an "@" is typed into the notice text area, an autocomplete box is displayed populated with the user's friends' screen names. +Autocomplete allows users to autocomplete screen names in @ replies and +! group references. -Note: This plugin doesn't work if the site is in Private mode, i.e. when $config['site']['private'] is set to true. +When an "@" or "!" is typed into the notice text area, an autocomplete box +is displayed populated with the user's friends' screen names or group +memberships. + +Completion suggestions can be selected via the mouse or arrow keys, and the +suggestion can be inserted either by clicking or hitting tab. Hitting enter +will also select the suggestion, but will submit your message too! Installation ============ diff --git a/plugins/Autocomplete/autocomplete.php b/plugins/Autocomplete/autocomplete.php index a4e2d9baa..c92002245 100644 --- a/plugins/Autocomplete/autocomplete.php +++ b/plugins/Autocomplete/autocomplete.php @@ -59,7 +59,7 @@ class AutocompleteAction extends Action { $max=0; foreach($this->users as $user){ - $max = max($max,strtotime($user->modified),strtotime($user->profile->modified)); + $max = max($max,strtotime($user->modified),strtotime($user->getProfile()->modified)); } foreach($this->groups as $group){ $max = max($max,strtotime($group->modified)); @@ -87,7 +87,15 @@ class AutocompleteAction extends Action function prepare($args) { + // If we die, show short error messages. + StatusNet::setApi(true); + parent::prepare($args); + + $cur = common_current_user(); + if (!$cur) { + throw new ClientException('Access forbidden', true); + } $this->groups=array(); $this->users=array(); $q = $this->arg('q'); @@ -126,10 +134,32 @@ class AutocompleteAction extends Action $results = array(); foreach($this->users as $user){ $profile = $user->getProfile(); - $results[]=array('nickname' => $user->nickname, 'fullname'=> $profile->fullname, 'type'=>'user'); + $avatar = $profile->getAvatar(AVATAR_MINI_SIZE); + // sigh.... encapsulate this upstream! + if ($avatar) { + $avatar = $avatar->displayUrl(); + } else { + $avatar = Avatar::defaultImage(AVATAR_MINI_SIZE); + } + $results[] = array( + 'nickname' => $user->nickname, + 'fullname'=> $profile->fullname, + 'avatar' => $avatar, + 'type' => 'user' + ); } foreach($this->groups as $group){ - $results[]=array('nickname' => $group->nickname, 'fullname'=> $group->fullname, 'type'=>'group'); + // sigh.... encapsulate this upstream! + if ($group->mini_logo) { + $avatar = $group->mini_logo; + } else { + $avatar = User_group::defaultLogo(AVATAR_MINI_SIZE); + } + $results[] = array( + 'nickname' => $group->nickname, + 'fullname'=> $group->fullname, + 'avatar' => $avatar, + 'type' => 'group'); } foreach($results as $result) { print json_encode($result) . "\n"; diff --git a/plugins/Autocomplete/locale/be-tarask/LC_MESSAGES/Autocomplete.po b/plugins/Autocomplete/locale/be-tarask/LC_MESSAGES/Autocomplete.po new file mode 100644 index 000000000..966ef3f86 --- /dev/null +++ b/plugins/Autocomplete/locale/be-tarask/LC_MESSAGES/Autocomplete.po @@ -0,0 +1,33 @@ +# Translation of StatusNet - Autocomplete to Belarusian (Taraškievica orthography) (Беларуская (тарашкевіца)) +# Expored from translatewiki.net +# +# Author: EugeneZelenko +# -- +# This file is distributed under the same license as the StatusNet package. +# +msgid "" +msgstr "" +"Project-Id-Version: StatusNet - Autocomplete\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2010-11-29 15:37+0000\n" +"PO-Revision-Date: 2010-11-29 15:40:01+0000\n" +"Language-Team: Belarusian (Taraškievica orthography) <http://translatewiki." +"net/wiki/Portal:be-tarask>\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-POT-Import-Date: 2010-10-29 16:11:52+0000\n" +"X-Generator: MediaWiki 1.17alpha (r77421); Translate extension (2010-09-17)\n" +"X-Translation-Project: translatewiki.net at http://translatewiki.net\n" +"X-Language-Code: be-tarask\n" +"X-Message-Group: #out-statusnet-plugin-autocomplete\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: AutocompletePlugin.php:80 +msgid "" +"The autocomplete plugin allows users to autocomplete screen names in @ " +"replies. When an \"@\" is typed into the notice text area, an autocomplete " +"box is displayed populated with the user's friend' screen names." +msgstr "" +"Дапаўненьне аўтаматычнага запаўненьня дазваляе карыстальнікам аўтаматычна " +"запаўняць імёны ў @-адказах. Калі «@» будзе ўведзенае ў тэкставую вобласьць " +"паведамленьня, то зьявіцца блёк аўтаматычнага запаўненьня з імёнамі сяброў." |