From 4a19c292fb444dca840591a5ccec960d63ab57b8 Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Sun, 13 Sep 2009 21:44:17 -0400 Subject: Make a new REST service for the autocomplete plugin, significantly reducing the size of the responses. Also enables caching in the browser. --- plugins/Autocomplete/AutocompletePlugin.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'plugins/Autocomplete/AutocompletePlugin.php') diff --git a/plugins/Autocomplete/AutocompletePlugin.php b/plugins/Autocomplete/AutocompletePlugin.php index b75397270..baaec73c1 100644 --- a/plugins/Autocomplete/AutocompletePlugin.php +++ b/plugins/Autocomplete/AutocompletePlugin.php @@ -31,6 +31,8 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } +require_once(INSTALLDIR.'/plugins/Autocomplete/autocomplete.php'); + class AutocompletePlugin extends Plugin { function __construct() @@ -40,13 +42,6 @@ class AutocompletePlugin extends Plugin function onEndShowScripts($action){ if (common_logged_in()) { - $current_user = common_current_user(); - $js_string = << -var current_user = { id: '$current_user->id' }; - -EOT; - $action->raw($js_string); $action->script('plugins/Autocomplete/jquery-autocomplete/jquery.autocomplete.pack.js'); $action->script('plugins/Autocomplete/Autocomplete.js'); } @@ -59,5 +54,12 @@ EOT; } } + function onRouterInitialized($m) + { + if (common_logged_in()) { + $m->connect('plugins/Autocomplete/autocomplete.json', array('action'=>'autocomplete')); + } + } + } ?> -- cgit v1.2.3-54-g00ecf