diff options
author | Craig Andrews <candrews@integralblue.com> | 2010-02-17 12:03:14 -0500 |
---|---|---|
committer | Craig Andrews <candrews@integralblue.com> | 2010-02-17 12:03:14 -0500 |
commit | 46e9aa13aa87955b441bc63b7cf2f58622b131b0 (patch) | |
tree | f57c2927d3ecfe415bac335cbed243bc61face06 | |
parent | c19300272f0074359b2713c35d2fb46bbd1b42ec (diff) |
htmloutputter->script() special cases src's that begin with plugin/ or local/ so that plugins don't need to include common_path() in every call to $action->script()
Adjust plugins to not call common_path() when it's not necessary
Fix minify plugin
-rw-r--r-- | lib/htmloutputter.php | 55 | ||||
-rw-r--r-- | plugins/Autocomplete/AutocompletePlugin.php | 4 | ||||
-rw-r--r-- | plugins/Comet/CometPlugin.php | 2 | ||||
-rw-r--r-- | plugins/Facebook/FacebookPlugin.php | 2 | ||||
-rw-r--r-- | plugins/Facebook/facebookaction.php | 2 | ||||
-rw-r--r-- | plugins/InfiniteScroll/InfiniteScrollPlugin.php | 4 | ||||
-rw-r--r-- | plugins/Minify/MinifyPlugin.php | 6 | ||||
-rw-r--r-- | plugins/OStatus/OStatusPlugin.php | 4 | ||||
-rw-r--r-- | plugins/Orbited/OrbitedPlugin.php | 4 | ||||
-rw-r--r-- | plugins/Realtime/RealtimePlugin.php | 4 |
10 files changed, 49 insertions, 38 deletions
diff --git a/lib/htmloutputter.php b/lib/htmloutputter.php index 7315fe2ad..7786b5941 100644 --- a/lib/htmloutputter.php +++ b/lib/htmloutputter.php @@ -356,40 +356,47 @@ class HTMLOutputter extends XMLOutputter if( empty($url['scheme']) && empty($url['host']) && empty($url['query']) && empty($url['fragment'])) { - $path = common_config('javascript', 'path'); + if (strpos($src, 'plugins/') === 0 || strpos($src, 'local/') === 0) { - if (empty($path)) { - $path = common_config('site', 'path') . '/js/'; - } + $src = common_path($src) . '?version=' . STATUSNET_VERSION; - if ($path[strlen($path)-1] != '/') { - $path .= '/'; - } + }else{ - if ($path[0] != '/') { - $path = '/'.$path; - } + $path = common_config('javascript', 'path'); - $server = common_config('javascript', 'server'); + if (empty($path)) { + $path = common_config('site', 'path') . '/js/'; + } - if (empty($server)) { - $server = common_config('site', 'server'); - } + if ($path[strlen($path)-1] != '/') { + $path .= '/'; + } - $ssl = common_config('javascript', 'ssl'); + if ($path[0] != '/') { + $path = '/'.$path; + } + + $server = common_config('javascript', 'server'); - if (is_null($ssl)) { // null -> guess - if (common_config('site', 'ssl') == 'always' && - !common_config('javascript', 'server')) { - $ssl = true; - } else { - $ssl = false; + if (empty($server)) { + $server = common_config('site', 'server'); } - } - $protocol = ($ssl) ? 'https' : 'http'; + $ssl = common_config('javascript', 'ssl'); - $src = $protocol.'://'.$server.$path.$src . '?version=' . STATUSNET_VERSION; + if (is_null($ssl)) { // null -> guess + if (common_config('site', 'ssl') == 'always' && + !common_config('javascript', 'server')) { + $ssl = true; + } else { + $ssl = false; + } + } + + $protocol = ($ssl) ? 'https' : 'http'; + + $src = $protocol.'://'.$server.$path.$src . '?version=' . STATUSNET_VERSION; + } } $this->element('script', array('type' => $type, diff --git a/plugins/Autocomplete/AutocompletePlugin.php b/plugins/Autocomplete/AutocompletePlugin.php index a28c65a29..d586631a4 100644 --- a/plugins/Autocomplete/AutocompletePlugin.php +++ b/plugins/Autocomplete/AutocompletePlugin.php @@ -42,8 +42,8 @@ class AutocompletePlugin extends Plugin function onEndShowScripts($action){ if (common_logged_in()) { - $action->script(common_path('plugins/Autocomplete/jquery-autocomplete/jquery.autocomplete.pack.js')); - $action->script(common_path('plugins/Autocomplete/Autocomplete.js')); + $action->script('plugins/Autocomplete/jquery-autocomplete/jquery.autocomplete.pack.js'); + $action->script('plugins/Autocomplete/Autocomplete.js'); } } diff --git a/plugins/Comet/CometPlugin.php b/plugins/Comet/CometPlugin.php index 300d1e9a2..29cb3004b 100644 --- a/plugins/Comet/CometPlugin.php +++ b/plugins/Comet/CometPlugin.php @@ -68,7 +68,7 @@ class CometPlugin extends RealtimePlugin $ours = array('jquery.comet.js', 'cometupdate.js'); foreach ($ours as $script) { - $scripts[] = common_path('plugins/Comet/'.$script); + $scripts[] = 'plugins/Comet/'.$script; } return $scripts; diff --git a/plugins/Facebook/FacebookPlugin.php b/plugins/Facebook/FacebookPlugin.php index 4266b886d..78c9054e1 100644 --- a/plugins/Facebook/FacebookPlugin.php +++ b/plugins/Facebook/FacebookPlugin.php @@ -181,7 +181,7 @@ class FacebookPlugin extends Plugin if ($this->reqFbScripts($action)) { $apikey = common_config('facebook', 'apikey'); - $plugin_path = common_path('plugins/Facebook'); + $plugin_path = 'plugins/Facebook'; $login_url = common_local_url('FBConnectAuth'); $logout_url = common_local_url('logout'); diff --git a/plugins/Facebook/facebookaction.php b/plugins/Facebook/facebookaction.php index 8437a705a..f65b97c86 100644 --- a/plugins/Facebook/facebookaction.php +++ b/plugins/Facebook/facebookaction.php @@ -89,7 +89,7 @@ class FacebookAction extends Action function showScripts() { - $this->script(common_path('plugins/Facebook/facebookapp.js')); + $this->script('plugins/Facebook/facebookapp.js'); } /** diff --git a/plugins/InfiniteScroll/InfiniteScrollPlugin.php b/plugins/InfiniteScroll/InfiniteScrollPlugin.php index 77ad83a51..a4d1a5d05 100644 --- a/plugins/InfiniteScroll/InfiniteScrollPlugin.php +++ b/plugins/InfiniteScroll/InfiniteScrollPlugin.php @@ -40,8 +40,8 @@ class InfiniteScrollPlugin extends Plugin function onEndShowScripts($action) { - $action->script(common_path('plugins/InfiniteScroll/jquery.infinitescroll.js')); - $action->script(common_path('plugins/InfiniteScroll/infinitescroll.js')); + $action->script('plugins/InfiniteScroll/jquery.infinitescroll.js'); + $action->script('plugins/InfiniteScroll/infinitescroll.js'); } function onPluginVersion(&$versions) diff --git a/plugins/Minify/MinifyPlugin.php b/plugins/Minify/MinifyPlugin.php index fe1883ded..69def6064 100644 --- a/plugins/Minify/MinifyPlugin.php +++ b/plugins/Minify/MinifyPlugin.php @@ -86,7 +86,11 @@ class MinifyPlugin extends Plugin $url = parse_url($src); if( empty($url['scheme']) && empty($url['host']) && empty($url['query']) && empty($url['fragment'])) { - $src = $this->minifyUrl($src); + if (strpos($src, 'plugins/') === 0 || strpos($src, 'local/') === 0) { + $src = $this->minifyUrl($src); + } else { + $src = $this->minifyUrl('js/'.$src); + } } } diff --git a/plugins/OStatus/OStatusPlugin.php b/plugins/OStatus/OStatusPlugin.php index 3b1329d6c..a30f68cb3 100644 --- a/plugins/OStatus/OStatusPlugin.php +++ b/plugins/OStatus/OStatusPlugin.php @@ -281,12 +281,12 @@ class OStatusPlugin extends Plugin } function onEndShowStatusNetStyles($action) { - $action->cssLink(common_path('plugins/OStatus/theme/base/css/ostatus.css')); + $action->cssLink('plugins/OStatus/theme/base/css/ostatus.css'); return true; } function onEndShowStatusNetScripts($action) { - $action->script(common_path('plugins/OStatus/js/ostatus.js')); + $action->script('plugins/OStatus/js/ostatus.js'); return true; } } diff --git a/plugins/Orbited/OrbitedPlugin.php b/plugins/Orbited/OrbitedPlugin.php index ba87b266a..8af71af74 100644 --- a/plugins/Orbited/OrbitedPlugin.php +++ b/plugins/Orbited/OrbitedPlugin.php @@ -77,9 +77,9 @@ class OrbitedPlugin extends RealtimePlugin $root = 'http://'.$server.(($port == 80) ? '':':'.$port); $scripts[] = $root.'/static/Orbited.js'; - $scripts[] = common_path('plugins/Orbited/orbitedextra.js'); + $scripts[] = 'plugins/Orbited/orbitedextra.js'; $scripts[] = $root.'/static/protocols/stomp/stomp.js'; - $scripts[] = common_path('plugins/Orbited/orbitedupdater.js'); + $scripts[] = 'plugins/Orbited/orbitedupdater.js'; return $scripts; } diff --git a/plugins/Realtime/RealtimePlugin.php b/plugins/Realtime/RealtimePlugin.php index 6c212453e..e8c44a743 100644 --- a/plugins/Realtime/RealtimePlugin.php +++ b/plugins/Realtime/RealtimePlugin.php @@ -117,7 +117,7 @@ class RealtimePlugin extends Plugin function onEndShowStatusNetStyles($action) { - $action->cssLink(common_path('plugins/Realtime/realtimeupdate.css'), + $action->cssLink('plugins/Realtime/realtimeupdate.css', null, 'screen, projection, tv'); return true; } @@ -307,7 +307,7 @@ class RealtimePlugin extends Plugin function _getScripts() { - return array(common_path('plugins/Realtime/realtimeupdate.js')); + return array('plugins/Realtime/realtimeupdate.js'); } function _updateInitialize($timeline, $user_id) |