Skip to content

Commit

Permalink
Add helper PHP class and concentrate dependencies.
Browse files Browse the repository at this point in the history
  • Loading branch information
gauthierm committed Mar 6, 2015
1 parent 7cb3a2b commit 31f9f50
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 2 deletions.
60 changes: 60 additions & 0 deletions JQuery/JQuery.php
@@ -0,0 +1,60 @@
<?php

/* vim: set noexpandtab tabstop=4 shiftwidth=4 foldmethod=marker: */

require_once 'Swat/SwatHtmlHeadEntrySet.php';
require_once 'Swat/SwatJavaScriptHtmlHeadEntry.php';

/**
* Gets a HTML head entry set for using jQuery
*
* @package JQuery
* @copyright 2015 silverorange
* @license http://www.opensource.org/licenses/mit-license.html MIT License
*/
class JQuery
{
// {{{ class constants

/**
* The current jQuery version. Update this when updating the bundled
* version.
*/
const VERSION = '1.11.2';

// }}}
// {{{ protected properties

/**
* Static collection of head entries
*
* @var SwatHtmlHeadEntrySet
*/
protected static $html_head_entries = null;

// }}}
// {{{ public function getHtmlHeadEntrySet()

/**
* Gets the HTML head entries needed for jQuery
*
* @return SwatHtmlHeadEntrySet the HTML head entries needed for jQuery.
*/
public function getHtmlHeadEntrySet()
{
if (!self::$html_head_entries instanceof SwatHtmlHeadEntrySet) {
$filename = printf('jquery-%s.js', self::VERSION);
self::$html_head_entries = new SwatHtmlHeadEntrySet();
self::$html_head_entries->add(
new SwatJavaScriptHtmlHeadEntry(
'packages/jquery/javascript/'.$filename
)
);
return self::$html_head_entries;
}
}

// }}}
}

?>
30 changes: 30 additions & 0 deletions dependencies/jquery.yaml
@@ -0,0 +1,30 @@
##
## Static Web-resource dependencies for the jQuery package
##
## Copyright (c) 2015 silverorange
##
## Permission is hereby granted, free of charge, to any person obtaining
## a copy of this software and associated documentation files (the
## "Software"), to deal in the Software without restriction, including
## without limitation the rights to use, copy, modify, merge, publish,
## distribute, sublicense, and/or sell copies of the Software, and to
## permit persons to whom the Software is furnished to do so, subject to
## the following conditions:
##
## The above copyright notice and this permission notice shall be
## included in all copies or substantial portions of the Software.
##
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
## EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
## MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
## NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
## LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
## OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
## WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
##
## vim: set expandtab tabstop=2 shiftwidth=2 softtabstop=2:
##
JQuery:
Provides:
# JavaScript resources
packages/jquery/javascript/jquery-1.11.2.js:
18 changes: 16 additions & 2 deletions package.php
Expand Up @@ -31,7 +31,9 @@
'baseinstalldir' => '/',
'packagedirectory' => './',
'dir_roles' => array(
'JQuery' => 'php',
'www' => 'data',
'dependencies' => 'data',
'/' => 'data',
),
'exceptions' => array(
Expand Down Expand Up @@ -59,12 +61,24 @@

$package->addIgnore('package.php');

$package->addMaintainer('lead', 'gauthierm', 'Mike Gauthier', 'mike@silverorange.com');
$package->addMaintainer(
'lead',
'gauthierm',
'Mike Gauthier',
'mike@silverorange.com'
);

// This package technically has a circular dependency with the Swat package
// because it uses SwatJavaScriptHtmlHeadEntry and SwatHtmlHeadEntrySet.
// Ideally those parts of Swat would be split into a parent package and both
// Swat and JQuery would depend on it.

$package->setPearinstallerDep('1.4.0');
$package->generateContents();

if (isset($_GET['make']) || (isset($_SERVER['argv']) && @$_SERVER['argv'][1] == 'make')) {
if ( isset($_GET['make'])
|| (isset($_SERVER['argv']) && @$_SERVER['argv'][1] == 'make')
) {
$package->writePackageFile();
} else {
$package->debugPackageFile();
Expand Down

0 comments on commit 31f9f50

Please sign in to comment.