]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Merge remote branch 'origin/pluginstatic' into testing
authorEvan Prodromou <evan@status.net>
Tue, 8 Feb 2011 18:39:17 +0000 (13:39 -0500)
committerEvan Prodromou <evan@status.net>
Tue, 8 Feb 2011 18:39:17 +0000 (13:39 -0500)
25 files changed:
README
lib/default.php
lib/plugin.php
plugins/Autocomplete/AutocompletePlugin.php
plugins/BlankAd/BlankAdPlugin.php
plugins/Bookmark/BookmarkPlugin.php
plugins/Bookmark/bookmarkpopup.php
plugins/ClientSideShorten/ClientSideShortenPlugin.php
plugins/DirectionDetector/DirectionDetectorPlugin.php
plugins/FacebookBridge/actions/facebooklogin.php
plugins/InfiniteScroll/InfiniteScrollPlugin.php
plugins/LinkPreview/LinkPreviewPlugin.php
plugins/Mapstraction/MapstractionPlugin.php
plugins/Meteor/MeteorPlugin.php
plugins/MobileProfile/MobileProfilePlugin.php
plugins/ModPlus/ModPlusPlugin.php
plugins/NewMenu/NewMenuPlugin.php
plugins/OStatus/OStatusPlugin.php
plugins/OStatus/classes/Ostatus_profile.php
plugins/Realtime/RealtimePlugin.php
plugins/ShareNotice/ShareNoticePlugin.php
plugins/TabFocus/TabFocusPlugin.php
plugins/TinyMCE/TinyMCEPlugin.php
plugins/TwitterBridge/twitterlogin.php
plugins/YammerImport/actions/yammeradminpanel.php

diff --git a/README b/README
index d972bf5676fdb0cb7c52e4f31f9cc93347aea14e..b71d21aba50d77554e6892ae489f197bf5af4b57 100644 (file)
--- a/README
+++ b/README
@@ -1572,6 +1572,23 @@ proxy_user: Username to use for authenticating to the HTTP proxy. Default null.
 proxy_password: Password to use for authenticating to the HTTP proxy. Default null.
 proxy_auth_scheme: Scheme to use for authenticating to the HTTP proxy. Default null.
 
+plugins
+-------
+
+default: associative array mapping plugin name to array of arguments. To disable
+        a default plugin, unset its value in this array.
+locale_path: path for finding plugin locale files. In the plugin's directory
+            by default.
+server: Server to find static files for a plugin when the page is plain old HTTP.
+       Defaults to site/server (same as pages). Use this to move plugin CSS and
+       JS files to a CDN.
+sslserver: Server to find static files for a plugin when the page is HTTPS. Defaults
+          to site/server (same as pages). Use this to move plugin CSS and JS files
+          to a CDN.
+path: Path to the plugin files. defaults to site/path + '/plugins/'. Expects that
+      each plugin will have a subdirectory at plugins/NameOfPlugin. Change this
+      if you're using a CDN.
+
 Plugins
 =======
 
index 2ddc47bd17fbef451e16c049a5b18c9335fd24d5..7d8b1fec7a45460ed804ca4e4cba1661727b9221 100644 (file)
@@ -314,6 +314,9 @@ $default =
                                  'RSSCloud' => null,
                                  'OpenID' => null),
               'locale_path' => false, // Set to a path to use *instead of* each plugin's own locale subdirectories
+              'server' => null,
+              'sslserver' => null,
+              'path' => null,
               ),
         'admin' =>
         array('panels' => array('design', 'site', 'user', 'paths', 'access', 'sessions', 'sitenotice', 'license')),
index 3f84afa27e867a2c3c950a2ded5d1ae46cde44d7..1ca5deb5c5e08297448608856c94823b382ddb36 100644 (file)
@@ -110,11 +110,16 @@ class Plugin
     {
         $this->log(LOG_DEBUG, $msg);
     }
+    
+    function name()
+    {
+        $cls = get_class($this);
+        return mb_substr($cls, 0, -6);
+    }
 
     function onPluginVersion(&$versions)
     {
-        $cls = get_class($this);
-        $name = mb_substr($cls, 0, -6);
+        $name = $this->name();
 
         $versions[] = array('name' => $name,
                             // TRANS: Displayed as version information for a plugin if no version information was found.
@@ -122,4 +127,38 @@ class Plugin
 
         return true;
     }
+
+    function path($relative)
+    {
+        return self::staticPath($this->name(), $relative);
+    }
+
+    static function staticPath($plugin, $relative)
+    {
+        $isHTTPS = StatusNet::isHTTPS();
+
+        if ($isHTTPS) {
+            $server = common_config('plugins', 'sslserver');
+        } else {
+            $server = common_config('plugins', 'server');
+        }
+
+        if (is_null($server)) {
+            if ($isHTTPS) {
+                $server = common_config('site', 'sslserver');
+            } else {
+                $server = common_config('site', 'server');
+            }
+        }
+
+        $path = common_config('plugins', 'path');
+
+        if (is_null($path)) {
+            $path = common_config('site', 'path') . '/plugins/';
+        }
+
+        $protocol = ($isHTTPS) ? 'https' : 'http';
+
+        return $protocol.'://'.$server.$path.$plugin.'/'.$relative;
+    }
 }
index 230ba089de3e8fe0a6297ba27d196fb68a293920..ca495f79f4a8db1fa11e6b18bc2cb80d332dd2c1 100644 (file)
@@ -51,15 +51,15 @@ class AutocompletePlugin extends Plugin
 
     function onEndShowScripts($action){
         if (common_logged_in()) {
-            $action->script('plugins/Autocomplete/jquery-autocomplete/jquery.autocomplete.pack.js');
-            $action->script('plugins/Autocomplete/Autocomplete.js');
+            $action->script($this->path('jquery-autocomplete/jquery.autocomplete.pack.js'));
+            $action->script($this->path('Autocomplete.js'));
         }
     }
 
     function onEndShowStatusNetStyles($action)
     {
         if (common_logged_in()) {
-            $action->cssLink('plugins/Autocomplete/jquery-autocomplete/jquery.autocomplete.css');
+            $action->cssLink($this->path('jquery-autocomplete/jquery.autocomplete.css'));
         }
     }
 
index 49243aeea9dc9ff66e07e0c3340ed3b8f1671b6f..9128e7bcdb612886def664720f4c862f196485aa 100644 (file)
@@ -65,7 +65,7 @@ class BlankAdPlugin extends UAPPlugin
         $action->element('img',
                          array('width' => 300,
                                'height' => 250,
-                               'src' => common_path('plugins/BlankAd/redpixel.png')),
+                               'src' => $this->path('redpixel.png')),
                          '');
     }
 
@@ -81,7 +81,7 @@ class BlankAdPlugin extends UAPPlugin
         $action->element('img',
                          array('width' => 180,
                                'height' => 150,
-                               'src' => common_path('plugins/BlankAd/redpixel.png')),
+                               'src' => $this->path('redpixel.png')),
                          '');
     }
 
@@ -97,7 +97,7 @@ class BlankAdPlugin extends UAPPlugin
         $action->element('img',
                          array('width' => 160,
                                'height' => 600,
-                               'src' => common_path('plugins/BlankAd/redpixel.png')),
+                               'src' => $this->path('redpixel.png')),
                          '');
     }
 
@@ -113,7 +113,7 @@ class BlankAdPlugin extends UAPPlugin
         $action->element('img',
                          array('width' => 728,
                                'height' => 90,
-                               'src' => common_path('plugins/BlankAd/redpixel.png')),
+                               'src' => $this->path('redpixel.png')),
                          '');
     }
 
index 800a26e79573c1c650f802f7bd20f04e163f6eda..2e6baf5e4e5ab7b97c78993f70338c942610775e 100644 (file)
@@ -149,7 +149,7 @@ class BookmarkPlugin extends Plugin
 
     function onEndShowStyles($action)
     {
-        $action->cssLink('plugins/Bookmark/bookmark.css');
+        $action->cssLink($this->path('bookmark.css'));
         return true;
     }
 
index 24ed79612b3fd65fb3cc17101f6295219ff1c185..33f983a93a38578afcd14d3d66aa961a9dc7f1a9 100644 (file)
@@ -107,6 +107,6 @@ class BookmarkpopupAction extends NewbookmarkAction
     function showScripts()
     {
         parent::showScripts();
-        $this->script(common_path('plugins/Bookmark/bookmarkpopup.js'));
+        $this->script(Plugin::staticPath('Bookmark', 'bookmarkpopup.js'));
     }
 }
index 27a3a56f72d2e3cd62db96aaf3d366a03acef5b2..443d2fffe03fee20797a8f4e4f6c3e2e8deea806 100644 (file)
@@ -53,7 +53,7 @@ class ClientSideShortenPlugin extends Plugin
     function onEndShowScripts($action){
         $action->inlineScript('var Notice_maxContent = ' . Notice::maxContent());
         if (common_logged_in()) {
-            $action->script('plugins/ClientSideShorten/shorten.js');
+            $action->script($this->path('shorten.js'));
         }
     }
 
index 4a38f390f10a814089abba753c1fef5a5d2aa896..ec206dd75c2f8df2fae9846a2b2fa65ccbadf15e 100644 (file)
@@ -129,7 +129,7 @@ class DirectionDetectorPlugin extends Plugin {
      */
     function onEndShowScripts($action){
         if (common_logged_in()) {
-            $action->script('plugins/DirectionDetector/jquery.DirectionDetector.js');
+            $action->script($this->path('jquery.DirectionDetector.js'));
         }
     }
 
index f8a45c41b2969ebdb0c1803bf6f00026198a045c..924dd46565cdb53a44afe371ba50346a7391f726 100644 (file)
@@ -89,10 +89,7 @@ class FacebookloginAction extends Action
         );
 
         $attrs = array(
-            'src' => common_path(
-                'plugins/FacebookBridge/images/login-button.png',
-                true
-            ),
+            'src' => Plugin::staticPath('FacebookBridge', 'images/login-button.png'),
             'alt'   => 'Login with Facebook',
             'title' => 'Login with Facebook'
         );
index 50c1b5a208582f3dc0a9cb56147723c7f2c674b4..b6c4fabba001bb259c9c215825bde56d9e26668e 100644 (file)
@@ -40,8 +40,8 @@ class InfiniteScrollPlugin extends Plugin
 
     function onEndShowScripts($action)
     {
-        $action->script('plugins/InfiniteScroll/jquery.infinitescroll.js');
-        $action->script('plugins/InfiniteScroll/infinitescroll.js');
+        $action->script($this->path('jquery.infinitescroll.js'));
+        $action->script($this->path('infinitescroll.js'));
     }
 
     function onPluginVersion(&$versions)
index 65f896ca2745867200d2f31adbf594d08b9d4d57..8bc726413d42d39e8f30faa6e6870d9615f286c6 100644 (file)
@@ -51,7 +51,7 @@ class LinkPreviewPlugin extends Plugin
     {
         $user = common_current_user();
         if ($user && common_config('attachments', 'process_links')) {
-            $action->script('plugins/LinkPreview/linkpreview.min.js');
+            $action->script($this->path('linkpreview.min.js'));
             $data = json_encode(array(
                 'api' => common_local_url('oembedproxy'),
                 'width' => common_config('attachments', 'thumbwidth'),
index 020c0818ad20b055b778ad830c38ebf1616c3ca2..13c5e2205743f8a5e172e73375b7ff6722649d66 100644 (file)
@@ -129,7 +129,7 @@ class MapstractionPlugin extends Plugin
             break;
         case 'openlayers':
             // Use our included stripped & minified OpenLayers.
-            $action->script(common_path('plugins/Mapstraction/OpenLayers/OpenLayers.js'));
+            $action->script($this->path('OpenLayers/OpenLayers.js'));
             break;
         case 'yahoo':
             $action->script(sprintf('http://api.maps.yahoo.com/ajaxymap?v=3.8&appid=%s',
@@ -145,13 +145,13 @@ class MapstractionPlugin extends Plugin
             //
             // Note that OpenLayers.js needs to be separate, or it won't
             // be able to find its UI images and styles.
-            $action->script(common_path('plugins/Mapstraction/usermap-mxn-openlayers.min.js'));
+            $action->script($this->path('usermap-mxn-openlayers.min.js'));
         } else {
             $action->script(sprintf('%s?(%s)',
-                                    common_path('plugins/Mapstraction/js/mxn.js'),
+                                    $this->path('js/mxn.js'),
                                     $this->provider));
 
-            $action->script(common_path('plugins/Mapstraction/usermap.js'));
+            $action->script($this->path('usermap.js'));
         }
 
         $action->inlineScript(sprintf('var _provider = "%s";', $this->provider));
index 1bdccae7a82085fe331d2c711e642125ee30a3e3..6e93e364f736b900211e567672ef5ab8f781b368 100644 (file)
@@ -89,7 +89,7 @@ class MeteorPlugin extends RealtimePlugin
     {
         $scripts = parent::_getScripts();
         $scripts[] = 'http://'.$this->webserver.(($this->webport == 80) ? '':':'.$this->webport).'/meteor.js';
-        $scripts[] = common_path('plugins/Meteor/meteorupdater.min.js');
+        $scripts[] = $this->path('meteorupdater.min.js');
         return $scripts;
     }
 
index b50440682f70c532132193bdc5dcf6ea6e190ea8..b9c25ab998913d65cbf79ca2794a6f07ff30f9fc 100644 (file)
@@ -241,13 +241,13 @@ class MobileProfilePlugin extends WAP20Plugin
         if (file_exists(Theme::file('css/mp-screen.css'))) {
             $action->cssLink('css/mp-screen.css', null, 'screen');
         } else {
-            $action->cssLink('plugins/MobileProfile/mp-screen.css',null,'screen');
+            $action->cssLink($this->path('mp-screen.css'),null,'screen');
         }
 
         if (file_exists(Theme::file('css/mp-handheld.css'))) {
             $action->cssLink('css/mp-handheld.css', null, 'handheld');
         } else {
-            $action->cssLink('plugins/MobileProfile/mp-handheld.css',null,'handheld');
+            $action->cssLink($this->path('mp-handheld.css'),null,'handheld');
         }
 
         // Allow other plugins to load their styles.
index 3e7a8c745572c29ff56eabb430fbefc85a458807..d2b7c09346ba4a8758d820812b7dad1eab5b0c52 100644 (file)
@@ -51,13 +51,13 @@ class ModPlusPlugin extends Plugin
     {
         $user = common_current_user();
         if ($user) {
-            $action->script('plugins/ModPlus/modplus.js');
+            $action->script($this->path('modplus.js'));
         }
         return true;
     }
 
     function onEndShowStatusNetStyles($action) {
-        $action->cssLink('plugins/ModPlus/modplus.css');
+        $action->cssLink($this->path('modplus.css'));
         return true;
     }
 
index 382a3acc01fd56db22d287d0fa2ae35bdb90ed5d..bc8132f0daf8e4adc0116f1663ad2c33726b879f 100644 (file)
@@ -331,7 +331,7 @@ class NewMenuPlugin extends Plugin
                       array('default', 'identica', 'h4ck3r'))) &&
             ($action instanceof AccountSettingsAction ||
              $action instanceof ConnectSettingsAction)) {
-            $action->cssLink(common_path('plugins/NewMenu/newmenu.css'));
+            $action->cssLink($this->path('newmenu.css'));
         }
         return true;
     }
index 59c18746f0d6892398d34d34d1798892307db64f..8e6e2d2891ace0722f28f57f64ef7875dd0759e8 100644 (file)
@@ -419,12 +419,12 @@ class OStatusPlugin extends Plugin
     }
 
     function onEndShowStatusNetStyles($action) {
-        $action->cssLink('plugins/OStatus/theme/base/css/ostatus.css');
+        $action->cssLink($this->path('theme/base/css/ostatus.css'));
         return true;
     }
 
     function onEndShowStatusNetScripts($action) {
-        $action->script('plugins/OStatus/js/ostatus.js');
+        $action->script($this->path('js/ostatus.js'));
         return true;
     }
 
index 303e177a5702ae02d7e195bc1f7ed0a877c67a5f..13711d39f4cd6314d7f09043d73c65d57ce0c0e3 100644 (file)
@@ -1112,7 +1112,8 @@ class Ostatus_profile extends Memcached_DataObject
                 return $url;
             }
         }
-        return common_path('plugins/OStatus/images/96px-Feed-icon.svg.png');
+
+        return Plugin::staticPath('OStatus', 'images/96px-Feed-icon.svg.png');
     }
 
     /**
index 113187e1e3167dbfa28b9964d882704b98728658..246b1f9735d9ef8596115c17cf95708404239649 100644 (file)
@@ -116,8 +116,9 @@ class RealtimePlugin extends Plugin
 
     function onEndShowStatusNetStyles($action)
     {
-        $action->cssLink('plugins/Realtime/realtimeupdate.css',
-                         null, 'screen, projection, tv');
+        $action->cssLink(Plugin::staticPath('Realtime', 'realtimeupdate.css'),
+                         null,
+                         'screen, projection, tv');
         return true;
     }
 
@@ -322,7 +323,7 @@ class RealtimePlugin extends Plugin
 
     function _getScripts()
     {
-        return array('plugins/Realtime/realtimeupdate.min.js');
+        return array(Plugin::staticPath('Realtime', 'realtimeupdate.min.js'));
     }
 
     /**
index 8b94f83c8f09b00175802733486396195fa99b9f..0cd248e213bc0319de70e1429d172f16819960c1 100644 (file)
@@ -33,7 +33,7 @@ class ShareNoticePlugin extends Plugin
     );
 
     function onEndShowStatusNetStyles($action) {
-        $action->cssLink('plugins/ShareNotice/css/sharenotice.css');
+        $action->cssLink($this->path('css/sharenotice.css'));
         return true;
     }
 
index dd8a97276748a916e137ea0936ad96a775ddf027..1b1d1c2b0aba2800c92a93e9f061c5991182b2e3 100644 (file)
@@ -41,7 +41,7 @@ class TabFocusPlugin extends Plugin
 
     function onEndShowScripts($action)
     {
-        $action->script('plugins/TabFocus/tabfocus.js');
+        $action->script($this->path('tabfocus.js'));
     }
 
     function onPluginVersion(&$versions)
index e0640ebdf36d9194888cdac879441df33cc74676..49bbdf90db1159b236093299a0f73ae22f71259f 100644 (file)
@@ -38,6 +38,10 @@ if (!defined('STATUSNET')) {
  * Use TinyMCE library to allow rich text editing in the browser
  *
  * Converts the notice form in browser to a rich-text editor.
+ * 
+ * FIXME: this plugin DOES NOT load its static files from the configured
+ * plugin server if one exists. There are cross-server permissions errors
+ * if you try to do that (something about window.tinymce).
  *
  * @category  WYSIWYG
  * @package   StatusNet
index 5b5bfae191d9d616ed33e0aafeeb5d682f2df5d9..062c781f77c217b3170e66c8454d686ed51714b0 100644 (file)
@@ -83,7 +83,7 @@ class TwitterloginAction extends Action
         $this->elementStart('a', array('href' => common_local_url('twitterauthorization',
                                                                   null,
                                                                   array('signin' => true))));
-        $this->element('img', array('src' => common_path('plugins/TwitterBridge/Sign-in-with-Twitter-lighter.png'),
+        $this->element('img', array('src' => Plugin::staticPath('TwitterBridge', 'Sign-in-with-Twitter-lighter.png'),
                                     'alt' => _m('Sign in with Twitter')));
         $this->elementEnd('a');
     }
index 3faf390ac135c10894cd25bfeb8e5192e1a86456..4714154290781bb6df6c64aa5f7f8b7e7197b879 100644 (file)
@@ -176,12 +176,12 @@ class YammeradminpanelAction extends AdminPanelAction
     function showStylesheets()
     {
         parent::showStylesheets();
-        $this->cssLink('plugins/YammerImport/css/admin.css', null, 'screen, projection, tv');
+        $this->cssLink(Plugin::staticPath('YammerImport', 'css/admin.css'), null, 'screen, projection, tv');
     }
 
     function showScripts()
     {
         parent::showScripts();
-        $this->script('plugins/YammerImport/js/yammer-admin.js');
+        $this->script(Plugin::staticPath('YammerImport', 'js/yammer-admin.js'));
     }
 }