You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ra...@apache.org on 2012/05/17 19:27:06 UTC
svn commit: r1339729 - in /incubator/ambari/branches/ambari-186: CHANGES.txt
hmc/html/bootstrapJs.htmli hmc/yuiCombinator.php
Author: ramya
Date: Thu May 17 17:27:05 2012
New Revision: 1339729
URL: http://svn.apache.org/viewvc?rev=1339729&view=rev
Log:
AMBARI-218. Install Combo-Handler On HMC Webserver To Drastically Speed Up Page Load Times
Added:
incubator/ambari/branches/ambari-186/hmc/yuiCombinator.php
Modified:
incubator/ambari/branches/ambari-186/CHANGES.txt
incubator/ambari/branches/ambari-186/hmc/html/bootstrapJs.htmli
Modified: incubator/ambari/branches/ambari-186/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/CHANGES.txt?rev=1339729&r1=1339728&r2=1339729&view=diff
==============================================================================
--- incubator/ambari/branches/ambari-186/CHANGES.txt (original)
+++ incubator/ambari/branches/ambari-186/CHANGES.txt Thu May 17 17:27:05 2012
@@ -2,6 +2,9 @@ Ambari Change log
Release 0.x.x - unreleased
+ AMBARI-218. Install Combo-Handler On HMC Webserver To Drastically Speed Up
+ Page Load Times (Varun Kapoor via ramya)
+
AMBARI-259. add nodes to a cluster gives an option for ganglia and dashboard,
these should be on by default (Vinod via ramya)
Modified: incubator/ambari/branches/ambari-186/hmc/html/bootstrapJs.htmli
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/hmc/html/bootstrapJs.htmli?rev=1339729&r1=1339728&r2=1339729&view=diff
==============================================================================
--- incubator/ambari/branches/ambari-186/hmc/html/bootstrapJs.htmli (original)
+++ incubator/ambari/branches/ambari-186/hmc/html/bootstrapJs.htmli Thu May 17 17:27:05 2012
@@ -18,7 +18,13 @@
}
}
- var globalYui = YUI().use(
+ var globalYuiLoaderOptions = {
+ combine: true,
+ comboBase: '../yuiCombinator.php?',
+ root: 'yui-3.4.1/build/'
+ };
+
+ var globalYui = YUI( globalYuiLoaderOptions ).use(
"node", "io", "dump", "json", "panel", "event", "arraysort",
"array-extras", "datasource", "datasource-io", "datasource-jsonschema",
"datasource-polling", "stylesheet", "dd-drop", "dd-constrain",
Added: incubator/ambari/branches/ambari-186/hmc/yuiCombinator.php
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/hmc/yuiCombinator.php?rev=1339729&view=auto
==============================================================================
--- incubator/ambari/branches/ambari-186/hmc/yuiCombinator.php (added)
+++ incubator/ambari/branches/ambari-186/hmc/yuiCombinator.php Thu May 17 17:27:05 2012
@@ -0,0 +1,52 @@
+<?php
+
+function deduceContentType ($fileToLoad)
+{
+ $contentType = '';
+
+ $fileExtension = pathinfo($fileToLoad, PATHINFO_EXTENSION);
+
+ if ($fileExtension == 'css')
+ {
+ $contentType = 'text/css';
+ }
+ elseif ($fileExtension == 'js' )
+ {
+ $contentType = 'application/js';
+ }
+
+ return $contentType;
+}
+
+/* main() */
+$filesToLoad = explode('&', $_SERVER['QUERY_STRING']);
+
+$contentType = '';
+$responseBody = '';
+
+foreach ($filesToLoad as $fileToLoad)
+{
+ /* Assumes a request has only homogenous file types, which holds true for
+ * the combined requests YUI makes.
+ */
+ if (empty($contentType))
+ {
+ $contentType = deduceContentType($fileToLoad);
+ }
+
+ $fileContents = file_get_contents('./' . $fileToLoad);
+
+ if ($fileContents)
+ {
+ $responseBody .= $fileContents;
+ }
+}
+
+header('Content-type: ' . $contentType);
+/* TODO XXX Add appropriate Cache-Control/Age/Last-Modified/Expires headers
+ * here to be super-efficient.
+ */
+
+echo $responseBody;
+
+?>