Skip to content

Commit

Permalink
Doc and example cleanup. Fixing combo.php query string explode bug. M…
Browse files Browse the repository at this point in the history
…odifying loader APC/Curl support checks. Adding support for APC to combo.php. Fixing most of the CSS relative image path issues with combo.php.
  • Loading branch information
cauld committed Oct 30, 2009
1 parent af5528e commit 5a52dbf
Show file tree
Hide file tree
Showing 15 changed files with 166 additions and 155 deletions.
7 changes: 7 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,10 @@ ChangeLog

1.0.0b1
* Initial release

1.0.0b2
* Doc cleanup
* Combo script incorrectly exploded the query string on & not &.
* Modified APC/Curl support checks
* Adding APC support for combo.php
* Combo.php was not handling relative image path in the raw css. Now converts to absolute paths.
7 changes: 3 additions & 4 deletions INSTALL
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,20 @@ Local Combo Handler Setup
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This feature will allow YUI PHP Loader to combine files without relying
on a remote combo-service. The key use case here would be someone
writing their own website/application in PHP.
on a remote combo-service.

1. The main endpoint for combo requests in this case is combo.php. Place
this file in the same location as loader.php.

Note: If the phploader directory does not live in the webserver's root
folder then modify the $pathToYUILoader variable in combo.php accordingly
folder then modify the PATH_TO_LOADER variable in combo.php accordingly.

2. Download and extract each version of YUI you intend to support into
the phploader/lib directory.

A valid setup would look something like:
htdocs/phploader/lib/2.8.0r4/build
htdocs/phploader/lib/2.7.0/build
htdocs/phploader/lib/2.6.0/build
etc...

3. Refer to usage documents and examples:
Expand Down
5 changes: 3 additions & 2 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ license.txt
Open source license details.

lib/meta
Contains the YUI module dependency metadata. The latest version is
shipped with each release, but you can manually add additional version.
Contains the YUI module dependency metadata (for versions 2 and 3).
The latest version is shipped with each release, but you can manually
add additional version.

phploader/loader.php
The main YUI PHP Loader class file
Expand Down
2 changes: 1 addition & 1 deletion examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ <h1 class="firstContent">
<li><a href='phploader-basic.php'>Using PHP Loader to Load the Calendar Control (Basic)</a>: This example demonstrates a simple implementation in which we bring in the YUI Calendar Control — and its JavaScript and CSS dependencies — using the PHP Loader Utility.</li>
<li><a href='phploader-advanced.php'>Using PHP Loader to Load the Calendar Control (Advanced)</a>: This example demonstrates a more advanced implementation in which we bring in the YUI Calendar Control — and its JavaScript and CSS dependencies — using the PHP Loader Utility. The major difference between this and the previous example is that the CSS and JavaScript are output via separate method calls allowing for more control/optimization.</li>
<li><a href='phploader-custom-modules.php'>Adding Custom (Non-YUI) Content with PHP Loader</a>: PHP Loader can be used to add YUI components to the page, but it can also be used to add other components that you create yourself (or that you pull from a third-party source). This example shows one simple way to pull in external content with PHP Loader.</li>
<li><a href='phploader-custom-modules-with-yui.php'>Adding Custom Modules with YUI Dependencies</a>: PHP Loader can be used to add YUI components to the page, but it can also be used to add other components that you create yourself (or that you pull from a third-party source). This example shows how to pull in external content that has dependancies on YUI components.</li>
<li><a href='phploader-custom-modules-with-yui.php'>Adding Custom Modules with YUI Dependencies</a>: PHP Loader can be used to add YUI components to the page, but it can also be used to add other components that you create yourself (or that you pull from a third-party source). This example shows how to pull in external content that has dependencies on YUI components.</li>
<li><a href='phploader-local-combo-handler.php'>Using the Local Combo Handler</a>: PHP Loader ships with intrinsic combo-handling support. This feature will allow PHP Loader to combine files without relying on a remote combo-service such as the one outlined <a href="http://developer.yahoo.com/yui/articles/hosting/?#combo">here</a>. It should also prove useful in environments where SSL is required and/or where including scripts from remote servers is prohibited.</li>
</ul>
</div>
Expand Down
2 changes: 1 addition & 1 deletion examples/phploader-advanced_source.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?PHP
include("./inc/config.inc");
include("../phploader/loader.php");
$loader = new YAHOO_util_Loader($yuiCurrentVersion); //(ex) 2.7.0
$loader = new YAHOO_util_Loader($yuiCurrentVersion); //$customModules

//Specify YUI components to load
$loader->load("calendar");
Expand Down
13 changes: 7 additions & 6 deletions examples/phploader-basic.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,19 @@
</ol>
<p>Here's what that looks like in terms of raw source &mdash; this is the full source code for this example: </p>
<textarea name="code" class="php" cols="60" rows="1">
&lt;?PHP
include("loader.php");
$loader = new YAHOO_util_Loader("<?PHP echo($yuiCurrentVersion);?>");

//Specify YUI components to load
$loader->load("calendar");
?&gt;
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>YUI PHP Loader Utility Basic Example: Loading YUI Calendar with the YUI PHP Loader Utility</title>

&lt;?PHP
include("loader.php");
$loader = new YAHOO_util_Loader("<?PHP echo($yuiCurrentVersion);?>");

//Specify YUI components to load
$loader->load("calendar");

//Output the CSS and JavaScript tags
echo $loader->tags();
?&gt;
Expand Down
2 changes: 1 addition & 1 deletion examples/phploader-basic_source.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?PHP
include("./inc/config.inc");
include("../phploader/loader.php");
$loader = new YAHOO_util_Loader($yuiCurrentVersion); //(ex) 2.7.0
$loader = new YAHOO_util_Loader($yuiCurrentVersion); //$customModules

//Specify YUI components to load
$loader->load("calendar");
Expand Down
44 changes: 19 additions & 25 deletions examples/phploader-custom-modules-with-yui.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,29 +28,31 @@
<h2 class="first">Defining a Custom Module with YUI Component Dependencies</h2>

<p>
The YAHOO_util_Loader class constructor accepts three parameters:
The YAHOO_util_Loader class constructor accepts four parameters:
</p>
<ol>
<li><strong>yuiVersion</strong>: Version of YUI metadata to load</li>
<li><strong>cacheKey</strong>: Unique name to use as the <a href="http://us.php.net/manual/en/book.apc.php">APC</a> cache key. Module calculations
are cached for performance if the environment supports APC.</li>
<li><strong>modules</strong>: A list of custom modules</li>
<li><strong>modules</strong>: An array of custom modules</li>
<li><strong>noYUI</strong>: Enable or disable the base YUI metadata</li>
</ol>

<p>The <em>modules</em> parameter expects an associative array. The array should consist of custom JavaScript and/or
CSS modules defined using the following format:</p>
CSS modules. The modules array format mirrors that of the YUI metadata included with PHP Loader. Use the metadata in the lib/meta folder as
a reference for determining all the possible options. Below is an example of such an array:</p>

<textarea name="code" class="php" cols="60" rows="1">
$customConfig = array(
"customJS" => array(
"name" => 'customJS',
$customModules = array(
"JSONModule" => array(
"name" => 'JSONModule',
"type" => 'js', // 'js' or 'css'
// "path" => 'path/to/file3.css', // includes base
"fullpath" => '../assets/custom/data.js', // overrides path
"global" => true, // globals are always loaded
"requires" => array (0 => 'event', 1 => 'dom', 2 => 'json'),
// "supersedes" => array (0 => 'something'), // if a rollup
// "rollup" => 3 // the rollup threshold
// "requires" => array('event', 'dom'),
// "optional" => array('connection'),
// "supersedes" => array('something'), // if a rollup
// "rollup" => 3, // the rollup threshold
// "path" => 'path/to/file.js', // includes base
"fullpath" => 'http://www.json.org/json2.js' // overrides path
)
);
</textarea>
Expand All @@ -76,31 +78,23 @@
include("loader.php");

//Create a custom module metadata set
$customConfig = array(
$customModules = array(
"customJS" => array(
"name" => 'customJS',
"type" => 'js', // 'js' or 'css'
// "path" => 'path/to/file3.css', // includes base
"fullpath" => './assets/custom/data.js', // overrides path
"global" => true, // globals are always loaded
"requires" => array (0 => 'event', 1 => 'dom', 2 => 'json'),
// "supersedes" => array (0 => 'something'), // if a rollup
// "rollup" => 3 // the rollup threshold
"requires" => array("event", "dom", "json")
),
"customCSS" => array(
"name" => 'customCSS',
"type" => 'css', // 'js' or 'css'
// "path" => 'path/to/file3.css', // includes base
"fullpath" => './assets/custom/custom.css', // overrides path
"global" => true, // globals are always loaded
// "supersedes" => array (0 => 'something'), // if a rollup
// "rollup" => 3 // the rollup threshold
"type" => 'css',
"fullpath" => './assets/custom/custom.css'
)
);

//Get a new YAHOO_util_Loader instance which includes our custom metadata along with the base YUI metadata
//Note: rand is used here to help cache bust the example
$loader = new YAHOO_util_Loader('<?PHP echo($yuiCurrentVersion);?>', 'my_custom_config_'.rand(), $customConfig);
$loader = new YAHOO_util_Loader('<?PHP echo($yuiCurrentVersion);?>', 'my_custom_config_'.rand(), $customModules);
$loader->load("customJS", "customCSS");
?&gt;

Expand Down
14 changes: 3 additions & 11 deletions examples/phploader-custom-modules-with-yui_source.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,23 @@
include("../phploader/loader.php");

//Create a custom module metadata set
$customConfig = array(
$customModules = array(
"customJS" => array(
"name" => 'customJS',
"type" => 'js', // 'js' or 'css'
// "path" => 'path/to/file3.css', // includes base
"fullpath" => './assets/custom/data.js', // overrides path
"global" => true, // globals are always loaded
"requires" => array (0 => 'event', 1 => 'dom', 2 => 'json'),
// "supersedes" => array (0 => 'something'), // if a rollup
// "rollup" => 3 // the rollup threshold
"requires" => array("event", "dom", "json")
),
"customCSS" => array(
"name" => 'customCSS',
"type" => 'css', // 'js' or 'css'
// "path" => 'path/to/file3.css', // includes base
"fullpath" => './assets/custom/custom.css', // overrides path
"global" => true, // globals are always loaded
// "supersedes" => array (0 => 'something'), // if a rollup
// "rollup" => 3 // the rollup threshold
)
);

//Get a new YAHOO_util_Loader instance which includes our custom metadata along with the base YUI metadata
//Note: rand is used here to help cache bust the example
$loader = new YAHOO_util_Loader($yuiCurrentVersion, 'my_custom_config_'.rand(), $customConfig);
$loader = new YAHOO_util_Loader($yuiCurrentVersion, 'my_custom_config_'.rand(), $customModules);
$loader->load("customJS", "customCSS");
?>

Expand Down
59 changes: 26 additions & 33 deletions examples/phploader-custom-modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,36 +27,37 @@
<h2 class="first">Defining a Custom Module</h2>

<p>
The YAHOO_util_Loader class constructor accepts three parameters:
The YAHOO_util_Loader class constructor accepts four parameters:
</p>
<ol>
<li><strong>yuiVersion</strong>: Version of YUI metadata to load</li>
<li><strong>cacheKey</strong>: Unique name to use as the <a href="http://us.php.net/manual/en/book.apc.php">APC</a> cache key. Module calculations
are cached for performance if the environment supports APC.</li>
<li><strong>modules</strong>: A list of custom modules</li>
<li><strong>modules</strong>: An array of custom modules</li>
<li><strong>noYUI</strong>: Enable or disable the base YUI metadata</li>
</ol>

<p>The <em>modules</em> parameter expects an associative array. The array should consist of custom JavaScript and/or
CSS modules defined using the following format:</p>
CSS modules. The modules array format mirrors that of the YUI metadata included with PHP Loader. Use the metadata in the lib/meta folder as
a reference for determining all the possible options. Below is an example of such an array:</p>

<textarea name="code" class="php" cols="60" rows="1">
$customConfig = array(
"dcJson" => array(
"name" => 'dcJson',
$customModules = array(
"JSONModule" => array(
"name" => 'JSONModule',
"type" => 'js', // 'js' or 'css'
// "requires" => array('event', 'dom'),
// "optional" => array('connection'),
// "supersedes" => array('something'), // if a rollup
// "rollup" => 3, // the rollup threshold
// "path" => 'path/to/file.js', // includes base
"fullpath" => 'http://www.json.org/json2.js', // overrides path
// "requires" => array (0 => 'event', 1 => 'dom'),
// "optional" => array (0 => 'connection'),
// "global" => true, // globals are always loaded
// "supersedes" => array (0 => 'something'), // if a rollup
// "rollup" => 3 // the rollup threshold
"fullpath" => 'http://www.json.org/json2.js' // overrides path
)
);
</textarea>

<p><strong>Note:</strong> The module names must be unique and should not conflict with any of the existing YUI
component names if you have chosen to leave the YUI metadata enabled. To make a custom module dependant on an existing
component names if you have chosen to leave the YUI metadata enabled. To make a custom module dependent on an existing
YUI module simply default a <em>requires</em> key/value pair that lists out the desired YUI components.</p>

<h2>Simple Example with no YUI Dependencies</h2>
Expand All @@ -73,37 +74,29 @@
include("loader.php");

//Create a custom module metadata set
$customConfig = array(
"dcJson" => array(
"name" => 'dcJson',
$customModules = array(
"JSONModule" => array(
"name" => 'JSONModule',
"type" => 'js', // 'js' or 'css'
// "path" => 'path/to/file.js', // includes base
"fullpath" => 'http://www.json.org/json2.js', // overrides path
// "requires" => array (0 => 'event', 1 => 'dom'),
// "optional" => array (0 => 'connection'),
// "global" => true, // globals are always loaded
// "supersedes" => array (0 => 'something'), // if a rollup
// "rollup" => 3 // the rollup threshold
"fullpath" => 'http://www.json.org/json2.js' // overrides path
),
"customJS" => array(
"name" => 'customJS',
"type" => 'js', // 'js' or 'css'
"fullpath" => './assets/custom/data.js', // overrides path
"global" => true, // globals are always loaded
"requires" => array (0 => 'dcJson')
"type" => 'js',
"fullpath" => './assets/custom/data.js',
"requires" => array('JSONModule')
),
"customCSS" => array(
"name" => 'customCSS',
"type" => 'css', // 'js' or 'css'
"fullpath" => './assets/custom/custom.css', // overrides path
"global" => true // globals are always loaded
"type" => 'css',
"fullpath" => './assets/custom/custom.css'
)
);

//Get a new YAHOO_util_Loader instance which includes just our custom metadata (No YUI metadata)
//Note: rand is used here to help cache bust the example
$loader = new YAHOO_util_Loader('<?PHP echo($yuiCurrentVersion);?>', 'my_custom_config_'.rand(), $customConfig, true);
$loader->load("dcJson", "customJS", "customCSS");
$loader = new YAHOO_util_Loader('<?PHP echo($yuiCurrentVersion);?>', 'my_custom_config_'.rand(), $customModules, true);
$loader->load("JSONModule", "customJS", "customCSS");
?&gt;

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
Expand Down Expand Up @@ -170,7 +163,7 @@
<li><strong>A custom module set is defined</strong></li>
<li><strong>An instance of YUI PHP Loader is created:</strong> Our custom module set is passed to the Loader</li>
<li><strong>YUI PHP Loader calculates the dependencies and order of our custom modules: </strong>The Loader knows
our <em>customJS</em> module is dependent on our <em>dcJson</em> module.</li>
our <em>customJS</em> module is dependent on our <em>JSONModule</em> module.</li>
<li><strong>YUI PHP Loader loads the modules and is used to output the CSS and JavaScript: </strong>The &lt;link&gt;
nodes are output in the document head and the &lt;script&gt; nodes are output just before the closing body node. This
is in accordance with the best practice performance recommendations outlined <a href="http://developer.yahoo.com/performance/rules.html">here</a>.</li>
Expand Down
30 changes: 11 additions & 19 deletions examples/phploader-custom-modules_source.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,29 @@
include("../phploader/loader.php");

//Create a custom module metadata set
$customConfig = array(
"dcJson" => array(
"name" => 'dcJson',
$customModules = array(
"JSONModule" => array(
"name" => 'JSONModule',
"type" => 'js', // 'js' or 'css'
// "path" => 'path/to/file.js', // includes base
"fullpath" => 'http://www.json.org/json2.js', // overrides path
// "requires" => array (0 => 'event', 1 => 'dom'),
// "optional" => array (0 => 'connection'),
// "global" => true, // globals are always loaded
// "supersedes" => array (0 => 'something'), // if a rollup
// "rollup" => 3 // the rollup threshold
"fullpath" => 'http://www.json.org/json2.js' // overrides path
),
"customJS" => array(
"name" => 'customJS',
"type" => 'js', // 'js' or 'css'
"fullpath" => './assets/custom/data.js', // overrides path
"global" => true, // globals are always loaded
"requires" => array (0 => 'dcJson')
"type" => 'js',
"fullpath" => './assets/custom/data.js',
"requires" => array('JSONModule')
),
"customCSS" => array(
"name" => 'customCSS',
"type" => 'css', // 'js' or 'css'
"fullpath" => './assets/custom/custom.css', // overrides path
"global" => true // globals are always loaded
"type" => 'css',
"fullpath" => './assets/custom/custom.css'
)
);

//Get a new YAHOO_util_Loader instance which includes just our custom metadata (No YUI metadata)
//Note: rand is used here to help cache bust the example
$loader = new YAHOO_util_Loader($yuiCurrentVersion, 'my_custom_config_'.rand(), $customConfig, true);
$loader->load("dcJson", "customJS", "customCSS");
$loader = new YAHOO_util_Loader($yuiCurrentVersion, 'my_custom_config_'.rand(), $customModules, true);
$loader->load("JSONModule", "customJS", "customCSS");
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
Expand Down

0 comments on commit 5a52dbf

Please sign in to comment.