[geeklog-cvs] geeklog: Added Config option for using CDN hosted jQuery files.

geeklog-cvs at lists.geeklog.net geeklog-cvs at lists.geeklog.net
Sat Mar 5 15:41:41 EST 2011


changeset 8144:f8fd9ffb2b7c
url:  http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/f8fd9ffb2b7c
user: Tom <websitemaster at cogeco.net>
date: Sat Mar 05 15:41:08 2011 -0500
description:
Added Config option for using CDN hosted jQuery files.
Fixed bug where the Common Javascript file was not always loaded

diffstat:

 language/english.php                           |   1 +
 public_html/admin/configuration_validation.php |   1 +
 public_html/admin/install/config-install.php   |   1 +
 public_html/docs/english/config.html           |   5 +++
 sql/updates/mssql_1.7.1_to_1.8.0.php           |   4 +-
 sql/updates/mysql_1.7.1_to_1.8.0.php           |   4 +-
 sql/updates/pgsql_1.7.1_to_1.8.0.php           |   4 +-
 system/classes/scripts.class.php               |  43 ++++++++++++++++---------
 8 files changed, 44 insertions(+), 19 deletions(-)

diffs (183 lines):

diff -r 5e855016cbc6 -r f8fd9ffb2b7c language/english.php
--- a/language/english.php	Sat Mar 05 18:14:50 2011 +0000
+++ b/language/english.php	Sat Mar 05 15:41:08 2011 -0500
@@ -1951,6 +1951,7 @@
     'censorlist' => "Censor List",
     'ip_lookup' => "IP Lookup",
     'url_rewrite' => "Enable URL Rewrite",
+    'cdn_hosted' => "Use CDN-hosted copy of jQuery",
     'meta_tags' => "Meta Tags",
     'meta_description' => "Default Meta Description",
     'meta_keywords' => "Default Meta Keywords",    
diff -r 5e855016cbc6 -r f8fd9ffb2b7c public_html/admin/configuration_validation.php
--- a/public_html/admin/configuration_validation.php	Sat Mar 05 18:14:50 2011 +0000
+++ b/public_html/admin/configuration_validation.php	Sat Mar 05 15:41:08 2011 -0500
@@ -42,6 +42,7 @@
     'message' => isset($LANG_VALIDATION['year']) ? $LANG_VALIDATION['year'] : $LANG_VALIDATION['default']
 );
 $_CONF_VALIDATE['Core']['url_rewrite'] = array('rule' => 'boolean');
+$_CONF_VALIDATE['Core']['cdn_hosted'] = array('rule' => 'boolean');
 $_CONF_VALIDATE['Core']['meta_tags'] = array('rule' => array('inList', array(0, 1, 2), true));
 $_CONF_VALIDATE['Core']['meta_description'] = array('rule' => 'stringOrEmpty');
 $_CONF_VALIDATE['Core']['meta_keywords'] = array('rule' => 'stringOrEmpty');
diff -r 5e855016cbc6 -r f8fd9ffb2b7c public_html/admin/install/config-install.php
--- a/public_html/admin/install/config-install.php	Sat Mar 05 18:14:50 2011 +0000
+++ b/public_html/admin/install/config-install.php	Sat Mar 05 15:41:08 2011 -0500
@@ -54,6 +54,7 @@
     $c->add('site_disabled_msg','Geeklog Site is down. Please come back soon.','textarea',0,0,NULL,510,TRUE, $me, 0);
     $c->add('copyrightyear',date('Y'),'text',0,0,NULL,1440,FALSE, $me, 0);
     $c->add('url_rewrite',FALSE,'select',0,0,1,1800,TRUE, $me, 0);
+    $c->add('cdn_hosted',FALSE,'select',0,0,1,1900,TRUE, $me, 0);
     $c->add('meta_tags',0,'select',0,0,23,2000,TRUE, $me, 0);
     $c->add('meta_description','Geeklog - The secure Content Management System.','textarea',0,0,NULL,2010,TRUE, $me, 0);
     $c->add('meta_keywords','Geeklog, Content Management System, CMS, Open Source, Secure, Security, Blog, Weblog','textarea',0,0,NULL,2020,TRUE, $me, 0);
diff -r 5e855016cbc6 -r f8fd9ffb2b7c public_html/docs/english/config.html
--- a/public_html/docs/english/config.html	Sat Mar 05 18:14:50 2011 +0000
+++ b/public_html/docs/english/config.html	Sat Mar 05 15:41:08 2011 -0500
@@ -94,6 +94,11 @@
   <td valign="top">Enable (true) or disable (false) URL rewriting.<br>
     Also see the section on <a href="#url-rewrite">URL Rewriting</a> below.</td></tr>
 <tr>
+  <td valign="top"><a name="desc_cdn_hosted">cdn_hosted</a></td>
+  <td valign="top">false</td>
+  <td valign="top">Enable (true) or disable (false) Google CDN-hosted source for jQuery 
+   and jQuery UI.</td></tr>    
+<tr>
   <td valign="top"><a name="desc_meta_tags">meta_tags</a></td>
   <td valign="top">disabled</td>
   <td valign="top">Enabled - The meta tags for stories and topics will be displayed. If none are found, then the default will be used. The default will also be used for any page that doesn't have meta tags.<br>
diff -r 5e855016cbc6 -r f8fd9ffb2b7c sql/updates/mssql_1.7.1_to_1.8.0.php
--- a/sql/updates/mssql_1.7.1_to_1.8.0.php	Sat Mar 05 18:14:50 2011 +0000
+++ b/sql/updates/mssql_1.7.1_to_1.8.0.php	Sat Mar 05 15:41:08 2011 -0500
@@ -166,8 +166,10 @@
     $c->add('autotag_permissions_story', array(2, 2, 2, 2), '@select', 7, 41, 28, 1870, TRUE, $me, 37);
     $c->add('autotag_permissions_user', array(2, 2, 2, 2), '@select', 7, 41, 28, 1880, TRUE, $me, 37);
     
+    // JavaScript use Google CDN for jQuery
+    $c->add('cdn_hosted',FALSE,'select',0,0,1,1900,TRUE, $me, 0);    
+    
     // Add in all the New Tabs
-
     $c->add('tab_site', NULL, 'tab', 0, 0, NULL, 0, TRUE, $me, 0);
     $c->add('tab_mail', NULL, 'tab', 0, 1, NULL, 0, TRUE, $me, 1);
     $c->add('tab_syndication', NULL, 'tab', 0, 2, NULL, 0, TRUE, $me, 2);
diff -r 5e855016cbc6 -r f8fd9ffb2b7c sql/updates/mysql_1.7.1_to_1.8.0.php
--- a/sql/updates/mysql_1.7.1_to_1.8.0.php	Sat Mar 05 18:14:50 2011 +0000
+++ b/sql/updates/mysql_1.7.1_to_1.8.0.php	Sat Mar 05 15:41:08 2011 -0500
@@ -166,8 +166,10 @@
     $c->add('autotag_permissions_story', array(2, 2, 2, 2), '@select', 7, 41, 28, 1870, TRUE, $me, 37);
     $c->add('autotag_permissions_user', array(2, 2, 2, 2), '@select', 7, 41, 28, 1880, TRUE, $me, 37);
     
+    // JavaScript use Google CDN for jQuery
+    $c->add('cdn_hosted',FALSE,'select',0,0,1,1900,TRUE, $me, 0);
+    
     // Add in all the New Tabs
-
     $c->add('tab_site', NULL, 'tab', 0, 0, NULL, 0, TRUE, $me, 0);
     $c->add('tab_mail', NULL, 'tab', 0, 1, NULL, 0, TRUE, $me, 1);
     $c->add('tab_syndication', NULL, 'tab', 0, 2, NULL, 0, TRUE, $me, 2);
diff -r 5e855016cbc6 -r f8fd9ffb2b7c sql/updates/pgsql_1.7.1_to_1.8.0.php
--- a/sql/updates/pgsql_1.7.1_to_1.8.0.php	Sat Mar 05 18:14:50 2011 +0000
+++ b/sql/updates/pgsql_1.7.1_to_1.8.0.php	Sat Mar 05 15:41:08 2011 -0500
@@ -167,8 +167,10 @@
     $c->add('autotag_permissions_story', array(2, 2, 2, 2), '@select', 7, 41, 28, 1870, TRUE, $me, 37);
     $c->add('autotag_permissions_user', array(2, 2, 2, 2), '@select', 7, 41, 28, 1880, TRUE, $me, 37);
     
+    // JavaScript use Google CDN for jQuery
+    $c->add('cdn_hosted',FALSE,'select',0,0,1,1900,TRUE, $me, 0);    
+    
     // Add in all the New Tabs
-
     $c->add('tab_site', NULL, 'tab', 0, 0, NULL, 0, TRUE, $me, 0);
     $c->add('tab_mail', NULL, 'tab', 0, 1, NULL, 0, TRUE, $me, 1);
     $c->add('tab_syndication', NULL, 'tab', 0, 2, NULL, 0, TRUE, $me, 2);
diff -r 5e855016cbc6 -r f8fd9ffb2b7c system/classes/scripts.class.php
--- a/system/classes/scripts.class.php	Sat Mar 05 18:14:50 2011 +0000
+++ b/system/classes/scripts.class.php	Sat Mar 05 15:41:08 2011 -0500
@@ -40,10 +40,10 @@
 
     private $library_files; // Array of available jQuery library files that can be loaded
     
-    private $jquery_cdn; // Flag to use jQuery file from Google CDN
+    private $jquery_cdn; // Flag to use jQuery file from CDN-hosted source (Google)
     private $jquery_cdn_file; // Location of jQuery file at Google
     
-    private $jquery_ui_cdn; // Flag to use jQuery UI file from Google CDN
+    private $jquery_ui_cdn; // Flag to use jQuery UI file from CDN-hosted source (Google)
     private $jquery_ui_cdn_file; // Location of jQuery UI file at Google
     
     private $script_files; // Array of JavaScript files set to be loaded either in the header or footer
@@ -79,7 +79,6 @@
         
         $theme_path = '/layout/' . $_CONF['theme'];
         
-        $_CONF['Google_CDN'] = false;
         $this->jquery_cdn = false;
         $this->jquery_ui_cdn = false;
         
@@ -196,8 +195,8 @@
         if (isset($this->library_files[$name])) {
             if (!$this->library_files[$name]['load']) {
                 $this->library_files[$name]['load'] = true;
-                // If name is subset of jQuery.UI make sure all UI libraries are loaded
-                if (substr($name, 0, 10) == 'jquery.ui.' && !$this->jquery_ui_cdn) {
+                // If name is subset of jQuery. make sure all Core UI libraries are loaded
+                if (substr($name, 0, 7) == 'jquery.' && !$this->jquery_ui_cdn) {
                     // Check that file exists, if not use Google version
                     if (!file_exists($_CONF['path'] . 'public_html/' .$this->library_files[$name]['file'])) {
                         $this->jquery_ui_cdn = true;
@@ -215,11 +214,11 @@
                     $this->library_files['jquery.ui.position']['load'] = true;
                     $this->library_files['jquery.ui.mouse']['load'] = true;
                     
-                    if ($_CONF['Google_CDN']) {
+                    if ($_CONF['cdn_hosted']) {
                         $this->jquery_cdn = true;
                         $this->jquery_ui_cdn = true;
                     }
-                } elseif ($name == 'jquery' && $_CONF['Google_CDN']) {
+                } elseif ($name == 'jquery' && $_CONF['cdn_hosted']) {
                     $this->jquery_cdn = true;
                 }
 
@@ -426,19 +425,31 @@
             // Set JavaScript Library Files first incase other scripts need them
             if ($this->jquery_cdn) {
                 $footercode .= '<script type="text/javascript" src="' . $this->jquery_cdn_file . '"></script>' . LB;
+                $this->library_files['jquery']['load'] = false; // Set to false so not reloaded
                 if ($this->jquery_ui_cdn) {
                     $footercode .= '<script type="text/javascript" src="' . $this->jquery_ui_cdn_file . '"></script>' . LB;
+                    // Since using CDN file reset loading of jQuery UI
+                    foreach ($this->library_files as $key => &$file) {
+                        if (substr($key, 0, 7) == 'jquery.') {
+                            $file['load'] = false;
+                        }
+                    }                    
                 }
-            } else{
-                if ($this->jquery_ui_cdn) { //This might happen if a jQuery UI file is not found
-                    $footercode .= '<script type="text/javascript" src="' . $_CONF['site_url'] . '/' . $this->library_files['jquery']['file'] . '"></script>' . LB;
-                    $footercode .= '<script type="text/javascript" src="' . $this->jquery_ui_cdn_file . '"></script>' . LB;
-                } else {
-                    foreach ($this->library_files as $file) {
-                        if ($file['load']) {
-                            $footercode .= '<script type="text/javascript" src="' . $_CONF['site_url'] . '/' . $file['file'] . '"></script>' . LB;
-                        }
+            } elseif ($this->jquery_ui_cdn) { // This might happen if a jQuery UI file is not found
+                $footercode .= '<script type="text/javascript" src="' . $_CONF['site_url'] . '/' . $this->library_files['jquery']['file'] . '"></script>' . LB;
+                $this->library_files['jquery']['load'] = false; // Set to false so not reloaded
+                $footercode .= '<script type="text/javascript" src="' . $this->jquery_ui_cdn_file . '"></script>' . LB;
+                // Since using CDN file reset loading of jQuery UI
+                foreach ($this->library_files as $key => &$file) {
+                    if (substr($key, 0, 7) == 'jquery.') {
+                        $file['load'] = false;
                     }
+                }                  
+            }
+            // Now load in the rest of the libraries
+            foreach ($this->library_files as $file) {
+                if ($file['load']) {
+                    $footercode .= '<script type="text/javascript" src="' . $_CONF['site_url'] . '/' . $file['file'] . '"></script>' . LB;
                 }
             }
             



More information about the geeklog-cvs mailing list