From 95b900d4f47489a285024e3037f375a8dd79efd7 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Mon, 29 Jun 2009 19:11:59 -0700 Subject: Fix some bugs in the combined JS/CSS code (most of which I introduced in my last refactor): 1) Actually combine the JS (I was only combining the CSS) 2) Add line breaks between the files and comment them so that we can find a specific file inside the blob. 3) Add an HTML comment to help developers figure out why they can't find their CSS/JS. --- modules/gallery/libraries/Admin_View.php | 2 +- modules/gallery/libraries/Gallery_View.php | 13 +++++++------ modules/gallery/libraries/Theme_View.php | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) (limited to 'modules') diff --git a/modules/gallery/libraries/Admin_View.php b/modules/gallery/libraries/Admin_View.php index f7de96bf..58daf3d2 100644 --- a/modules/gallery/libraries/Admin_View.php +++ b/modules/gallery/libraries/Admin_View.php @@ -100,7 +100,7 @@ class Admin_View_Core extends Gallery_View { if ($function == "head") { array_unshift($blocks, $this->combine_files($this->css, "css")); - array_unshift($blocks, $this->combine_files($this->css, "javascript")); + array_unshift($blocks, $this->combine_files($this->scripts, "javascript")); } if (Session::instance()->get("debug")) { diff --git a/modules/gallery/libraries/Gallery_View.php b/modules/gallery/libraries/Gallery_View.php index 490fb574..40d78f94 100644 --- a/modules/gallery/libraries/Gallery_View.php +++ b/modules/gallery/libraries/Gallery_View.php @@ -74,7 +74,7 @@ class Gallery_View_Core extends View { $links = array(); $key = array(); - foreach (array_keys($this->css) as $file) { + foreach (array_keys($files) as $file) { $path = DOCROOT . $file; if (file_exists($path)) { $stats = stat($path); @@ -95,9 +95,9 @@ class Gallery_View_Core extends View { $contents = ""; foreach ($links as $link) { if ($type == "css") { - $contents .= $this->process_css($link); + $contents .= "/* $link */\n" . $this->process_css($link) . "\n"; } else { - $contents .= file_get_contents($link); + $contents .= "/* $link */\n" . file_get_contents($link) . "\n"; } } @@ -109,10 +109,11 @@ class Gallery_View_Core extends View { } if ($type == "css") { - return html::stylesheet("combined/css/$key", "screen,print,projection", true); + return "\n" . + html::stylesheet("combined/css/$key", "screen,print,projection", true); } else { - // Handcraft the script link because html::script will add a .js extenstion - return html::script("combined/javascript/$key", true); + return "\n" . + html::script("combined/javascript/$key", true); } } diff --git a/modules/gallery/libraries/Theme_View.php b/modules/gallery/libraries/Theme_View.php index b73a932c..898574d7 100644 --- a/modules/gallery/libraries/Theme_View.php +++ b/modules/gallery/libraries/Theme_View.php @@ -217,7 +217,7 @@ class Theme_View_Core extends Gallery_View { if ($function == "head") { array_unshift($blocks, $this->combine_files($this->css, "css")); - array_unshift($blocks, $this->combine_files($this->css, "javascript")); + array_unshift($blocks, $this->combine_files($this->scripts, "javascript")); } if (Session::instance()->get("debug")) { -- cgit v1.2.3