mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-13 13:03:20 +00:00
Move minify to dedicated controller, www directory cleanup
This commit is contained in:
@@ -5,6 +5,10 @@
|
||||
"config": {
|
||||
"bin-dir" : "bin/"
|
||||
},
|
||||
"scripts" : {
|
||||
"post-install-cmd" : "Alchemy\\Phrasea\\ComposerScripts::postInstall",
|
||||
"post-update-cmd" : "Alchemy\\Phrasea\\ComposerScripts::postUpdate"
|
||||
},
|
||||
"require": {
|
||||
"php" : ">=5.3.3",
|
||||
"alchemy/oauth2php" : "dev-master",
|
||||
@@ -18,6 +22,7 @@
|
||||
"mediavorus/mediavorus" : "~0.3",
|
||||
"media-alchemyst/media-alchemyst" : "~0.2, >=0.2.3",
|
||||
"monolog/monolog" : "~1.3.0",
|
||||
"mrclay/minify" : "dev-master",
|
||||
"neutron/silex-imagine-provider" : "dev-master",
|
||||
"neutron/silex-badfaith-provider" : "dev-master",
|
||||
"neutron/silex-filesystem-provider": "dev-master",
|
||||
|
109
composer.lock
generated
109
composer.lock
generated
@@ -3,7 +3,7 @@
|
||||
"This file locks the dependencies of your project to a known state",
|
||||
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file"
|
||||
],
|
||||
"hash": "c6ac4fcc07ff4a6b97fbe949f2f31f23",
|
||||
"hash": "ab7edbf0a921471d05d7a9a08a02dfd7",
|
||||
"packages": [
|
||||
{
|
||||
"name": "BadFaith/BadFaith",
|
||||
@@ -406,16 +406,16 @@
|
||||
},
|
||||
{
|
||||
"name": "doctrine/dbal",
|
||||
"version": "2.3.3",
|
||||
"version": "2.3.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/doctrine/dbal.git",
|
||||
"reference": "2.3.3"
|
||||
"reference": "2.3.4"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/doctrine/dbal/zipball/2.3.3",
|
||||
"reference": "2.3.3",
|
||||
"url": "https://api.github.com/repos/doctrine/dbal/zipball/2.3.4",
|
||||
"reference": "2.3.4",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -465,20 +465,20 @@
|
||||
"persistence",
|
||||
"queryobject"
|
||||
],
|
||||
"time": "2013-03-24 19:16:29"
|
||||
"time": "2013-05-11 07:45:37"
|
||||
},
|
||||
{
|
||||
"name": "doctrine/orm",
|
||||
"version": "2.3.3",
|
||||
"version": "2.3.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/doctrine/doctrine2.git",
|
||||
"reference": "2.3.3"
|
||||
"reference": "2.3.4"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/doctrine/doctrine2/zipball/2.3.3",
|
||||
"reference": "2.3.3",
|
||||
"url": "https://api.github.com/repos/doctrine/doctrine2/zipball/2.3.4",
|
||||
"reference": "2.3.4",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -535,20 +535,20 @@
|
||||
"database",
|
||||
"orm"
|
||||
],
|
||||
"time": "2013-03-24 20:43:58"
|
||||
"time": "2013-05-11 07:51:12"
|
||||
},
|
||||
{
|
||||
"name": "gedmo/doctrine-extensions",
|
||||
"version": "v2.3.5",
|
||||
"version": "v2.3.6",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/l3pp4rd/DoctrineExtensions.git",
|
||||
"reference": "v2.3.5"
|
||||
"reference": "v2.3.6"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/l3pp4rd/DoctrineExtensions/zipball/v2.3.5",
|
||||
"reference": "v2.3.5",
|
||||
"url": "https://api.github.com/repos/l3pp4rd/DoctrineExtensions/zipball/v2.3.6",
|
||||
"reference": "v2.3.6",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -556,10 +556,11 @@
|
||||
"php": ">=5.3.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"doctrine/dbal": ">=2.2",
|
||||
"doctrine/mongodb": "1.0.1",
|
||||
"doctrine/mongodb-odm": "1.0.0-BETA7",
|
||||
"doctrine/orm": ">=2.2",
|
||||
"doctrine/common": ">=2.4.0-BETA2",
|
||||
"doctrine/dbal": ">=2.4.0-BETA2",
|
||||
"doctrine/mongodb": ">=1.0.2",
|
||||
"doctrine/mongodb-odm": ">=1.0.0-BETA8",
|
||||
"doctrine/orm": ">=2.4.0-BETA2",
|
||||
"symfony/yaml": "2.*"
|
||||
},
|
||||
"suggest": {
|
||||
@@ -614,7 +615,7 @@
|
||||
"tree",
|
||||
"uploadable"
|
||||
],
|
||||
"time": "2013-03-05 06:32:22"
|
||||
"time": "2013-05-21 12:09:55"
|
||||
},
|
||||
{
|
||||
"name": "imagine/Imagine",
|
||||
@@ -847,6 +848,46 @@
|
||||
],
|
||||
"time": "2013-01-11 10:23:20"
|
||||
},
|
||||
{
|
||||
"name": "mrclay/minify",
|
||||
"version": "dev-master",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/mrclay/minify.git",
|
||||
"reference": "6f5721d2db7f290a4528ea4c0b0be21621f670bc"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/mrclay/minify/zipball/6f5721d2db7f290a4528ea4c0b0be21621f670bc",
|
||||
"reference": "6f5721d2db7f290a4528ea4c0b0be21621f670bc",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-pcre": "*",
|
||||
"php": ">=5.2.1"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"min/lib/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Stephen Clay",
|
||||
"email": "steve@mrclay.org",
|
||||
"homepage": "http://www.mrclay.org/",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"description": "Minify is a PHP5 app that helps you follow several rules for client-side performance. It combines multiple CSS or Javascript files, removes unnecessary whitespace and comments, and serves them with gzip encoding and optimal client-side cache headers",
|
||||
"homepage": "http://code.google.com/p/minify/",
|
||||
"time": "2013-04-01 15:25:27"
|
||||
},
|
||||
{
|
||||
"name": "neutron/silex-badfaith-provider",
|
||||
"version": "dev-master",
|
||||
@@ -1028,16 +1069,16 @@
|
||||
},
|
||||
{
|
||||
"name": "php-ffmpeg/php-ffmpeg",
|
||||
"version": "0.2.3",
|
||||
"version": "0.2.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/alchemy-fr/PHP-FFmpeg.git",
|
||||
"reference": "0.2.3"
|
||||
"reference": "0.2.4"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/alchemy-fr/PHP-FFmpeg/zipball/0.2.3",
|
||||
"reference": "0.2.3",
|
||||
"url": "https://api.github.com/repos/alchemy-fr/PHP-FFmpeg/zipball/0.2.4",
|
||||
"reference": "0.2.4",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -1085,7 +1126,7 @@
|
||||
"video",
|
||||
"video processing"
|
||||
],
|
||||
"time": "2013-04-21 16:03:45"
|
||||
"time": "2013-05-10 21:28:35"
|
||||
},
|
||||
{
|
||||
"name": "php-mp4box/php-mp4box",
|
||||
@@ -1750,7 +1791,7 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "git://git.code.sf.net/p/tcpdf/code",
|
||||
"reference": "c7c8e26f67041b45d3d2b655064c8d8c26e3d7c0"
|
||||
"reference": "9a03e8743c50d6d8f1a641e80d4296c91cd314bb"
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.0"
|
||||
@@ -1759,7 +1800,6 @@
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"fonts",
|
||||
"config/lang",
|
||||
"config",
|
||||
"include",
|
||||
"tcpdf.php",
|
||||
@@ -1800,7 +1840,7 @@
|
||||
"pdf417",
|
||||
"qrcode"
|
||||
],
|
||||
"time": "2013-04-24 16:30:18"
|
||||
"time": "2013-05-19 16:46:11"
|
||||
},
|
||||
{
|
||||
"name": "twig/extensions",
|
||||
@@ -1851,16 +1891,16 @@
|
||||
},
|
||||
{
|
||||
"name": "twig/twig",
|
||||
"version": "v1.12.3",
|
||||
"version": "v1.13.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/fabpot/Twig.git",
|
||||
"reference": "v1.12.3"
|
||||
"reference": "v1.13.0"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/fabpot/Twig/zipball/v1.12.3",
|
||||
"reference": "v1.12.3",
|
||||
"url": "https://api.github.com/repos/fabpot/Twig/zipball/v1.13.0",
|
||||
"reference": "v1.13.0",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -1869,7 +1909,7 @@
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.12-dev"
|
||||
"dev-master": "1.13-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
@@ -1896,7 +1936,7 @@
|
||||
"keywords": [
|
||||
"templating"
|
||||
],
|
||||
"time": "2013-04-08 12:40:11"
|
||||
"time": "2013-05-10 15:12:43"
|
||||
},
|
||||
{
|
||||
"name": "zend/gdata",
|
||||
@@ -2008,6 +2048,7 @@
|
||||
"dailymotion/sdk": 20,
|
||||
"data-uri/data-uri": 20,
|
||||
"imagine/imagine": 20,
|
||||
"mrclay/minify": 20,
|
||||
"neutron/silex-imagine-provider": 20,
|
||||
"neutron/silex-badfaith-provider": 20,
|
||||
"neutron/silex-filesystem-provider": 20,
|
||||
|
@@ -1,59 +0,0 @@
|
||||
rewrite ^/include/minify/([a-z]=.*) /include/minify/index.php?$1 last;
|
||||
|
||||
rewrite ^/admin/.*$ /index.php last;
|
||||
rewrite ^/_profiler/.*$ /index.php last;
|
||||
rewrite ^/lightbox.?$ /index.php last;
|
||||
rewrite ^/robots.txt$ /index.php last;
|
||||
rewrite ^/feeds/.*$ /index.php last;
|
||||
rewrite ^/account/.*$ /index.php last;
|
||||
rewrite ^/login/.*$ /index.php last;
|
||||
rewrite ^/developers/.*$ /index.php last;
|
||||
rewrite ^/permalink/.*$ /index.php last;
|
||||
rewrite ^/datafiles/.*$ /index.php last;
|
||||
rewrite ^/thesaurus/.*$ /index.php last;
|
||||
rewrite ^/xmlhttp/.*$ /index.php last;
|
||||
rewrite ^/prod/records/.*$ /index.php last;
|
||||
rewrite ^/prod/records/edit/.*$ /index.php last;
|
||||
rewrite ^/prod/records/property/.*$ /index.php last;
|
||||
rewrite ^/prod/records/movecollection/.*$ /index.php last;
|
||||
rewrite ^/prod/records/delete/.*$ /index.php last;
|
||||
rewrite ^/prod/order/.*$ /index.php last;
|
||||
rewrite ^/prod/bridge/.*$ /index.php last;
|
||||
rewrite ^/prod/lists/.*$ /index.php last;
|
||||
rewrite ^/prod/MustacheLoader/.*$ /index.php last;
|
||||
rewrite ^/prod/feeds/.*$ /index.php last;
|
||||
rewrite ^/prod/tooltip/.*$ /index.php last;
|
||||
rewrite ^/prod/printer/.*$ /index.php last;
|
||||
rewrite ^/prod/push/.*$ /index.php last;
|
||||
rewrite ^/prod/baskets/.*$ /index.php last;
|
||||
rewrite ^/prod/story/.*$ /index.php last;
|
||||
rewrite ^/prod/WorkZone/.*$ /index.php last;
|
||||
rewrite ^/prod/language/.*$ /index.php last;
|
||||
rewrite ^/prod/tools/.*$ /index.php last;
|
||||
rewrite ^/prod/TOU/.?$ /index.php last;
|
||||
rewrite ^/prod/upload/.*$ /index.php last;
|
||||
rewrite ^/prod/lazaret/.*$ /index.php last;
|
||||
rewrite ^/prod/export/$ /index.php last;
|
||||
rewrite ^/prod/$ /index.php last;
|
||||
rewrite ^/prod/query/.*$ /index.php last;
|
||||
rewrite ^/prod/export/.*$ /index.php last;
|
||||
rewrite ^/prod/record/preview/.*$ /index.php last;
|
||||
rewrite ^/prod/notifications/.*$ /index.php last;
|
||||
rewrite ^/prod/share/.*$ /index.php last;
|
||||
rewrite ^/setup/.*$ /index.php last;
|
||||
rewrite ^/setup/$ /index.php last;
|
||||
|
||||
rewrite ^/user/preferences/.*$ /index.php last;
|
||||
rewrite ^/user/notifications/.*$ /index.php last;
|
||||
|
||||
rewrite ^/download/.*$ /index.php last;
|
||||
rewrite ^/session/.*$ /index.php last;
|
||||
|
||||
rewrite ^/report/.*$ /index.php last;
|
||||
|
||||
rewrite ^/client/.*$ /index.php last;
|
||||
rewrite ^/client/baskets.*$ /index.php last;
|
||||
|
||||
rewrite ^/api/v1/.*$ /api/v1/index.php last;
|
||||
rewrite ^/api/oauthv2/.*$ /api/oauthv2/index.php last;
|
||||
rewrite ^/api/.*$ /api/index.php last;
|
@@ -608,6 +608,10 @@ class Application extends SilexApplication
|
||||
$this->mount('/datafiles/', new Datafiles());
|
||||
$this->mount('/permalink/', new Permalink());
|
||||
|
||||
$this->get('/include/minify/', function () {
|
||||
require __DIR__ . '/../../../vendor/mrclay/minify/min/index.php';
|
||||
});
|
||||
|
||||
$this->mount('/admin/', new Root());
|
||||
$this->mount('/admin/dashboard', new Dashboard());
|
||||
$this->mount('/admin/collection', new Collection());
|
||||
|
@@ -29,7 +29,7 @@ return call_user_func(function($environment = 'prod') {
|
||||
$app->get('/', function(Request $request, SilexApplication $app) {
|
||||
$apiAdapter = new \API_V1_adapter($app);
|
||||
|
||||
$result = new \API_V1_result($request, $apiAdapter);
|
||||
$result = new \API_V1_result($app, $request, $apiAdapter);
|
||||
|
||||
return $result->set_datas(array(
|
||||
'name' => $app['phraseanet.registry']->get('GV_homeTitle'),
|
||||
|
35
lib/Alchemy/Phrasea/ComposerScripts.php
Normal file
35
lib/Alchemy/Phrasea/ComposerScripts.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace Alchemy\Phrasea;
|
||||
|
||||
use Symfony\Component\Filesystem\Filesystem;
|
||||
|
||||
class ComposerScripts
|
||||
{
|
||||
public static function postUpdate()
|
||||
{
|
||||
static::overwriteMinifyGroupsConfig();
|
||||
}
|
||||
|
||||
public static function postInstall()
|
||||
{
|
||||
static::overwriteMinifyGroupsConfig();
|
||||
}
|
||||
|
||||
private static function overwriteMinifyGroupsConfig()
|
||||
{
|
||||
$filesystem = new Filesystem();
|
||||
|
||||
$source = __DIR__ . '/../../conf.d/groupsConfig.php';
|
||||
$target = __DIR__ . '/../../../vendor/mrclay/minify/min/groupsConfig.php';
|
||||
|
||||
$filesystem->remove($target);
|
||||
$filesystem->copy($source, $target);
|
||||
|
||||
$source = __DIR__ . '/../../conf.d/config.php';
|
||||
$target = __DIR__ . '/../../../vendor/mrclay/minify/min/config.php';
|
||||
|
||||
$filesystem->remove($target);
|
||||
$filesystem->copy($source, $target);
|
||||
}
|
||||
}
|
@@ -1,112 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2013 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Alchemy\Phrasea\Application;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class gatekeeper
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_directory;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_script_name;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_PHP_SELF;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var gatekeeper
|
||||
*/
|
||||
protected static $_instance;
|
||||
protected $app;
|
||||
|
||||
/**
|
||||
*
|
||||
* @return gatekeeper
|
||||
*/
|
||||
public static function getInstance(Application $app)
|
||||
{
|
||||
if (!(self::$_instance instanceof self))
|
||||
self::$_instance = new self($app);
|
||||
|
||||
return self::$_instance;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return gatekeeper
|
||||
*/
|
||||
public function __construct(Application $app)
|
||||
{
|
||||
$this->app = $app;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Redirect to the correct guest location
|
||||
*
|
||||
* @return gatekeeper
|
||||
*/
|
||||
protected function give_guest_access()
|
||||
{
|
||||
$request = http_request::getInstance();
|
||||
|
||||
$parm = $request->get_parms('nolog', 'redirect');
|
||||
|
||||
if (!is_null($parm['nolog']) && phrasea::guest_allowed($this->app)) {
|
||||
try {
|
||||
$auth = new Session_Authentication_Guest($this->app);
|
||||
$this->app->openAccount($auth);
|
||||
} catch (Exception $e) {
|
||||
$url = '/login/?redirect=' . $parm['redirect']
|
||||
. '&error=' . urlencode($e->getMessage());
|
||||
phrasea::redirect($url);
|
||||
}
|
||||
phrasea::redirect('/' . $this->_directory . '/');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if session is open
|
||||
* Redirect if session is missing
|
||||
*
|
||||
* @return Void
|
||||
*/
|
||||
public function require_session()
|
||||
{
|
||||
if ($this->app->isAuthenticated()) {
|
||||
return true;
|
||||
}
|
||||
phrasea::headers(403);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
@@ -301,43 +301,6 @@ class phrasea
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function headers($code = 200, $nocache = false, $content = 'text/html', $charset = 'UTF-8', $doctype = true)
|
||||
{
|
||||
switch ((int) $code) {
|
||||
case 204:
|
||||
case 403:
|
||||
case 404:
|
||||
case 400:
|
||||
case 500:
|
||||
$request = http_request::getInstance();
|
||||
if ($request->is_ajax()) {
|
||||
$Response = new \Symfony\Component\HttpFoundation\Response(sprintf('error %d : Content unavailable', (int) $code), $code);
|
||||
$Response->send();
|
||||
exit();
|
||||
} else {
|
||||
$request->set_code($code);
|
||||
include(__DIR__ . '/../../www/include/error.php');
|
||||
}
|
||||
die();
|
||||
break;
|
||||
|
||||
case 200:
|
||||
header("Content-Type: " . $content . "; charset=" . $charset);
|
||||
if ($nocache) {
|
||||
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
|
||||
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified
|
||||
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
|
||||
header("Cache-Control: post-check=0, pre-check=0", false);
|
||||
header("Pragma: no-cache"); // HTTP/1.0
|
||||
}
|
||||
if ($doctype)
|
||||
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">';
|
||||
break;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
public static function scheduler_key(Application $app, $renew = false)
|
||||
{
|
||||
$conn = connection::getPDOConnection($app);
|
||||
|
@@ -1,19 +1,23 @@
|
||||
<?php
|
||||
$_SERVER["DOCUMENT_ROOT"] = __DIR__ . '/../../../www/';
|
||||
$_SERVER["DOCUMENT_ROOT"] = __DIR__ . '/../../../../www/';
|
||||
/**
|
||||
* Configuration for default Minify application
|
||||
* Configuration for "min", the default application built with the Minify
|
||||
* library
|
||||
*
|
||||
* @package Minify
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* In 'debug' mode, Minify can combine files with no minification and
|
||||
* add comments to indicate line #s of the original files.
|
||||
*
|
||||
* To allow debugging, set this option to true and add "&debug=1" to
|
||||
* a URI. E.g. /min/?f=script1.js,script2.js&debug=1
|
||||
* Allow use of the Minify URI Builder app. Only set this to true while you need it.
|
||||
*/
|
||||
$min_allowDebugFlag = false;
|
||||
$min_enableBuilder = true;
|
||||
|
||||
/**
|
||||
* If non-empty, the Builder will be protected with HTTP Digest auth.
|
||||
* The username is "admin".
|
||||
*/
|
||||
//$min_builderPassword = 'admin';
|
||||
|
||||
|
||||
/**
|
||||
@@ -23,17 +27,23 @@ $min_allowDebugFlag = false;
|
||||
*
|
||||
* If you want to use a custom error logger, set this to your logger
|
||||
* instance. Your object should have a method log(string $message).
|
||||
*
|
||||
* @todo cache system does not have error logging yet.
|
||||
*/
|
||||
$min_errorLogger = false;
|
||||
|
||||
|
||||
/**
|
||||
* Allow use of the Minify URI Builder app. If you no longer need
|
||||
* this, set to false.
|
||||
**/
|
||||
$min_enableBuilder = true;
|
||||
* To allow debug mode output, you must set this option to true.
|
||||
*
|
||||
* Once true, you can send the cookie minDebug to request debug mode output. The
|
||||
* cookie value should match the URIs you'd like to debug. E.g. to debug
|
||||
* /min/f=file1.js send the cookie minDebug=file1.js
|
||||
* You can manually enable debugging by appending "&debug" to a URI.
|
||||
* E.g. /min/?f=script1.js,script2.js&debug
|
||||
*
|
||||
* In 'debug' mode, Minify combines files with no minification and adds comments
|
||||
* to indicate line #s of the original files.
|
||||
*/
|
||||
$min_allowDebugFlag = false;
|
||||
|
||||
|
||||
/**
|
||||
@@ -43,6 +53,12 @@ $min_enableBuilder = true;
|
||||
//$min_cachePath = 'c:\\WINDOWS\\Temp';
|
||||
//$min_cachePath = '/tmp';
|
||||
//$min_cachePath = preg_replace('/^\\d+;/', '', session_save_path());
|
||||
/**
|
||||
* To use APC/Memcache/ZendPlatform for cache storage, require the class and
|
||||
* set $min_cachePath to an instance. Example below:
|
||||
*/
|
||||
//require dirname(__FILE__) . '/lib/Minify/Cache/APC.php';
|
||||
//$min_cachePath = new Minify_Cache_APC();
|
||||
|
||||
|
||||
/**
|
||||
@@ -56,7 +72,7 @@ $min_enableBuilder = true;
|
||||
* second line. The third line might work on some Apache servers.
|
||||
*/
|
||||
$min_documentRoot = '';
|
||||
//$min_documentRoot = substr(__FILE__, 0, strlen(__FILE__) - 15);
|
||||
//$min_documentRoot = substr(__FILE__, 0, -15);
|
||||
//$min_documentRoot = $_SERVER['SUBDOMAIN_DOCUMENT_ROOT'];
|
||||
|
||||
|
||||
@@ -79,9 +95,9 @@ $min_serveOptions['bubbleCssImports'] = false;
|
||||
|
||||
|
||||
/**
|
||||
* Maximum age of browser cache in seconds. After this period, the browser
|
||||
* will send another conditional GET. Use a longer period for lower traffic
|
||||
* but you may want to shorten this before making changes if it's crucial
|
||||
* Cache-Control: max-age value sent to browser (in seconds). After this period,
|
||||
* the browser will send another conditional GET. Use a longer period for lower
|
||||
* traffic but you may want to shorten this before making changes if it's crucial
|
||||
* those changes are seen immediately.
|
||||
*
|
||||
* Note: Despite this setting, if you include a number at the end of the
|
||||
@@ -90,6 +106,13 @@ $min_serveOptions['bubbleCssImports'] = false;
|
||||
$min_serveOptions['maxAge'] = 1800;
|
||||
|
||||
|
||||
/**
|
||||
* To use Google's Closure Compiler API to minify Javascript (falling back to JSMin
|
||||
* on failure), uncomment the following line:
|
||||
*/
|
||||
//$min_serveOptions['minifiers']['application/x-javascript'] = array('Minify_JS_ClosureCompiler', 'minify');
|
||||
|
||||
|
||||
/**
|
||||
* If you'd like to restrict the "f" option to files within/below
|
||||
* particular directories below DOCUMENT_ROOT, set this here.
|
||||
@@ -106,6 +129,7 @@ $min_serveOptions['maxAge'] = 1800;
|
||||
*/
|
||||
$min_serveOptions['minApp']['groupsOnly'] = false;
|
||||
|
||||
|
||||
/**
|
||||
* Maximum # of files that can be specified in the "f" GET parameter
|
||||
*/
|
||||
@@ -151,8 +175,7 @@ $min_uploaderHoursBehind = 0;
|
||||
* this accordingly.
|
||||
*/
|
||||
$min_libPath = __DIR__ . '/lib';
|
||||
$min_cachePath = __DIR__ . '/../../../tmp/cache_minify';
|
||||
|
||||
$min_cachePath = __DIR__ . '/../../../../tmp/cache_minify';
|
||||
|
||||
// try to disable output_compression (may not have an effect)
|
||||
ini_set('zlib.output_compression', '0');
|
@@ -18,8 +18,8 @@ $groups = array(
|
||||
, '//include/jslibs/json2.js'
|
||||
, '//include/jslibs/audio-player/audio-player-noswfobject.js'
|
||||
, '//include/jslibs/jquery.form.2.49.js'
|
||||
, '//prod/jquery.Dialog.js'
|
||||
, '//client/jquery.p4client.1.0.js'
|
||||
, '//skins/prod/jquery.Dialog.js'
|
||||
, '//skins/client/jquery.p4client.1.0.js'
|
||||
, '//include/jquery.tooltip.js'
|
||||
, '//include/jquery.p4.preview.js'
|
||||
, '//include/jquery.image_enhancer.js'
|
||||
@@ -49,7 +49,7 @@ $groups = array(
|
||||
, '//include/jslibs/jquery.multiselect.js'
|
||||
, '//include/jslibs/jquery.cluetip.js'
|
||||
, '//include/jquery.nicoslider.js'
|
||||
, '//report/report.js'
|
||||
, '//skins/report/report.js'
|
||||
),
|
||||
'modalBox' => array(
|
||||
'//include/jslibs/jquery-ui-1.8.17/jquery-ui-i18n.js'
|
||||
@@ -75,23 +75,23 @@ $groups = array(
|
||||
, '//include/js/jquery.Selection.js'
|
||||
, '//include/js/jquery.Edit.js'
|
||||
, '//include/js/jquery.lists.js'
|
||||
, '//prod/jquery.Mustache.js'
|
||||
, '//prod/jquery.Prod.js'
|
||||
, '//prod/jquery.Dialog.js'
|
||||
, '//prod/jquery.Feedback.js'
|
||||
, '//prod/jquery.Results.js'
|
||||
, '//prod/page0.js'
|
||||
, '//prod/jquery.WorkZone.js'
|
||||
, '//prod/jquery.Alerts.js'
|
||||
, '//prod/jquery.Upload.js'
|
||||
, '//skins/prod/jquery.Mustache.js'
|
||||
, '//skins/prod/jquery.Prod.js'
|
||||
, '//skins/prod/jquery.Dialog.js'
|
||||
, '//skins/prod/jquery.Feedback.js'
|
||||
, '//skins/prod/jquery.Results.js'
|
||||
, '//skins/prod/page0.js'
|
||||
, '//skins/prod/jquery.WorkZone.js'
|
||||
, '//skins/prod/jquery.Alerts.js'
|
||||
, '//skins/prod/jquery.Upload.js'
|
||||
, '//include/jslibs/pixastic.custom.js'
|
||||
, '//prod/ThumbExtractor.js'
|
||||
, '//prod/publicator.js'
|
||||
, '//skins/prod/ThumbExtractor.js'
|
||||
, '//skins/prod/publicator.js'
|
||||
, '//include/jslibs/jquery.sprintf.1.0.3.js'
|
||||
, '//include/jquery.tooltip.js'
|
||||
, '//include/jslibs/flowplayer/flowplayer-3.2.11.min.js'
|
||||
, '//include/jquery.p4.preview.js'
|
||||
, '//prod/jquery.edit.js'
|
||||
, '//skins/prod/jquery.edit.js'
|
||||
, '//include/jslibs/jquery.color.animation.js'
|
||||
, '//include/jquery.image_enhancer.js'
|
||||
, '//include/jslibs/jquery.contextmenu_scroll.js'
|
@@ -6,11 +6,11 @@
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
|
||||
<title>{{ app['phraseanet.registry'].get('GV_homeTitle') }} - {{ module_name }} </title>
|
||||
<link rel="stylesheet" href="/include/jslibs/jquery.mobile-1.0a4/jquery.mobile-1.0a4.min.css" />
|
||||
<script src="/include/minify/f=include/jslibs/jquery-1.7.1.js"></script>
|
||||
<script src="/include/minify/?f=include/jslibs/jquery-1.7.1.js"></script>
|
||||
{% block stylesheet %}{% endblock %}
|
||||
{% block icon %}{% endblock %}
|
||||
{% block javascript %}{% endblock %}
|
||||
<script src="/include/minify/f=include/jslibs/jquery.mobile-1.0a4/jquery.mobile-1.0a4.js"></script>
|
||||
<script src="/include/minify/?f=include/jslibs/jquery.mobile-1.0a4/jquery.mobile-1.0a4.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
{% block content %}{% endblock %}
|
||||
|
@@ -3,11 +3,11 @@
|
||||
{% extends "common/index.html.twig" %}
|
||||
|
||||
{% block javascript %}
|
||||
<script type="text/javascript" src="/include/minify/f=skins/lightbox/jquery.validator.mobile.js"></script>
|
||||
<script type="text/javascript" src="/include/minify/?f=skins/lightbox/jquery.validator.mobile.js"></script>
|
||||
{% endblock %}
|
||||
|
||||
{% block stylesheet %}
|
||||
<link rel="stylesheet" href="/include/minify/f=skins/lightbox/jquery.validator.mobile.css" />
|
||||
<link rel="stylesheet" href="/include/minify/?f=skins/lightbox/jquery.validator.mobile.css" />
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
@@ -2,11 +2,11 @@
|
||||
{% extends "common/index.html.twig" %}
|
||||
|
||||
{% block javascript %}
|
||||
<script type="text/javascript" src="/include/minify/f=skins/lightbox/jquery.validator.mobile.js"></script>
|
||||
<script type="text/javascript" src="/include/minify/?f=skins/lightbox/jquery.validator.mobile.js"></script>
|
||||
{% endblock %}
|
||||
|
||||
{% block stylesheet %}
|
||||
<link rel="stylesheet" href="/include/minify/f=skins/lightbox/jquery.validator.mobile.css" />
|
||||
<link rel="stylesheet" href="/include/minify/?f=skins/lightbox/jquery.validator.mobile.css" />
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
@@ -3,11 +3,11 @@
|
||||
{% extends "common/index.html.twig" %}
|
||||
|
||||
{% block javascript %}
|
||||
<script type="text/javascript" src="/include/minify/f=skins/lightbox/jquery.validator.mobile.js"></script>
|
||||
<script type="text/javascript" src="/include/minify/?f=skins/lightbox/jquery.validator.mobile.js"></script>
|
||||
{% endblock %}
|
||||
|
||||
{% block stylesheet %}
|
||||
<link rel="stylesheet" href="/include/minify/f=skins/lightbox/jquery.validator.mobile.css" />
|
||||
<link rel="stylesheet" href="/include/minify/?f=skins/lightbox/jquery.validator.mobile.css" />
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
@@ -1,11 +1,11 @@
|
||||
{% extends "common/index.html.twig" %}
|
||||
|
||||
{% block javascript %}
|
||||
<script type="text/javascript" src="/include/minify/f=skins/lightbox/jquery.validator.mobile.js"></script>
|
||||
<script type="text/javascript" src="/include/minify/?f=skins/lightbox/jquery.validator.mobile.js"></script>
|
||||
{% endblock %}
|
||||
|
||||
{% block stylesheet %}
|
||||
<link rel="stylesheet" href="/include/minify/f=skins/lightbox/jquery.validator.mobile.css" />
|
||||
<link rel="stylesheet" href="/include/minify/?f=skins/lightbox/jquery.validator.mobile.css" />
|
||||
{% endblock %}
|
||||
|
||||
{% block icon %}
|
||||
|
@@ -2,11 +2,11 @@
|
||||
{% extends "common/index.html.twig" %}
|
||||
|
||||
{% block javascript %}
|
||||
<script type="text/javascript" src="/include/minify/f=skins/lightbox/jquery.validator.mobile.js"></script>
|
||||
<script type="text/javascript" src="/include/minify/?f=skins/lightbox/jquery.validator.mobile.js"></script>
|
||||
{% endblock %}
|
||||
|
||||
{% block stylesheet %}
|
||||
<link rel="stylesheet" href="/include/minify/f=skins/lightbox/jquery.validator.mobile.css" />
|
||||
<link rel="stylesheet" href="/include/minify/?f=skins/lightbox/jquery.validator.mobile.css" />
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
@@ -1,8 +1,8 @@
|
||||
{% extends 'account/base.html.twig' %}
|
||||
|
||||
{% block head %}
|
||||
<link rel="stylesheet" type="text/css" href="/include/minify/f=/skins/account/geonames.css">
|
||||
<script type="text/javascript" src="/include/minify/f=/include/account/geonames.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/include/minify/?f=/skins/account/geonames.css">
|
||||
<script type="text/javascript" src="/include/minify/?f=/include/account/geonames.js"></script>
|
||||
<script type="text/javascript">
|
||||
initialize_geoname_field($('#form_geonameid'));
|
||||
</script>
|
||||
|
@@ -1,8 +1,8 @@
|
||||
<html lang="{{ app['locale.I18n'] }}">
|
||||
<head>
|
||||
<title>{{ app['phraseanet.registry'].get('GV_homeTitle') }} {% block title %}{% endblock %}</title>
|
||||
<link rel="stylesheet" type="text/css" href="/include/minify/f=/skins/login/home.css,/skins/html5/bootstrap/css/bootstrap.min.css,/skins/html5/bootstrap/css/bootstrap-responsive.min.css,/skins/login/css/main.css"/>
|
||||
<script type="text/javascript" language="javascript" src="/include/minify/f=include/jslibs/jquery-1.7.1.js,include/jslibs/jquery-ui-1.8.17/js/jquery-ui-1.8.17.custom.min.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/include/minify/?f=/skins/login/home.css,/skins/html5/bootstrap/css/bootstrap.min.css,/skins/html5/bootstrap/css/bootstrap-responsive.min.css,/skins/login/css/main.css"/>
|
||||
<script type="text/javascript" language="javascript" src="/include/minify/?f=include/jslibs/jquery-1.7.1.js,include/jslibs/jquery-ui-1.8.17/js/jquery-ui-1.8.17.custom.min.js"></script>
|
||||
{% block head %}{% endblock %}
|
||||
</head>
|
||||
|
||||
|
@@ -5,7 +5,7 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block head %}
|
||||
<script type="text/javascript" language="javascript" src="/include/minify/f=include/jslibs/jquery.validate.js"></script>
|
||||
<script type="text/javascript" language="javascript" src="/include/minify/?f=include/jslibs/jquery.validate.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$("#mainform").validate(
|
||||
|
@@ -5,7 +5,7 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block head %}
|
||||
<script type="text/javascript" language="javascript" src="/include/minify/f=include/jslibs/jquery.validate.js,include/jslibs/jquery.validate.password.js"></script>
|
||||
<script type="text/javascript" language="javascript" src="/include/minify/?f=include/jslibs/jquery.validate.js,include/jslibs/jquery.validate.password.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
|
||||
|
@@ -8,17 +8,17 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block stylesheet %}
|
||||
<link type="text/css" rel="stylesheet" href="/include/minify/f=include/jslibs/jquery-ui-1.8.17/css/ui-lightness/jquery-ui-1.8.17.custom.css,include/jslibs/jquery-treeview/jquery.treeview.css,include/jslibs/jquery.contextmenu.css,skins/account/geonames.css,skins/common/main.css,skins/admin/css/Main.css,skins/admin/css/Bases.css,skins/admin/css/Tables.css" />
|
||||
<link type="text/css" rel="stylesheet" href="/include/minify/?f=include/jslibs/jquery-ui-1.8.17/css/ui-lightness/jquery-ui-1.8.17.custom.css,include/jslibs/jquery-treeview/jquery.treeview.css,include/jslibs/jquery.contextmenu.css,skins/account/geonames.css,skins/common/main.css,skins/admin/css/Main.css,skins/admin/css/Bases.css,skins/admin/css/Tables.css" />
|
||||
{% endblock %}
|
||||
|
||||
|
||||
{% block javascript %}
|
||||
<script type="text/javascript" src="/include/jslibs/jquery-1.7.1.js"></script>
|
||||
<script type="text/javascript" src="/include/minify/f=include/jslibs/jquery.validate.js"></script>
|
||||
<script type="text/javascript" src="/include/minify/f=include/jslibs/jquery.validate.password.js"></script>
|
||||
<script type="text/javascript" src="/include/minify/?f=include/jslibs/jquery.validate.js"></script>
|
||||
<script type="text/javascript" src="/include/minify/?f=include/jslibs/jquery.validate.password.js"></script>
|
||||
<script type="text/javascript" src="/include/jslibs/jquery-ui-1.8.17/js/jquery-ui-1.8.17.custom.min.js"></script>
|
||||
<script type="text/javascript" src="/include/vendor/javascript-load-image/load-image.min.js"></script>
|
||||
<script type="text/javascript" src="/include/minify/g=admin"></script>
|
||||
<script type="text/javascript" src="/include/minify/?g=admin"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
var p4 = {users:{sel:[]}};
|
||||
|
@@ -2,7 +2,7 @@
|
||||
{% extends "admin/common/iframe_wrap.html.twig" %}
|
||||
|
||||
{% block stylesheet %}
|
||||
<link type="text/css" rel="stylesheet" href="/include/minify/f=include/jslibs/jquery-ui-1.8.17/css/ui-lightness/jquery-ui-1.8.17.custom.css" >
|
||||
<link type="text/css" rel="stylesheet" href="/include/minify/?f=include/jslibs/jquery-ui-1.8.17/css/ui-lightness/jquery-ui-1.8.17.custom.css" >
|
||||
<style>
|
||||
body{
|
||||
overflow:auto;
|
||||
@@ -11,7 +11,7 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block javascript %}
|
||||
<script type="text/javascript" src="/include/minify/f=include/jslibs/jquery-1.7.1.js,include/path_files_tests.jquery.js"></script>
|
||||
<script type="text/javascript" src="/include/minify/?f=include/jslibs/jquery-1.7.1.js,include/path_files_tests.jquery.js"></script>
|
||||
<script type="text/javascript" src="/include/jslibs/jquery-ui-1.8.17/js/jquery-ui-1.8.17.custom.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){
|
||||
|
@@ -3,7 +3,7 @@
|
||||
<title>{{ app['phraseanet.registry'].get('GV_homeTitle') }} Client</title>
|
||||
<meta http-equiv="X-UA-Compatible" content="chrome=1">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
|
||||
<link rel="shortcut icon" type="image/x-icon" href="/skins/client/favicon.ico" />
|
||||
<style ID="MYS" type="text/css">
|
||||
IMG.hthbimg {
|
||||
WIDTH: 108px;
|
||||
@@ -22,10 +22,10 @@
|
||||
}
|
||||
</style>
|
||||
<link rel="stylesheet" type="text/css" href="/include/jslibs/jquery-ui-1.8.17/css/dark-hive/jquery-ui-1.8.17.custom.css" />
|
||||
<link type="text/css" rel="stylesheet" href="/include/minify/f=include/jslibs/jquery.contextmenu.css,skins/common/main.css" />
|
||||
<link type="text/css" rel="stylesheet" href="/include/minify/f=skins/client/clientcolor.css" />
|
||||
<link type="text/css" rel="stylesheet" href="/include/minify/?f=include/jslibs/jquery.contextmenu.css,skins/common/main.css" />
|
||||
<link type="text/css" rel="stylesheet" href="/include/minify/?f=skins/client/clientcolor.css" />
|
||||
{% if css_file %}
|
||||
<link id="skinCss" type="text/css" rel="stylesheet" href="/include/minify/f={{ css_file }}" />
|
||||
<link id="skinCss" type="text/css" rel="stylesheet" href="/include/minify/?f={{ css_file }}" />
|
||||
{% endif %}
|
||||
<style>
|
||||
#PREVIEWCURRENTCONT {
|
||||
@@ -36,12 +36,12 @@
|
||||
}
|
||||
</style>
|
||||
<!--[if IE 6]>
|
||||
<link type="text/css" rel="stylesheet" href="/include/minify/f=skins/client/ie6.css" >
|
||||
<link type="text/css" rel="stylesheet" href="/include/minify/?f=skins/client/ie6.css" >
|
||||
<![endif]-->
|
||||
<script type="text/javascript" src="/include/minify/f=include/jslibs/jquery-1.7.1.js"></script>
|
||||
<script type="text/javascript" src="/include/minify/f=include/tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
|
||||
<script type="text/javascript" src="/include/minify/?f=include/jslibs/jquery-1.7.1.js"></script>
|
||||
<script type="text/javascript" src="/include/minify/?f=include/tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
|
||||
<script type="text/javascript" src="/include/jslibs/jquery-ui-1.8.17/js/jquery-ui-1.8.17.custom.min.js"></script>
|
||||
<script type="text/javascript" src="/include/minify/g=client"></script>
|
||||
<script type="text/javascript" src="/include/minify/?g=client"></script>
|
||||
<script type="text/javascript" src="/include/jslibs/flowplayer/flowplayer-3.2.11.min.js"></script>
|
||||
|
||||
</head>
|
||||
|
@@ -8,7 +8,7 @@
|
||||
<link type="text/css" rel="stylesheet" href="/skins/html5/bootstrap/css/bootstrap-responsive.min.css" />
|
||||
<link type="text/css" rel="stylesheet" href="{{app['phraseanet.registry'].get('GV_STATIC_URL')}}/skins/common/main.css">
|
||||
|
||||
<script type="text/javascript" src="/include/minify/f=include/jslibs/jquery-1.7.1.js"></script>
|
||||
<script type="text/javascript" src="/include/minify/?f=include/jslibs/jquery-1.7.1.js"></script>
|
||||
<script type="text/javascript" src="/skins/html5/bootstrap/js/bootstrap.min.js"></script>
|
||||
|
||||
{% block stylesheet %}{% endblock %}
|
||||
|
@@ -6,11 +6,11 @@
|
||||
{% block javascript %}
|
||||
<script type="text/javascript" src="/include/jslibs/jquery-1.7.1.js"></script>
|
||||
<script type="text/javascript" src="/include/jslibs/jquery-ui-1.8.17/js/jquery-ui-1.8.17.custom.min.js"></script>
|
||||
<script type="text/javascript" src="/include/minify/g=lightboxie6"></script>
|
||||
<script type="text/javascript" src="/include/minify/?g=lightboxie6"></script>
|
||||
{% endblock %}
|
||||
|
||||
{% block stylesheet %}
|
||||
<link type="text/css" rel="stylesheet" href="/include/minify/f=include/jslibs/jquery-ui-1.8.17/css/ui-lightness/jquery-ui-1.8.17.custom.css,skins/lightbox/lightboxie6.css" media="screen"/>
|
||||
<link type="text/css" rel="stylesheet" href="/include/minify/?f=include/jslibs/jquery-ui-1.8.17/css/ui-lightness/jquery-ui-1.8.17.custom.css,skins/lightbox/lightboxie6.css" media="screen"/>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
@@ -5,11 +5,11 @@
|
||||
{% block javascript %}
|
||||
<script type="text/javascript" src="/include/jslibs/jquery-1.7.1.js"></script>
|
||||
<script type="text/javascript" src="/include/jslibs/jquery-ui-1.8.17/js/jquery-ui-1.8.17.custom.min.js"></script>
|
||||
<script type="text/javascript" src="/include/minify/g=lightbox"></script>
|
||||
<script type="text/javascript" src="/include/minify/?g=lightbox"></script>
|
||||
{% endblock %}
|
||||
|
||||
{% block stylesheet %}
|
||||
<link type="text/css" rel="stylesheet" href="/include/minify/f=include/jslibs/jquery.contextmenu.css,include/jslibs/jquery-ui-1.8.17/css/ui-lightness/jquery-ui-1.8.17.custom.css,skins/lightbox/lightboxie6.css" media="screen"/>
|
||||
<link type="text/css" rel="stylesheet" href="/include/minify/?f=include/jslibs/jquery.contextmenu.css,include/jslibs/jquery-ui-1.8.17/css/ui-lightness/jquery-ui-1.8.17.custom.css,skins/lightbox/lightboxie6.css" media="screen"/>
|
||||
{% endblock %}
|
||||
|
||||
{% block icon %}
|
||||
|
@@ -6,12 +6,12 @@
|
||||
{% block javascript %}
|
||||
<script type="text/javascript" src="/include/jslibs/jquery-1.7.1.js"></script>
|
||||
<script type="text/javascript" src="/include/jslibs/jquery-ui-1.8.17/js/jquery-ui-1.8.17.custom.min.js"></script>
|
||||
<script type="text/javascript" src="/include/minify/g=lightboxie6"></script>
|
||||
<script type="text/javascript" src="/include/minify/?g=lightboxie6"></script>
|
||||
{% endblock %}
|
||||
|
||||
{% block stylesheet %}
|
||||
<link type="text/css" rel="stylesheet"
|
||||
href="/include/minify/f=include/jslibs/jquery-ui-1.8.17/css/ui-lightness/jquery-ui-1.8.17.custom.css,skins/lightbox/lightboxie6.css" media="screen"/>
|
||||
href="/include/minify/?f=include/jslibs/jquery-ui-1.8.17/css/ui-lightness/jquery-ui-1.8.17.custom.css,skins/lightbox/lightboxie6.css" media="screen"/>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
{% block stylesheet %}
|
||||
<link type="text/css" rel="stylesheet"
|
||||
href="/include/minify/f=skins/lightbox/lightbox.css" media="screen"/>
|
||||
href="/include/minify/?f=skins/lightbox/lightbox.css" media="screen"/>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
@@ -6,12 +6,12 @@
|
||||
{% block javascript %}
|
||||
<script type="text/javascript" src="/include/jslibs/jquery-1.7.1.js"></script>
|
||||
<script type="text/javascript" src="/include/jslibs/jquery-ui-1.8.17/js/jquery-ui-1.8.17.custom.min.js"></script>
|
||||
<script type="text/javascript" src="/include/minify/g=lightbox"></script>
|
||||
<script type="text/javascript" src="/include/minify/?g=lightbox"></script>
|
||||
{% endblock %}
|
||||
|
||||
{% block stylesheet %}
|
||||
<link type="text/css" rel="stylesheet"
|
||||
href="/include/minify/f=include/jslibs/jquery.contextmenu.css,include/jslibs/jquery-ui-1.8.17/css/ui-lightness/jquery-ui-1.8.17.custom.css,skins/lightbox/lightbox.css" media="screen"/>
|
||||
href="/include/minify/?f=include/jslibs/jquery.contextmenu.css,include/jslibs/jquery-ui-1.8.17/css/ui-lightness/jquery-ui-1.8.17.custom.css,skins/lightbox/lightbox.css" media="screen"/>
|
||||
{% endblock %}
|
||||
|
||||
|
||||
|
@@ -5,12 +5,12 @@
|
||||
{% block javascript %}
|
||||
<script type="text/javascript" src="/include/jslibs/jquery-1.7.1.js"></script>
|
||||
<script type="text/javascript" src="/include/jslibs/jquery-ui-1.8.17/js/jquery-ui-1.8.17.custom.min.js"></script>
|
||||
<script type="text/javascript" src="/include/minify/g=lightbox"></script>
|
||||
<script type="text/javascript" src="/include/minify/?g=lightbox"></script>
|
||||
{% endblock %}
|
||||
|
||||
{% block stylesheet %}
|
||||
<link type="text/css" rel="stylesheet"
|
||||
href="/include/minify/f=include/jslibs/jquery.contextmenu.css,include/jslibs/jquery-ui-1.8.17/css/ui-lightness/jquery-ui-1.8.17.custom.css,skins/lightbox/lightbox.css" media="screen"/>
|
||||
href="/include/minify/?f=include/jslibs/jquery.contextmenu.css,include/jslibs/jquery-ui-1.8.17/css/ui-lightness/jquery-ui-1.8.17.custom.css,skins/lightbox/lightbox.css" media="screen"/>
|
||||
{% endblock %}
|
||||
|
||||
{% block icon %}
|
||||
|
@@ -6,12 +6,12 @@
|
||||
{% block javascript %}
|
||||
<script type="text/javascript" src="/include/jslibs/jquery-1.7.1.js"></script>
|
||||
<script type="text/javascript" src="/include/jslibs/jquery-ui-1.8.17/js/jquery-ui-1.8.17.custom.min.js"></script>
|
||||
<script type="text/javascript" src="/include/minify/g=lightbox"></script>
|
||||
<script type="text/javascript" src="/include/minify/?g=lightbox"></script>
|
||||
{% endblock %}
|
||||
|
||||
{% block stylesheet %}
|
||||
<link type="text/css" rel="stylesheet"
|
||||
href="/include/minify/f=include/jslibs/jquery.contextmenu.css,include/jslibs/jquery-ui-1.8.17/css/ui-lightness/jquery-ui-1.8.17.custom.css,skins/lightbox/lightbox.css" media="screen"/>
|
||||
href="/include/minify/?f=include/jslibs/jquery.contextmenu.css,include/jslibs/jquery-ui-1.8.17/css/ui-lightness/jquery-ui-1.8.17.custom.css,skins/lightbox/lightbox.css" media="screen"/>
|
||||
{% endblock %}
|
||||
|
||||
|
||||
|
@@ -7,7 +7,7 @@
|
||||
|
||||
{% block head %}
|
||||
|
||||
<script type="text/javascript" language="javascript" src="/include/minify/f=include/jslibs/jquery.validate.js,include/jslibs/jquery.validate.password.js"></script>
|
||||
<script type="text/javascript" language="javascript" src="/include/minify/?f=include/jslibs/jquery.validate.js,include/jslibs/jquery.validate.password.js"></script>
|
||||
|
||||
<script type="text/javascript" >
|
||||
{% if tokenize %}
|
||||
|
@@ -12,5 +12,5 @@
|
||||
{% endfor %}
|
||||
|
||||
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
|
||||
<link rel="stylesheet" type="text/css" href="/include/minify/f=skins/login/home.css,skins/login/css/main.css" />
|
||||
<script type="text/javascript" language="javascript" src="/include/minify/f=include/jslibs/jquery-1.7.1.js,include/jslibs/jquery.cookie.js,include/login/home.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/include/minify/?f=skins/login/home.css,skins/login/css/main.css" />
|
||||
<script type="text/javascript" language="javascript" src="/include/minify/?f=include/jslibs/jquery-1.7.1.js,include/jslibs/jquery.cookie.js,include/login/home.js"></script>
|
||||
|
@@ -9,8 +9,8 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block head %}
|
||||
<script type="text/javascript" language="javascript" src="/include/minify/f=include/jslibs/jquery.validate.js,include/jslibs/jquery.validate.password.js,include/jslibs/jquery.validate.login.js"></script>
|
||||
<script type="text/javascript" src="/include/minify/f=include/account/geonames.js"></script>
|
||||
<script type="text/javascript" language="javascript" src="/include/minify/?f=include/jslibs/jquery.validate.js,include/jslibs/jquery.validate.password.js,include/jslibs/jquery.validate.login.js"></script>
|
||||
<script type="text/javascript" src="/include/minify/?f=include/account/geonames.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
{% set sep = '' %}
|
||||
|
@@ -7,7 +7,7 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block stylesheet %}
|
||||
<link type="text/css" rel="stylesheet" href="{{app['phraseanet.registry'].get('GV_STATIC_URL')}}/include/minify/f=include/jslibs/yui2.8/build/reset/reset.css" >
|
||||
<link type="text/css" rel="stylesheet" href="{{app['phraseanet.registry'].get('GV_STATIC_URL')}}/include/minify/?f=include/jslibs/yui2.8/build/reset/reset.css" >
|
||||
<style type="text/css">
|
||||
html{
|
||||
|
||||
@@ -60,7 +60,7 @@
|
||||
</style>
|
||||
{% endblock %}
|
||||
{% block javascript %}
|
||||
<script type="text/javascript" src="/include/minify/f=include/jslibs/jquery-1.7.1.js,include/jslibs/jquery.mousewheel.js,include/jquery.image_enhancer.js,include/jslibs/swfobject/swfobject.js"></script>
|
||||
<script type="text/javascript" src="/include/minify/?f=include/jslibs/jquery-1.7.1.js,include/jslibs/jquery.mousewheel.js,include/jquery.image_enhancer.js,include/jslibs/swfobject/swfobject.js"></script>
|
||||
<script type="text/javascript" src="/include/jslibs/jquery-ui-1.8.17/js/jquery-ui-1.8.17.custom.min.js"></script>
|
||||
<script type="text/javascript" src="/include/jslibs/flowplayer/flowplayer-3.2.11.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
@@ -48,7 +48,7 @@
|
||||
|
||||
|
||||
{% block icon %}
|
||||
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico">
|
||||
<link rel="shortcut icon" type="image/x-icon" href="/skins/prod/favicon.ico">
|
||||
{% endblock %}
|
||||
|
||||
|
||||
@@ -97,15 +97,15 @@
|
||||
}
|
||||
</style>
|
||||
|
||||
<link type="text/css" rel="stylesheet" href="{{app['phraseanet.registry'].get('GV_STATIC_URL')}}/include/minify/f=include/jslibs/jquery.contextmenu.css,include/jslibs/colorpicker/css/colorpicker.css,include/jslibs/jquery-treeview/jquery.treeview.css,skins/common/main.css,skins/account/geonames.css,include/jquery.image_enhancer.css,include/jslibs/jquery-ui-1.8.17/css/dark-hive/jquery-ui-1.8.17.custom.css" >
|
||||
<link id="skinCss" type="text/css" rel="stylesheet" href="{{app['phraseanet.registry'].get('GV_STATIC_URL')}}/include/minify/f=skins/prod/{{cssfile}}/prodcolor.css" >
|
||||
<link type="text/css" rel="stylesheet" href="{{app['phraseanet.registry'].get('GV_STATIC_URL')}}/include/minify/f=include/vendor/humane-js/themes/libnotify.css,skins/prod/Prod.css,skins/prod/Basket.css,skins/prod/Push.css" >
|
||||
<link type="text/css" rel="stylesheet" href="{{app['phraseanet.registry'].get('GV_STATIC_URL')}}/include/minify/?f=include/jslibs/jquery.contextmenu.css,include/jslibs/colorpicker/css/colorpicker.css,include/jslibs/jquery-treeview/jquery.treeview.css,skins/common/main.css,skins/account/geonames.css,include/jquery.image_enhancer.css,include/jslibs/jquery-ui-1.8.17/css/dark-hive/jquery-ui-1.8.17.custom.css" >
|
||||
<link id="skinCss" type="text/css" rel="stylesheet" href="{{app['phraseanet.registry'].get('GV_STATIC_URL')}}/include/minify/?f=skins/prod/{{cssfile}}/prodcolor.css" >
|
||||
<link type="text/css" rel="stylesheet" href="{{app['phraseanet.registry'].get('GV_STATIC_URL')}}/include/minify/?f=include/vendor/humane-js/themes/libnotify.css,skins/prod/Prod.css,skins/prod/Basket.css,skins/prod/Push.css" >
|
||||
|
||||
<!--[if IE 7]>
|
||||
<link type="text/css" rel="stylesheet" href="/include/minify/f=skins/prod/ie7.css" >
|
||||
<link type="text/css" rel="stylesheet" href="/include/minify/?f=skins/prod/ie7.css" >
|
||||
<![endif]-->
|
||||
<!--[if IE 8]>
|
||||
<link type="text/css" rel="stylesheet" href="/include/minify/f=skins/prod/ie8.css" >
|
||||
<link type="text/css" rel="stylesheet" href="/include/minify/?f=skins/prod/ie8.css" >
|
||||
<![endif]-->
|
||||
|
||||
<style title="color_selection" type="text/css">
|
||||
@@ -1021,7 +1021,7 @@
|
||||
<script type="text/javascript">
|
||||
{% include "prod/thesaurus.js" %}
|
||||
</script>
|
||||
<script type="text/javascript" src="{{app['phraseanet.registry'].get('GV_STATIC_URL')}}/include/minify/g=prod"></script>
|
||||
<script type="text/javascript" src="{{app['phraseanet.registry'].get('GV_STATIC_URL')}}/include/minify/?g=prod"></script>
|
||||
<script type="text/javascript" src="{{app['phraseanet.registry'].get('GV_STATIC_URL')}}/include/jslibs/jquery-ui-1.8.17/js/jquery-ui-1.8.17.custom.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){
|
||||
@@ -1057,7 +1057,7 @@
|
||||
};
|
||||
|
||||
function setCss(color) {
|
||||
$("#skinCss").attr("href","/include/minify/f=skins/prod/"+color+"/prodcolor.css");
|
||||
$("#skinCss").attr("href","/include/minify/?f=skins/prod/"+color+"/prodcolor.css");
|
||||
$.post("prodFeedBack.php", {
|
||||
action: "CSS",
|
||||
color: color,
|
||||
|
@@ -126,7 +126,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript" src="/include/minify/g=uploadflash"></script>
|
||||
<script type="text/javascript" src="/include/minify/?g=uploadflash"></script>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){
|
||||
|
||||
|
@@ -1,8 +1,8 @@
|
||||
{% extends "common/index_bootstrap.html.twig" %}
|
||||
|
||||
{% block stylesheet %}
|
||||
<link type="text/css" rel="stylesheet" href="/include/minify/f=skins/common/main.css,skins/report/jquery-ui.css,skins/report/jquery-ui-2.css,skins/report/report-table.css,skins/report/jquery.cluetip.css,include/jslibs/jquery.contextmenu.css" media="screen" />
|
||||
<link type="text/css" rel="stylesheet" href="/include/minify/f=skins/report/print.css" media="print" />
|
||||
<link type="text/css" rel="stylesheet" href="/include/minify/?f=skins/common/main.css,skins/report/jquery-ui.css,skins/report/jquery-ui-2.css,skins/report/report-table.css,skins/report/jquery.cluetip.css,include/jslibs/jquery.contextmenu.css" media="screen" />
|
||||
<link type="text/css" rel="stylesheet" href="/include/minify/?f=skins/report/print.css" media="print" />
|
||||
{% endblock stylesheet %}
|
||||
|
||||
{% block icon %}
|
||||
@@ -40,8 +40,8 @@
|
||||
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
|
||||
<script type="text/javascript" src="/include/jslibs/jquery-1.7.1.js"></script>
|
||||
<script type="text/javascript" src="/include/jslibs/jquery-ui-1.8.17/js/jquery-ui-1.8.17.custom.min.js"></script>
|
||||
<script type="text/javascript" src="/include/minify/g=report"></script>
|
||||
<script type="text/javascript" src="/include/minify/f=include/jslibs/jquery.gvChart-0.1.js"></script>
|
||||
<script type="text/javascript" src="/include/minify/?g=report"></script>
|
||||
<script type="text/javascript" src="/include/minify/?f=include/jslibs/jquery.gvChart-0.1.js"></script>
|
||||
<script type="text/javascript">
|
||||
gvChartInit();
|
||||
</script>
|
||||
|
@@ -2,7 +2,7 @@
|
||||
"http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html lang="{{ locale }}">
|
||||
<head>
|
||||
<script src="/include/minify/f=include/jslibs/jquery-1.7.1.js,include/jslibs/jquery-validation/jquery.validate.js,include/jslibs/jquery-validate.password/jquery.validate.password.js,include/jslibs/jquery.cookie.js" type="text/javascript"></script>
|
||||
<script src="/include/minify/?f=include/jslibs/jquery-1.7.1.js,include/jslibs/jquery-validation/jquery.validate.js,include/jslibs/jquery-validate.password/jquery.validate.password.js,include/jslibs/jquery.cookie.js" type="text/javascript"></script>
|
||||
<script type="text/javascript" src="/include/jslibs/jquery-ui-1.8.17/js/jquery-ui-1.8.17.custom.min.js"></script>
|
||||
<script type="text/javascript" src="/include/path_files_tests.jquery.js"></script>
|
||||
<script type="text/javascript" src="/include/login/home.js"></script>
|
||||
|
@@ -26,7 +26,7 @@
|
||||
|
||||
<script type="text/javascript" src="/skins/thesaurus/win.js"></script>
|
||||
<script type="text/javascript" src="/skins/thesaurus/xmlhttp.js"></script>
|
||||
<script type="text/javascript" src="/include/minify/f=include/jslibs/jquery-1.7.1.js,include/jslibs/jquery.sprintf.1.0.3.js"></script>
|
||||
<script type="text/javascript" src="/include/minify/?f=include/jslibs/jquery-1.7.1.js,include/jslibs/jquery.sprintf.1.0.3.js"></script>
|
||||
<script type="text/javascript" src="/skins/thesaurus/sprintf.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
@@ -16,7 +16,7 @@
|
||||
<link rel="shortcut icon" type="image/x-icon" href="/skins/thesaurus/favicon.ico">
|
||||
<script type="text/javascript" src="/include/jslibs/jquery-1.7.1.js"></script>
|
||||
<script type="text/javascript" src="/include/jslibs/jquery-ui-1.8.17/js/jquery-ui-1.8.17.custom.min.js"></script>
|
||||
<script type="text/javascript" src="/include/minify/g=thesaurus"></script>
|
||||
<script type="text/javascript" src="/include/minify/?g=thesaurus"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
var currentBaseName = "";
|
||||
|
47
tests/Alchemy/Tests/Phrasea/Application/ApiRootTest.php
Normal file
47
tests/Alchemy/Tests/Phrasea/Application/ApiRootTest.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace Alchemy\Tests\Phrasea\Application;
|
||||
|
||||
use Alchemy\Phrasea\Border\File;
|
||||
use Alchemy\Phrasea\Border\Manager;
|
||||
use Symfony\Component\HttpKernel\Client;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class ApiRootTest extends \PhraseanetWebTestCaseAbstract
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var Symfony\Component\HttpKernel\Client
|
||||
*/
|
||||
protected $client;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
self::$DI['app'] = self::$DI->share(function() {
|
||||
$environment = 'test';
|
||||
$app = require __DIR__ . '/../../../../../lib/Alchemy/Phrasea/Application/ApiVersion.php';
|
||||
|
||||
$app['debug'] = true;
|
||||
|
||||
return $app;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public function testRoot()
|
||||
{
|
||||
self::$DI['client']->request('GET', '/');
|
||||
|
||||
$response = self::$DI['client']->getResponse();
|
||||
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
$this->assertEquals('application/json', $response->headers->get('content-type'));
|
||||
|
||||
$data = json_decode($response->getContent(), true);
|
||||
|
||||
$this->assertArrayHasKey('meta', $data);
|
||||
$this->assertArrayHasKey('response', $data);
|
||||
}
|
||||
}
|
122
www/.htaccess
122
www/.htaccess
@@ -1,122 +0,0 @@
|
||||
<IfModule mod_rewrite.c>
|
||||
RewriteEngine on
|
||||
RewriteRule ^include/minify/([a-z]=.*) /include/minify/index.php$1 [L,NE]
|
||||
|
||||
RewriteRule ^_profiler/.*$ /index.php [L]
|
||||
RewriteRule ^lightbox/.*$ /index.php [L]
|
||||
RewriteRule ^admin/.*$ /index.php [L]
|
||||
RewriteRule ^permalink/.*$ /index.php [L]
|
||||
RewriteRule ^datafiles/.*$ /index.php [L]
|
||||
RewriteRule ^robots.txt$ /index.php [L]
|
||||
RewriteRule ^feeds/.*$ /index.php [L]
|
||||
RewriteRule ^account/.*$ /index.php [L]
|
||||
RewriteRule ^developers/.*$ /index.php [L]
|
||||
RewriteRule ^login/.*$ /index.php [L]
|
||||
RewriteRule ^xmlhttp/.*$ /index.php [L]
|
||||
RewriteRule ^thesaurus/.*$ /index.php [L]
|
||||
RewriteRule ^prod/records/.*$ /index.php [L]
|
||||
RewriteRule ^prod/records/edit/.*$ /index.php [L]
|
||||
RewriteRule ^prod/records/property/.*$ /index.php [L]
|
||||
RewriteRule ^prod/records/movecollection/.*$ /index.php [L]
|
||||
RewriteRule ^prod/records/delete/.*$ /index.php [L]
|
||||
RewriteRule ^prod/order/.*$ /index.php [L]
|
||||
RewriteRule ^prod/bridge/.*$ /index.php [L]
|
||||
RewriteRule ^prod/MustacheLoader/.*$ /index.php [L]
|
||||
RewriteRule ^prod/feeds/.*$ /index.php [L]
|
||||
RewriteRule ^prod/tooltip/.*$ /index.php [L]
|
||||
RewriteRule ^prod/lists/.*$ /index.php [L]
|
||||
RewriteRule ^prod/baskets/.*$ /index.php [L]
|
||||
RewriteRule ^prod/push/.*$ /index.php [L]
|
||||
RewriteRule ^prod/printer/.*$ /index.php [L]
|
||||
RewriteRule ^prod/story/.*$ /index.php [L]
|
||||
RewriteRule ^prod/TOU/.*$ /index.php [L]
|
||||
RewriteRule ^prod/WorkZone/.*$ /index.php [L]
|
||||
RewriteRule ^prod/language/.*$ /index.php [L]
|
||||
RewriteRule ^prod/tools/.*$ /index.php [L]
|
||||
RewriteRule ^prod/upload/.*$ /index.php [L]
|
||||
RewriteRule ^prod/lazaret/.*$ /index.php [L]
|
||||
RewriteRule ^prod/$ /index.php [L]
|
||||
RewriteRule ^prod/query/.*$ /index.php [L]
|
||||
RewriteRule ^prod/export/.*$ /index.php [L]
|
||||
RewriteRule ^prod/record/preview/.*$ /index.php [L]
|
||||
RewriteRule ^prod/notifications/.*$ /index.php [L]
|
||||
RewriteRule ^prod/share/.*$ /index.php [L]
|
||||
RewriteRule ^setup/.*$ /index.php [L]
|
||||
RewriteRule ^setup/$ /index.php [L]
|
||||
|
||||
RewriteRule ^user/preferences/.*$ /index.php [L]
|
||||
RewriteRule ^user/notifications/.*$ /index.php [L]
|
||||
|
||||
RewriteRule ^download/.*$ /index.php [L]
|
||||
RewriteRule ^session/.*$ /index.php [L]
|
||||
|
||||
RewriteRule ^report/.*$ /index.php [L]
|
||||
|
||||
RewriteRule ^client/.*$ /index.php [L]
|
||||
RewriteRule ^client/baskets.*$ /index.php [L]
|
||||
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteRule ^api/v1/.*$ /api/v1/index.php [L]
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteRule ^api/oauthv2/.*$ /api/oauthv2/index.php [L]
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteRule ^api/.*$ /api/index.php [L]
|
||||
|
||||
|
||||
RewriteRule ^admin/test-rewrite$ admin/adminFeedback.php?action=APACHE&test=success [L]
|
||||
<IfModule mod_xsendfile.c>
|
||||
RewriteRule ^admin/test-xsendfile$ admin/adminFeedback.php?action=APACHE&test=success [L]
|
||||
</IfModule>
|
||||
<IfModule mod_auth_token.c>
|
||||
RewriteRule ^admin/test-authtoken$ admin/adminFeedback.php?action=APACHE&test=success [L]
|
||||
</IfModule>
|
||||
<IfModule mod_h264_streaming.c>
|
||||
RewriteRule ^admin/test-h264$ admin/adminFeedback.php?action=APACHE&test=success [L]
|
||||
</IfModule>
|
||||
|
||||
RewriteRule ^admin/test-rewrite$ admin/adminFeedback.php?action=APACHE&test=fail [L]
|
||||
RewriteRule ^admin/test-xsendfile$ admin/adminFeedback.php?action=APACHE&test=fail [L]
|
||||
RewriteRule ^admin/test-authtoken$ admin/adminFeedback.php?action=APACHE&test=fail [L]
|
||||
RewriteRule ^admin/test-h264$ admin/adminFeedback.php?action=APACHE&est=fail [L]
|
||||
</IfModule>
|
||||
|
||||
|
||||
<Files .htaccess>
|
||||
order allow,deny
|
||||
deny from all
|
||||
</Files>
|
||||
|
||||
<ifModule mod_gzip.c>
|
||||
mod_gzip_on Yes
|
||||
mod_gzip_dechunk Yes
|
||||
mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$
|
||||
mod_gzip_item_include handler ^cgi-script$
|
||||
mod_gzip_item_include mime ^text/.*
|
||||
mod_gzip_item_include mime ^application/x-javascript.*
|
||||
mod_gzip_item_exclude mime ^image/.*
|
||||
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
|
||||
</ifModule>
|
||||
|
||||
<ifModule mod_deflate.c>
|
||||
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/x-javascript
|
||||
</ifModule>
|
||||
|
||||
ErrorDocument 204 /include/error.php
|
||||
ErrorDocument 400 /include/error.php
|
||||
ErrorDocument 403 /include/error.php
|
||||
ErrorDocument 404 /include/error.php
|
||||
ErrorDocument 500 /include/error.php
|
||||
|
||||
<IfModule mod_php5.c>
|
||||
php_flag short_open_tag off
|
||||
php_flag asp_tags off
|
||||
php_flag magic_quotes_gpc off
|
||||
php_flag register_globals off
|
||||
php_value max_execution_time "30"
|
||||
php_value output_buffering "4096"
|
||||
</IfModule>
|
||||
|
||||
# video
|
||||
AddType video/ogg ogg ogv
|
||||
AddType video/mp4 mp4
|
||||
AddType video/webm webm
|
@@ -1,120 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2013 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
$app = new Application();
|
||||
$request = Symfony\Component\HttpFoundation\Request::createFromGlobals();
|
||||
|
||||
$locales = \Alchemy\Phrasea\Core::getAvailableLanguages();
|
||||
|
||||
$current_locale = $app['locale'];
|
||||
|
||||
if ( ! $current_locale) {
|
||||
foreach ($locales as $code => $locale) {
|
||||
if ($request->getLocale() == $locale) {
|
||||
$current_locale = $locale;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( ! $current_locale)
|
||||
$current_locale = 'fr_FR';
|
||||
}
|
||||
|
||||
phrasea::use_i18n($current_locale);
|
||||
|
||||
$request = http_request::getInstance();
|
||||
|
||||
switch ($request->get_code()) {
|
||||
case '204':
|
||||
$title = '204 NO Content';
|
||||
$desc = '<p>' . _('error:204::Le contenu que vous demandez n\'existe pas ou a expire') . '</p>';
|
||||
break;
|
||||
case '400':
|
||||
$title = '400 Bad Request';
|
||||
$desc = '<p>' . _('error:400::La requete que vous faites ne peut etre traitee car les parametres necessaire a son traitement, sont mauvais ou manquants.') . '</p>';
|
||||
break;
|
||||
case '403':
|
||||
$title = '403 Forbidden';
|
||||
$desc = '<p>' . _('error:403::Vous avez demande une page a laquelle vous n\'avez pas acces.') . '</p>
|
||||
<p>' . _('error:403::Soit vous n\'avez pas les droits, soit vous avez ete deconnecte.') . '</p>';
|
||||
break;
|
||||
case '404':
|
||||
$title = '404 Not Found';
|
||||
$desc = '<p>' . _('error:404::Vous avez demande une page qui n\'existe pas ou plus') . '</p>';
|
||||
break;
|
||||
case '500':
|
||||
$title = '500 Internal Server Error';
|
||||
$desc = '<p>' . _('error:500::Erreur interne du serveur') . '</p>
|
||||
<p>' . _('error:500::Une erreur interne est survenue. Ceci se produit lorsque la connetion a la base de donnee a ete interrompue ou lorsqu\'un module rencontre un probleme.') . '</p>
|
||||
<p>' . _('error:500::Si ce probleme persiste, contactez l\'administrateur du serveur') . '</p>';
|
||||
break;
|
||||
default:
|
||||
$title = 'Unknown Error';
|
||||
$desc = '';
|
||||
break;
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title><?php echo $title; ?></title>
|
||||
</head>
|
||||
<style>
|
||||
body{
|
||||
background-color:#000000;
|
||||
color:#b1b1b1;
|
||||
font-family:Verdana, Arial, Sans-serif;
|
||||
}
|
||||
.title{
|
||||
font-size:28px;
|
||||
font-family:Helvetica, Arial, Sans-serif;
|
||||
}
|
||||
p{
|
||||
font-size:12px;
|
||||
}
|
||||
color:
|
||||
</style>
|
||||
<body>
|
||||
<h1><?php echo $title; ?></h1>
|
||||
<?php echo $desc; ?>
|
||||
|
||||
<!--
|
||||
|
||||
Cette page doit au moins peser 512 bytes, auquel cas IE l'affichera correctement.
|
||||
Du coup, lisons un petit coup de Ciceron en l'honneur de Microsoft :
|
||||
----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium,
|
||||
totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.
|
||||
|
||||
Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit,
|
||||
sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt.
|
||||
|
||||
Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit,
|
||||
sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem.
|
||||
|
||||
Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam,
|
||||
nisi ut aliquid ex ea commodi consequatur?
|
||||
|
||||
Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur,
|
||||
vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?
|
||||
|
||||
----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
-->
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
@@ -7,7 +7,7 @@
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.js"></script>
|
||||
<script src="/include/vendor/qunit/qunit/qunit.js"></script>
|
||||
<script src="/include/jslibs/blueimp.load-image.js"></script>
|
||||
<script src="../../../prod/jquery.Upload.js"></script>
|
||||
<script src="../../../skins/prod/jquery.Upload.js"></script>
|
||||
<link type="text/css" rel="stylesheet" href="/include/vendor/qunit/qunit/qunit.css"/>
|
||||
<script> $(document).ready(function(){
|
||||
|
||||
|
13140
www/include/magic
13140
www/include/magic
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -1,957 +0,0 @@
|
||||
# Magic data for KMimeMagic (originally for file(1) command)
|
||||
#
|
||||
# The format is 4-5 columns:
|
||||
# Column #1: byte number to begin checking from, ">" indicates continuation
|
||||
# Column #2: type of data to match
|
||||
# Column #3: contents of data to match
|
||||
# Column #4: MIME type of result
|
||||
# Column #5: MIME encoding of result (optional)
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# Localstuff: file(1) magic for locally observed files
|
||||
# Add any locally observed files here.
|
||||
|
||||
# Real Audio (Magic .ra\0375)
|
||||
0 belong 0x2e7261fd audio/x-pn-realaudio
|
||||
0 string .RMF application/vnd.rn-realmedia
|
||||
|
||||
#video/x-pn-realvideo
|
||||
#video/vnd.rn-realvideo
|
||||
#application/vnd.rn-realmedia
|
||||
# sigh, there are many mimes for that but the above are the most common.
|
||||
|
||||
# Taken from magic, converted to magic.mime
|
||||
# mime types according to http://www.geocities.com/nevilo/mod.htm:
|
||||
# audio/it .it
|
||||
# audio/x-zipped-it .itz
|
||||
# audio/xm fasttracker modules
|
||||
# audio/x-s3m screamtracker modules
|
||||
# audio/s3m screamtracker modules
|
||||
# audio/x-zipped-mod mdz
|
||||
# audio/mod mod
|
||||
# audio/x-mod All modules (mod, s3m, 669, mtm, med, xm, it, mdz, stm, itz, xmz, s3z)
|
||||
|
||||
# Taken from loader code from mikmod version 2.14
|
||||
# by Steve McIntyre (stevem@chiark.greenend.org.uk)
|
||||
# <doj@cubic.org> added title printing on 2003-06-24
|
||||
0 string MAS_UTrack_V00
|
||||
>14 string >/0 audio/x-mod
|
||||
#audio/x-tracker-module
|
||||
|
||||
#0 string UN05 MikMod UNI format module sound data
|
||||
|
||||
0 string Extended\ Module: audio/x-mod
|
||||
#audio/x-tracker-module
|
||||
##>17 string >\0 Title: "%s"
|
||||
|
||||
21 string/c \!SCREAM! audio/x-mod
|
||||
#audio/x-screamtracker-module
|
||||
21 string BMOD2STM audio/x-mod
|
||||
#audio/x-screamtracker-module
|
||||
1080 string M.K. audio/x-mod
|
||||
#audio/x-protracker-module
|
||||
#>0 string >\0 Title: "%s"
|
||||
1080 string M!K! audio/x-mod
|
||||
#audio/x-protracker-module
|
||||
#>0 string >\0 Title: "%s"
|
||||
1080 string FLT4 audio/x-mod
|
||||
#audio/x-startracker-module
|
||||
#>0 string >\0 Title: "%s"
|
||||
1080 string FLT8 audio/x-mod
|
||||
#audio/x-startracker-module
|
||||
#>0 string >\0 Title: "%s"
|
||||
1080 string 4CHN audio/x-mod
|
||||
#audio/x-fasttracker-module
|
||||
#>0 string >\0 Title: "%s"
|
||||
1080 string 6CHN audio/x-mod
|
||||
#audio/x-fasttracker-module
|
||||
#>0 string >\0 Title: "%s"
|
||||
1080 string 8CHN audio/x-mod
|
||||
#audio/x-fasttracker-module
|
||||
#>0 string >\0 Title: "%s"
|
||||
1080 string CD81 audio/x-mod
|
||||
#audio/x-oktalyzer-tracker-module
|
||||
#>0 string >\0 Title: "%s"
|
||||
1080 string OKTA audio/x-mod
|
||||
#audio/x-oktalyzer-tracker-module
|
||||
#>0 string >\0 Title: "%s"
|
||||
# Not good enough.
|
||||
#1082 string CH
|
||||
#>1080 string >/0 %.2s-channel Fasttracker "oktalyzer" module sound data
|
||||
1080 string 16CN audio/x-mod
|
||||
#audio/x-taketracker-module
|
||||
#>0 string >\0 Title: "%s"
|
||||
1080 string 32CN audio/x-mod
|
||||
#audio/x-taketracker-module
|
||||
#>0 string >\0 Title: "%s"
|
||||
|
||||
# Impuse tracker module (it)
|
||||
0 string IMPM audio/x-mod
|
||||
#>4 string >\0 "%s"
|
||||
#>40 leshort !0 compatible w/ITv%x
|
||||
#>42 leshort !0 created w/ITv%x
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# end local stuff
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# xml based formats!
|
||||
|
||||
# svg
|
||||
|
||||
38 string \<\!DOCTYPE\040svg image/svg+xml
|
||||
|
||||
|
||||
# xml
|
||||
0 string \<?xml text/xml
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# Java
|
||||
|
||||
0 beshort 0xcafe
|
||||
>2 beshort 0xbabe application/java
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# audio: file(1) magic for sound formats
|
||||
#
|
||||
# from Jan Nicolai Langfeldt <janl@ifi.uio.no>,
|
||||
#
|
||||
|
||||
# Sun/NeXT audio data
|
||||
0 string .snd
|
||||
>12 belong 1 audio/basic
|
||||
>12 belong 2 audio/basic
|
||||
>12 belong 3 audio/basic
|
||||
>12 belong 4 audio/basic
|
||||
>12 belong 5 audio/basic
|
||||
>12 belong 6 audio/basic
|
||||
>12 belong 7 audio/basic
|
||||
|
||||
>12 belong 23 audio/x-adpcm
|
||||
|
||||
# DEC systems (e.g. DECstation 5000) use a variant of the Sun/NeXT format
|
||||
# that uses little-endian encoding and has a different magic number
|
||||
# (0x0064732E in little-endian encoding).
|
||||
0 lelong 0x0064732E
|
||||
>12 lelong 1 audio/x-dec-basic
|
||||
>12 lelong 2 audio/x-dec-basic
|
||||
>12 lelong 3 audio/x-dec-basic
|
||||
>12 lelong 4 audio/x-dec-basic
|
||||
>12 lelong 5 audio/x-dec-basic
|
||||
>12 lelong 6 audio/x-dec-basic
|
||||
>12 lelong 7 audio/x-dec-basic
|
||||
# compressed (G.721 ADPCM)
|
||||
>12 lelong 23 audio/x-dec-adpcm
|
||||
|
||||
# Bytes 0-3 of AIFF, AIFF-C, & 8SVX audio files are "FORM"
|
||||
# AIFF audio data
|
||||
8 string AIFF audio/x-aiff
|
||||
# AIFF-C audio data
|
||||
8 string AIFC audio/x-aiff
|
||||
# IFF/8SVX audio data
|
||||
8 string 8SVX audio/x-aiff
|
||||
|
||||
|
||||
|
||||
# Creative Labs AUDIO stuff
|
||||
# Standard MIDI data
|
||||
0 string MThd audio/unknown
|
||||
#>9 byte >0 (format %d)
|
||||
#>11 byte >1 using %d channels
|
||||
# Creative Music (CMF) data
|
||||
0 string CTMF audio/unknown
|
||||
# SoundBlaster instrument data
|
||||
0 string SBI audio/unknown
|
||||
# Creative Labs voice data
|
||||
0 string Creative\ Voice\ File audio/unknown
|
||||
## is this next line right? it came this way...
|
||||
#>19 byte 0x1A
|
||||
#>23 byte >0 - version %d
|
||||
#>22 byte >0 \b.%d
|
||||
|
||||
# [GRR 950115: is this also Creative Labs? Guessing that first line
|
||||
# should be string instead of unknown-endian long...]
|
||||
#0 long 0x4e54524b MultiTrack sound data
|
||||
#0 string NTRK MultiTrack sound data
|
||||
#>4 long x - version %ld
|
||||
|
||||
# Microsoft WAVE format (*.wav)
|
||||
# [GRR 950115: probably all of the shorts and longs should be leshort/lelong]
|
||||
# Microsoft RIFF
|
||||
0 string RIFF
|
||||
# - WAVE format
|
||||
>8 string WAVE audio/x-wav
|
||||
>8 string/B AVI video/x-msvideo
|
||||
#
|
||||
>8 string CDRA image/x-coreldraw
|
||||
|
||||
# AAC (aka MPEG-2 NBC)
|
||||
0 beshort&0xfff6 0xfff0 audio/X-HX-AAC-ADTS
|
||||
0 string ADIF audio/X-HX-AAC-ADIF
|
||||
0 beshort&0xffe0 0x56e0 audio/MP4A-LATM
|
||||
0 beshort 0x4De1 audio/MP4A-LATM
|
||||
|
||||
# MPEG Layer 3 sound files
|
||||
# modified by Joerg Jenderek
|
||||
# GRR the original test are too common for many DOS files
|
||||
# so test 1 <= kbits nibble <= E
|
||||
0 beshort &0xffe0
|
||||
>2 ubyte&0xF0 >0x0F
|
||||
>>2 ubyte&0xF0 <0xE1 audio/mpeg
|
||||
#MP3 with ID3 tag
|
||||
0 string ID3 audio/mpeg
|
||||
# Ogg/Vorbis
|
||||
0 string OggS application/ogg
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# c-lang: file(1) magic for C programs or various scripts
|
||||
#
|
||||
|
||||
# XPM icons (Greg Roelofs, newt@uchicago.edu)
|
||||
# ideally should go into "images", but entries below would tag XPM as C source
|
||||
0 string /*\ XPM image/x-xpmi 7bit
|
||||
|
||||
# 3DS (3d Studio files) Conflicts with diff output 0x3d '='
|
||||
#16 beshort 0x3d3d image/x-3ds
|
||||
|
||||
# this first will upset you if you're a PL/1 shop... (are there any left?)
|
||||
# in which case rm it; ascmagic will catch real C programs
|
||||
# C or REXX program text
|
||||
#0 string /* text/x-c
|
||||
# C++ program text
|
||||
#0 string // text/x-c++
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# commands: file(1) magic for various shells and interpreters
|
||||
#
|
||||
#0 string :\ shell archive or commands for antique kernel text
|
||||
0 string #!/bin/sh application/x-shellscript
|
||||
0 string #!\ /bin/sh application/x-shellscript
|
||||
0 string #!/bin/csh application/x-shellscript
|
||||
0 string #!\ /bin/csh application/x-shellscript
|
||||
# korn shell magic, sent by George Wu, gwu@clyde.att.com
|
||||
0 string #!/bin/ksh application/x-shellscript
|
||||
0 string #!\ /bin/ksh application/x-shellscript
|
||||
0 string #!/bin/tcsh application/x-shellscript
|
||||
0 string #!\ /bin/tcsh application/x-shellscript
|
||||
0 string #!/usr/local/tcsh application/x-shellscript
|
||||
0 string #!\ /usr/local/tcsh application/x-shellscript
|
||||
0 string #!/usr/local/bin/tcsh application/x-shellscript
|
||||
0 string #!\ /usr/local/bin/tcsh application/x-shellscript
|
||||
# bash shell magic, from Peter Tobias (tobias@server.et-inf.fho-emden.de)
|
||||
0 string #!/bin/bash application/x-shellscript
|
||||
0 string #!\ /bin/bash application/x-shellscript
|
||||
0 string #!/usr/local/bin/bash application/x-shellscript
|
||||
0 string #!\ /usr/local/bin/bash application/x-shellscript
|
||||
|
||||
#
|
||||
# zsh/ash/ae/nawk/gawk magic from cameron@cs.unsw.oz.au (Cameron Simpson)
|
||||
0 string #!/bin/zsh application/x-shellscript
|
||||
0 string #!/usr/bin/zsh application/x-shellscript
|
||||
0 string #!/usr/local/bin/zsh application/x-shellscript
|
||||
0 string #!\ /usr/local/bin/zsh application/x-shellscript
|
||||
0 string #!/usr/local/bin/ash application/x-shellscript
|
||||
0 string #!\ /usr/local/bin/ash application/x-shellscript
|
||||
#0 string #!/usr/local/bin/ae Neil Brown's ae
|
||||
#0 string #!\ /usr/local/bin/ae Neil Brown's ae
|
||||
0 string #!/bin/nawk application/x-nawk
|
||||
0 string #!\ /bin/nawk application/x-nawk
|
||||
0 string #!/usr/bin/nawk application/x-nawk
|
||||
0 string #!\ /usr/bin/nawk application/x-nawk
|
||||
0 string #!/usr/local/bin/nawk application/x-nawk
|
||||
0 string #!\ /usr/local/bin/nawk application/x-nawk
|
||||
0 string #!/bin/gawk application/x-gawk
|
||||
0 string #!\ /bin/gawk application/x-gawk
|
||||
0 string #!/usr/bin/gawk application/x-gawk
|
||||
0 string #!\ /usr/bin/gawk application/x-gawk
|
||||
0 string #!/usr/local/bin/gawk application/x-gawk
|
||||
0 string #!\ /usr/local/bin/gawk application/x-gawk
|
||||
#
|
||||
0 string #!/bin/awk application/x-awk
|
||||
0 string #!\ /bin/awk application/x-awk
|
||||
0 string #!/usr/bin/awk application/x-awk
|
||||
0 string #!\ /usr/bin/awk application/x-awk
|
||||
# update to distinguish from *.vcf files by Joerg Jenderek: joerg dot jenderek at web dot de
|
||||
0 regex BEGIN[[:space:]]*[{] application/x-awk
|
||||
|
||||
# For Larry Wall's perl language. The ``eval'' line recognizes an
|
||||
# outrageously clever hack for USG systems.
|
||||
# Keith Waclena <keith@cerberus.uchicago.edu>
|
||||
0 string #!/bin/perl application/x-perl
|
||||
0 string #!\ /bin/perl application/x-perl
|
||||
0 string eval\ "exec\ /bin/perl application/x-perl
|
||||
0 string #!/usr/bin/perl application/x-perl
|
||||
0 string #!\ /usr/bin/perl application/x-perl
|
||||
0 string eval\ "exec\ /usr/bin/perl application/x-perl
|
||||
0 string #!/usr/local/bin/perl application/x-perl
|
||||
0 string #!\ /usr/local/bin/perl application/x-perl
|
||||
0 string eval\ "exec\ /usr/local/bin/perl application/x-perl
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# compress: file(1) magic for pure-compression formats (no archives)
|
||||
#
|
||||
# compress, gzip, pack, compact, huf, squeeze, crunch, freeze, yabba, whap, etc.
|
||||
#
|
||||
# Formats for various forms of compressed data
|
||||
# Formats for "compress" proper have been moved into "compress.c",
|
||||
# because it tries to uncompress it to figure out what's inside.
|
||||
|
||||
# standard unix compress
|
||||
0 string \037\235 application/x-compress
|
||||
|
||||
# gzip (GNU zip, not to be confused with [Info-ZIP/PKWARE] zip archiver)
|
||||
0 string \037\213 application/x-gzip
|
||||
|
||||
0 string PK\003\004 application/x-zip
|
||||
|
||||
# RAR archiver (Greg Roelofs, newt@uchicago.edu)
|
||||
0 string Rar! application/x-rar
|
||||
|
||||
# According to gzip.h, this is the correct byte order for packed data.
|
||||
0 string \037\036 application/octet-stream
|
||||
#
|
||||
# This magic number is byte-order-independent.
|
||||
#
|
||||
0 short 017437 application/octet-stream
|
||||
|
||||
# XXX - why *two* entries for "compacted data", one of which is
|
||||
# byte-order independent, and one of which is byte-order dependent?
|
||||
#
|
||||
# compacted data
|
||||
0 short 0x1fff application/octet-stream
|
||||
0 string \377\037 application/octet-stream
|
||||
# huf output
|
||||
0 short 0145405 application/octet-stream
|
||||
|
||||
# Squeeze and Crunch...
|
||||
# These numbers were gleaned from the Unix versions of the programs to
|
||||
# handle these formats. Note that I can only uncrunch, not crunch, and
|
||||
# I didn't have a crunched file handy, so the crunch number is untested.
|
||||
# Keith Waclena <keith@cerberus.uchicago.edu>
|
||||
#0 leshort 0x76FF squeezed data (CP/M, DOS)
|
||||
#0 leshort 0x76FE crunched data (CP/M, DOS)
|
||||
|
||||
# Freeze
|
||||
#0 string \037\237 Frozen file 2.1
|
||||
#0 string \037\236 Frozen file 1.0 (or gzip 0.5)
|
||||
|
||||
# lzh?
|
||||
#0 string \037\240 LZH compressed data
|
||||
|
||||
257 string ustar\0 application/x-tar posix
|
||||
257 string ustar\040\040\0 application/x-tar gnu
|
||||
|
||||
0 short 070707 application/x-cpio
|
||||
0 short 0143561 application/x-cpio swapped
|
||||
|
||||
0 string =<ar> application/x-archive
|
||||
0 string \!<arch> application/x-archive
|
||||
>8 string debian application/x-debian-package
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
#
|
||||
# RPM: file(1) magic for Red Hat Packages Erik Troan (ewt@redhat.com)
|
||||
#
|
||||
0 beshort 0xedab
|
||||
>2 beshort 0xeedb application/x-rpm
|
||||
|
||||
0 lelong&0x8080ffff 0x0000081a application/x-arc lzw
|
||||
0 lelong&0x8080ffff 0x0000091a application/x-arc squashed
|
||||
0 lelong&0x8080ffff 0x0000021a application/x-arc uncompressed
|
||||
0 lelong&0x8080ffff 0x0000031a application/x-arc packed
|
||||
0 lelong&0x8080ffff 0x0000041a application/x-arc squeezed
|
||||
0 lelong&0x8080ffff 0x0000061a application/x-arc crunched
|
||||
|
||||
0 leshort 0xea60 application/x-arj
|
||||
|
||||
# LHARC/LHA archiver (Greg Roelofs, newt@uchicago.edu)
|
||||
2 string -lh0- application/x-lharc lh0
|
||||
2 string -lh1- application/x-lharc lh1
|
||||
2 string -lz4- application/x-lharc lz4
|
||||
2 string -lz5- application/x-lharc lz5
|
||||
# [never seen any but the last; -lh4- reported in comp.compression:]
|
||||
2 string -lzs- application/x-lha lzs
|
||||
2 string -lh\ - application/x-lha lh
|
||||
2 string -lhd- application/x-lha lhd
|
||||
2 string -lh2- application/x-lha lh2
|
||||
2 string -lh3- application/x-lha lh3
|
||||
2 string -lh4- application/x-lha lh4
|
||||
2 string -lh5- application/x-lha lh5
|
||||
2 string -lh6- application/x-lha lh6
|
||||
2 string -lh7- application/x-lha lh7
|
||||
# Shell archives
|
||||
10 string #\ This\ is\ a\ shell\ archive application/octet-stream x-shell
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# frame: file(1) magic for FrameMaker files
|
||||
#
|
||||
# This stuff came on a FrameMaker demo tape, most of which is
|
||||
# copyright, but this file is "published" as witness the following:
|
||||
#
|
||||
0 string \<MakerFile application/x-frame
|
||||
0 string \<MIFFile application/x-frame
|
||||
0 string \<MakerDictionary application/x-frame
|
||||
0 string \<MakerScreenFon application/x-frame
|
||||
0 string \<MML application/x-frame
|
||||
0 string \<Book application/x-frame
|
||||
0 string \<Maker application/x-frame
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# html: file(1) magic for HTML (HyperText Markup Language) docs
|
||||
#
|
||||
# from Daniel Quinlan <quinlan@yggdrasil.com>
|
||||
#
|
||||
0 string \<HEAD text/html
|
||||
0 string \<head text/html
|
||||
0 string \<TITLE text/html
|
||||
0 string \<title text/html
|
||||
0 string \<html text/html
|
||||
0 string \<HTML text/html
|
||||
0 string \<!-- text/html
|
||||
0 string \<h1 text/html
|
||||
0 string \<H1 text/html
|
||||
0 string/c \<!doctype\ html text/html
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# images: file(1) magic for image formats (see also "c-lang" for XPM bitmaps)
|
||||
#
|
||||
# originally from jef@helios.ee.lbl.gov (Jef Poskanzer),
|
||||
# additions by janl@ifi.uio.no as well as others. Jan also suggested
|
||||
# merging several one- and two-line files into here.
|
||||
#
|
||||
# XXX - byte order for GIF and TIFF fields?
|
||||
# [GRR: TIFF allows both byte orders; GIF is probably little-endian]
|
||||
#
|
||||
|
||||
# [GRR: what the hell is this doing in here?]
|
||||
#0 string xbtoa btoa'd file
|
||||
|
||||
# PBMPLUS
|
||||
# PBM file
|
||||
0 string P1 image/x-portable-bitmap 7bit
|
||||
# PGM file
|
||||
0 string P2 image/x-portable-greymap 7bit
|
||||
# PPM file
|
||||
0 string P3 image/x-portable-pixmap 7bit
|
||||
# PBM "rawbits" file
|
||||
0 string P4 image/x-portable-bitmap
|
||||
# PGM "rawbits" file
|
||||
0 string P5 image/x-portable-greymap
|
||||
# PPM "rawbits" file
|
||||
0 string P6 image/x-portable-pixmap
|
||||
|
||||
# NIFF (Navy Interchange File Format, a modification of TIFF)
|
||||
# [GRR: this *must* go before TIFF]
|
||||
0 string IIN1 image/x-niff
|
||||
|
||||
# TIFF and friends
|
||||
# TIFF file, big-endian
|
||||
0 string MM image/tiff
|
||||
# TIFF file, little-endian
|
||||
0 string II image/tiff
|
||||
|
||||
# possible GIF replacements; none yet released!
|
||||
# (Greg Roelofs, newt@uchicago.edu)
|
||||
#
|
||||
# GRR 950115: this was mine ("Zip GIF"):
|
||||
# ZIF image (GIF+deflate alpha)
|
||||
0 string GIF94z image/unknown
|
||||
#
|
||||
# GRR 950115: this is Jeremy Wohl's Free Graphics Format (better):
|
||||
# FGF image (GIF+deflate beta)
|
||||
0 string FGF95a image/unknown
|
||||
#
|
||||
# GRR 950115: this is Thomas Boutell's Portable Bitmap Format proposal
|
||||
# (best; not yet implemented):
|
||||
# PBF image (deflate compression)
|
||||
0 string PBF image/unknown
|
||||
|
||||
# GIF
|
||||
0 string GIF image/gif
|
||||
|
||||
# JPEG images
|
||||
0 beshort 0xffd8 image/jpeg
|
||||
|
||||
# PC bitmaps (OS/2, Windoze BMP files) (Greg Roelofs, newt@uchicago.edu)
|
||||
0 string BM image/bmp
|
||||
#>14 byte 12 (OS/2 1.x format)
|
||||
#>14 byte 64 (OS/2 2.x format)
|
||||
#>14 byte 40 (Windows 3.x format)
|
||||
#0 string IC icon
|
||||
#0 string PI pointer
|
||||
#0 string CI color icon
|
||||
#0 string CP color pointer
|
||||
#0 string BA bitmap array
|
||||
|
||||
# CDROM Filesystems
|
||||
32769 string CD001 application/x-iso9660
|
||||
|
||||
# Newer StuffIt archives (grant@netbsd.org)
|
||||
0 string StuffIt application/x-stuffit
|
||||
#>162 string >0 : %s
|
||||
|
||||
# BinHex is the Macintosh ASCII-encoded file format (see also "apple")
|
||||
# Daniel Quinlan, quinlan@yggdrasil.com
|
||||
11 string must\ be\ converted\ with\ BinHex\ 4 application/mac-binhex40
|
||||
##>41 string x \b, version %.3s
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# lisp: file(1) magic for lisp programs
|
||||
#
|
||||
# various lisp types, from Daniel Quinlan (quinlan@yggdrasil.com)
|
||||
0 string ;; text/plain 8bit
|
||||
# Emacs 18 - this is always correct, but not very magical.
|
||||
0 string \012( application/x-elc
|
||||
# Emacs 19
|
||||
0 string ;ELC\023\000\000\000 application/x-elc
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# mail.news: file(1) magic for mail and news
|
||||
#
|
||||
# There are tests to ascmagic.c to cope with mail and news.
|
||||
0 string Relay-Version: message/rfc822 7bit
|
||||
0 string #!\ rnews message/rfc822 7bit
|
||||
0 string N#!\ rnews message/rfc822 7bit
|
||||
0 string Forward\ to message/rfc822 7bit
|
||||
0 string Pipe\ to message/rfc822 7bit
|
||||
0 string Return-Path: message/rfc822 7bit
|
||||
0 string Received: message/rfc822
|
||||
0 string Path: message/news 8bit
|
||||
0 string Xref: message/news 8bit
|
||||
0 string From: message/rfc822 7bit
|
||||
0 string Article message/news 8bit
|
||||
#------------------------------------------------------------------------------
|
||||
# msword: file(1) magic for MS Word files
|
||||
#
|
||||
# Contributor claims:
|
||||
# Reversed-engineered MS Word magic numbers
|
||||
#
|
||||
|
||||
0 string \376\067\0\043 application/msword
|
||||
# disable this one because it applies also to other
|
||||
# Office/OLE documents for which msword is not correct. See PR#2608.
|
||||
# from magic file of the apache
|
||||
#0 string \320\317\021\340\241\261 application/msword
|
||||
512 string \354\245\301 application/msword
|
||||
0 string \333\245-\0\0\0 application/msword
|
||||
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# printer: file(1) magic for printer-formatted files
|
||||
#
|
||||
|
||||
# PostScript
|
||||
0 string %! application/postscript
|
||||
0 string \004%! application/postscript
|
||||
|
||||
# Acrobat
|
||||
# (due to clamen@cs.cmu.edu)
|
||||
0 string %PDF- application/pdf
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# sc: file(1) magic for "sc" spreadsheet
|
||||
#
|
||||
38 string Spreadsheet application/x-sc
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# tex: file(1) magic for TeX files
|
||||
#
|
||||
# XXX - needs byte-endian stuff (big-endian and little-endian DVI?)
|
||||
#
|
||||
# From <conklin@talisman.kaleida.com>
|
||||
|
||||
# Although we may know the offset of certain text fields in TeX DVI
|
||||
# and font files, we can't use them reliably because they are not
|
||||
# zero terminated. [but we do anyway, christos]
|
||||
0 string \367\002 application/x-dvi
|
||||
#0 string \367\203 TeX generic font data
|
||||
#0 string \367\131 TeX packed font data
|
||||
#0 string \367\312 TeX virtual font data
|
||||
#0 string This\ is\ TeX, TeX transcript text
|
||||
#0 string This\ is\ METAFONT, METAFONT transcript text
|
||||
|
||||
# There is no way to detect TeX Font Metric (*.tfm) files without
|
||||
# breaking them apart and reading the data. The following patterns
|
||||
# match most *.tfm files generated by METAFONT or afm2tfm.
|
||||
2 string \000\021 application/x-tex-tfm
|
||||
2 string \000\022 application/x-tex-tfm
|
||||
#>34 string >\0 (%s)
|
||||
|
||||
# Texinfo and GNU Info, from Daniel Quinlan (quinlan@yggdrasil.com)
|
||||
0 string \\input\ texinfo text/x-texinfo
|
||||
0 string This\ is\ Info\ file text/x-info
|
||||
|
||||
# correct TeX magic for Linux (and maybe more)
|
||||
# from Peter Tobias (tobias@server.et-inf.fho-emden.de)
|
||||
#
|
||||
0 leshort 0x02f7 application/x-dvi
|
||||
|
||||
# RTF - Rich Text Format
|
||||
0 string {\\rtf text/rtf
|
||||
|
||||
# TeX documents, from Daniel Quinlan (quinlan@yggdrasil.com)
|
||||
0 search/400 \\input text/x-tex
|
||||
0 search/400 \\section text/x-tex
|
||||
0 search/400 \\setlength text/x-tex
|
||||
0 search/400 \\documentstyle text/x-tex
|
||||
0 search/400 \\chapter text/x-tex
|
||||
0 search/400 \\documentclass text/x-tex
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# animation: file(1) magic for animation/movie formats
|
||||
#
|
||||
# animation formats, originally from vax@ccwf.cc.utexas.edu (VaX#n8)
|
||||
# MPEG file
|
||||
# MPEG sequences
|
||||
0 belong 0x000001BA
|
||||
>4 byte &0x40 video/mp2p
|
||||
>4 byte ^0x40 video/mpeg
|
||||
0 belong 0x000001BB video/mpeg
|
||||
0 belong 0x000001B0 video/mp4v-es
|
||||
0 belong 0x000001B5 video/mp4v-es
|
||||
0 belong 0x000001B3 video/mpv
|
||||
0 belong&0xFF5FFF1F 0x47400010 video/mp2t
|
||||
0 belong 0x00000001
|
||||
>4 byte&0x1F 0x07 video/h264
|
||||
|
||||
# FLI animation format
|
||||
0 leshort 0xAF11 video/fli
|
||||
# FLC animation format
|
||||
0 leshort 0xAF12 video/flc
|
||||
#
|
||||
# SGI and Apple formats
|
||||
# Added ISO mimes
|
||||
0 string MOVI video/sgi
|
||||
4 string moov video/quicktime
|
||||
4 string mdat video/quicktime
|
||||
4 string wide video/quicktime
|
||||
4 string skip video/quicktime
|
||||
4 string free video/quicktime
|
||||
4 string idsc image/x-quicktime
|
||||
4 string idat image/x-quicktime
|
||||
4 string pckg application/x-quicktime
|
||||
4 string/B jP image/jp2
|
||||
4 string ftyp
|
||||
>8 string isom video/mp4
|
||||
>8 string mp41 video/mp4
|
||||
>8 string mp42 video/mp4
|
||||
>8 string/B jp2 image/jp2
|
||||
>8 string 3gp video/3gpp
|
||||
>8 string avc1 video/3gpp
|
||||
>8 string mmp4 video/mp4
|
||||
>8 string/B M4A audio/mp4
|
||||
>8 string/B qt video/quicktime
|
||||
# The contributor claims:
|
||||
# I couldn't find a real magic number for these, however, this
|
||||
# -appears- to work. Note that it might catch other files, too,
|
||||
# so BE CAREFUL!
|
||||
#
|
||||
# Note that title and author appear in the two 20-byte chunks
|
||||
# at decimal offsets 2 and 22, respectively, but they are XOR'ed with
|
||||
# 255 (hex FF)! DL format SUCKS BIG ROCKS.
|
||||
#
|
||||
# DL file version 1 , medium format (160x100, 4 images/screen)
|
||||
0 byte 1 video/unknown
|
||||
0 byte 2 video/unknown
|
||||
#
|
||||
# Databases
|
||||
#
|
||||
# GDBM magic numbers
|
||||
# Will be maintained as part of the GDBM distribution in the future.
|
||||
# <downsj@teeny.org>
|
||||
0 belong 0x13579ace application/x-gdbm
|
||||
0 lelong 0x13579ace application/x-gdbm
|
||||
0 string GDBM application/x-gdbm
|
||||
#
|
||||
0 belong 0x061561 application/x-dbm
|
||||
#
|
||||
# Executables
|
||||
#
|
||||
0 string \177ELF
|
||||
>16 leshort 0 application/octet-stream
|
||||
>16 leshort 1 application/x-object
|
||||
>16 leshort 2 application/x-executable
|
||||
>16 leshort 3 application/x-sharedlib
|
||||
>16 leshort 4 application/x-coredump
|
||||
>16 beshort 0 application/octet-stream
|
||||
>16 beshort 1 application/x-object
|
||||
>16 beshort 2 application/x-executable
|
||||
>16 beshort 3 application/x-sharedlib
|
||||
>16 beshort 4 application/x-coredump
|
||||
#
|
||||
# DOS
|
||||
0 string MZ application/x-dosexec
|
||||
#
|
||||
# KDE
|
||||
0 string [KDE\ Desktop\ Entry] application/x-kdelnk
|
||||
0 string #\ KDE\ Config\ File application/x-kdelnk
|
||||
# xmcd database file for kscd
|
||||
0 string #\ xmcd text/xmcd
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# pkgadd: file(1) magic for SysV R4 PKG Datastreams
|
||||
#
|
||||
0 string #\ PaCkAgE\ DaTaStReAm application/x-svr4-package
|
||||
|
||||
#PNG Image Format
|
||||
0 string \x89PNG image/png
|
||||
|
||||
# MNG Video Format, <URL:http://www.libpng.org/pub/mng/spec/>
|
||||
0 string \x8aMNG video/x-mng
|
||||
0 string \x8aJNG video/x-jng
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# Hierarchical Data Format, used to facilitate scientific data exchange
|
||||
# specifications at http://hdf.ncsa.uiuc.edu/
|
||||
0 belong 0x0e031301 Hierarchical Data Format (version 4) data
|
||||
0 string \211HDF\r\n\032 Hierarchical Data Format (version 5) data
|
||||
|
||||
# Adobe Photoshop
|
||||
0 string 8BPS image/x-photoshop
|
||||
|
||||
# Felix von Leitner <felix-file@fefe.de>
|
||||
0 string d8:announce application/x-bittorrent
|
||||
|
||||
|
||||
# lotus 1-2-3 document
|
||||
0 belong 0x00001a00 application/x-123
|
||||
0 belong 0x00000200 application/x-123
|
||||
|
||||
# MS Access database
|
||||
4 string Standard\ Jet\ DB application/msaccess
|
||||
|
||||
## magic for XBase files
|
||||
#0 byte 0x02
|
||||
#>8 leshort >0
|
||||
#>>12 leshort 0 application/x-dbf
|
||||
#
|
||||
#0 byte 0x03
|
||||
#>8 leshort >0
|
||||
#>>12 leshort 0 application/x-dbf
|
||||
#
|
||||
#0 byte 0x04
|
||||
#>8 leshort >0
|
||||
#>>12 leshort 0 application/x-dbf
|
||||
#
|
||||
#0 byte 0x05
|
||||
#>8 leshort >0
|
||||
#>>12 leshort 0 application/x-dbf
|
||||
#
|
||||
#0 byte 0x30
|
||||
#>8 leshort >0
|
||||
#>>12 leshort 0 application/x-dbf
|
||||
#
|
||||
#0 byte 0x43
|
||||
#>8 leshort >0
|
||||
#>>12 leshort 0 application/x-dbf
|
||||
#
|
||||
#0 byte 0x7b
|
||||
#>8 leshort >0
|
||||
#>>12 leshort 0 application/x-dbf
|
||||
#
|
||||
#0 byte 0x83
|
||||
#>8 leshort >0
|
||||
#>>12 leshort 0 application/x-dbf
|
||||
#
|
||||
#0 byte 0x8b
|
||||
#>8 leshort >0
|
||||
#>>12 leshort 0 application/x-dbf
|
||||
#
|
||||
#0 byte 0x8e
|
||||
#>8 leshort >0
|
||||
#>>12 leshort 0 application/x-dbf
|
||||
#
|
||||
#0 byte 0xb3
|
||||
#>8 leshort >0
|
||||
#>>12 leshort 0 application/x-dbf
|
||||
#
|
||||
#0 byte 0xf5
|
||||
#>8 leshort >0
|
||||
#>>12 leshort 0 application/x-dbf
|
||||
#
|
||||
#0 leshort 0x0006 application/x-dbt
|
||||
|
||||
# Debian has entries for the old PGP formats:
|
||||
# pgp: file(1) magic for Pretty Good Privacy
|
||||
# see http://lists.gnupg.org/pipermail/gnupg-devel/1999-September/016052.html
|
||||
0 beshort 0x9900 text/PGP key public ring
|
||||
0 beshort 0x9501 text/PGP key security ring
|
||||
0 beshort 0x9500 text/PGP key security ring
|
||||
0 beshort 0xa600 text/PGP encrypted data
|
||||
0 string -----BEGIN\040PGP text/PGP armored data
|
||||
>15 string PUBLIC\040KEY\040BLOCK- public key block
|
||||
>15 string MESSAGE- message
|
||||
>15 string SIGNED\040MESSAGE- signed message
|
||||
>15 string PGP\040SIGNATURE- signature
|
||||
0 beshort 0x8501 data
|
||||
#
|
||||
# GnuPG Magic:
|
||||
#
|
||||
0 beshort 0x9901 text/GnuPG key public ring
|
||||
0 beshort 0x8501 text/OpenPGP data
|
||||
|
||||
# flash: file(1) magic for Macromedia Flash file format
|
||||
#
|
||||
# See
|
||||
#
|
||||
# http://www.macromedia.com/software/flash/open/
|
||||
#
|
||||
0 string FWS
|
||||
>3 byte x application/x-shockwave-flash
|
||||
|
||||
# The following paramaters are created for Namazu.
|
||||
# <http://www.namazu.org/>
|
||||
#
|
||||
# 1999/08/13
|
||||
#0 string \<!--\ MHonArc text/html; x-type=mhonarc
|
||||
0 string BZh application/x-bzip2
|
||||
|
||||
# 1999/09/09
|
||||
# VRML (suggested by Masao Takaku)
|
||||
0 string #VRML\ V1.0\ ascii model/vrml
|
||||
0 string #VRML\ V2.0\ utf8 model/vrml
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# ichitaro456: file(1) magic for Just System Word Processor Ichitaro
|
||||
#
|
||||
# Contributor kenzo-:
|
||||
# Reversed-engineered JS Ichitaro magic numbers
|
||||
#
|
||||
|
||||
0 string DOC
|
||||
>43 byte 0x14 application/ichitaro4
|
||||
>144 string JDASH application/ichitaro4
|
||||
|
||||
0 string DOC
|
||||
>43 byte 0x15 application/ichitaro5
|
||||
|
||||
0 string DOC
|
||||
>43 byte 0x16 application/ichitaro6
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# office97: file(1) magic for MicroSoft Office files
|
||||
#
|
||||
# Contributor kenzo-:
|
||||
# Reversed-engineered MS Office magic numbers
|
||||
#
|
||||
|
||||
#0 string \320\317\021\340\241\261\032\341
|
||||
#>48 byte 0x1B application/excel
|
||||
|
||||
2080 string Microsoft\ Excel\ 5.0\ Worksheet application/excel
|
||||
2114 string Biff5 application/excel
|
||||
|
||||
0 string \224\246\056 application/msword
|
||||
|
||||
0 belong 0x31be0000 application/msword
|
||||
|
||||
0 string PO^Q` application/msword
|
||||
|
||||
0 string \320\317\021\340\241\261\032\341
|
||||
>546 string bjbj application/msword
|
||||
>546 string jbjb application/msword
|
||||
|
||||
512 string R\0o\0o\0t\0\ \0E\0n\0t\0r\0y application/msword
|
||||
|
||||
2080 string Microsoft\ Word\ 6.0\ Document application/msword
|
||||
2080 string Documento\ Microsoft\ Word\ 6 application/msword
|
||||
2112 string MSWordDoc application/msword
|
||||
|
||||
#0 string \320\317\021\340\241\261\032\341 application/powerpoint
|
||||
0 string \320\317\021\340\241\261\032\341 application/msword
|
||||
|
||||
0 string #\ PaCkAgE\ DaTaStReAm application/x-svr4-package
|
||||
|
||||
|
||||
# WinNT/WinCE PE files (Warner Losh, imp@village.org)
|
||||
#
|
||||
128 string PE\000\000 application/octet-stream
|
||||
0 string PE\000\000 application/octet-stream
|
||||
|
||||
# miscellaneous formats
|
||||
0 string LZ application/octet-stream
|
||||
|
||||
# DOS device drivers by Joerg Jenderek
|
||||
0 belong 0xffffffff application/octet-stream
|
||||
|
||||
# .EXE formats (Greg Roelofs, newt@uchicago.edu)
|
||||
#
|
||||
0 string MZ
|
||||
>24 string @ application/octet-stream
|
||||
|
||||
0 string MZ
|
||||
>30 string Copyright\ 1989-1990\ PKWARE\ Inc. application/x-zip
|
||||
|
||||
0 string MZ
|
||||
>30 string PKLITE\ Copr. application/x-zip
|
||||
|
||||
0 string MZ
|
||||
>36 string LHa's\ SFX application/x-lha
|
||||
|
||||
0 string MZ application/octet-stream
|
||||
|
||||
# LHA archiver
|
||||
2 string -lh
|
||||
>6 string - application/x-lha
|
||||
|
||||
|
||||
# Zoo archiver
|
||||
20 lelong 0xfdc4a7dc application/x-zoo
|
||||
|
||||
# ARC archiver
|
||||
0 lelong&0x8080ffff 0x0000081a application/x-arc
|
||||
0 lelong&0x8080ffff 0x0000091a application/x-arc
|
||||
0 lelong&0x8080ffff 0x0000021a application/x-arc
|
||||
0 lelong&0x8080ffff 0x0000031a application/x-arc
|
||||
0 lelong&0x8080ffff 0x0000041a application/x-arc
|
||||
0 lelong&0x8080ffff 0x0000061a application/x-arc
|
||||
|
||||
# Microsoft Outlook's Transport Neutral Encapsulation Format (TNEF)
|
||||
0 lelong 0x223e9f78 application/ms-tnef
|
||||
|
||||
# From: stephane.loeuillet@tiscali.f
|
||||
# http://www.djvuzone.org/
|
||||
0 string AT&TFORM image/x.djvu
|
||||
|
||||
# Danny Milosavljevic <danny.milo@gmx.net>
|
||||
# this are adrift (adventure game standard) game files, extension .taf
|
||||
# depending on version magic continues with 0x93453E6139FA (V 4.0)
|
||||
# 0x9445376139FA (V 3.90)
|
||||
# 0x9445366139FA (V 3.80)
|
||||
# this is from source (http://www.adrift.org.uk/) and I have some taf
|
||||
# files, and checked them.
|
||||
#0 belong 0x3C423FC9
|
||||
#>4 belong 0x6A87C2CF application/x-adrift
|
||||
#0 string \000\000\001\000 image/x-ico
|
||||
|
||||
# Quark Xpress 3 Files:
|
||||
# (made the mimetype up)
|
||||
0 string \0\0MMXPR3\0 application/x-quark-xpress-3
|
||||
|
||||
# EET archive
|
||||
# From: Tilman Sauerbeck <tilman@code-monkey.de>
|
||||
0 belong 0x1ee7ff00 application/x-eet
|
||||
|
||||
# From: Denis Knauf, via gentoo.
|
||||
0 string fLaC audio/x-flac
|
||||
0 string CWS application/x-shockwave-flash
|
||||
|
||||
# Hangul Document Files:
|
||||
# Reversed-engineered HWP magic numbers
|
||||
# From: Won-Kyu Park <wkpark@kldp.org>
|
||||
512 string R\0o\0o\0t\0 application/x-hwp
|
||||
|
||||
0 string/c BEGIN:VCARD text/x-vcard
|
||||
0 string WordPro\0 application/vnd.lotus-wordpro
|
||||
0 string WordPro\r\373 application/vnd.lotus-wordpro
|
||||
0 string CPC\262 image/cpi
|
||||
|
||||
#
|
||||
128 string DICM application/dicom
|
||||
|
||||
# Symbian installation files
|
||||
8 lelong 0x10000419 application/vnd.symbian.install
|
||||
0 lelong 0x10201A7A x-epoc/x-sisx-app
|
Binary file not shown.
@@ -1,4 +0,0 @@
|
||||
<IfModule mod_rewrite.c>
|
||||
RewriteEngine on
|
||||
RewriteRule ^([a-z]=.*) index.php?$1 [L,NE]
|
||||
</IfModule>
|
@@ -1,26 +0,0 @@
|
||||
Copyright (c) 2008 Ryan Grove <ryan@wonko.com>
|
||||
Copyright (c) 2008 Steve Clay <steve@mrclay.org>
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
* Neither the name of this project nor the names of its contributors may be
|
||||
used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
@@ -1,132 +0,0 @@
|
||||
The files in this directory represent the default Minify setup designed to ease
|
||||
integration with your site. This app will combine and minify your Javascript or
|
||||
CSS files and serve them with HTTP compression and cache headers.
|
||||
|
||||
|
||||
RECOMMENDED
|
||||
|
||||
It's recommended to edit config.php to set $min_cachePath to a writeable
|
||||
(by PHP) directory on your system. This will improve performance.
|
||||
|
||||
|
||||
GETTING STARTED
|
||||
|
||||
The quickest way to get started is to use the Minify URI Builder application
|
||||
on your website: http://example.com/min/builder/
|
||||
|
||||
|
||||
MINIFYING A SINGLE FILE
|
||||
|
||||
Let's say you want to serve this file:
|
||||
http://example.com/wp-content/themes/default/default.css
|
||||
|
||||
Here's the "Minify URL" for this file:
|
||||
http://example.com/min/?f=wp-content/themes/default/default.css
|
||||
|
||||
In other words, the "f" argument is set to the file path from root without the
|
||||
initial "/". As CSS files may contain relative URIs, Minify will automatically
|
||||
"fix" these by rewriting them as root relative.
|
||||
|
||||
|
||||
COMBINING MULTIPLE FILES IN ONE DOWNLOAD
|
||||
|
||||
Separate the paths given to "f" with commas.
|
||||
|
||||
Let's say you have CSS files at these URLs:
|
||||
http://example.com/scripts/jquery-1.2.6.js
|
||||
http://example.com/scripts/site.js
|
||||
|
||||
You can combine these files through Minify by requesting this URL:
|
||||
http://example.com/min/?f=scripts/jquery-1.2.6.js,scripts/site.js
|
||||
|
||||
|
||||
SIMPLIFYING URLS WITH A BASE PATH
|
||||
|
||||
If you're combining files that share the same ancestor directory, you can use
|
||||
the "b" argument to set the base directory for the "f" argument. Do not include
|
||||
the leading or trailing "/" characters.
|
||||
|
||||
E.g., the following URLs will serve the exact same content:
|
||||
http://example.com/min/?f=scripts/jquery-1.2.6.js,scripts/site.js,scripts/home.js
|
||||
http://example.com/min/?b=scripts&f=jquery-1.2.6.js,site.js,home.js
|
||||
|
||||
|
||||
MINIFY URLS IN HTML
|
||||
|
||||
In (X)HTML files, don't forget to replace any "&" characters with "&".
|
||||
|
||||
|
||||
SPECIFYING ALLOWED DIRECTORIES
|
||||
|
||||
By default, Minify will serve any *.css/*.js files within the DOCUMENT_ROOT. If
|
||||
you'd prefer to limit Minify's access to certain directories, set the
|
||||
$min_serveOptions['minApp']['allowDirs'] array in config.php. E.g. to limit
|
||||
to the /js and /themes/default directories, use:
|
||||
|
||||
$min_serveOptions['minApp']['allowDirs'] = array('//js', '//themes/default');
|
||||
|
||||
|
||||
GROUPS: FASTER PERFORMANCE AND BETTER URLS
|
||||
|
||||
For the best performance, edit groupsConfig.php to pre-specify groups of files
|
||||
to be combined under preset keys. E.g., here's an example configuration in
|
||||
groupsConfig.php:
|
||||
|
||||
return array(
|
||||
'js' => array('//js/Class.js', '//js/email.js')
|
||||
);
|
||||
|
||||
This pre-selects the following files to be combined under the key "js":
|
||||
http://example.com/js/Class.js
|
||||
http://example.com/js/email.js
|
||||
|
||||
You can now serve these files with this simple URL:
|
||||
http://example.com/min/?g=js
|
||||
|
||||
|
||||
GROUPS: SPECIFYING FILES OUTSIDE THE DOC_ROOT
|
||||
|
||||
In the groupsConfig.php array, the "//" in the file paths is a shortcut for
|
||||
the DOCUMENT_ROOT, but you can also specify paths from the root of the filesystem
|
||||
or relative to the DOC_ROOT:
|
||||
|
||||
return array(
|
||||
'js' => array(
|
||||
'//js/file.js' // file within DOC_ROOT
|
||||
,'//../file.js' // file in parent directory of DOC_ROOT
|
||||
,'C:/Users/Steve/file.js' // file anywhere on filesystem
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
FAR-FUTURE EXPIRES HEADERS
|
||||
|
||||
Minify can send far-future (one year) Expires headers. To enable this you must
|
||||
add a number to the querystring (e.g. /min/?g=js&1234 or /min/f=file.js&1234)
|
||||
and alter it whenever a source file is changed. If you have a build process you
|
||||
can use a build/source control revision number.
|
||||
|
||||
If you serve files as a group, you can use the utility function Minify_groupUri()
|
||||
to get a "versioned" Minify URI for use in your HTML. E.g.:
|
||||
|
||||
<?php
|
||||
// add /min/lib to your include_path first!
|
||||
require $_SERVER['DOCUMENT_ROOT'] . '/min/utils.php';
|
||||
|
||||
$jsUri = Minify_groupUri('js');
|
||||
echo "<script type='text/javascript' src='{$jsUri}'></script>";
|
||||
|
||||
|
||||
DEBUG MODE
|
||||
|
||||
In debug mode, instead of compressing files, Minify sends combined files with
|
||||
comments prepended to each line to show the line number in the original source
|
||||
file. To enable this, set $min_allowDebugFlag to true in config.php and append
|
||||
"&debug=1" to your URIs. E.g. /min/?f=script1.js,script2.js&debug=1
|
||||
|
||||
Known issue: files with comment-like strings/regexps can cause problems in this mode.
|
||||
|
||||
|
||||
QUESTIONS?
|
||||
|
||||
http://groups.google.com/group/minify
|
@@ -1,242 +0,0 @@
|
||||
var MUB = {
|
||||
_uid : 0
|
||||
,_minRoot : '/min/?'
|
||||
,checkRewrite : function () {
|
||||
var testUri = location.pathname.replace(/\/[^\/]*$/, '/rewriteTest.js').substr(1);
|
||||
function fail() {
|
||||
$('#minRewriteFailed')[0].className = 'topNote';
|
||||
};
|
||||
$.ajax({
|
||||
url : '../f=' + testUri + '&' + (new Date()).getTime()
|
||||
,success : function (data) {
|
||||
if (data === '1') {
|
||||
MUB._minRoot = '/min/';
|
||||
$('span.minRoot').html('/min/');
|
||||
} else
|
||||
fail();
|
||||
}
|
||||
,error : fail
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Get markup for new source LI element
|
||||
*/
|
||||
,newLi : function () {
|
||||
return '<li id="li' + MUB._uid + '">http://' + location.host + '/<input type=text size=20>'
|
||||
+ ' <button title="Remove">x</button> <button title="Include Earlier">↑</button>'
|
||||
+ ' <button title="Include Later">↓</button> <span></span></li>';
|
||||
}
|
||||
/**
|
||||
* Add new empty source LI and attach handlers to buttons
|
||||
*/
|
||||
,addLi : function () {
|
||||
$('#sources').append(MUB.newLi());
|
||||
var li = $('#li' + MUB._uid)[0];
|
||||
$('button[title=Remove]', li).click(function () {
|
||||
$('#results').hide();
|
||||
var hadValue = !!$('input', li)[0].value;
|
||||
$(li).remove();
|
||||
});
|
||||
$('button[title$=Earlier]', li).click(function () {
|
||||
$(li).prev('li').find('input').each(function () {
|
||||
$('#results').hide();
|
||||
// this = previous li input
|
||||
var tmp = this.value;
|
||||
this.value = $('input', li).val();
|
||||
$('input', li).val(tmp);
|
||||
MUB.updateAllTestLinks();
|
||||
});
|
||||
});
|
||||
$('button[title$=Later]', li).click(function () {
|
||||
$(li).next('li').find('input').each(function () {
|
||||
$('#results').hide();
|
||||
// this = next li input
|
||||
var tmp = this.value;
|
||||
this.value = $('input', li).val();
|
||||
$('input', li).val(tmp);
|
||||
MUB.updateAllTestLinks();
|
||||
});
|
||||
});
|
||||
++MUB._uid;
|
||||
}
|
||||
/**
|
||||
* In the context of a source LI element, this will analyze the URI in
|
||||
* the INPUT and check the URL on the site.
|
||||
*/
|
||||
,liUpdateTestLink : function () { // call in context of li element
|
||||
if (! $('input', this)[0].value)
|
||||
return;
|
||||
var li = this;
|
||||
$('span', this).html('');
|
||||
var url = 'http://' + location.host + '/'
|
||||
+ $('input', this)[0].value.replace(/^\//, '');
|
||||
$.ajax({
|
||||
url : url
|
||||
,complete : function (xhr, stat) {
|
||||
if ('success' == stat)
|
||||
$('span', li).html('✓');
|
||||
else {
|
||||
$('span', li).html('<button><b>404! </b> recheck</button>')
|
||||
.find('button').click(function () {
|
||||
MUB.liUpdateTestLink.call(li);
|
||||
});
|
||||
}
|
||||
}
|
||||
,dataType : 'text'
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Check all source URLs
|
||||
*/
|
||||
,updateAllTestLinks : function () {
|
||||
$('#sources li').each(MUB.liUpdateTestLink);
|
||||
}
|
||||
/**
|
||||
* In a given array of strings, find the character they all have at
|
||||
* a particular index
|
||||
* @param Array arr array of strings
|
||||
* @param Number pos index to check
|
||||
* @return mixed a common char or '' if any do not match
|
||||
*/
|
||||
,getCommonCharAtPos : function (arr, pos) {
|
||||
var i
|
||||
,l = arr.length
|
||||
,c = arr[0].charAt(pos);
|
||||
if (c === '' || l === 1)
|
||||
return c;
|
||||
for (i = 1; i < l; ++i)
|
||||
if (arr[i].charAt(pos) !== c)
|
||||
return '';
|
||||
return c;
|
||||
}
|
||||
/**
|
||||
* Get the shortest URI to minify the set of source files
|
||||
* @param Array sources URIs
|
||||
*/
|
||||
,getBestUri : function (sources) {
|
||||
var pos = 0
|
||||
,base = ''
|
||||
,c;
|
||||
while (true) {
|
||||
c = MUB.getCommonCharAtPos(sources, pos);
|
||||
if (c === '')
|
||||
break;
|
||||
else
|
||||
base += c;
|
||||
++pos;
|
||||
}
|
||||
base = base.replace(/[^\/]+$/, '');
|
||||
var uri = MUB._minRoot + 'f=' + sources.join(',');
|
||||
if (base.charAt(base.length - 1) === '/') {
|
||||
// we have a base dir!
|
||||
var basedSources = sources
|
||||
,i
|
||||
,l = sources.length;
|
||||
for (i = 0; i < l; ++i) {
|
||||
basedSources[i] = sources[i].substr(base.length);
|
||||
}
|
||||
base = base.substr(0, base.length - 1);
|
||||
var bUri = MUB._minRoot + 'b=' + base + '&f=' + basedSources.join(',');
|
||||
//window.console && console.log([uri, bUri]);
|
||||
uri = uri.length < bUri.length
|
||||
? uri
|
||||
: bUri;
|
||||
}
|
||||
return uri;
|
||||
}
|
||||
/**
|
||||
* Create the Minify URI for the sources
|
||||
*/
|
||||
,update : function () {
|
||||
MUB.updateAllTestLinks();
|
||||
var sources = []
|
||||
,ext = false
|
||||
,fail = false;
|
||||
$('#sources input').each(function () {
|
||||
var m, val;
|
||||
if (! fail && this.value && (m = this.value.match(/\.(css|js)$/))) {
|
||||
var thisExt = m[1];
|
||||
if (ext === false)
|
||||
ext = thisExt;
|
||||
else if (thisExt !== ext) {
|
||||
fail = true;
|
||||
return alert('extensions must match!');
|
||||
}
|
||||
this.value = this.value.replace(/^\//, '');
|
||||
if (-1 != $.inArray(this.value, sources)) {
|
||||
fail = true;
|
||||
return alert('duplicate file!');
|
||||
}
|
||||
sources.push(this.value);
|
||||
}
|
||||
});
|
||||
if (fail || ! sources.length)
|
||||
return;
|
||||
$('#groupConfig').val(" 'keyName' => array('//" + sources.join("', '//") + "'),");
|
||||
var uri = MUB.getBestUri(sources)
|
||||
,uriH = uri.replace(/</, '<').replace(/>/, '>').replace(/&/, '&');
|
||||
$('#uriA').html(uriH)[0].href = uri;
|
||||
$('#uriHtml').val(
|
||||
ext === 'js'
|
||||
? '<script type="text/javascript" src="' + uriH + '"></script>'
|
||||
: '<link type="text/css" rel="stylesheet" href="' + uriH + '" />'
|
||||
);
|
||||
$('#results').show();
|
||||
}
|
||||
/**
|
||||
* Handler for the "Add file +" button
|
||||
*/
|
||||
,addButtonClick : function () {
|
||||
$('#results').hide();
|
||||
MUB.addLi();
|
||||
MUB.updateAllTestLinks();
|
||||
$('#update').show().click(MUB.update);
|
||||
$('#sources li:last input')[0].focus();
|
||||
}
|
||||
/**
|
||||
* Runs on DOMready
|
||||
*/
|
||||
,init : function () {
|
||||
$('#app').show();
|
||||
$('#sources').html('');
|
||||
$('#add button').click(MUB.addButtonClick);
|
||||
// make easier to copy text out of
|
||||
$('#uriHtml, #groupConfig').click(function () {
|
||||
this.select();
|
||||
}).focus(function () {
|
||||
this.select();
|
||||
});
|
||||
$('a.ext').attr({target:'_blank'});
|
||||
if (location.hash) {
|
||||
// make links out of URIs from bookmarklet
|
||||
$('#getBm').hide();
|
||||
$('#bmUris').html('<p><strong>Found by bookmarklet:</strong> /<a href=#>'
|
||||
+ location.hash.substr(1).split(',').join('</a> | /<a href=#>')
|
||||
+ '</a></p>'
|
||||
);
|
||||
$('#bmUris a').click(function () {
|
||||
MUB.addButtonClick();
|
||||
$('#sources li:last input').val(this.innerHTML)
|
||||
MUB.liUpdateTestLink.call($('#sources li:last')[0]);
|
||||
$('#results').hide();
|
||||
return false;
|
||||
}).attr({title:'Add file +'});
|
||||
} else {
|
||||
// copy bookmarklet code into href
|
||||
var bmUri = location.pathname.replace(/\/[^\/]*$/, '/bm.js').substr(1);
|
||||
$.ajax({
|
||||
url : '../?f=' + bmUri
|
||||
,success : function (code) {
|
||||
$('#bm')[0].href = code
|
||||
.replace('%BUILDER_URL%', location.href)
|
||||
.replace(/\n/g, ' ');
|
||||
}
|
||||
,dataType : 'text'
|
||||
});
|
||||
$.browser.msie && $('#getBm p:last').append(' Sorry, not supported in MSIE!');
|
||||
MUB.addButtonClick();
|
||||
}
|
||||
MUB.checkRewrite();
|
||||
}
|
||||
};
|
||||
window.onload = MUB.init;
|
@@ -1,36 +0,0 @@
|
||||
javascript:(function() {
|
||||
var d = document
|
||||
,uris = []
|
||||
,i = 0
|
||||
,o
|
||||
,home = (location + '').split('/').splice(0, 3).join('/') + '/';
|
||||
function add(uri) {
|
||||
return (0 === uri.indexOf(home))
|
||||
&& (!/[\?&]/.test(uri))
|
||||
&& uris.push(escape(uri.substr(home.length)));
|
||||
};
|
||||
function sheet(ss) {
|
||||
// we must check the domain with add() before accessing ss.cssRules
|
||||
// otherwise a security exception will be thrown
|
||||
if (ss.href && add(ss.href) && ss.cssRules) {
|
||||
var i = 0, r;
|
||||
while (r = ss.cssRules[i++])
|
||||
r.styleSheet && sheet(r.styleSheet);
|
||||
}
|
||||
};
|
||||
while (o = d.getElementsByTagName('script')[i++])
|
||||
o.src && !(o.type && /vbs/i.test(o.type)) && add(o.src);
|
||||
i = 0;
|
||||
while (o = d.styleSheets[i++])
|
||||
/* http://www.w3.org/TR/DOM-Level-2-Style/stylesheets.html#StyleSheets-DocumentStyle-styleSheets
|
||||
document.styleSheet is a list property where [0] accesses the 1st element and
|
||||
[outOfRange] returns null. In IE, styleSheets is a function, and also throws an
|
||||
exception when you check the out of bounds index. (sigh) */
|
||||
sheet(o);
|
||||
if (uris.length)
|
||||
window.open('%BUILDER_URL%#' + uris.join(','));
|
||||
else
|
||||
alert('No js/css files found with URLs within "'
|
||||
+ home.split('/')[2]
|
||||
+ '".\n(This tool is limited to URLs with the same domain.)');
|
||||
})();
|
@@ -1,182 +0,0 @@
|
||||
<?php
|
||||
|
||||
if (phpversion() < 5) {
|
||||
exit('Minify requires PHP5 or greater.');
|
||||
}
|
||||
|
||||
// check for auto-encoding
|
||||
$encodeOutput = (function_exists('gzdeflate')
|
||||
&& !ini_get('zlib.output_compression'));
|
||||
|
||||
require __DIR__ . '/../config.php';
|
||||
|
||||
if (! $min_enableBuilder) {
|
||||
header('Location: /');
|
||||
exit();
|
||||
}
|
||||
|
||||
ob_start();
|
||||
?>
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<head>
|
||||
<meta name="ROBOTS" content="NOINDEX, NOFOLLOW">
|
||||
<title>Minify URI Builder</title>
|
||||
<style type="text/css">
|
||||
body {margin:1em 60px;}
|
||||
h1, h2, h3 {margin-left:-25px; position:relative;}
|
||||
h1 {margin-top:0;}
|
||||
#sources {margin:0; padding:0;}
|
||||
#sources li {margin:0 0 0 40px}
|
||||
#sources li input {margin-left:2px}
|
||||
#add {margin:5px 0 1em 40px}
|
||||
.hide {display:none}
|
||||
#uriTable {border-collapse:collapse;}
|
||||
#uriTable td, #uriTable th {padding-top:10px;}
|
||||
#uriTable th {padding-right:10px;}
|
||||
#groupConfig {font-family:monospace;}
|
||||
b {color:#c00}
|
||||
.topNote {background: #ff9; display:inline-block; padding:.5em .6em; margin:0 0 1em;}
|
||||
.topWarning {background:#c00; color:#fff; padding:.5em .6em; margin:0 0 1em;}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<?php if (! isset($min_cachePath)): ?>
|
||||
<p class=topNote><strong>Note:</strong> Please set <code>$min_cachePath</code>
|
||||
in /min/config.php to improve performance.</p>
|
||||
<?php endIf; ?>
|
||||
|
||||
<p id=minRewriteFailed class="hide"><strong>Note:</strong> Your webserver does not seem to
|
||||
support mod_rewrite (used in /min/.htaccess). Your Minify URIs will contain "?", which
|
||||
<a href="http://www.stevesouders.com/blog/2008/08/23/revving-filenames-dont-use-querystring/"
|
||||
>may reduce the benefit of proxy cache servers</a>.</p>
|
||||
|
||||
<h1>Minify URI Builder</h1>
|
||||
|
||||
<noscript><p class="topNote">Javascript and a browser supported by jQuery 1.2.6 is required
|
||||
for this application.</p></noscript>
|
||||
|
||||
<div id=app class=hide>
|
||||
|
||||
<p>Create a list of Javascript or CSS files (or 1 is fine) you'd like to combine
|
||||
and click [Update].</p>
|
||||
|
||||
<ol id=sources><li></li></ol>
|
||||
<div id=add><button>Add file +</button></div>
|
||||
|
||||
<div id=bmUris></div>
|
||||
|
||||
<p><button id=update class=hide>Update</button></p>
|
||||
|
||||
<div id=results class=hide>
|
||||
|
||||
<h2>Minify URI</h2>
|
||||
<p>Place this URI in your HTML to serve the files above combined, minified, compressed and
|
||||
with cache headers.</p>
|
||||
<table id=uriTable>
|
||||
<tr><th>URI</th><td><a id=uriA class=ext>/min</a> <small>(opens in new window)</small></td></tr>
|
||||
<tr><th>HTML</th><td><input id=uriHtml type=text size=100 readonly></td></tr>
|
||||
</table>
|
||||
|
||||
<h2>How to serve these files as a group</h2>
|
||||
<p>For the best performance you can serve these files as a pre-defined group with a URI
|
||||
like: <code><span class=minRoot>/min/?</span>g=keyName</code></p>
|
||||
<p>To do this, add a line like this to /min/groupsConfig.php:</p>
|
||||
|
||||
<pre><code>return array(
|
||||
<span style="color:#666">... your existing groups here ...</span>
|
||||
<input id=groupConfig size=100 type=text readonly>
|
||||
);</code></pre>
|
||||
|
||||
<p><em>Make sure to replace <code>keyName</code> with a unique key for this group.</em></p>
|
||||
</div>
|
||||
|
||||
<div id=getBm>
|
||||
<h3>Find URIs on a Page</h3>
|
||||
<p>You can use the bookmarklet below to fetch all CSS & Javascript URIs from a page
|
||||
on your site. When you active it, this page will open in a new window with a list of
|
||||
available URIs to add.</p>
|
||||
|
||||
<p><a id=bm>Create Minify URIs</a> <small>(right-click, add to bookmarks)</small></p>
|
||||
</div>
|
||||
|
||||
<h3>Combining CSS files that contain <code>@import</code></h3>
|
||||
<p>If your CSS files contain <code>@import</code> declarations, Minify will not
|
||||
remove them. Therefore, you will want to remove those that point to files already
|
||||
in your list, and move any others to the top of the first file in your list
|
||||
(imports below any styles will be ignored by browsers as invalid).</p>
|
||||
<p>If you desire, you can use Minify URIs in imports and they will not be touched
|
||||
by Minify. E.g. <code>@import "<span class=minRoot>/min/?</span>g=css2";</code></p>
|
||||
|
||||
</div><!-- #app -->
|
||||
|
||||
<hr>
|
||||
<p>Need help? Search or post to the <a class=ext
|
||||
href="http://groups.google.com/group/minify">Minify discussion list</a>.</p>
|
||||
<p><small>This app is minified :) <a class=ext
|
||||
href="http://code.google.com/p/minify/source/browse/trunk/min/builder/index.php">view
|
||||
source</a></small></p>
|
||||
|
||||
<script type="text/javascript"
|
||||
src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
// detection of double output encoding
|
||||
var msg = '<\p class=topWarning><\strong>Warning:<\/strong> ';
|
||||
var url = 'ocCheck.php?' + (new Date()).getTime();
|
||||
$.get(url, function (ocStatus) {
|
||||
$.get(url + '&hello=1', function (ocHello) {
|
||||
if (ocHello != 'World!') {
|
||||
msg += 'It appears output is being automatically compressed, interfering '
|
||||
+ ' with Minify\'s own compression. ';
|
||||
if (ocStatus == '1')
|
||||
msg += 'The option "zlib.output_compression" is enabled in your PHP configuration. '
|
||||
+ 'Minify set this to "0", but it had no effect. This option must be disabled '
|
||||
+ 'in php.ini or .htaccess.';
|
||||
else
|
||||
msg += 'The option "zlib.output_compression" is disabled in your PHP configuration '
|
||||
+ 'so this behavior is likely due to a server option.';
|
||||
$(document.body).prepend(msg + '<\/p>');
|
||||
} else
|
||||
if (ocStatus == '1')
|
||||
$(document.body).prepend('<\p class=topNote><\strong>Note:</\strong> The option '
|
||||
+ '"zlib.output_compression" is enabled in your PHP configuration, but has been '
|
||||
+ 'successfully disabled via ini_set(). If you experience mangled output you '
|
||||
+ 'may want to consider disabling this option in your PHP configuration.<\/p>'
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
// workaround required to test when /min isn't child of web root
|
||||
var src = location.pathname.replace(/\/[^\/]*$/, '/_index.js').substr(1);
|
||||
document.write('<\script type="text/javascript" src="../?f=' + src + '"><\/script>');
|
||||
</script>
|
||||
|
||||
<?php
|
||||
|
||||
$serveOpts = array(
|
||||
'content' => ob_get_contents()
|
||||
,'id' => __FILE__
|
||||
,'lastModifiedTime' => max(
|
||||
// regenerate cache if either of these change
|
||||
filemtime(__FILE__)
|
||||
,filemtime(__DIR__ . '/../config.php')
|
||||
)
|
||||
,'minifyAll' => true
|
||||
,'encodeOutput' => $encodeOutput
|
||||
);
|
||||
ob_end_clean();
|
||||
|
||||
set_include_path(__DIR__ . '/../lib' . PATH_SEPARATOR . get_include_path());
|
||||
|
||||
require 'Minify.php';
|
||||
|
||||
if (0 === stripos(PHP_OS, 'win')) {
|
||||
Minify::setDocRoot(); // we may be on IIS
|
||||
}
|
||||
Minify::setCache(isset($min_cachePath) ? $min_cachePath : null);
|
||||
Minify::$uploaderHoursBehind = $min_uploaderHoursBehind;
|
||||
|
||||
Minify::serve('Page', $serveOpts);
|
@@ -1,36 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* AJAX checks for zlib.output_compression
|
||||
*
|
||||
* @package Minify
|
||||
*/
|
||||
|
||||
$_oc = ini_get('zlib.output_compression');
|
||||
|
||||
// allow access only if builder is enabled
|
||||
require __DIR__ . '/../config.php';
|
||||
if (! $min_enableBuilder) {
|
||||
header('Location: /');
|
||||
exit();
|
||||
}
|
||||
|
||||
if (isset($_GET['hello'])) {
|
||||
// echo 'World!'
|
||||
|
||||
// try to prevent double encoding (may not have an effect)
|
||||
ini_set('zlib.output_compression', '0');
|
||||
|
||||
require $min_libPath . '/HTTP/Encoder.php';
|
||||
HTTP_Encoder::$encodeToIe6 = true; // just in case
|
||||
$he = new HTTP_Encoder(array(
|
||||
'content' => 'World!'
|
||||
,'method' => 'deflate'
|
||||
));
|
||||
$he->encode();
|
||||
$he->sendAll();
|
||||
|
||||
} else {
|
||||
// echo status "0" or "1"
|
||||
header('Content-Type: text/plain');
|
||||
echo (int)$_oc;
|
||||
}
|
@@ -1 +0,0 @@
|
||||
1
|
@@ -1,66 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Front controller for default Minify implementation
|
||||
*
|
||||
* DO NOT EDIT! Configure this utility via config.php and groupsConfig.php
|
||||
*
|
||||
* @package Minify
|
||||
*/
|
||||
|
||||
define('MINIFY_MIN_DIR', __DIR__);
|
||||
|
||||
// load config
|
||||
require MINIFY_MIN_DIR . '/config.php';
|
||||
|
||||
// setup include path
|
||||
set_include_path($min_libPath . PATH_SEPARATOR . get_include_path());
|
||||
|
||||
require 'Minify.php';
|
||||
|
||||
Minify::$uploaderHoursBehind = $min_uploaderHoursBehind;
|
||||
Minify::setCache(
|
||||
isset($min_cachePath) ? $min_cachePath : ''
|
||||
,$min_cacheFileLocking
|
||||
);
|
||||
|
||||
if ($min_documentRoot) {
|
||||
$_SERVER['DOCUMENT_ROOT'] = $min_documentRoot;
|
||||
} elseif (0 === stripos(PHP_OS, 'win')) {
|
||||
Minify::setDocRoot(); // IIS may need help
|
||||
}
|
||||
|
||||
$min_serveOptions['minifierOptions']['text/css']['symlinks'] = $min_symlinks;
|
||||
|
||||
if ($min_allowDebugFlag && isset($_GET['debug'])) {
|
||||
$min_serveOptions['debug'] = true;
|
||||
}
|
||||
|
||||
if ($min_errorLogger) {
|
||||
require_once 'Minify/Logger.php';
|
||||
if (true === $min_errorLogger) {
|
||||
require_once 'FirePHP.php';
|
||||
Minify_Logger::setLogger(FirePHP::getInstance(true));
|
||||
} else {
|
||||
Minify_Logger::setLogger($min_errorLogger);
|
||||
}
|
||||
}
|
||||
|
||||
// check for URI versioning
|
||||
if (preg_match('/&\\d/', $_SERVER['QUERY_STRING'])) {
|
||||
$min_serveOptions['maxAge'] = 31536000;
|
||||
}
|
||||
if (isset($_GET['g'])) {
|
||||
// well need groups config
|
||||
$min_serveOptions['minApp']['groups'] = (require MINIFY_MIN_DIR . '/groupsConfig.php');
|
||||
}
|
||||
if (isset($_GET['f']) || isset($_GET['g'])) {
|
||||
// serve!
|
||||
Minify::serve('MinApp', $min_serveOptions);
|
||||
|
||||
} elseif ($min_enableBuilder) {
|
||||
header('Location: builder/');
|
||||
exit();
|
||||
} else {
|
||||
header("Location: /");
|
||||
exit();
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@@ -1,354 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Class HTTP_ConditionalGet
|
||||
* @package Minify
|
||||
* @subpackage HTTP
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implement conditional GET via a timestamp or hash of content
|
||||
*
|
||||
* E.g. Content from DB with update time:
|
||||
* <code>
|
||||
* list($updateTime, $content) = getDbUpdateAndContent();
|
||||
* $cg = new HTTP_ConditionalGet(array(
|
||||
* 'lastModifiedTime' => $updateTime
|
||||
* ,'isPublic' => true
|
||||
* ));
|
||||
* $cg->sendHeaders();
|
||||
* if ($cg->cacheIsValid) {
|
||||
* exit();
|
||||
* }
|
||||
* echo $content;
|
||||
* </code>
|
||||
*
|
||||
* E.g. Shortcut for the above
|
||||
* <code>
|
||||
* HTTP_ConditionalGet::check($updateTime, true); // exits if client has cache
|
||||
* echo $content;
|
||||
* </code>
|
||||
*
|
||||
* E.g. Content from DB with no update time:
|
||||
* <code>
|
||||
* $content = getContentFromDB();
|
||||
* $cg = new HTTP_ConditionalGet(array(
|
||||
* 'contentHash' => md5($content)
|
||||
* ));
|
||||
* $cg->sendHeaders();
|
||||
* if ($cg->cacheIsValid) {
|
||||
* exit();
|
||||
* }
|
||||
* echo $content;
|
||||
* </code>
|
||||
*
|
||||
* E.g. Static content with some static includes:
|
||||
* <code>
|
||||
* // before content
|
||||
* $cg = new HTTP_ConditionalGet(array(
|
||||
* 'lastUpdateTime' => max(
|
||||
* filemtime(__FILE__)
|
||||
* ,filemtime('/path/to/header.inc')
|
||||
* ,filemtime('/path/to/footer.inc')
|
||||
* )
|
||||
* ));
|
||||
* $cg->sendHeaders();
|
||||
* if ($cg->cacheIsValid) {
|
||||
* exit();
|
||||
* }
|
||||
* </code>
|
||||
* @package Minify
|
||||
* @subpackage HTTP
|
||||
* @author Stephen Clay <steve@mrclay.org>
|
||||
*/
|
||||
class HTTP_ConditionalGet {
|
||||
|
||||
/**
|
||||
* Does the client have a valid copy of the requested resource?
|
||||
*
|
||||
* You'll want to check this after instantiating the object. If true, do
|
||||
* not send content, just call sendHeaders() if you haven't already.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $cacheIsValid = null;
|
||||
|
||||
/**
|
||||
* @param array $spec options
|
||||
*
|
||||
* 'isPublic': (bool) if true, the Cache-Control header will contain
|
||||
* "public", allowing proxies to cache the content. Otherwise "private" will
|
||||
* be sent, allowing only browser caching. (default false)
|
||||
*
|
||||
* 'lastModifiedTime': (int) if given, both ETag AND Last-Modified headers
|
||||
* will be sent with content. This is recommended.
|
||||
*
|
||||
* 'encoding': (string) if set, the header "Vary: Accept-Encoding" will
|
||||
* always be sent and a truncated version of the encoding will be appended
|
||||
* to the ETag. E.g. "pub123456;gz". This will also trigger a more lenient
|
||||
* checking of the client's If-None-Match header, as the encoding portion of
|
||||
* the ETag will be stripped before comparison.
|
||||
*
|
||||
* 'contentHash': (string) if given, only the ETag header can be sent with
|
||||
* content (only HTTP1.1 clients can conditionally GET). The given string
|
||||
* should be short with no quote characters and always change when the
|
||||
* resource changes (recommend md5()). This is not needed/used if
|
||||
* lastModifiedTime is given.
|
||||
*
|
||||
* 'eTag': (string) if given, this will be used as the ETag header rather
|
||||
* than values based on lastModifiedTime or contentHash. Also the encoding
|
||||
* string will not be appended to the given value as described above.
|
||||
*
|
||||
* 'invalidate': (bool) if true, the client cache will be considered invalid
|
||||
* without testing. Effectively this disables conditional GET.
|
||||
* (default false)
|
||||
*
|
||||
* 'maxAge': (int) if given, this will set the Cache-Control max-age in
|
||||
* seconds, and also set the Expires header to the equivalent GMT date.
|
||||
* After the max-age period has passed, the browser will again send a
|
||||
* conditional GET to revalidate its cache.
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public function __construct($spec)
|
||||
{
|
||||
$scope = (isset($spec['isPublic']) && $spec['isPublic'])
|
||||
? 'public'
|
||||
: 'private';
|
||||
$maxAge = 0;
|
||||
// backwards compatibility (can be removed later)
|
||||
if (isset($spec['setExpires'])
|
||||
&& is_numeric($spec['setExpires'])
|
||||
&& ! isset($spec['maxAge'])) {
|
||||
$spec['maxAge'] = $spec['setExpires'] - $_SERVER['REQUEST_TIME'];
|
||||
}
|
||||
if (isset($spec['maxAge'])) {
|
||||
$maxAge = $spec['maxAge'];
|
||||
$this->_headers['Expires'] = self::gmtDate(
|
||||
$_SERVER['REQUEST_TIME'] + $spec['maxAge']
|
||||
);
|
||||
}
|
||||
$etagAppend = '';
|
||||
if (isset($spec['encoding'])) {
|
||||
$this->_stripEtag = true;
|
||||
$this->_headers['Vary'] = 'Accept-Encoding';
|
||||
if ('' !== $spec['encoding']) {
|
||||
if (0 === strpos($spec['encoding'], 'x-')) {
|
||||
$spec['encoding'] = substr($spec['encoding'], 2);
|
||||
}
|
||||
$etagAppend = ';' . substr($spec['encoding'], 0, 2);
|
||||
}
|
||||
}
|
||||
if (isset($spec['lastModifiedTime'])) {
|
||||
$this->_setLastModified($spec['lastModifiedTime']);
|
||||
if (isset($spec['eTag'])) { // Use it
|
||||
$this->_setEtag($spec['eTag'], $scope);
|
||||
} else { // base both headers on time
|
||||
$this->_setEtag($spec['lastModifiedTime'] . $etagAppend, $scope);
|
||||
}
|
||||
} elseif (isset($spec['eTag'])) { // Use it
|
||||
$this->_setEtag($spec['eTag'], $scope);
|
||||
} elseif (isset($spec['contentHash'])) { // Use the hash as the ETag
|
||||
$this->_setEtag($spec['contentHash'] . $etagAppend, $scope);
|
||||
}
|
||||
$this->_headers['Cache-Control'] = "max-age={$maxAge}, {$scope}";
|
||||
// invalidate cache if disabled, otherwise check
|
||||
$this->cacheIsValid = (isset($spec['invalidate']) && $spec['invalidate'])
|
||||
? false
|
||||
: $this->_isCacheValid();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get array of output headers to be sent
|
||||
*
|
||||
* In the case of 304 responses, this array will only contain the response
|
||||
* code header: array('_responseCode' => 'HTTP/1.0 304 Not Modified')
|
||||
*
|
||||
* Otherwise something like:
|
||||
* <code>
|
||||
* array(
|
||||
* 'Cache-Control' => 'max-age=0, public'
|
||||
* ,'ETag' => '"foobar"'
|
||||
* )
|
||||
* </code>
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getHeaders()
|
||||
{
|
||||
return $this->_headers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Content-Length header in bytes
|
||||
*
|
||||
* With most PHP configs, as long as you don't flush() output, this method
|
||||
* is not needed and PHP will buffer all output and set Content-Length for
|
||||
* you. Otherwise you'll want to call this to let the client know up front.
|
||||
*
|
||||
* @param int $bytes
|
||||
*
|
||||
* @return int copy of input $bytes
|
||||
*/
|
||||
public function setContentLength($bytes)
|
||||
{
|
||||
return $this->_headers['Content-Length'] = $bytes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send headers
|
||||
*
|
||||
* @see getHeaders()
|
||||
*
|
||||
* Note this doesn't "clear" the headers. Calling sendHeaders() will
|
||||
* call header() again (but probably have not effect) and getHeaders() will
|
||||
* still return the headers.
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public function sendHeaders()
|
||||
{
|
||||
$headers = $this->_headers;
|
||||
if (array_key_exists('_responseCode', $headers)) {
|
||||
header($headers['_responseCode']);
|
||||
unset($headers['_responseCode']);
|
||||
}
|
||||
foreach ($headers as $name => $val) {
|
||||
header($name . ': ' . $val);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Exit if the client's cache is valid for this resource
|
||||
*
|
||||
* This is a convenience method for common use of the class
|
||||
*
|
||||
* @param int $lastModifiedTime if given, both ETag AND Last-Modified headers
|
||||
* will be sent with content. This is recommended.
|
||||
*
|
||||
* @param bool $isPublic (default false) if true, the Cache-Control header
|
||||
* will contain "public", allowing proxies to cache the content. Otherwise
|
||||
* "private" will be sent, allowing only browser caching.
|
||||
*
|
||||
* @param array $options (default empty) additional options for constructor
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public static function check($lastModifiedTime = null, $isPublic = false, $options = array())
|
||||
{
|
||||
if (null !== $lastModifiedTime) {
|
||||
$options['lastModifiedTime'] = (int)$lastModifiedTime;
|
||||
}
|
||||
$options['isPublic'] = (bool)$isPublic;
|
||||
$cg = new HTTP_ConditionalGet($options);
|
||||
$cg->sendHeaders();
|
||||
if ($cg->cacheIsValid) {
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a GMT formatted date for use in HTTP headers
|
||||
*
|
||||
* <code>
|
||||
* header('Expires: ' . HTTP_ConditionalGet::gmtdate($time));
|
||||
* </code>
|
||||
*
|
||||
* @param int $time unix timestamp
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function gmtDate($time)
|
||||
{
|
||||
return gmdate('D, d M Y H:i:s \G\M\T', $time);
|
||||
}
|
||||
|
||||
protected $_headers = array();
|
||||
protected $_lmTime = null;
|
||||
protected $_etag = null;
|
||||
protected $_stripEtag = false;
|
||||
|
||||
protected function _setEtag($hash, $scope)
|
||||
{
|
||||
$this->_etag = '"' . substr($scope, 0, 3) . $hash . '"';
|
||||
$this->_headers['ETag'] = $this->_etag;
|
||||
}
|
||||
|
||||
protected function _setLastModified($time)
|
||||
{
|
||||
$this->_lmTime = (int)$time;
|
||||
$this->_headers['Last-Modified'] = self::gmtDate($time);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine validity of client cache and queue 304 header if valid
|
||||
*/
|
||||
protected function _isCacheValid()
|
||||
{
|
||||
if (null === $this->_etag) {
|
||||
// lmTime is copied to ETag, so this condition implies that the
|
||||
// server sent neither ETag nor Last-Modified, so the client can't
|
||||
// possibly has a valid cache.
|
||||
return false;
|
||||
}
|
||||
$isValid = ($this->resourceMatchedEtag() || $this->resourceNotModified());
|
||||
if ($isValid) {
|
||||
$this->_headers['_responseCode'] = 'HTTP/1.0 304 Not Modified';
|
||||
}
|
||||
|
||||
return $isValid;
|
||||
}
|
||||
|
||||
protected function resourceMatchedEtag()
|
||||
{
|
||||
if (!isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
|
||||
return false;
|
||||
}
|
||||
$clientEtagList = get_magic_quotes_gpc()
|
||||
? stripslashes($_SERVER['HTTP_IF_NONE_MATCH'])
|
||||
: $_SERVER['HTTP_IF_NONE_MATCH'];
|
||||
$clientEtags = explode(',', $clientEtagList);
|
||||
|
||||
$compareTo = $this->normalizeEtag($this->_etag);
|
||||
foreach ($clientEtags as $clientEtag) {
|
||||
if ($this->normalizeEtag($clientEtag) === $compareTo) {
|
||||
// respond with the client's matched ETag, even if it's not what
|
||||
// we would've sent by default
|
||||
$this->_headers['ETag'] = trim($clientEtag);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function normalizeEtag($etag) {
|
||||
$etag = trim($etag);
|
||||
|
||||
return $this->_stripEtag
|
||||
? preg_replace('/;\\w\\w"$/', '"', $etag)
|
||||
: $etag;
|
||||
}
|
||||
|
||||
protected function resourceNotModified()
|
||||
{
|
||||
if (!isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
|
||||
return false;
|
||||
}
|
||||
$ifModifiedSince = $_SERVER['HTTP_IF_MODIFIED_SINCE'];
|
||||
if (false !== ($semicolon = strrpos($ifModifiedSince, ';'))) {
|
||||
// IE has tacked on extra data to this header, strip it
|
||||
$ifModifiedSince = substr($ifModifiedSince, 0, $semicolon);
|
||||
}
|
||||
if ($ifModifiedSince == self::gmtDate($this->_lmTime)) {
|
||||
// Apache 2.2's behavior. If there was no ETag match, send the
|
||||
// non-encoded version of the ETag value.
|
||||
$this->_headers['ETag'] = $this->normalizeEtag($this->_etag);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
@@ -1,330 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Class HTTP_Encoder
|
||||
* @package Minify
|
||||
* @subpackage HTTP
|
||||
*/
|
||||
|
||||
/**
|
||||
* Encode and send gzipped/deflated content
|
||||
*
|
||||
* The "Vary: Accept-Encoding" header is sent. If the client allows encoding,
|
||||
* Content-Encoding and Content-Length are added.
|
||||
*
|
||||
* <code>
|
||||
* // Send a CSS file, compressed if possible
|
||||
* $he = new HTTP_Encoder(array(
|
||||
* 'content' => file_get_contents($cssFile)
|
||||
* ,'type' => 'text/css'
|
||||
* ));
|
||||
* $he->encode();
|
||||
* $he->sendAll();
|
||||
* </code>
|
||||
*
|
||||
* <code>
|
||||
* // Shortcut to encoding output
|
||||
* header('Content-Type: text/css'); // needed if not HTML
|
||||
* HTTP_Encoder::output($css);
|
||||
* </code>
|
||||
*
|
||||
* <code>
|
||||
* // Just sniff for the accepted encoding
|
||||
* $encoding = HTTP_Encoder::getAcceptedEncoding();
|
||||
* </code>
|
||||
*
|
||||
* For more control over headers, use getHeaders() and getData() and send your
|
||||
* own output.
|
||||
*
|
||||
* Note: If you don't need header mgmt, use PHP's native gzencode, gzdeflate,
|
||||
* and gzcompress functions for gzip, deflate, and compress-encoding
|
||||
* respectively.
|
||||
*
|
||||
* @package Minify
|
||||
* @subpackage HTTP
|
||||
* @author Stephen Clay <steve@mrclay.org>
|
||||
*/
|
||||
class HTTP_Encoder {
|
||||
|
||||
/**
|
||||
* Should the encoder allow HTTP encoding to IE6?
|
||||
*
|
||||
* If you have many IE6 users and the bandwidth savings is worth troubling
|
||||
* some of them, set this to true.
|
||||
*
|
||||
* By default, encoding is only offered to IE7+. When this is true,
|
||||
* getAcceptedEncoding() will return an encoding for IE6 if its user agent
|
||||
* string contains "SV1". This has been documented in many places as "safe",
|
||||
* but there seem to be remaining, intermittent encoding bugs in patched
|
||||
* IE6 on the wild web.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public static $encodeToIe6 = false;
|
||||
|
||||
|
||||
/**
|
||||
* Default compression level for zlib operations
|
||||
*
|
||||
* This level is used if encode() is not given a $compressionLevel
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public static $compressionLevel = 6;
|
||||
|
||||
|
||||
/**
|
||||
* Get an HTTP Encoder object
|
||||
*
|
||||
* @param array $spec options
|
||||
*
|
||||
* 'content': (string required) content to be encoded
|
||||
*
|
||||
* 'type': (string) if set, the Content-Type header will have this value.
|
||||
*
|
||||
* 'method: (string) only set this if you are forcing a particular encoding
|
||||
* method. If not set, the best method will be chosen by getAcceptedEncoding()
|
||||
* The available methods are 'gzip', 'deflate', 'compress', and '' (no
|
||||
* encoding)
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public function __construct($spec)
|
||||
{
|
||||
$this->_content = $spec['content'];
|
||||
$this->_headers['Content-Length'] = (string)strlen($this->_content);
|
||||
if (isset($spec['type'])) {
|
||||
$this->_headers['Content-Type'] = $spec['type'];
|
||||
}
|
||||
if (isset($spec['method'])
|
||||
&& in_array($spec['method'], array('gzip', 'deflate', 'compress', '')))
|
||||
{
|
||||
$this->_encodeMethod = array($spec['method'], $spec['method']);
|
||||
} else {
|
||||
$this->_encodeMethod = self::getAcceptedEncoding();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get content in current form
|
||||
*
|
||||
* Call after encode() for encoded content.
|
||||
*
|
||||
* return string
|
||||
*/
|
||||
public function getContent()
|
||||
{
|
||||
return $this->_content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get array of output headers to be sent
|
||||
*
|
||||
* E.g.
|
||||
* <code>
|
||||
* array(
|
||||
* 'Content-Length' => '615'
|
||||
* ,'Content-Encoding' => 'x-gzip'
|
||||
* ,'Vary' => 'Accept-Encoding'
|
||||
* )
|
||||
* </code>
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getHeaders()
|
||||
{
|
||||
return $this->_headers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send output headers
|
||||
*
|
||||
* You must call this before headers are sent and it probably cannot be
|
||||
* used in conjunction with zlib output buffering / mod_gzip. Errors are
|
||||
* not handled purposefully.
|
||||
*
|
||||
* @see getHeaders()
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public function sendHeaders()
|
||||
{
|
||||
foreach ($this->_headers as $name => $val) {
|
||||
header($name . ': ' . $val);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send output headers and content
|
||||
*
|
||||
* A shortcut for sendHeaders() and echo getContent()
|
||||
*
|
||||
* You must call this before headers are sent and it probably cannot be
|
||||
* used in conjunction with zlib output buffering / mod_gzip. Errors are
|
||||
* not handled purposefully.
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public function sendAll()
|
||||
{
|
||||
$this->sendHeaders();
|
||||
echo $this->_content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine the client's best encoding method from the HTTP Accept-Encoding
|
||||
* header.
|
||||
*
|
||||
* If no Accept-Encoding header is set, or the browser is IE before v6 SP2,
|
||||
* this will return ('', ''), the "identity" encoding.
|
||||
*
|
||||
* A syntax-aware scan is done of the Accept-Encoding, so the method must
|
||||
* be non 0. The methods are favored in order of gzip, deflate, then
|
||||
* compress. Deflate is always smallest and generally faster, but is
|
||||
* rarely sent by servers, so client support could be buggier.
|
||||
*
|
||||
* @param bool $allowCompress allow the older compress encoding
|
||||
*
|
||||
* @param bool $allowDeflate allow the more recent deflate encoding
|
||||
*
|
||||
* @return array two values, 1st is the actual encoding method, 2nd is the
|
||||
* alias of that method to use in the Content-Encoding header (some browsers
|
||||
* call gzip "x-gzip" etc.)
|
||||
*/
|
||||
public static function getAcceptedEncoding($allowCompress = true, $allowDeflate = true)
|
||||
{
|
||||
// @link http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
|
||||
|
||||
if (! isset($_SERVER['HTTP_ACCEPT_ENCODING'])
|
||||
|| self::_isBuggyIe())
|
||||
{
|
||||
return array('', '');
|
||||
}
|
||||
$ae = $_SERVER['HTTP_ACCEPT_ENCODING'];
|
||||
// gzip checks (quick)
|
||||
if (0 === strpos($ae, 'gzip,') // most browsers
|
||||
|| 0 === strpos($ae, 'deflate, gzip,') // opera
|
||||
) {
|
||||
return array('gzip', 'gzip');
|
||||
}
|
||||
// gzip checks (slow)
|
||||
if (preg_match(
|
||||
'@(?:^|,)\\s*((?:x-)?gzip)\\s*(?:$|,|;\\s*q=(?:0\\.|1))@'
|
||||
,$ae
|
||||
,$m)) {
|
||||
return array('gzip', $m[1]);
|
||||
}
|
||||
if ($allowDeflate) {
|
||||
// deflate checks
|
||||
$aeRev = strrev($ae);
|
||||
if (0 === strpos($aeRev, 'etalfed ,') // ie, webkit
|
||||
|| 0 === strpos($aeRev, 'etalfed,') // gecko
|
||||
|| 0 === strpos($ae, 'deflate,') // opera
|
||||
// slow parsing
|
||||
|| preg_match(
|
||||
'@(?:^|,)\\s*deflate\\s*(?:$|,|;\\s*q=(?:0\\.|1))@', $ae)) {
|
||||
return array('deflate', 'deflate');
|
||||
}
|
||||
}
|
||||
if ($allowCompress && preg_match(
|
||||
'@(?:^|,)\\s*((?:x-)?compress)\\s*(?:$|,|;\\s*q=(?:0\\.|1))@'
|
||||
,$ae
|
||||
,$m)) {
|
||||
return array('compress', $m[1]);
|
||||
}
|
||||
|
||||
return array('', '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode (compress) the content
|
||||
*
|
||||
* If the encode method is '' (none) or compression level is 0, or the 'zlib'
|
||||
* extension isn't loaded, we return false.
|
||||
*
|
||||
* Then the appropriate gz_* function is called to compress the content. If
|
||||
* this fails, false is returned.
|
||||
*
|
||||
* The header "Vary: Accept-Encoding" is added. If encoding is successful,
|
||||
* the Content-Length header is updated, and Content-Encoding is also added.
|
||||
*
|
||||
* @param int $compressionLevel given to zlib functions. If not given, the
|
||||
* class default will be used.
|
||||
*
|
||||
* @return bool success true if the content was actually compressed
|
||||
*/
|
||||
public function encode($compressionLevel = null)
|
||||
{
|
||||
$this->_headers['Vary'] = 'Accept-Encoding';
|
||||
if (null === $compressionLevel) {
|
||||
$compressionLevel = self::$compressionLevel;
|
||||
}
|
||||
if ('' === $this->_encodeMethod[0]
|
||||
|| ($compressionLevel == 0)
|
||||
|| !extension_loaded('zlib'))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if ($this->_encodeMethod[0] === 'deflate') {
|
||||
$encoded = gzdeflate($this->_content, $compressionLevel);
|
||||
} elseif ($this->_encodeMethod[0] === 'gzip') {
|
||||
$encoded = gzencode($this->_content, $compressionLevel);
|
||||
} else {
|
||||
$encoded = gzcompress($this->_content, $compressionLevel);
|
||||
}
|
||||
if (false === $encoded) {
|
||||
return false;
|
||||
}
|
||||
$this->_headers['Content-Length'] = strlen($encoded);
|
||||
$this->_headers['Content-Encoding'] = $this->_encodeMethod[1];
|
||||
$this->_content = $encoded;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode and send appropriate headers and content
|
||||
*
|
||||
* This is a convenience method for common use of the class
|
||||
*
|
||||
* @param string $content
|
||||
*
|
||||
* @param int $compressionLevel given to zlib functions. If not given, the
|
||||
* class default will be used.
|
||||
*
|
||||
* @return bool success true if the content was actually compressed
|
||||
*/
|
||||
public static function output($content, $compressionLevel = null)
|
||||
{
|
||||
if (null === $compressionLevel) {
|
||||
$compressionLevel = self::$compressionLevel;
|
||||
}
|
||||
$he = new HTTP_Encoder(array('content' => $content));
|
||||
$ret = $he->encode($compressionLevel);
|
||||
$he->sendAll();
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
protected $_content = '';
|
||||
protected $_headers = array();
|
||||
protected $_encodeMethod = array('', '');
|
||||
|
||||
/**
|
||||
* Is the browser an IE version earlier than 6 SP2?
|
||||
*/
|
||||
protected static function _isBuggyIe()
|
||||
{
|
||||
$ua = $_SERVER['HTTP_USER_AGENT'];
|
||||
// quick escape for non-IEs
|
||||
if (0 !== strpos($ua, 'Mozilla/4.0 (compatible; MSIE ')
|
||||
|| false !== strpos($ua, 'Opera')) {
|
||||
return false;
|
||||
}
|
||||
// no regex = faaast
|
||||
$version = (float)substr($ua, 30);
|
||||
|
||||
return self::$encodeToIe6
|
||||
? ($version < 6 || ($version == 6 && false === strpos($ua, 'SV1')))
|
||||
: ($version < 7);
|
||||
}
|
||||
}
|
@@ -1,326 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* jsmin.php - PHP implementation of Douglas Crockford's JSMin.
|
||||
*
|
||||
* This is a direct port of jsmin.c to PHP with a few PHP performance tweaks and
|
||||
* modifications to preserve some comments (see below). Also, rather than using
|
||||
* stdin/stdout, JSMin::minify() accepts a string as input and returns another
|
||||
* string as output.
|
||||
*
|
||||
* Comments containing IE conditional compilation are preserved, as are multi-line
|
||||
* comments that begin with "/*!" (for documentation purposes). In the latter case
|
||||
* newlines are inserted around the comment to enhance readability.
|
||||
*
|
||||
* PHP 5 or higher is required.
|
||||
*
|
||||
* Permission is hereby granted to use this version of the library under the
|
||||
* same terms as jsmin.c, which has the following license:
|
||||
*
|
||||
* --
|
||||
* Copyright (c) 2002 Douglas Crockford (www.crockford.com)
|
||||
*
|
||||
* 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 shall be used for Good, not Evil.
|
||||
*
|
||||
* 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.
|
||||
* --
|
||||
*
|
||||
* @package JSMin
|
||||
* @author Ryan Grove <ryan@wonko.com> (PHP port)
|
||||
* @author Steve Clay <steve@mrclay.org> (modifications + cleanup)
|
||||
* @author Andrea Giammarchi <http://www.3site.eu> (spaceBeforeRegExp)
|
||||
* @copyright 2002 Douglas Crockford <douglas@crockford.com> (jsmin.c)
|
||||
* @copyright 2008 Ryan Grove <ryan@wonko.com> (PHP port)
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @link http://code.google.com/p/jsmin-php/
|
||||
*/
|
||||
|
||||
class JSMin {
|
||||
const ORD_LF = 10;
|
||||
const ORD_SPACE = 32;
|
||||
const ACTION_KEEP_A = 1;
|
||||
const ACTION_DELETE_A = 2;
|
||||
const ACTION_DELETE_A_B = 3;
|
||||
|
||||
protected $a = "\n";
|
||||
protected $b = '';
|
||||
protected $input = '';
|
||||
protected $inputIndex = 0;
|
||||
protected $inputLength = 0;
|
||||
protected $lookAhead = null;
|
||||
protected $output = '';
|
||||
|
||||
/**
|
||||
* Minify Javascript
|
||||
*
|
||||
* @param string $js Javascript to be minified
|
||||
* @return string
|
||||
*/
|
||||
public static function minify($js)
|
||||
{
|
||||
$jsmin = new JSMin($js);
|
||||
|
||||
return $jsmin->min();
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup process
|
||||
*/
|
||||
public function __construct($input)
|
||||
{
|
||||
$this->input = str_replace("\r\n", "\n", $input);
|
||||
$this->inputLength = strlen($this->input);
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform minification, return result
|
||||
*/
|
||||
public function min()
|
||||
{
|
||||
if ($this->output !== '') { // min already run
|
||||
|
||||
return $this->output;
|
||||
}
|
||||
$this->action(self::ACTION_DELETE_A_B);
|
||||
|
||||
while ($this->a !== null) {
|
||||
// determine next command
|
||||
$command = self::ACTION_KEEP_A; // default
|
||||
if ($this->a === ' ') {
|
||||
if (! $this->isAlphaNum($this->b)) {
|
||||
$command = self::ACTION_DELETE_A;
|
||||
}
|
||||
} elseif ($this->a === "\n") {
|
||||
if ($this->b === ' ') {
|
||||
$command = self::ACTION_DELETE_A_B;
|
||||
} elseif (false === strpos('{[(+-', $this->b)
|
||||
&& ! $this->isAlphaNum($this->b)) {
|
||||
$command = self::ACTION_DELETE_A;
|
||||
}
|
||||
} elseif (! $this->isAlphaNum($this->a)) {
|
||||
if ($this->b === ' '
|
||||
|| ($this->b === "\n"
|
||||
&& (false === strpos('}])+-"\'', $this->a)))) {
|
||||
$command = self::ACTION_DELETE_A_B;
|
||||
}
|
||||
}
|
||||
$this->action($command);
|
||||
}
|
||||
$this->output = trim($this->output);
|
||||
|
||||
return $this->output;
|
||||
}
|
||||
|
||||
/**
|
||||
* ACTION_KEEP_A = Output A. Copy B to A. Get the next B.
|
||||
* ACTION_DELETE_A = Copy B to A. Get the next B.
|
||||
* ACTION_DELETE_A_B = Get the next B.
|
||||
*/
|
||||
protected function action($command)
|
||||
{
|
||||
switch ($command) {
|
||||
case self::ACTION_KEEP_A:
|
||||
$this->output .= $this->a;
|
||||
// fallthrough
|
||||
case self::ACTION_DELETE_A:
|
||||
$this->a = $this->b;
|
||||
if ($this->a === "'" || $this->a === '"') { // string literal
|
||||
$str = $this->a; // in case needed for exception
|
||||
while (true) {
|
||||
$this->output .= $this->a;
|
||||
$this->a = $this->get();
|
||||
if ($this->a === $this->b) { // end quote
|
||||
break;
|
||||
}
|
||||
if (ord($this->a) <= self::ORD_LF) {
|
||||
throw new JSMin_UnterminatedStringException(
|
||||
'Unterminated String: ' . var_export($str, true));
|
||||
}
|
||||
$str .= $this->a;
|
||||
if ($this->a === '\\') {
|
||||
$this->output .= $this->a;
|
||||
$this->a = $this->get();
|
||||
$str .= $this->a;
|
||||
}
|
||||
}
|
||||
}
|
||||
// fallthrough
|
||||
case self::ACTION_DELETE_A_B:
|
||||
$this->b = $this->next();
|
||||
if ($this->b === '/' && $this->isRegexpLiteral()) { // RegExp literal
|
||||
$this->output .= $this->a . $this->b;
|
||||
$pattern = '/'; // in case needed for exception
|
||||
while (true) {
|
||||
$this->a = $this->get();
|
||||
$pattern .= $this->a;
|
||||
if ($this->a === '/') { // end pattern
|
||||
break; // while (true)
|
||||
} elseif ($this->a === '\\') {
|
||||
$this->output .= $this->a;
|
||||
$this->a = $this->get();
|
||||
$pattern .= $this->a;
|
||||
} elseif (ord($this->a) <= self::ORD_LF) {
|
||||
throw new JSMin_UnterminatedRegExpException(
|
||||
'Unterminated RegExp: '. var_export($pattern, true));
|
||||
}
|
||||
$this->output .= $this->a;
|
||||
}
|
||||
$this->b = $this->next();
|
||||
}
|
||||
// end case ACTION_DELETE_A_B
|
||||
}
|
||||
}
|
||||
|
||||
protected function isRegexpLiteral()
|
||||
{
|
||||
if (false !== strpos("\n{;(,=:[!&|?", $this->a)) { // we aren't dividing
|
||||
|
||||
return true;
|
||||
}
|
||||
if (' ' === $this->a) {
|
||||
$length = strlen($this->output);
|
||||
if ($length < 2) { // weird edge case
|
||||
|
||||
return true;
|
||||
}
|
||||
// you can't divide a keyword
|
||||
if (preg_match('/(?:case|else|in|return|typeof)$/', $this->output, $m)) {
|
||||
if ($this->output === $m[0]) { // odd but could happen
|
||||
|
||||
return true;
|
||||
}
|
||||
// make sure it's a keyword, not end of an identifier
|
||||
$charBeforeKeyword = substr($this->output, $length - strlen($m[0]) - 1, 1);
|
||||
if (! $this->isAlphaNum($charBeforeKeyword)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get next char. Convert ctrl char to space.
|
||||
*/
|
||||
protected function get()
|
||||
{
|
||||
$c = $this->lookAhead;
|
||||
$this->lookAhead = null;
|
||||
if ($c === null) {
|
||||
if ($this->inputIndex < $this->inputLength) {
|
||||
$c = $this->input[$this->inputIndex];
|
||||
$this->inputIndex += 1;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
if ($c === "\r" || $c === "\n") {
|
||||
return "\n";
|
||||
}
|
||||
if (ord($c) < self::ORD_SPACE) { // control char
|
||||
|
||||
return ' ';
|
||||
}
|
||||
|
||||
return $c;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get next char. If is ctrl character, translate to a space or newline.
|
||||
*/
|
||||
protected function peek()
|
||||
{
|
||||
$this->lookAhead = $this->get();
|
||||
|
||||
return $this->lookAhead;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is $c a letter, digit, underscore, dollar sign, escape, or non-ASCII?
|
||||
*/
|
||||
protected function isAlphaNum($c)
|
||||
{
|
||||
return (preg_match('/^[0-9a-zA-Z_\\$\\\\]$/', $c) || ord($c) > 126);
|
||||
}
|
||||
|
||||
protected function singleLineComment()
|
||||
{
|
||||
$comment = '';
|
||||
while (true) {
|
||||
$get = $this->get();
|
||||
$comment .= $get;
|
||||
if (ord($get) <= self::ORD_LF) { // EOL reached
|
||||
// if IE conditional comment
|
||||
if (preg_match('/^\\/@(?:cc_on|if|elif|else|end)\\b/', $comment)) {
|
||||
return "/{$comment}";
|
||||
}
|
||||
|
||||
return $get;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function multipleLineComment()
|
||||
{
|
||||
$this->get();
|
||||
$comment = '';
|
||||
while (true) {
|
||||
$get = $this->get();
|
||||
if ($get === '*') {
|
||||
if ($this->peek() === '/') { // end of comment reached
|
||||
$this->get();
|
||||
// if comment preserved by YUI Compressor
|
||||
if (0 === strpos($comment, '!')) {
|
||||
return "\n/*" . substr($comment, 1) . "*/\n";
|
||||
}
|
||||
// if IE conditional comment
|
||||
if (preg_match('/^@(?:cc_on|if|elif|else|end)\\b/', $comment)) {
|
||||
return "/*{$comment}*/";
|
||||
}
|
||||
|
||||
return ' ';
|
||||
}
|
||||
} elseif ($get === null) {
|
||||
throw new JSMin_UnterminatedCommentException('Unterminated Comment: ' . var_export('/*' . $comment, true));
|
||||
}
|
||||
$comment .= $get;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the next character, skipping over comments.
|
||||
* Some comments may be preserved.
|
||||
*/
|
||||
protected function next()
|
||||
{
|
||||
$get = $this->get();
|
||||
if ($get !== '/') {
|
||||
return $get;
|
||||
}
|
||||
switch ($this->peek()) {
|
||||
case '/': return $this->singleLineComment();
|
||||
case '*': return $this->multipleLineComment();
|
||||
default: return $get;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class JSMin_UnterminatedStringException extends Exception {}
|
||||
class JSMin_UnterminatedCommentException extends Exception {}
|
||||
class JSMin_UnterminatedRegExpException extends Exception {}
|
File diff suppressed because it is too large
Load Diff
@@ -1,538 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Class Minify
|
||||
* @package Minify
|
||||
*/
|
||||
|
||||
/**
|
||||
* Minify_Source
|
||||
*/
|
||||
require_once 'Minify/Source.php';
|
||||
|
||||
/**
|
||||
* Minify - Combines, minifies, and caches JavaScript and CSS files on demand.
|
||||
*
|
||||
* See README for usage instructions (for now).
|
||||
*
|
||||
* This library was inspired by {@link mailto:flashkot@mail.ru jscsscomp by Maxim Martynyuk}
|
||||
* and by the article {@link http://www.hunlock.com/blogs/Supercharged_Javascript "Supercharged JavaScript" by Patrick Hunlock}.
|
||||
*
|
||||
* Requires PHP 5.1.0.
|
||||
* Tested on PHP 5.1.6.
|
||||
*
|
||||
* @package Minify
|
||||
* @author Ryan Grove <ryan@wonko.com>
|
||||
* @author Stephen Clay <steve@mrclay.org>
|
||||
* @copyright 2008 Ryan Grove, Stephen Clay. All rights reserved.
|
||||
* @license http://opensource.org/licenses/bsd-license.php New BSD License
|
||||
* @link http://code.google.com/p/minify/
|
||||
*/
|
||||
class Minify {
|
||||
|
||||
const VERSION = '2.1.3';
|
||||
const TYPE_CSS = 'text/css';
|
||||
const TYPE_HTML = 'text/html';
|
||||
// there is some debate over the ideal JS Content-Type, but this is the
|
||||
// Apache default and what Yahoo! uses..
|
||||
const TYPE_JS = 'application/x-javascript';
|
||||
|
||||
/**
|
||||
* How many hours behind are the file modification times of uploaded files?
|
||||
*
|
||||
* If you upload files from Windows to a non-Windows server, Windows may report
|
||||
* incorrect mtimes for the files. Immediately after modifying and uploading a
|
||||
* file, use the touch command to update the mtime on the server. If the mtime
|
||||
* jumps ahead by a number of hours, set this variable to that number. If the mtime
|
||||
* moves back, this should not be needed.
|
||||
*
|
||||
* @var int $uploaderHoursBehind
|
||||
*/
|
||||
public static $uploaderHoursBehind = 0;
|
||||
|
||||
/**
|
||||
* If this string is not empty AND the serve() option 'bubbleCssImports' is
|
||||
* NOT set, then serve() will check CSS files for @import declarations that
|
||||
* appear too late in the combined stylesheet. If found, serve() will prepend
|
||||
* the output with this warning.
|
||||
*
|
||||
* @var string $importWarning
|
||||
*/
|
||||
public static $importWarning = "/* See http://code.google.com/p/minify/wiki/CommonProblems#@imports_can_appear_in_invalid_locations_in_combined_CSS_files */\n";
|
||||
|
||||
/**
|
||||
* Specify a cache object (with identical interface as Minify_Cache_File) or
|
||||
* a path to use with Minify_Cache_File.
|
||||
*
|
||||
* If not called, Minify will not use a cache and, for each 200 response, will
|
||||
* need to recombine files, minify and encode the output.
|
||||
*
|
||||
* @param mixed $cache object with identical interface as Minify_Cache_File or
|
||||
* a directory path, or null to disable caching. (default = '')
|
||||
*
|
||||
* @param bool $fileLocking (default = true) This only applies if the first
|
||||
* parameter is a string.
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public static function setCache($cache = '', $fileLocking = true)
|
||||
{
|
||||
if (is_string($cache)) {
|
||||
require_once 'Minify/Cache/File.php';
|
||||
self::$_cache = new Minify_Cache_File($cache, $fileLocking);
|
||||
} else {
|
||||
self::$_cache = $cache;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Serve a request for a minified file.
|
||||
*
|
||||
* Here are the available options and defaults in the base controller:
|
||||
*
|
||||
* 'isPublic' : send "public" instead of "private" in Cache-Control
|
||||
* headers, allowing shared caches to cache the output. (default true)
|
||||
*
|
||||
* 'quiet' : set to true to have serve() return an array rather than sending
|
||||
* any headers/output (default false)
|
||||
*
|
||||
* 'encodeOutput' : set to false to disable content encoding, and not send
|
||||
* the Vary header (default true)
|
||||
*
|
||||
* 'encodeMethod' : generally you should let this be determined by
|
||||
* HTTP_Encoder (leave null), but you can force a particular encoding
|
||||
* to be returned, by setting this to 'gzip' or '' (no encoding)
|
||||
*
|
||||
* 'encodeLevel' : level of encoding compression (0 to 9, default 9)
|
||||
*
|
||||
* 'contentTypeCharset' : appended to the Content-Type header sent. Set to a falsey
|
||||
* value to remove. (default 'utf-8')
|
||||
*
|
||||
* 'maxAge' : set this to the number of seconds the client should use its cache
|
||||
* before revalidating with the server. This sets Cache-Control: max-age and the
|
||||
* Expires header. Unlike the old 'setExpires' setting, this setting will NOT
|
||||
* prevent conditional GETs. Note this has nothing to do with server-side caching.
|
||||
*
|
||||
* 'rewriteCssUris' : If true, serve() will automatically set the 'currentDir'
|
||||
* minifier option to enable URI rewriting in CSS files (default true)
|
||||
*
|
||||
* 'bubbleCssImports' : If true, all @import declarations in combined CSS
|
||||
* files will be move to the top. Note this may alter effective CSS values
|
||||
* due to a change in order. (default false)
|
||||
*
|
||||
* 'debug' : set to true to minify all sources with the 'Lines' controller, which
|
||||
* eases the debugging of combined files. This also prevents 304 responses.
|
||||
* @see Minify_Lines::minify()
|
||||
*
|
||||
* 'minifiers' : to override Minify's default choice of minifier function for
|
||||
* a particular content-type, specify your callback under the key of the
|
||||
* content-type:
|
||||
* <code>
|
||||
* // call customCssMinifier($css) for all CSS minification
|
||||
* $options['minifiers'][Minify::TYPE_CSS] = 'customCssMinifier';
|
||||
*
|
||||
* // don't minify Javascript at all
|
||||
* $options['minifiers'][Minify::TYPE_JS] = '';
|
||||
* </code>
|
||||
*
|
||||
* 'minifierOptions' : to send options to the minifier function, specify your options
|
||||
* under the key of the content-type. E.g. To send the CSS minifier an option:
|
||||
* <code>
|
||||
* // give CSS minifier array('optionName' => 'optionValue') as 2nd argument
|
||||
* $options['minifierOptions'][Minify::TYPE_CSS]['optionName'] = 'optionValue';
|
||||
* </code>
|
||||
*
|
||||
* 'contentType' : (optional) this is only needed if your file extension is not
|
||||
* js/css/html. The given content-type will be sent regardless of source file
|
||||
* extension, so this should not be used in a Groups config with other
|
||||
* Javascript/CSS files.
|
||||
*
|
||||
* Any controller options are documented in that controller's setupSources() method.
|
||||
*
|
||||
* @param mixed instance of subclass of Minify_Controller_Base or string name of
|
||||
* controller. E.g. 'Files'
|
||||
*
|
||||
* @param array $options controller/serve options
|
||||
*
|
||||
* @return mixed null, or, if the 'quiet' option is set to true, an array
|
||||
* with keys "success" (bool), "statusCode" (int), "content" (string), and
|
||||
* "headers" (array).
|
||||
*/
|
||||
public static function serve($controller, $options = array())
|
||||
{
|
||||
if (is_string($controller)) {
|
||||
// make $controller into object
|
||||
$class = 'Minify_Controller_' . $controller;
|
||||
if (! class_exists($class, false)) {
|
||||
require_once "Minify/Controller/"
|
||||
. str_replace('_', '/', $controller) . ".php";
|
||||
}
|
||||
$controller = new $class();
|
||||
}
|
||||
|
||||
// set up controller sources and mix remaining options with
|
||||
// controller defaults
|
||||
$options = $controller->setupSources($options);
|
||||
$options = $controller->analyzeSources($options);
|
||||
self::$_options = $controller->mixInDefaultOptions($options);
|
||||
|
||||
// check request validity
|
||||
if (! $controller->sources) {
|
||||
// invalid request!
|
||||
if (! self::$_options['quiet']) {
|
||||
header(self::$_options['badRequestHeader']);
|
||||
echo self::$_options['badRequestHeader'];
|
||||
|
||||
return;
|
||||
} else {
|
||||
list(,$statusCode) = explode(' ', self::$_options['badRequestHeader']);
|
||||
|
||||
return array(
|
||||
'success' => false
|
||||
,'statusCode' => (int)$statusCode
|
||||
,'content' => ''
|
||||
,'headers' => array()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
self::$_controller = $controller;
|
||||
|
||||
if (self::$_options['debug']) {
|
||||
self::_setupDebug($controller->sources);
|
||||
self::$_options['maxAge'] = 0;
|
||||
}
|
||||
|
||||
// determine encoding
|
||||
if (self::$_options['encodeOutput']) {
|
||||
if (self::$_options['encodeMethod'] !== null) {
|
||||
// controller specifically requested this
|
||||
$contentEncoding = self::$_options['encodeMethod'];
|
||||
} else {
|
||||
// sniff request header
|
||||
require_once 'HTTP/Encoder.php';
|
||||
// depending on what the client accepts, $contentEncoding may be
|
||||
// 'x-gzip' while our internal encodeMethod is 'gzip'. Calling
|
||||
// getAcceptedEncoding(false, false) leaves out compress and deflate as options.
|
||||
list(self::$_options['encodeMethod'], $contentEncoding) = HTTP_Encoder::getAcceptedEncoding(false, false);
|
||||
}
|
||||
} else {
|
||||
self::$_options['encodeMethod'] = ''; // identity (no encoding)
|
||||
}
|
||||
|
||||
// check client cache
|
||||
require_once 'HTTP/ConditionalGet.php';
|
||||
$cgOptions = array(
|
||||
'lastModifiedTime' => self::$_options['lastModifiedTime']
|
||||
,'isPublic' => self::$_options['isPublic']
|
||||
,'encoding' => self::$_options['encodeMethod']
|
||||
);
|
||||
if (self::$_options['maxAge'] > 0) {
|
||||
$cgOptions['maxAge'] = self::$_options['maxAge'];
|
||||
}
|
||||
$cg = new HTTP_ConditionalGet($cgOptions);
|
||||
if ($cg->cacheIsValid) {
|
||||
// client's cache is valid
|
||||
if (! self::$_options['quiet']) {
|
||||
$cg->sendHeaders();
|
||||
|
||||
return;
|
||||
} else {
|
||||
return array(
|
||||
'success' => true
|
||||
,'statusCode' => 304
|
||||
,'content' => ''
|
||||
,'headers' => $cg->getHeaders()
|
||||
);
|
||||
}
|
||||
} else {
|
||||
// client will need output
|
||||
$headers = $cg->getHeaders();
|
||||
unset($cg);
|
||||
}
|
||||
|
||||
if (self::$_options['contentType'] === self::TYPE_CSS
|
||||
&& self::$_options['rewriteCssUris']) {
|
||||
reset($controller->sources);
|
||||
while (list($key, $source) = each($controller->sources)) {
|
||||
if ($source->filepath
|
||||
&& !isset($source->minifyOptions['currentDir'])
|
||||
&& !isset($source->minifyOptions['prependRelativePath'])
|
||||
) {
|
||||
$source->minifyOptions['currentDir'] = dirname($source->filepath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// check server cache
|
||||
if (null !== self::$_cache) {
|
||||
// using cache
|
||||
// the goal is to use only the cache methods to sniff the length and
|
||||
// output the content, as they do not require ever loading the file into
|
||||
// memory.
|
||||
$cacheId = 'minify_' . self::_getCacheId();
|
||||
$fullCacheId = (self::$_options['encodeMethod'])
|
||||
? $cacheId . '.gz'
|
||||
: $cacheId;
|
||||
// check cache for valid entry
|
||||
$cacheIsReady = self::$_cache->isValid($fullCacheId, self::$_options['lastModifiedTime']);
|
||||
if ($cacheIsReady) {
|
||||
$cacheContentLength = self::$_cache->getSize($fullCacheId);
|
||||
} else {
|
||||
// generate & cache content
|
||||
$content = self::_combineMinify();
|
||||
self::$_cache->store($cacheId, $content);
|
||||
if (function_exists('gzencode')) {
|
||||
self::$_cache->store($cacheId . '.gz', gzencode($content, self::$_options['encodeLevel']));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// no cache
|
||||
$cacheIsReady = false;
|
||||
$content = self::_combineMinify();
|
||||
}
|
||||
if (! $cacheIsReady && self::$_options['encodeMethod']) {
|
||||
// still need to encode
|
||||
$content = gzencode($content, self::$_options['encodeLevel']);
|
||||
}
|
||||
|
||||
// add headers
|
||||
$headers['Content-Length'] = $cacheIsReady
|
||||
? $cacheContentLength
|
||||
: strlen($content);
|
||||
$headers['Content-Type'] = self::$_options['contentTypeCharset']
|
||||
? self::$_options['contentType'] . '; charset=' . self::$_options['contentTypeCharset']
|
||||
: self::$_options['contentType'];
|
||||
if (self::$_options['encodeMethod'] !== '') {
|
||||
$headers['Content-Encoding'] = $contentEncoding;
|
||||
}
|
||||
if (self::$_options['encodeOutput']) {
|
||||
$headers['Vary'] = 'Accept-Encoding';
|
||||
}
|
||||
|
||||
if (! self::$_options['quiet']) {
|
||||
// output headers & content
|
||||
foreach ($headers as $name => $val) {
|
||||
header($name . ': ' . $val);
|
||||
}
|
||||
if ($cacheIsReady) {
|
||||
self::$_cache->display($fullCacheId);
|
||||
} else {
|
||||
echo $content;
|
||||
}
|
||||
} else {
|
||||
return array(
|
||||
'success' => true
|
||||
,'statusCode' => 200
|
||||
,'content' => $cacheIsReady
|
||||
? self::$_cache->fetch($fullCacheId)
|
||||
: $content
|
||||
,'headers' => $headers
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return combined minified content for a set of sources
|
||||
*
|
||||
* No internal caching will be used and the content will not be HTTP encoded.
|
||||
*
|
||||
* @param array $sources array of filepaths and/or Minify_Source objects
|
||||
*
|
||||
* @param array $options (optional) array of options for serve. By default
|
||||
* these are already set: quiet = true, encodeMethod = '', lastModifiedTime = 0.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function combine($sources, $options = array())
|
||||
{
|
||||
$cache = self::$_cache;
|
||||
self::$_cache = null;
|
||||
$options = array_merge(array(
|
||||
'files' => (array)$sources
|
||||
,'quiet' => true
|
||||
,'encodeMethod' => ''
|
||||
,'lastModifiedTime' => 0
|
||||
), $options);
|
||||
$out = self::serve('Files', $options);
|
||||
self::$_cache = $cache;
|
||||
|
||||
return $out['content'];
|
||||
}
|
||||
|
||||
/**
|
||||
* On IIS, create $_SERVER['DOCUMENT_ROOT']
|
||||
*
|
||||
* @param bool $unsetPathInfo (default false) if true, $_SERVER['PATH_INFO']
|
||||
* will be unset (it is inconsistent with Apache's setting)
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public static function setDocRoot($unsetPathInfo = false)
|
||||
{
|
||||
if (isset($_SERVER['SERVER_SOFTWARE'])
|
||||
&& 0 === strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS/')
|
||||
) {
|
||||
$_SERVER['DOCUMENT_ROOT'] = rtrim(substr(
|
||||
$_SERVER['PATH_TRANSLATED']
|
||||
,0
|
||||
,strlen($_SERVER['PATH_TRANSLATED']) - strlen($_SERVER['SCRIPT_NAME'])
|
||||
), '\\');
|
||||
if ($unsetPathInfo) {
|
||||
unset($_SERVER['PATH_INFO']);
|
||||
}
|
||||
require_once 'Minify/Logger.php';
|
||||
Minify_Logger::log("setDocRoot() set DOCUMENT_ROOT to \"{$_SERVER['DOCUMENT_ROOT']}\"");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @var mixed Minify_Cache_* object or null (i.e. no server cache is used)
|
||||
*/
|
||||
private static $_cache = null;
|
||||
|
||||
/**
|
||||
* @var Minify_Controller active controller for current request
|
||||
*/
|
||||
protected static $_controller = null;
|
||||
|
||||
/**
|
||||
* @var array options for current request
|
||||
*/
|
||||
protected static $_options = null;
|
||||
|
||||
/**
|
||||
* Set up sources to use Minify_Lines
|
||||
*
|
||||
* @param array $sources Minify_Source instances
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
protected static function _setupDebug($sources)
|
||||
{
|
||||
foreach ($sources as $source) {
|
||||
$source->minifier = array('Minify_Lines', 'minify');
|
||||
$id = $source->getId();
|
||||
$source->minifyOptions = array(
|
||||
'id' => (is_file($id) ? basename($id) : $id)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Combines sources and minifies the result.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected static function _combineMinify()
|
||||
{
|
||||
$type = self::$_options['contentType']; // ease readability
|
||||
|
||||
// when combining scripts, make sure all statements separated and
|
||||
// trailing single line comment is terminated
|
||||
$implodeSeparator = ($type === self::TYPE_JS)
|
||||
? "\n;"
|
||||
: '';
|
||||
// allow the user to pass a particular array of options to each
|
||||
// minifier (designated by type). source objects may still override
|
||||
// these
|
||||
$defaultOptions = isset(self::$_options['minifierOptions'][$type])
|
||||
? self::$_options['minifierOptions'][$type]
|
||||
: array();
|
||||
// if minifier not set, default is no minification. source objects
|
||||
// may still override this
|
||||
$defaultMinifier = isset(self::$_options['minifiers'][$type])
|
||||
? self::$_options['minifiers'][$type]
|
||||
: false;
|
||||
|
||||
if (Minify_Source::haveNoMinifyPrefs(self::$_controller->sources)) {
|
||||
// all source have same options/minifier, better performance
|
||||
// to combine, then minify once
|
||||
foreach (self::$_controller->sources as $source) {
|
||||
$pieces[] = $source->getContent();
|
||||
}
|
||||
$content = implode($implodeSeparator, $pieces);
|
||||
if ($defaultMinifier) {
|
||||
self::$_controller->loadMinifier($defaultMinifier);
|
||||
$content = call_user_func($defaultMinifier, $content, $defaultOptions);
|
||||
}
|
||||
} else {
|
||||
// minify each source with its own options and minifier, then combine
|
||||
foreach (self::$_controller->sources as $source) {
|
||||
// allow the source to override our minifier and options
|
||||
$minifier = (null !== $source->minifier)
|
||||
? $source->minifier
|
||||
: $defaultMinifier;
|
||||
$options = (null !== $source->minifyOptions)
|
||||
? array_merge($defaultOptions, $source->minifyOptions)
|
||||
: $defaultOptions;
|
||||
if ($minifier) {
|
||||
self::$_controller->loadMinifier($minifier);
|
||||
// get source content and minify it
|
||||
$pieces[] = call_user_func($minifier, $source->getContent(), $options);
|
||||
} else {
|
||||
$pieces[] = $source->getContent();
|
||||
}
|
||||
}
|
||||
$content = implode($implodeSeparator, $pieces);
|
||||
}
|
||||
|
||||
if ($type === self::TYPE_CSS && false !== strpos($content, '@import')) {
|
||||
$content = self::_handleCssImports($content);
|
||||
}
|
||||
|
||||
// do any post-processing (esp. for editing build URIs)
|
||||
if (self::$_options['postprocessorRequire']) {
|
||||
require_once self::$_options['postprocessorRequire'];
|
||||
}
|
||||
if (self::$_options['postprocessor']) {
|
||||
$content = call_user_func(self::$_options['postprocessor'], $content, $type);
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a unique cache id for for this request.
|
||||
*
|
||||
* Any settings that could affect output are taken into consideration
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected static function _getCacheId()
|
||||
{
|
||||
return md5(serialize(array(
|
||||
Minify_Source::getDigest(self::$_controller->sources)
|
||||
,self::$_options['minifiers']
|
||||
,self::$_options['minifierOptions']
|
||||
,self::$_options['postprocessor']
|
||||
,self::$_options['bubbleCssImports']
|
||||
)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Bubble CSS @imports to the top or prepend a warning if an
|
||||
* @import is detected not at the top.
|
||||
*/
|
||||
protected static function _handleCssImports($css)
|
||||
{
|
||||
if (self::$_options['bubbleCssImports']) {
|
||||
// bubble CSS imports
|
||||
preg_match_all('/@import.*?;/', $css, $imports);
|
||||
$css = implode('', $imports[0]) . preg_replace('/@import.*?;/', '', $css);
|
||||
} else if ('' !== self::$importWarning) {
|
||||
// remove comments so we don't mistake { in a comment as a block
|
||||
$noCommentCss = preg_replace('@/\\*[\\s\\S]*?\\*/@', '', $css);
|
||||
$lastImportPos = strrpos($noCommentCss, '@import');
|
||||
$firstBlockPos = strpos($noCommentCss, '{');
|
||||
if (false !== $lastImportPos
|
||||
&& false !== $firstBlockPos
|
||||
&& $firstBlockPos < $lastImportPos
|
||||
) {
|
||||
// { appears before @import : prepend warning
|
||||
$css = self::$importWarning . $css;
|
||||
}
|
||||
}
|
||||
|
||||
return $css;
|
||||
}
|
||||
}
|
@@ -1,104 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Class Minify_Build
|
||||
* @package Minify
|
||||
*/
|
||||
|
||||
require_once 'Minify/Source.php';
|
||||
|
||||
/**
|
||||
* Maintain a single last modification time for a group of Minify sources to
|
||||
* allow use of far off Expires headers in Minify.
|
||||
*
|
||||
* <code>
|
||||
* // in config file
|
||||
* $groupSources = array(
|
||||
* 'js' => array('file1.js', 'file2.js')
|
||||
* ,'css' => array('file1.css', 'file2.css', 'file3.css')
|
||||
* )
|
||||
*
|
||||
* // during HTML generation
|
||||
* $jsBuild = new Minify_Build($groupSources['js']);
|
||||
* $cssBuild = new Minify_Build($groupSources['css']);
|
||||
*
|
||||
* $script = "<script type='text/javascript' src='"
|
||||
* . $jsBuild->uri('/min.php/js') . "'></script>";
|
||||
* $link = "<link rel='stylesheet' type='text/css' href='"
|
||||
* . $cssBuild->uri('/min.php/css') . "'>";
|
||||
*
|
||||
* // in min.php
|
||||
* Minify::serve('Groups', array(
|
||||
* 'groups' => $groupSources
|
||||
* ,'setExpires' => (time() + 86400 * 365)
|
||||
* ));
|
||||
* </code>
|
||||
*
|
||||
* @package Minify
|
||||
* @author Stephen Clay <steve@mrclay.org>
|
||||
*/
|
||||
class Minify_Build {
|
||||
|
||||
/**
|
||||
* Last modification time of all files in the build
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $lastModified = 0;
|
||||
|
||||
/**
|
||||
* String to use as ampersand in uri(). Set this to '&' if
|
||||
* you are not HTML-escaping URIs.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public static $ampersand = '&';
|
||||
|
||||
/**
|
||||
* Get a time-stamped URI
|
||||
*
|
||||
* <code>
|
||||
* echo $b->uri('/site.js');
|
||||
* // outputs "/site.js?1678242"
|
||||
*
|
||||
* echo $b->uri('/scriptaculous.js?load=effects');
|
||||
* // outputs "/scriptaculous.js?load=effects&1678242"
|
||||
* </code>
|
||||
*
|
||||
* @param string $uri
|
||||
* @param boolean $forceAmpersand (default = false) Force the use of ampersand to
|
||||
* append the timestamp to the URI.
|
||||
* @return string
|
||||
*/
|
||||
public function uri($uri, $forceAmpersand = false) {
|
||||
$sep = ($forceAmpersand || strpos($uri, '?') !== false)
|
||||
? self::$ampersand
|
||||
: '?';
|
||||
|
||||
return "{$uri}{$sep}{$this->lastModified}";
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a build object
|
||||
*
|
||||
* @param array $sources array of Minify_Source objects and/or file paths
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public function __construct($sources)
|
||||
{
|
||||
$max = 0;
|
||||
foreach ((array)$sources as $source) {
|
||||
if ($source instanceof Minify_Source) {
|
||||
$max = max($max, $source->lastModified);
|
||||
} elseif (is_string($source)) {
|
||||
if (0 === strpos($source, '//')) {
|
||||
$source = $_SERVER['DOCUMENT_ROOT'] . substr($source, 1);
|
||||
}
|
||||
if (is_file($source)) {
|
||||
$max = max($max, filemtime($source));
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->lastModified = $max;
|
||||
}
|
||||
}
|
@@ -1,83 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Class Minify_CSS
|
||||
* @package Minify
|
||||
*/
|
||||
|
||||
/**
|
||||
* Minify CSS
|
||||
*
|
||||
* This class uses Minify_CSS_Compressor and Minify_CSS_UriRewriter to
|
||||
* minify CSS and rewrite relative URIs.
|
||||
*
|
||||
* @package Minify
|
||||
* @author Stephen Clay <steve@mrclay.org>
|
||||
* @author http://code.google.com/u/1stvamp/ (Issue 64 patch)
|
||||
*/
|
||||
class Minify_CSS {
|
||||
|
||||
/**
|
||||
* Minify a CSS string
|
||||
*
|
||||
* @param string $css
|
||||
*
|
||||
* @param array $options available options:
|
||||
*
|
||||
* 'preserveComments': (default true) multi-line comments that begin
|
||||
* with "/*!" will be preserved with newlines before and after to
|
||||
* enhance readability.
|
||||
*
|
||||
* 'prependRelativePath': (default null) if given, this string will be
|
||||
* prepended to all relative URIs in import/url declarations
|
||||
*
|
||||
* 'currentDir': (default null) if given, this is assumed to be the
|
||||
* directory of the current CSS file. Using this, minify will rewrite
|
||||
* all relative URIs in import/url declarations to correctly point to
|
||||
* the desired files. For this to work, the files *must* exist and be
|
||||
* visible by the PHP process.
|
||||
*
|
||||
* 'symlinks': (default = array()) If the CSS file is stored in
|
||||
* a symlink-ed directory, provide an array of link paths to
|
||||
* target paths, where the link paths are within the document root. Because
|
||||
* paths need to be normalized for this to work, use "//" to substitute
|
||||
* the doc root in the link paths (the array keys). E.g.:
|
||||
* <code>
|
||||
* array('//symlink' => '/real/target/path') // unix
|
||||
* array('//static' => 'D:\\staticStorage') // Windows
|
||||
* </code>
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function minify($css, $options = array())
|
||||
{
|
||||
require_once 'Minify/CSS/Compressor.php';
|
||||
if (isset($options['preserveComments'])
|
||||
&& !$options['preserveComments']) {
|
||||
$css = Minify_CSS_Compressor::process($css, $options);
|
||||
} else {
|
||||
require_once 'Minify/CommentPreserver.php';
|
||||
$css = Minify_CommentPreserver::process(
|
||||
$css
|
||||
,array('Minify_CSS_Compressor', 'process')
|
||||
,array($options)
|
||||
);
|
||||
}
|
||||
if (! isset($options['currentDir']) && ! isset($options['prependRelativePath'])) {
|
||||
return $css;
|
||||
}
|
||||
require_once 'Minify/CSS/UriRewriter.php';
|
||||
if (isset($options['currentDir'])) {
|
||||
return Minify_CSS_UriRewriter::rewrite(
|
||||
$css
|
||||
,$options['currentDir']
|
||||
,isset($options['docRoot']) ? $options['docRoot'] : $_SERVER['DOCUMENT_ROOT']
|
||||
,isset($options['symlinks']) ? $options['symlinks'] : array()
|
||||
);
|
||||
} else {
|
||||
return Minify_CSS_UriRewriter::prepend(
|
||||
$css
|
||||
,$options['prependRelativePath']
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,256 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Class Minify_CSS_Compressor
|
||||
* @package Minify
|
||||
*/
|
||||
|
||||
/**
|
||||
* Compress CSS
|
||||
*
|
||||
* This is a heavy regex-based removal of whitespace, unnecessary
|
||||
* comments and tokens, and some CSS value minimization, where practical.
|
||||
* Many steps have been taken to avoid breaking comment-based hacks,
|
||||
* including the ie5/mac filter (and its inversion), but expect tricky
|
||||
* hacks involving comment tokens in 'content' value strings to break
|
||||
* minimization badly. A test suite is available.
|
||||
*
|
||||
* @package Minify
|
||||
* @author Stephen Clay <steve@mrclay.org>
|
||||
* @author http://code.google.com/u/1stvamp/ (Issue 64 patch)
|
||||
*/
|
||||
class Minify_CSS_Compressor {
|
||||
|
||||
/**
|
||||
* Minify a CSS string
|
||||
*
|
||||
* @param string $css
|
||||
*
|
||||
* @param array $options (currently ignored)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function process($css, $options = array())
|
||||
{
|
||||
$obj = new Minify_CSS_Compressor($options);
|
||||
|
||||
return $obj->_process($css);
|
||||
}
|
||||
|
||||
/**
|
||||
* @var array options
|
||||
*/
|
||||
protected $_options = null;
|
||||
|
||||
/**
|
||||
* @var bool Are we "in" a hack?
|
||||
*
|
||||
* I.e. are some browsers targetted until the next comment?
|
||||
*/
|
||||
protected $_inHack = false;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param array $options (currently ignored)
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
private function __construct($options) {
|
||||
$this->_options = $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Minify a CSS string
|
||||
*
|
||||
* @param string $css
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function _process($css)
|
||||
{
|
||||
$css = str_replace("\r\n", "\n", $css);
|
||||
|
||||
// preserve empty comment after '>'
|
||||
// http://www.webdevout.net/css-hacks#in_css-selectors
|
||||
$css = preg_replace('@>/\\*\\s*\\*/@', '>/*keep*/', $css);
|
||||
|
||||
// preserve empty comment between property and value
|
||||
// http://css-discuss.incutio.com/?page=BoxModelHack
|
||||
$css = preg_replace('@/\\*\\s*\\*/\\s*:@', '/*keep*/:', $css);
|
||||
$css = preg_replace('@:\\s*/\\*\\s*\\*/@', ':/*keep*/', $css);
|
||||
|
||||
// apply callback to all valid comments (and strip out surrounding ws
|
||||
$css = preg_replace_callback('@\\s*/\\*([\\s\\S]*?)\\*/\\s*@'
|
||||
,array($this, '_commentCB'), $css);
|
||||
|
||||
// remove ws around { } and last semicolon in declaration block
|
||||
$css = preg_replace('/\\s*{\\s*/', '{', $css);
|
||||
$css = preg_replace('/;?\\s*}\\s*/', '}', $css);
|
||||
|
||||
// remove ws surrounding semicolons
|
||||
$css = preg_replace('/\\s*;\\s*/', ';', $css);
|
||||
|
||||
// remove ws around urls
|
||||
$css = preg_replace('/
|
||||
url\\( # url(
|
||||
\\s*
|
||||
([^\\)]+?) # 1 = the URL (really just a bunch of non right parenthesis)
|
||||
\\s*
|
||||
\\) # )
|
||||
/x', 'url($1)', $css);
|
||||
|
||||
// remove ws between rules and colons
|
||||
$css = preg_replace('/
|
||||
\\s*
|
||||
([{;]) # 1 = beginning of block or rule separator
|
||||
\\s*
|
||||
([\\*_]?[\\w\\-]+) # 2 = property (and maybe IE filter)
|
||||
\\s*
|
||||
:
|
||||
\\s*
|
||||
(\\b|[#\'"]) # 3 = first character of a value
|
||||
/x', '$1$2:$3', $css);
|
||||
|
||||
// remove ws in selectors
|
||||
$css = preg_replace_callback('/
|
||||
(?: # non-capture
|
||||
\\s*
|
||||
[^~>+,\\s]+ # selector part
|
||||
\\s*
|
||||
[,>+~] # combinators
|
||||
)+
|
||||
\\s*
|
||||
[^~>+,\\s]+ # selector part
|
||||
{ # open declaration block
|
||||
/x'
|
||||
,array($this, '_selectorsCB'), $css);
|
||||
|
||||
// minimize hex colors
|
||||
$css = preg_replace('/([^=])#([a-f\\d])\\2([a-f\\d])\\3([a-f\\d])\\4([\\s;\\}])/i'
|
||||
, '$1#$2$3$4$5', $css);
|
||||
|
||||
// remove spaces between font families
|
||||
$css = preg_replace_callback('/font-family:([^;}]+)([;}])/'
|
||||
,array($this, '_fontFamilyCB'), $css);
|
||||
|
||||
$css = preg_replace('/@import\\s+url/', '@import url', $css);
|
||||
|
||||
// replace any ws involving newlines with a single newline
|
||||
$css = preg_replace('/[ \\t]*\\n+\\s*/', "\n", $css);
|
||||
|
||||
// separate common descendent selectors w/ newlines (to limit line lengths)
|
||||
$css = preg_replace('/([\\w#\\.\\*]+)\\s+([\\w#\\.\\*]+){/', "$1\n$2{", $css);
|
||||
|
||||
// Use newline after 1st numeric value (to limit line lengths).
|
||||
$css = preg_replace('/
|
||||
((?:padding|margin|border|outline):\\d+(?:px|em)?) # 1 = prop : 1st numeric value
|
||||
\\s+
|
||||
/x'
|
||||
,"$1\n", $css);
|
||||
|
||||
// prevent triggering IE6 bug: http://www.crankygeek.com/ie6pebug/
|
||||
$css = preg_replace('/:first-l(etter|ine)\\{/', ':first-l$1 {', $css);
|
||||
|
||||
return trim($css);
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace what looks like a set of selectors
|
||||
*
|
||||
* @param array $m regex matches
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function _selectorsCB($m)
|
||||
{
|
||||
// remove ws around the combinators
|
||||
return preg_replace('/\\s*([,>+~])\\s*/', '$1', $m[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process a comment and return a replacement
|
||||
*
|
||||
* @param array $m regex matches
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function _commentCB($m)
|
||||
{
|
||||
$hasSurroundingWs = (trim($m[0]) !== $m[1]);
|
||||
$m = $m[1];
|
||||
// $m is the comment content w/o the surrounding tokens,
|
||||
// but the return value will replace the entire comment.
|
||||
if ($m === 'keep') {
|
||||
return '/**/';
|
||||
}
|
||||
if ($m === '" "') {
|
||||
// component of http://tantek.com/CSS/Examples/midpass.html
|
||||
return '/*" "*/';
|
||||
}
|
||||
if (preg_match('@";\\}\\s*\\}/\\*\\s+@', $m)) {
|
||||
// component of http://tantek.com/CSS/Examples/midpass.html
|
||||
return '/*";}}/* */';
|
||||
}
|
||||
if ($this->_inHack) {
|
||||
// inversion: feeding only to one browser
|
||||
if (preg_match('@
|
||||
^/ # comment started like /*/
|
||||
\\s*
|
||||
(\\S[\\s\\S]+?) # has at least some non-ws content
|
||||
\\s*
|
||||
/\\* # ends like /*/ or /**/
|
||||
@x', $m, $n)) {
|
||||
// end hack mode after this comment, but preserve the hack and comment content
|
||||
$this->_inHack = false;
|
||||
|
||||
return "/*/{$n[1]}/**/";
|
||||
}
|
||||
}
|
||||
if (substr($m, -1) === '\\') { // comment ends like \*/
|
||||
// begin hack mode and preserve hack
|
||||
$this->_inHack = true;
|
||||
|
||||
return '/*\\*/';
|
||||
}
|
||||
if ($m !== '' && $m[0] === '/') { // comment looks like /*/ foo */
|
||||
// begin hack mode and preserve hack
|
||||
$this->_inHack = true;
|
||||
|
||||
return '/*/*/';
|
||||
}
|
||||
if ($this->_inHack) {
|
||||
// a regular comment ends hack mode but should be preserved
|
||||
$this->_inHack = false;
|
||||
|
||||
return '/**/';
|
||||
}
|
||||
// Issue 107: if there's any surrounding whitespace, it may be important, so
|
||||
// replace the comment with a single space
|
||||
return $hasSurroundingWs // remove all other comments
|
||||
? ' '
|
||||
: '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Process a font-family listing and return a replacement
|
||||
*
|
||||
* @param array $m regex matches
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function _fontFamilyCB($m)
|
||||
{
|
||||
$m[1] = preg_replace('/
|
||||
\\s*
|
||||
(
|
||||
"[^"]+" # 1 = family in double qutoes
|
||||
|\'[^\']+\' # or 1 = family in single quotes
|
||||
|[\\w\\-]+ # or 1 = unquoted family
|
||||
)
|
||||
\\s*
|
||||
/x', '$1', $m[1]);
|
||||
|
||||
return 'font-family:' . $m[1] . $m[2];
|
||||
}
|
||||
}
|
@@ -1,273 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Class Minify_CSS_UriRewriter
|
||||
* @package Minify
|
||||
*/
|
||||
|
||||
/**
|
||||
* Rewrite file-relative URIs as root-relative in CSS files
|
||||
*
|
||||
* @package Minify
|
||||
* @author Stephen Clay <steve@mrclay.org>
|
||||
*/
|
||||
class Minify_CSS_UriRewriter {
|
||||
|
||||
/**
|
||||
* Defines which class to call as part of callbacks, change this
|
||||
* if you extend Minify_CSS_UriRewriter
|
||||
* @var string
|
||||
*/
|
||||
protected static $className = 'Minify_CSS_UriRewriter';
|
||||
|
||||
/**
|
||||
* rewrite() and rewriteRelative() append debugging information here
|
||||
* @var string
|
||||
*/
|
||||
public static $debugText = '';
|
||||
|
||||
/**
|
||||
* Rewrite file relative URIs as root relative in CSS files
|
||||
*
|
||||
* @param string $css
|
||||
*
|
||||
* @param string $currentDir The directory of the current CSS file.
|
||||
*
|
||||
* @param string $docRoot The document root of the web site in which
|
||||
* the CSS file resides (default = $_SERVER['DOCUMENT_ROOT']).
|
||||
*
|
||||
* @param array $symlinks (default = array()) If the CSS file is stored in
|
||||
* a symlink-ed directory, provide an array of link paths to
|
||||
* target paths, where the link paths are within the document root. Because
|
||||
* paths need to be normalized for this to work, use "//" to substitute
|
||||
* the doc root in the link paths (the array keys). E.g.:
|
||||
* <code>
|
||||
* array('//symlink' => '/real/target/path') // unix
|
||||
* array('//static' => 'D:\\staticStorage') // Windows
|
||||
* </code>
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function rewrite($css, $currentDir, $docRoot = null, $symlinks = array())
|
||||
{
|
||||
self::$_docRoot = self::_realpath(
|
||||
$docRoot ? $docRoot : $_SERVER['DOCUMENT_ROOT']
|
||||
);
|
||||
self::$_currentDir = self::_realpath($currentDir);
|
||||
self::$_symlinks = array();
|
||||
|
||||
// normalize symlinks
|
||||
foreach ($symlinks as $link => $target) {
|
||||
$link = ($link === '//')
|
||||
? self::$_docRoot
|
||||
: str_replace('//', self::$_docRoot . '/', $link);
|
||||
$link = strtr($link, '/', DIRECTORY_SEPARATOR);
|
||||
self::$_symlinks[$link] = self::_realpath($target);
|
||||
}
|
||||
|
||||
self::$debugText .= "docRoot : " . self::$_docRoot . "\n"
|
||||
. "currentDir : " . self::$_currentDir . "\n";
|
||||
if (self::$_symlinks) {
|
||||
self::$debugText .= "symlinks : " . var_export(self::$_symlinks, 1) . "\n";
|
||||
}
|
||||
self::$debugText .= "\n";
|
||||
|
||||
$css = self::_trimUrls($css);
|
||||
|
||||
// rewrite
|
||||
$css = preg_replace_callback('/@import\\s+([\'"])(.*?)[\'"]/'
|
||||
,array(self::$className, '_processUriCB'), $css);
|
||||
$css = preg_replace_callback('/url\\(\\s*([^\\)\\s]+)\\s*\\)/'
|
||||
,array(self::$className, '_processUriCB'), $css);
|
||||
|
||||
return $css;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepend a path to relative URIs in CSS files
|
||||
*
|
||||
* @param string $css
|
||||
*
|
||||
* @param string $path The path to prepend.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function prepend($css, $path)
|
||||
{
|
||||
self::$_prependPath = $path;
|
||||
|
||||
$css = self::_trimUrls($css);
|
||||
|
||||
// append
|
||||
$css = preg_replace_callback('/@import\\s+([\'"])(.*?)[\'"]/'
|
||||
,array(self::$className, '_processUriCB'), $css);
|
||||
$css = preg_replace_callback('/url\\(\\s*([^\\)\\s]+)\\s*\\)/'
|
||||
,array(self::$className, '_processUriCB'), $css);
|
||||
|
||||
self::$_prependPath = null;
|
||||
|
||||
return $css;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @var string directory of this stylesheet
|
||||
*/
|
||||
private static $_currentDir = '';
|
||||
|
||||
/**
|
||||
* @var string DOC_ROOT
|
||||
*/
|
||||
private static $_docRoot = '';
|
||||
|
||||
/**
|
||||
* @var array directory replacements to map symlink targets back to their
|
||||
* source (within the document root) E.g. '/var/www/symlink' => '/var/realpath'
|
||||
*/
|
||||
private static $_symlinks = array();
|
||||
|
||||
/**
|
||||
* @var string path to prepend
|
||||
*/
|
||||
private static $_prependPath = null;
|
||||
|
||||
private static function _trimUrls($css)
|
||||
{
|
||||
return preg_replace('/
|
||||
url\\( # url(
|
||||
\\s*
|
||||
([^\\)]+?) # 1 = URI (assuming does not contain ")")
|
||||
\\s*
|
||||
\\) # )
|
||||
/x', 'url($1)', $css);
|
||||
}
|
||||
|
||||
private static function _processUriCB($m)
|
||||
{
|
||||
// $m matched either '/@import\\s+([\'"])(.*?)[\'"]/' or '/url\\(\\s*([^\\)\\s]+)\\s*\\)/'
|
||||
$isImport = ($m[0][0] === '@');
|
||||
// determine URI and the quote character (if any)
|
||||
if ($isImport) {
|
||||
$quoteChar = $m[1];
|
||||
$uri = $m[2];
|
||||
} else {
|
||||
// $m[1] is either quoted or not
|
||||
$quoteChar = ($m[1][0] === "'" || $m[1][0] === '"')
|
||||
? $m[1][0]
|
||||
: '';
|
||||
$uri = ($quoteChar === '')
|
||||
? $m[1]
|
||||
: substr($m[1], 1, strlen($m[1]) - 2);
|
||||
}
|
||||
// analyze URI
|
||||
if ('/' !== $uri[0] // root-relative
|
||||
&& false === strpos($uri, '//') // protocol (non-data)
|
||||
&& 0 !== strpos($uri, 'data:') // data protocol
|
||||
) {
|
||||
// URI is file-relative: rewrite depending on options
|
||||
$uri = (self::$_prependPath !== null)
|
||||
? (self::$_prependPath . $uri)
|
||||
: self::rewriteRelative($uri, self::$_currentDir, self::$_docRoot, self::$_symlinks);
|
||||
}
|
||||
|
||||
return $isImport
|
||||
? "@import {$quoteChar}{$uri}{$quoteChar}"
|
||||
: "url({$quoteChar}{$uri}{$quoteChar})";
|
||||
}
|
||||
|
||||
/**
|
||||
* Rewrite a file relative URI as root relative
|
||||
*
|
||||
* <code>
|
||||
* Minify_CSS_UriRewriter::rewriteRelative(
|
||||
* '../img/hello.gif'
|
||||
* , '/home/user/www/css' // path of CSS file
|
||||
* , '/home/user/www' // doc root
|
||||
* );
|
||||
* // returns '/img/hello.gif'
|
||||
*
|
||||
* // example where static files are stored in a symlinked directory
|
||||
* Minify_CSS_UriRewriter::rewriteRelative(
|
||||
* 'hello.gif'
|
||||
* , '/var/staticFiles/theme'
|
||||
* , '/home/user/www'
|
||||
* , array('/home/user/www/static' => '/var/staticFiles')
|
||||
* );
|
||||
* // returns '/static/theme/hello.gif'
|
||||
* </code>
|
||||
*
|
||||
* @param string $uri file relative URI
|
||||
*
|
||||
* @param string $realCurrentDir realpath of the current file's directory.
|
||||
*
|
||||
* @param string $realDocRoot realpath of the site document root.
|
||||
*
|
||||
* @param array $symlinks (default = array()) If the file is stored in
|
||||
* a symlink-ed directory, provide an array of link paths to
|
||||
* real target paths, where the link paths "appear" to be within the document
|
||||
* root. E.g.:
|
||||
* <code>
|
||||
* array('/home/foo/www/not/real/path' => '/real/target/path') // unix
|
||||
* array('C:\\htdocs\\not\\real' => 'D:\\real\\target\\path') // Windows
|
||||
* </code>
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function rewriteRelative($uri, $realCurrentDir, $realDocRoot, $symlinks = array())
|
||||
{
|
||||
// prepend path with current dir separator (OS-independent)
|
||||
$path = strtr($realCurrentDir, '/', DIRECTORY_SEPARATOR)
|
||||
. DIRECTORY_SEPARATOR . strtr($uri, '/', DIRECTORY_SEPARATOR);
|
||||
|
||||
self::$debugText .= "file-relative URI : {$uri}\n"
|
||||
. "path prepended : {$path}\n";
|
||||
|
||||
// "unresolve" a symlink back to doc root
|
||||
foreach ($symlinks as $link => $target) {
|
||||
if (0 === strpos($path, $target)) {
|
||||
// replace $target with $link
|
||||
$path = $link . substr($path, strlen($target));
|
||||
|
||||
self::$debugText .= "symlink unresolved : {$path}\n";
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
// strip doc root
|
||||
$path = substr($path, strlen($realDocRoot));
|
||||
|
||||
self::$debugText .= "docroot stripped : {$path}\n";
|
||||
|
||||
// fix to root-relative URI
|
||||
|
||||
$uri = strtr($path, '/\\', '//');
|
||||
|
||||
// remove /./ and /../ where possible
|
||||
$uri = str_replace('/./', '/', $uri);
|
||||
// inspired by patch from Oleg Cherniy
|
||||
do {
|
||||
$uri = preg_replace('@/[^/]+/\\.\\./@', '/', $uri, 1, $changed);
|
||||
} while ($changed);
|
||||
|
||||
self::$debugText .= "traversals removed : {$uri}\n\n";
|
||||
|
||||
return $uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get realpath with any trailing slash removed. If realpath() fails,
|
||||
* just remove the trailing slash.
|
||||
*
|
||||
* @param string $path
|
||||
*
|
||||
* @return mixed path with no trailing slash
|
||||
*/
|
||||
protected static function _realpath($path)
|
||||
{
|
||||
$realPath = realpath($path);
|
||||
if ($realPath !== false) {
|
||||
$path = $realPath;
|
||||
}
|
||||
|
||||
return rtrim($path, '/\\');
|
||||
}
|
||||
}
|
@@ -1,132 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Class Minify_Cache_APC
|
||||
* @package Minify
|
||||
*/
|
||||
|
||||
/**
|
||||
* APC-based cache class for Minify
|
||||
*
|
||||
* <code>
|
||||
* Minify::setCache(new Minify_Cache_APC());
|
||||
* </code>
|
||||
*
|
||||
* @package Minify
|
||||
* @author Chris Edwards
|
||||
**/
|
||||
class Minify_Cache_APC {
|
||||
|
||||
/**
|
||||
* Create a Minify_Cache_APC object, to be passed to
|
||||
* Minify::setCache().
|
||||
*
|
||||
*
|
||||
* @param int $expire seconds until expiration (default = 0
|
||||
* meaning the item will not get an expiration date)
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public function __construct($expire = 0)
|
||||
{
|
||||
$this->_exp = $expire;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write data to cache.
|
||||
*
|
||||
* @param string $id cache id
|
||||
*
|
||||
* @param string $data
|
||||
*
|
||||
* @return bool success
|
||||
*/
|
||||
public function store($id, $data)
|
||||
{
|
||||
return apc_store($id, "{$_SERVER['REQUEST_TIME']}|{$data}", $this->_exp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the size of a cache entry
|
||||
*
|
||||
* @param string $id cache id
|
||||
*
|
||||
* @return int size in bytes
|
||||
*/
|
||||
public function getSize($id)
|
||||
{
|
||||
return $this->_fetch($id)
|
||||
? strlen($this->_data)
|
||||
: false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Does a valid cache entry exist?
|
||||
*
|
||||
* @param string $id cache id
|
||||
*
|
||||
* @param int $srcMtime mtime of the original source file(s)
|
||||
*
|
||||
* @return bool exists
|
||||
*/
|
||||
public function isValid($id, $srcMtime)
|
||||
{
|
||||
return ($this->_fetch($id) && ($this->_lm >= $srcMtime));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the cached content to output
|
||||
*
|
||||
* @param string $id cache id
|
||||
*/
|
||||
public function display($id)
|
||||
{
|
||||
echo $this->_fetch($id)
|
||||
? $this->_data
|
||||
: '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the cached content
|
||||
*
|
||||
* @param string $id cache id
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function fetch($id)
|
||||
{
|
||||
return $this->_fetch($id)
|
||||
? $this->_data
|
||||
: '';
|
||||
}
|
||||
|
||||
private $_exp = null;
|
||||
|
||||
// cache of most recently fetched id
|
||||
private $_lm = null;
|
||||
private $_data = null;
|
||||
private $_id = null;
|
||||
|
||||
/**
|
||||
* Fetch data and timestamp from apc, store in instance
|
||||
*
|
||||
* @param string $id
|
||||
*
|
||||
* @return bool success
|
||||
*/
|
||||
private function _fetch($id)
|
||||
{
|
||||
if ($this->_id === $id) {
|
||||
return true;
|
||||
}
|
||||
$ret = apc_fetch($id);
|
||||
if (false === $ret) {
|
||||
$this->_id = null;
|
||||
|
||||
return false;
|
||||
}
|
||||
list($this->_lm, $this->_data) = explode('|', $ret, 2);
|
||||
$this->_id = $id;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@@ -1,129 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Class Minify_Cache_File
|
||||
* @package Minify
|
||||
*/
|
||||
|
||||
class Minify_Cache_File {
|
||||
|
||||
public function __construct($path = '', $fileLocking = false)
|
||||
{
|
||||
if (! $path) {
|
||||
require_once 'Solar/Dir.php';
|
||||
$path = rtrim(Solar_Dir::tmp(), DIRECTORY_SEPARATOR);
|
||||
}
|
||||
$this->_locking = $fileLocking;
|
||||
$this->_path = $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write data to cache.
|
||||
*
|
||||
* @param string $id cache id (e.g. a filename)
|
||||
*
|
||||
* @param string $data
|
||||
*
|
||||
* @return bool success
|
||||
*/
|
||||
public function store($id, $data)
|
||||
{
|
||||
$flag = $this->_locking
|
||||
? LOCK_EX
|
||||
: null;
|
||||
if (is_file($this->_path . '/' . $id)) {
|
||||
@unlink($this->_path . '/' . $id);
|
||||
}
|
||||
if (! @file_put_contents($this->_path . '/' . $id, $data, $flag)) {
|
||||
return false;
|
||||
}
|
||||
// write control
|
||||
if ($data !== $this->fetch($id)) {
|
||||
@unlink($file);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the size of a cache entry
|
||||
*
|
||||
* @param string $id cache id (e.g. a filename)
|
||||
*
|
||||
* @return int size in bytes
|
||||
*/
|
||||
public function getSize($id)
|
||||
{
|
||||
return filesize($this->_path . '/' . $id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Does a valid cache entry exist?
|
||||
*
|
||||
* @param string $id cache id (e.g. a filename)
|
||||
*
|
||||
* @param int $srcMtime mtime of the original source file(s)
|
||||
*
|
||||
* @return bool exists
|
||||
*/
|
||||
public function isValid($id, $srcMtime)
|
||||
{
|
||||
$file = $this->_path . '/' . $id;
|
||||
|
||||
return (is_file($file) && (filemtime($file) >= $srcMtime));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the cached content to output
|
||||
*
|
||||
* @param string $id cache id (e.g. a filename)
|
||||
*/
|
||||
public function display($id)
|
||||
{
|
||||
if ($this->_locking) {
|
||||
$fp = fopen($this->_path . '/' . $id, 'rb');
|
||||
flock($fp, LOCK_SH);
|
||||
fpassthru($fp);
|
||||
flock($fp, LOCK_UN);
|
||||
fclose($fp);
|
||||
} else {
|
||||
readfile($this->_path . '/' . $id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the cached content
|
||||
*
|
||||
* @param string $id cache id (e.g. a filename)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function fetch($id)
|
||||
{
|
||||
if ($this->_locking) {
|
||||
$fp = fopen($this->_path . '/' . $id, 'rb');
|
||||
flock($fp, LOCK_SH);
|
||||
$ret = stream_get_contents($fp);
|
||||
flock($fp, LOCK_UN);
|
||||
fclose($fp);
|
||||
|
||||
return $ret;
|
||||
} else {
|
||||
return file_get_contents($this->_path . '/' . $id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the cache path used
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPath()
|
||||
{
|
||||
return $this->_path;
|
||||
}
|
||||
|
||||
private $_path = null;
|
||||
private $_locking = null;
|
||||
}
|
@@ -1,139 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Class Minify_Cache_Memcache
|
||||
* @package Minify
|
||||
*/
|
||||
|
||||
/**
|
||||
* Memcache-based cache class for Minify
|
||||
*
|
||||
* <code>
|
||||
* // fall back to disk caching if memcache can't connect
|
||||
* $memcache = new Memcache;
|
||||
* if ($memcache->connect('localhost', 11211)) {
|
||||
* Minify::setCache(new Minify_Cache_Memcache($memcache));
|
||||
* } else {
|
||||
* Minify::setCache();
|
||||
* }
|
||||
* </code>
|
||||
**/
|
||||
class Minify_Cache_Memcache {
|
||||
|
||||
/**
|
||||
* Create a Minify_Cache_Memcache object, to be passed to
|
||||
* Minify::setCache().
|
||||
*
|
||||
* @param Memcache $memcache already-connected instance
|
||||
*
|
||||
* @param int $expire seconds until expiration (default = 0
|
||||
* meaning the item will not get an expiration date)
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public function __construct($memcache, $expire = 0)
|
||||
{
|
||||
$this->_mc = $memcache;
|
||||
$this->_exp = $expire;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write data to cache.
|
||||
*
|
||||
* @param string $id cache id
|
||||
*
|
||||
* @param string $data
|
||||
*
|
||||
* @return bool success
|
||||
*/
|
||||
public function store($id, $data)
|
||||
{
|
||||
return $this->_mc->set($id, "{$_SERVER['REQUEST_TIME']}|{$data}", 0, $this->_exp);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the size of a cache entry
|
||||
*
|
||||
* @param string $id cache id
|
||||
*
|
||||
* @return int size in bytes
|
||||
*/
|
||||
public function getSize($id)
|
||||
{
|
||||
return $this->_fetch($id)
|
||||
? strlen($this->_data)
|
||||
: false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Does a valid cache entry exist?
|
||||
*
|
||||
* @param string $id cache id
|
||||
*
|
||||
* @param int $srcMtime mtime of the original source file(s)
|
||||
*
|
||||
* @return bool exists
|
||||
*/
|
||||
public function isValid($id, $srcMtime)
|
||||
{
|
||||
return ($this->_fetch($id) && ($this->_lm >= $srcMtime));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the cached content to output
|
||||
*
|
||||
* @param string $id cache id
|
||||
*/
|
||||
public function display($id)
|
||||
{
|
||||
echo $this->_fetch($id)
|
||||
? $this->_data
|
||||
: '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the cached content
|
||||
*
|
||||
* @param string $id cache id
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function fetch($id)
|
||||
{
|
||||
return $this->_fetch($id)
|
||||
? $this->_data
|
||||
: '';
|
||||
}
|
||||
|
||||
private $_mc = null;
|
||||
private $_exp = null;
|
||||
|
||||
// cache of most recently fetched id
|
||||
private $_lm = null;
|
||||
private $_data = null;
|
||||
private $_id = null;
|
||||
|
||||
/**
|
||||
* Fetch data and timestamp from memcache, store in instance
|
||||
*
|
||||
* @param string $id
|
||||
*
|
||||
* @return bool success
|
||||
*/
|
||||
private function _fetch($id)
|
||||
{
|
||||
if ($this->_id === $id) {
|
||||
return true;
|
||||
}
|
||||
$ret = $this->_mc->get($id);
|
||||
if (false === $ret) {
|
||||
$this->_id = null;
|
||||
|
||||
return false;
|
||||
}
|
||||
list($this->_lm, $this->_data) = explode('|', $ret, 2);
|
||||
$this->_id = $id;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@@ -1,92 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Class Minify_CommentPreserver
|
||||
* @package Minify
|
||||
*/
|
||||
|
||||
/**
|
||||
* Process a string in pieces preserving C-style comments that begin with "/*!"
|
||||
*
|
||||
* @package Minify
|
||||
* @author Stephen Clay <steve@mrclay.org>
|
||||
*/
|
||||
class Minify_CommentPreserver {
|
||||
|
||||
/**
|
||||
* String to be prepended to each preserved comment
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public static $prepend = "\n";
|
||||
|
||||
/**
|
||||
* String to be appended to each preserved comment
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public static $append = "\n";
|
||||
|
||||
/**
|
||||
* Process a string outside of C-style comments that begin with "/*!"
|
||||
*
|
||||
* On each non-empty string outside these comments, the given processor
|
||||
* function will be called. The first "!" will be removed from the
|
||||
* preserved comments, and the comments will be surrounded by
|
||||
* Minify_CommentPreserver::$preprend and Minify_CommentPreserver::$append.
|
||||
*
|
||||
* @param string $content
|
||||
* @param callback $processor function
|
||||
* @param array $args array of extra arguments to pass to the processor
|
||||
* function (default = array())
|
||||
* @return string
|
||||
*/
|
||||
public static function process($content, $processor, $args = array())
|
||||
{
|
||||
$ret = '';
|
||||
while (true) {
|
||||
list($beforeComment, $comment, $afterComment) = self::_nextComment($content);
|
||||
if ('' !== $beforeComment) {
|
||||
$callArgs = $args;
|
||||
array_unshift($callArgs, $beforeComment);
|
||||
$ret .= call_user_func_array($processor, $callArgs);
|
||||
}
|
||||
if (false === $comment) {
|
||||
break;
|
||||
}
|
||||
$ret .= $comment;
|
||||
$content = $afterComment;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract comments that YUI Compressor preserves.
|
||||
*
|
||||
* @param string $in input
|
||||
*
|
||||
* @return array 3 elements are returned. If a YUI comment is found, the
|
||||
* 2nd element is the comment and the 1st and 2nd are the surrounding
|
||||
* strings. If no comment is found, the entire string is returned as the
|
||||
* 1st element and the other two are false.
|
||||
*/
|
||||
private static function _nextComment($in)
|
||||
{
|
||||
if (
|
||||
false === ($start = strpos($in, '/*!'))
|
||||
|| false === ($end = strpos($in, '*/', $start + 3))
|
||||
) {
|
||||
return array($in, false, false);
|
||||
}
|
||||
$ret = array(
|
||||
substr($in, 0, $start)
|
||||
,self::$prepend . '/*' . substr($in, $start + 3, $end - $start - 1) . self::$append
|
||||
);
|
||||
$endChars = (strlen($in) - $end - 2);
|
||||
$ret[] = (0 === $endChars)
|
||||
? ''
|
||||
: substr($in, -$endChars);
|
||||
|
||||
return $ret;
|
||||
}
|
||||
}
|
@@ -1,206 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Class Minify_Controller_Base
|
||||
* @package Minify
|
||||
*/
|
||||
|
||||
/**
|
||||
* Base class for Minify controller
|
||||
*
|
||||
* The controller class validates a request and uses it to create sources
|
||||
* for minification and set options like contentType. It's also responsible
|
||||
* for loading minifier code upon request.
|
||||
*
|
||||
* @package Minify
|
||||
* @author Stephen Clay <steve@mrclay.org>
|
||||
*/
|
||||
abstract class Minify_Controller_Base {
|
||||
|
||||
/**
|
||||
* Setup controller sources and set an needed options for Minify::source
|
||||
*
|
||||
* You must override this method in your subclass controller to set
|
||||
* $this->sources. If the request is NOT valid, make sure $this->sources
|
||||
* is left an empty array. Then strip any controller-specific options from
|
||||
* $options and return it. To serve files, $this->sources must be an array of
|
||||
* Minify_Source objects.
|
||||
*
|
||||
* @param array $options controller and Minify options
|
||||
*
|
||||
* return array $options Minify::serve options
|
||||
*/
|
||||
abstract public function setupSources($options);
|
||||
|
||||
/**
|
||||
* Get default Minify options for this controller.
|
||||
*
|
||||
* Override in subclass to change defaults
|
||||
*
|
||||
* @return array options for Minify
|
||||
*/
|
||||
public function getDefaultMinifyOptions() {
|
||||
return array(
|
||||
'isPublic' => true
|
||||
,'encodeOutput' => function_exists('gzdeflate')
|
||||
,'encodeMethod' => null // determine later
|
||||
,'encodeLevel' => 9
|
||||
,'minifierOptions' => array() // no minifier options
|
||||
,'contentTypeCharset' => 'utf-8'
|
||||
,'maxAge' => 1800 // 30 minutes
|
||||
,'rewriteCssUris' => true
|
||||
,'bubbleCssImports' => false
|
||||
,'quiet' => false // serve() will send headers and output
|
||||
,'debug' => false
|
||||
|
||||
// if you override this, the response code MUST be directly after
|
||||
// the first space.
|
||||
,'badRequestHeader' => 'HTTP/1.0 400 Bad Request'
|
||||
|
||||
// callback function to see/modify content of all sources
|
||||
,'postprocessor' => null
|
||||
// file to require to load preprocessor
|
||||
,'postprocessorRequire' => null
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get default minifiers for this controller.
|
||||
*
|
||||
* Override in subclass to change defaults
|
||||
*
|
||||
* @return array minifier callbacks for common types
|
||||
*/
|
||||
public function getDefaultMinifers() {
|
||||
$ret[Minify::TYPE_JS] = array('JSMin', 'minify');
|
||||
$ret[Minify::TYPE_CSS] = array('Minify_CSS', 'minify');
|
||||
$ret[Minify::TYPE_HTML] = array('Minify_HTML', 'minify');
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load any code necessary to execute the given minifier callback.
|
||||
*
|
||||
* The controller is responsible for loading minification code on demand
|
||||
* via this method. This built-in function will only load classes for
|
||||
* static method callbacks where the class isn't already defined. It uses
|
||||
* the PEAR convention, so, given array('Jimmy_Minifier', 'minCss'), this
|
||||
* function will include 'Jimmy/Minifier.php'.
|
||||
*
|
||||
* If you need code loaded on demand and this doesn't suit you, you'll need
|
||||
* to override this function in your subclass.
|
||||
* @see Minify_Controller_Page::loadMinifier()
|
||||
*
|
||||
* @param callback $minifierCallback callback of minifier function
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public function loadMinifier($minifierCallback)
|
||||
{
|
||||
if (is_array($minifierCallback)
|
||||
&& is_string($minifierCallback[0])
|
||||
&& !class_exists($minifierCallback[0], false)) {
|
||||
|
||||
require str_replace('_', '/', $minifierCallback[0]) . '.php';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Is a user-given file within an allowable directory, existing,
|
||||
* and having an extension js/css/html/txt ?
|
||||
*
|
||||
* This is a convenience function for controllers that have to accept
|
||||
* user-given paths
|
||||
*
|
||||
* @param string $file full file path (already processed by realpath())
|
||||
*
|
||||
* @param array $safeDirs directories where files are safe to serve. Files can also
|
||||
* be in subdirectories of these directories.
|
||||
*
|
||||
* @return bool file is safe
|
||||
*/
|
||||
public static function _fileIsSafe($file, $safeDirs)
|
||||
{
|
||||
$pathOk = false;
|
||||
foreach ((array)$safeDirs as $safeDir) {
|
||||
if (strpos($file, $safeDir) === 0) {
|
||||
$pathOk = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$base = basename($file);
|
||||
if (! $pathOk || ! is_file($file) || $base[0] === '.') {
|
||||
return false;
|
||||
}
|
||||
list($revExt) = explode('.', strrev($base));
|
||||
|
||||
return in_array(strrev($revExt), array('js', 'css', 'html', 'txt'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @var array instances of Minify_Source, which provide content and
|
||||
* any individual minification needs.
|
||||
*
|
||||
* @see Minify_Source
|
||||
*/
|
||||
public $sources = array();
|
||||
|
||||
/**
|
||||
* Mix in default controller options with user-given options
|
||||
*
|
||||
* @param array $options user options
|
||||
*
|
||||
* @return array mixed options
|
||||
*/
|
||||
public final function mixInDefaultOptions($options)
|
||||
{
|
||||
$ret = array_merge(
|
||||
$this->getDefaultMinifyOptions(), $options
|
||||
);
|
||||
if (! isset($options['minifiers'])) {
|
||||
$options['minifiers'] = array();
|
||||
}
|
||||
$ret['minifiers'] = array_merge(
|
||||
$this->getDefaultMinifers(), $options['minifiers']
|
||||
);
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Analyze sources (if there are any) and set $options 'contentType'
|
||||
* and 'lastModifiedTime' if they already aren't.
|
||||
*
|
||||
* @param array $options options for Minify
|
||||
*
|
||||
* @return array options for Minify
|
||||
*/
|
||||
public final function analyzeSources($options = array())
|
||||
{
|
||||
if ($this->sources) {
|
||||
if (! isset($options['contentType'])) {
|
||||
$options['contentType'] = Minify_Source::getContentType($this->sources);
|
||||
}
|
||||
// last modified is needed for caching, even if setExpires is set
|
||||
if (! isset($options['lastModifiedTime'])) {
|
||||
$max = 0;
|
||||
foreach ($this->sources as $source) {
|
||||
$max = max($source->lastModified, $max);
|
||||
}
|
||||
$options['lastModifiedTime'] = $max;
|
||||
}
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send message to the Minify logger
|
||||
* @param string $msg
|
||||
* @return null
|
||||
*/
|
||||
protected function log($msg) {
|
||||
require_once 'Minify/Logger.php';
|
||||
Minify_Logger::log($msg);
|
||||
}
|
||||
}
|
@@ -1,80 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Class Minify_Controller_Files
|
||||
* @package Minify
|
||||
*/
|
||||
|
||||
require_once 'Minify/Controller/Base.php';
|
||||
|
||||
/**
|
||||
* Controller class for minifying a set of files
|
||||
*
|
||||
* E.g. the following would serve the minified Javascript for a site
|
||||
* <code>
|
||||
* Minify::serve('Files', array(
|
||||
* 'files' => array(
|
||||
* '//js/jquery.js'
|
||||
* ,'//js/plugins.js'
|
||||
* ,'/home/username/file.js'
|
||||
* )
|
||||
* ));
|
||||
* </code>
|
||||
*
|
||||
* As a shortcut, the controller will replace "//" at the beginning
|
||||
* of a filename with $_SERVER['DOCUMENT_ROOT'] . '/'.
|
||||
*
|
||||
* @package Minify
|
||||
* @author Stephen Clay <steve@mrclay.org>
|
||||
*/
|
||||
class Minify_Controller_Files extends Minify_Controller_Base {
|
||||
|
||||
/**
|
||||
* Set up file sources
|
||||
*
|
||||
* @param array $options controller and Minify options
|
||||
* @return array Minify options
|
||||
*
|
||||
* Controller options:
|
||||
*
|
||||
* 'files': (required) array of complete file paths, or a single path
|
||||
*/
|
||||
public function setupSources($options) {
|
||||
// strip controller options
|
||||
|
||||
$files = $options['files'];
|
||||
// if $files is a single object, casting will break it
|
||||
if (is_object($files)) {
|
||||
$files = array($files);
|
||||
} elseif (! is_array($files)) {
|
||||
$files = (array)$files;
|
||||
}
|
||||
unset($options['files']);
|
||||
|
||||
$sources = array();
|
||||
foreach ($files as $file) {
|
||||
if ($file instanceof Minify_Source) {
|
||||
$sources[] = $file;
|
||||
continue;
|
||||
}
|
||||
if (0 === strpos($file, '//')) {
|
||||
$file = $_SERVER['DOCUMENT_ROOT'] . substr($file, 1);
|
||||
}
|
||||
$realPath = realpath($file);
|
||||
if (is_file($realPath)) {
|
||||
$sources[] = new Minify_Source(array(
|
||||
'filepath' => $realPath
|
||||
));
|
||||
} else {
|
||||
$this->log("The path \"{$file}\" could not be found (or was not a file)");
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
if ($sources) {
|
||||
$this->sources = $sources;
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
|
@@ -1,97 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Class Minify_Controller_Groups
|
||||
* @package Minify
|
||||
*/
|
||||
|
||||
require_once 'Minify/Controller/Base.php';
|
||||
|
||||
/**
|
||||
* Controller class for serving predetermined groups of minimized sets, selected
|
||||
* by PATH_INFO
|
||||
*
|
||||
* <code>
|
||||
* Minify::serve('Groups', array(
|
||||
* 'groups' => array(
|
||||
* 'css' => array('//css/type.css', '//css/layout.css')
|
||||
* ,'js' => array('//js/jquery.js', '//js/site.js')
|
||||
* )
|
||||
* ));
|
||||
* </code>
|
||||
*
|
||||
* If the above code were placed in /serve.php, it would enable the URLs
|
||||
* /serve.php/js and /serve.php/css
|
||||
*
|
||||
* As a shortcut, the controller will replace "//" at the beginning
|
||||
* of a filename with $_SERVER['DOCUMENT_ROOT'] . '/'.
|
||||
*
|
||||
* @package Minify
|
||||
* @author Stephen Clay <steve@mrclay.org>
|
||||
*/
|
||||
class Minify_Controller_Groups extends Minify_Controller_Base {
|
||||
|
||||
/**
|
||||
* Set up groups of files as sources
|
||||
*
|
||||
* @param array $options controller and Minify options
|
||||
* @return array Minify options
|
||||
*
|
||||
* Controller options:
|
||||
*
|
||||
* 'groups': (required) array mapping PATH_INFO strings to arrays
|
||||
* of complete file paths. @see Minify_Controller_Groups
|
||||
*/
|
||||
public function setupSources($options) {
|
||||
// strip controller options
|
||||
$groups = $options['groups'];
|
||||
unset($options['groups']);
|
||||
|
||||
// mod_fcgid places PATH_INFO in ORIG_PATH_INFO
|
||||
$pi = isset($_SERVER['ORIG_PATH_INFO'])
|
||||
? substr($_SERVER['ORIG_PATH_INFO'], 1)
|
||||
: (isset($_SERVER['PATH_INFO'])
|
||||
? substr($_SERVER['PATH_INFO'], 1)
|
||||
: false
|
||||
);
|
||||
if (false === $pi || ! isset($groups[$pi])) {
|
||||
// no PATH_INFO or not a valid group
|
||||
$this->log("Missing PATH_INFO or no group set for \"$pi\"");
|
||||
|
||||
return $options;
|
||||
}
|
||||
$sources = array();
|
||||
|
||||
$files = $groups[$pi];
|
||||
// if $files is a single object, casting will break it
|
||||
if (is_object($files)) {
|
||||
$files = array($files);
|
||||
} elseif (! is_array($files)) {
|
||||
$files = (array)$files;
|
||||
}
|
||||
foreach ($files as $file) {
|
||||
if ($file instanceof Minify_Source) {
|
||||
$sources[] = $file;
|
||||
continue;
|
||||
}
|
||||
if (0 === strpos($file, '//')) {
|
||||
$file = $_SERVER['DOCUMENT_ROOT'] . substr($file, 1);
|
||||
}
|
||||
$realPath = realpath($file);
|
||||
if (is_file($realPath)) {
|
||||
$sources[] = new Minify_Source(array(
|
||||
'filepath' => $realPath
|
||||
));
|
||||
} else {
|
||||
$this->log("The path \"{$file}\" could not be found (or was not a file)");
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
if ($sources) {
|
||||
$this->sources = $sources;
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
|
@@ -1,140 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Class Minify_Controller_MinApp
|
||||
* @package Minify
|
||||
*/
|
||||
|
||||
require_once 'Minify/Controller/Base.php';
|
||||
|
||||
/**
|
||||
* Controller class for requests to /min/index.php
|
||||
*
|
||||
* @package Minify
|
||||
* @author Stephen Clay <steve@mrclay.org>
|
||||
*/
|
||||
class Minify_Controller_MinApp extends Minify_Controller_Base {
|
||||
|
||||
/**
|
||||
* Set up groups of files as sources
|
||||
*
|
||||
* @param array $options controller and Minify options
|
||||
* @return array Minify options
|
||||
*
|
||||
*/
|
||||
public function setupSources($options) {
|
||||
// filter controller options
|
||||
$cOptions = array_merge(
|
||||
array(
|
||||
'allowDirs' => '//'
|
||||
,'groupsOnly' => false
|
||||
,'groups' => array()
|
||||
,'maxFiles' => 10
|
||||
)
|
||||
,(isset($options['minApp']) ? $options['minApp'] : array())
|
||||
);
|
||||
unset($options['minApp']);
|
||||
$sources = array();
|
||||
if (isset($_GET['g'])) {
|
||||
// try groups
|
||||
if (! isset($cOptions['groups'][$_GET['g']])) {
|
||||
$this->log("A group configuration for \"{$_GET['g']}\" was not set");
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
$files = $cOptions['groups'][$_GET['g']];
|
||||
// if $files is a single object, casting will break it
|
||||
if (is_object($files)) {
|
||||
$files = array($files);
|
||||
} elseif (! is_array($files)) {
|
||||
$files = (array)$files;
|
||||
}
|
||||
foreach ($files as $file) {
|
||||
if ($file instanceof Minify_Source) {
|
||||
$sources[] = $file;
|
||||
continue;
|
||||
}
|
||||
if (0 === strpos($file, '//')) {
|
||||
$file = $_SERVER['DOCUMENT_ROOT'] . substr($file, 1);
|
||||
}
|
||||
$file = realpath($file);
|
||||
if (is_file($file)) {
|
||||
$sources[] = new Minify_Source(array(
|
||||
'filepath' => $file
|
||||
));
|
||||
} else {
|
||||
$this->log("The path \"{$file}\" could not be found (or was not a file)");
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
} elseif (! $cOptions['groupsOnly'] && isset($_GET['f'])) {
|
||||
// try user files
|
||||
// The following restrictions are to limit the URLs that minify will
|
||||
// respond to. Ideally there should be only one way to reference a file.
|
||||
if (// verify at least one file, files are single comma separated,
|
||||
// and are all same extension
|
||||
! preg_match('/^[^,]+\\.(css|js)(?:,[^,]+\\.\\1)*$/', $_GET['f'])
|
||||
// no "//"
|
||||
|| strpos($_GET['f'], '//') !== false
|
||||
// no "\"
|
||||
|| strpos($_GET['f'], '\\') !== false
|
||||
// no "./"
|
||||
|| preg_match('/(?:^|[^\\.])\\.\\//', $_GET['f'])
|
||||
) {
|
||||
$this->log("GET param 'f' invalid (see MinApp.php line 63)");
|
||||
|
||||
return $options;
|
||||
}
|
||||
$files = explode(',', $_GET['f']);
|
||||
if (count($files) > $cOptions['maxFiles'] || $files != array_unique($files)) {
|
||||
$this->log("Too many or duplicate files specified");
|
||||
|
||||
return $options;
|
||||
}
|
||||
if (isset($_GET['b'])) {
|
||||
// check for validity
|
||||
if (preg_match('@^[^/]+(?:/[^/]+)*$@', $_GET['b'])
|
||||
&& false === strpos($_GET['b'], '..')
|
||||
&& $_GET['b'] !== '.') {
|
||||
// valid base
|
||||
$base = "/{$_GET['b']}/";
|
||||
} else {
|
||||
$this->log("GET param 'b' invalid (see MinApp.php line 84)");
|
||||
|
||||
return $options;
|
||||
}
|
||||
} else {
|
||||
$base = '/';
|
||||
}
|
||||
$allowDirs = array();
|
||||
foreach ((array)$cOptions['allowDirs'] as $allowDir) {
|
||||
$allowDirs[] = realpath(str_replace('//', $_SERVER['DOCUMENT_ROOT'] . '/', $allowDir));
|
||||
}
|
||||
foreach ($files as $file) {
|
||||
$path = $_SERVER['DOCUMENT_ROOT'] . $base . $file;
|
||||
$file = realpath($path);
|
||||
if (false === $file) {
|
||||
$this->log("Path \"{$path}\" failed realpath()");
|
||||
|
||||
return $options;
|
||||
} elseif (! parent::_fileIsSafe($file, $allowDirs)) {
|
||||
$this->log("Path \"{$path}\" failed Minify_Controller_Base::_fileIsSafe()");
|
||||
|
||||
return $options;
|
||||
} else {
|
||||
$sources[] = new Minify_Source(array(
|
||||
'filepath' => $file
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($sources) {
|
||||
$this->sources = $sources;
|
||||
} else {
|
||||
$this->log("No sources to serve");
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
@@ -1,83 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Class Minify_Controller_Page
|
||||
* @package Minify
|
||||
*/
|
||||
|
||||
require_once 'Minify/Controller/Base.php';
|
||||
|
||||
/**
|
||||
* Controller class for serving a single HTML page
|
||||
*
|
||||
* @link http://code.google.com/p/minify/source/browse/trunk/web/examples/1/index.php#59
|
||||
* @package Minify
|
||||
* @author Stephen Clay <steve@mrclay.org>
|
||||
*/
|
||||
class Minify_Controller_Page extends Minify_Controller_Base {
|
||||
|
||||
/**
|
||||
* Set up source of HTML content
|
||||
*
|
||||
* @param array $options controller and Minify options
|
||||
* @return array Minify options
|
||||
*
|
||||
* Controller options:
|
||||
*
|
||||
* 'content': (required) HTML markup
|
||||
*
|
||||
* 'id': (required) id of page (string for use in server-side caching)
|
||||
*
|
||||
* 'lastModifiedTime': timestamp of when this content changed. This
|
||||
* is recommended to allow both server and client-side caching.
|
||||
*
|
||||
* 'minifyAll': should all CSS and Javascript blocks be individually
|
||||
* minified? (default false)
|
||||
*
|
||||
* @todo Add 'file' option to read HTML file.
|
||||
*/
|
||||
public function setupSources($options) {
|
||||
if (isset($options['file'])) {
|
||||
$sourceSpec = array(
|
||||
'filepath' => $options['file']
|
||||
);
|
||||
} else {
|
||||
// strip controller options
|
||||
$sourceSpec = array(
|
||||
'content' => $options['content']
|
||||
,'id' => $options['id']
|
||||
);
|
||||
unset($options['content'], $options['id']);
|
||||
}
|
||||
if (isset($options['minifyAll'])) {
|
||||
// this will be the 2nd argument passed to Minify_HTML::minify()
|
||||
$sourceSpec['minifyOptions'] = array(
|
||||
'cssMinifier' => array('Minify_CSS', 'minify')
|
||||
,'jsMinifier' => array('JSMin', 'minify')
|
||||
);
|
||||
$this->_loadCssJsMinifiers = true;
|
||||
unset($options['minifyAll']);
|
||||
}
|
||||
$this->sources[] = new Minify_Source($sourceSpec);
|
||||
|
||||
$options['contentType'] = Minify::TYPE_HTML;
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
protected $_loadCssJsMinifiers = false;
|
||||
|
||||
/**
|
||||
* @see Minify_Controller_Base::loadMinifier()
|
||||
*/
|
||||
public function loadMinifier($minifierCallback)
|
||||
{
|
||||
if ($this->_loadCssJsMinifiers) {
|
||||
// Minify will not call for these so we must manually load
|
||||
// them when Minify/HTML.php is called for.
|
||||
require_once 'Minify/CSS.php';
|
||||
require_once 'JSMin.php';
|
||||
}
|
||||
parent::loadMinifier($minifierCallback); // load Minify/HTML.php
|
||||
}
|
||||
}
|
||||
|
@@ -1,119 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Class Minify_Controller_Version1
|
||||
* @package Minify
|
||||
*/
|
||||
|
||||
require_once 'Minify/Controller/Base.php';
|
||||
|
||||
/**
|
||||
* Controller class for emulating version 1 of minify.php
|
||||
*
|
||||
* <code>
|
||||
* Minify::serve('Version1');
|
||||
* </code>
|
||||
*
|
||||
* @package Minify
|
||||
* @author Stephen Clay <steve@mrclay.org>
|
||||
*/
|
||||
class Minify_Controller_Version1 extends Minify_Controller_Base {
|
||||
|
||||
/**
|
||||
* Set up groups of files as sources
|
||||
*
|
||||
* @param array $options controller and Minify options
|
||||
* @return array Minify options
|
||||
*
|
||||
*/
|
||||
public function setupSources($options) {
|
||||
self::_setupDefines();
|
||||
if (MINIFY_USE_CACHE) {
|
||||
$cacheDir = defined('MINIFY_CACHE_DIR')
|
||||
? MINIFY_CACHE_DIR
|
||||
: '';
|
||||
Minify::setCache($cacheDir);
|
||||
}
|
||||
$options['badRequestHeader'] = 'HTTP/1.0 404 Not Found';
|
||||
$options['contentTypeCharset'] = MINIFY_ENCODING;
|
||||
|
||||
// The following restrictions are to limit the URLs that minify will
|
||||
// respond to. Ideally there should be only one way to reference a file.
|
||||
if (! isset($_GET['files'])
|
||||
// verify at least one file, files are single comma separated,
|
||||
// and are all same extension
|
||||
|| ! preg_match('/^[^,]+\\.(css|js)(,[^,]+\\.\\1)*$/', $_GET['files'], $m)
|
||||
// no "//" (makes URL rewriting easier)
|
||||
|| strpos($_GET['files'], '//') !== false
|
||||
// no "\"
|
||||
|| strpos($_GET['files'], '\\') !== false
|
||||
// no "./"
|
||||
|| preg_match('/(?:^|[^\\.])\\.\\//', $_GET['files'])
|
||||
) {
|
||||
return $options;
|
||||
}
|
||||
$extension = $m[1];
|
||||
|
||||
$files = explode(',', $_GET['files']);
|
||||
if (count($files) > MINIFY_MAX_FILES) {
|
||||
return $options;
|
||||
}
|
||||
|
||||
// strings for prepending to relative/absolute paths
|
||||
$prependRelPaths = dirname($_SERVER['SCRIPT_FILENAME'])
|
||||
. DIRECTORY_SEPARATOR;
|
||||
$prependAbsPaths = $_SERVER['DOCUMENT_ROOT'];
|
||||
|
||||
$sources = array();
|
||||
$goodFiles = array();
|
||||
$hasBadSource = false;
|
||||
|
||||
$allowDirs = isset($options['allowDirs'])
|
||||
? $options['allowDirs']
|
||||
: MINIFY_BASE_DIR;
|
||||
|
||||
foreach ($files as $file) {
|
||||
// prepend appropriate string for abs/rel paths
|
||||
$file = ($file[0] === '/' ? $prependAbsPaths : $prependRelPaths) . $file;
|
||||
// make sure a real file!
|
||||
$file = realpath($file);
|
||||
// don't allow unsafe or duplicate files
|
||||
if (parent::_fileIsSafe($file, $allowDirs)
|
||||
&& !in_array($file, $goodFiles))
|
||||
{
|
||||
$goodFiles[] = $file;
|
||||
$srcOptions = array(
|
||||
'filepath' => $file
|
||||
);
|
||||
$this->sources[] = new Minify_Source($srcOptions);
|
||||
} else {
|
||||
$hasBadSource = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($hasBadSource) {
|
||||
$this->sources = array();
|
||||
}
|
||||
if (! MINIFY_REWRITE_CSS_URLS) {
|
||||
$options['rewriteCssUris'] = false;
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
private static function _setupDefines()
|
||||
{
|
||||
$defaults = array(
|
||||
'MINIFY_BASE_DIR' => realpath($_SERVER['DOCUMENT_ROOT'])
|
||||
,'MINIFY_ENCODING' => 'utf-8'
|
||||
,'MINIFY_MAX_FILES' => 16
|
||||
,'MINIFY_REWRITE_CSS_URLS' => true
|
||||
,'MINIFY_USE_CACHE' => true
|
||||
);
|
||||
foreach ($defaults as $const => $val) {
|
||||
if (! defined($const)) {
|
||||
define($const, $val);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,248 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Class Minify_HTML
|
||||
* @package Minify
|
||||
*/
|
||||
|
||||
/**
|
||||
* Compress HTML
|
||||
*
|
||||
* This is a heavy regex-based removal of whitespace, unnecessary comments and
|
||||
* tokens. IE conditional comments are preserved. There are also options to have
|
||||
* STYLE and SCRIPT blocks compressed by callback functions.
|
||||
*
|
||||
* A test suite is available.
|
||||
*
|
||||
* @package Minify
|
||||
* @author Stephen Clay <steve@mrclay.org>
|
||||
*/
|
||||
class Minify_HTML {
|
||||
|
||||
/**
|
||||
* "Minify" an HTML page
|
||||
*
|
||||
* @param string $html
|
||||
*
|
||||
* @param array $options
|
||||
*
|
||||
* 'cssMinifier' : (optional) callback function to process content of STYLE
|
||||
* elements.
|
||||
*
|
||||
* 'jsMinifier' : (optional) callback function to process content of SCRIPT
|
||||
* elements. Note: the type attribute is ignored.
|
||||
*
|
||||
* 'xhtml' : (optional boolean) should content be treated as XHTML1.0? If
|
||||
* unset, minify will sniff for an XHTML doctype.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function minify($html, $options = array()) {
|
||||
$min = new Minify_HTML($html, $options);
|
||||
|
||||
return $min->process();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a minifier object
|
||||
*
|
||||
* @param string $html
|
||||
*
|
||||
* @param array $options
|
||||
*
|
||||
* 'cssMinifier' : (optional) callback function to process content of STYLE
|
||||
* elements.
|
||||
*
|
||||
* 'jsMinifier' : (optional) callback function to process content of SCRIPT
|
||||
* elements. Note: the type attribute is ignored.
|
||||
*
|
||||
* 'xhtml' : (optional boolean) should content be treated as XHTML1.0? If
|
||||
* unset, minify will sniff for an XHTML doctype.
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public function __construct($html, $options = array())
|
||||
{
|
||||
$this->_html = str_replace("\r\n", "\n", trim($html));
|
||||
if (isset($options['xhtml'])) {
|
||||
$this->_isXhtml = (bool)$options['xhtml'];
|
||||
}
|
||||
if (isset($options['cssMinifier'])) {
|
||||
$this->_cssMinifier = $options['cssMinifier'];
|
||||
}
|
||||
if (isset($options['jsMinifier'])) {
|
||||
$this->_jsMinifier = $options['jsMinifier'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Minify the markeup given in the constructor
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function process()
|
||||
{
|
||||
if ($this->_isXhtml === null) {
|
||||
$this->_isXhtml = (false !== strpos($this->_html, '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML'));
|
||||
}
|
||||
|
||||
$this->_replacementHash = 'MINIFYHTML' . md5($_SERVER['REQUEST_TIME']);
|
||||
$this->_placeholders = array();
|
||||
|
||||
// replace SCRIPTs (and minify) with placeholders
|
||||
$this->_html = preg_replace_callback(
|
||||
'/(\\s*)(<script\\b[^>]*?>)([\\s\\S]*?)<\\/script>(\\s*)/i'
|
||||
,array($this, '_removeScriptCB')
|
||||
,$this->_html);
|
||||
|
||||
// replace STYLEs (and minify) with placeholders
|
||||
$this->_html = preg_replace_callback(
|
||||
'/\\s*(<style\\b[^>]*?>)([\\s\\S]*?)<\\/style>\\s*/i'
|
||||
,array($this, '_removeStyleCB')
|
||||
,$this->_html);
|
||||
|
||||
// remove HTML comments (not containing IE conditional comments).
|
||||
$this->_html = preg_replace_callback(
|
||||
'/<!--([\\s\\S]*?)-->/'
|
||||
,array($this, '_commentCB')
|
||||
,$this->_html);
|
||||
|
||||
// replace PREs with placeholders
|
||||
$this->_html = preg_replace_callback('/\\s*(<pre\\b[^>]*?>[\\s\\S]*?<\\/pre>)\\s*/i'
|
||||
,array($this, '_removePreCB')
|
||||
,$this->_html);
|
||||
|
||||
// replace TEXTAREAs with placeholders
|
||||
$this->_html = preg_replace_callback(
|
||||
'/\\s*(<textarea\\b[^>]*?>[\\s\\S]*?<\\/textarea>)\\s*/i'
|
||||
,array($this, '_removeTextareaCB')
|
||||
,$this->_html);
|
||||
|
||||
// trim each line.
|
||||
// @todo take into account attribute values that span multiple lines.
|
||||
$this->_html = preg_replace('/^\\s+|\\s+$/m', '', $this->_html);
|
||||
|
||||
// remove ws around block/undisplayed elements
|
||||
$this->_html = preg_replace('/\\s+(<\\/?(?:area|base(?:font)?|blockquote|body'
|
||||
.'|caption|center|cite|col(?:group)?|dd|dir|div|dl|dt|fieldset|form'
|
||||
.'|frame(?:set)?|h[1-6]|head|hr|html|legend|li|link|map|menu|meta'
|
||||
.'|ol|opt(?:group|ion)|p|param|t(?:able|body|head|d|h||r|foot|itle)'
|
||||
.'|ul)\\b[^>]*>)/i', '$1', $this->_html);
|
||||
|
||||
// remove ws outside of all elements
|
||||
$this->_html = preg_replace_callback(
|
||||
'/>([^<]+)</'
|
||||
,array($this, '_outsideTagCB')
|
||||
,$this->_html);
|
||||
|
||||
// use newlines before 1st attribute in open tags (to limit line lengths)
|
||||
$this->_html = preg_replace('/(<[a-z\\-]+)\\s+([^>]+>)/i', "$1\n$2", $this->_html);
|
||||
|
||||
// fill placeholders
|
||||
$this->_html = str_replace(
|
||||
array_keys($this->_placeholders)
|
||||
,array_values($this->_placeholders)
|
||||
,$this->_html
|
||||
);
|
||||
|
||||
return $this->_html;
|
||||
}
|
||||
|
||||
protected function _commentCB($m)
|
||||
{
|
||||
return (0 === strpos($m[1], '[') || false !== strpos($m[1], '<!['))
|
||||
? $m[0]
|
||||
: '';
|
||||
}
|
||||
|
||||
protected function _reservePlace($content)
|
||||
{
|
||||
$placeholder = '%' . $this->_replacementHash . count($this->_placeholders) . '%';
|
||||
$this->_placeholders[$placeholder] = $content;
|
||||
|
||||
return $placeholder;
|
||||
}
|
||||
|
||||
protected $_isXhtml = null;
|
||||
protected $_replacementHash = null;
|
||||
protected $_placeholders = array();
|
||||
protected $_cssMinifier = null;
|
||||
protected $_jsMinifier = null;
|
||||
|
||||
protected function _outsideTagCB($m)
|
||||
{
|
||||
return '>' . preg_replace('/^\\s+|\\s+$/', ' ', $m[1]) . '<';
|
||||
}
|
||||
|
||||
protected function _removePreCB($m)
|
||||
{
|
||||
return $this->_reservePlace($m[1]);
|
||||
}
|
||||
|
||||
protected function _removeTextareaCB($m)
|
||||
{
|
||||
return $this->_reservePlace($m[1]);
|
||||
}
|
||||
|
||||
protected function _removeStyleCB($m)
|
||||
{
|
||||
$openStyle = $m[1];
|
||||
$css = $m[2];
|
||||
// remove HTML comments
|
||||
$css = preg_replace('/(?:^\\s*<!--|-->\\s*$)/', '', $css);
|
||||
|
||||
// remove CDATA section markers
|
||||
$css = $this->_removeCdata($css);
|
||||
|
||||
// minify
|
||||
$minifier = $this->_cssMinifier
|
||||
? $this->_cssMinifier
|
||||
: 'trim';
|
||||
$css = call_user_func($minifier, $css);
|
||||
|
||||
return $this->_reservePlace($this->_needsCdata($css)
|
||||
? "{$openStyle}/*<![CDATA[*/{$css}/*]]>*/</style>"
|
||||
: "{$openStyle}{$css}</style>"
|
||||
);
|
||||
}
|
||||
|
||||
protected function _removeScriptCB($m)
|
||||
{
|
||||
$openScript = $m[2];
|
||||
$js = $m[3];
|
||||
|
||||
// whitespace surrounding? preserve at least one space
|
||||
$ws1 = ($m[1] === '') ? '' : ' ';
|
||||
$ws2 = ($m[4] === '') ? '' : ' ';
|
||||
|
||||
// remove HTML comments (and ending "//" if present)
|
||||
$js = preg_replace('/(?:^\\s*<!--\\s*|\\s*(?:\\/\\/)?\\s*-->\\s*$)/', '', $js);
|
||||
|
||||
// remove CDATA section markers
|
||||
$js = $this->_removeCdata($js);
|
||||
|
||||
// minify
|
||||
$minifier = $this->_jsMinifier
|
||||
? $this->_jsMinifier
|
||||
: 'trim';
|
||||
$js = call_user_func($minifier, $js);
|
||||
|
||||
return $this->_reservePlace($this->_needsCdata($js)
|
||||
? "{$ws1}{$openScript}/*<![CDATA[*/{$js}/*]]>*/</script>{$ws2}"
|
||||
: "{$ws1}{$openScript}{$js}</script>{$ws2}"
|
||||
);
|
||||
}
|
||||
|
||||
protected function _removeCdata($str)
|
||||
{
|
||||
return (false !== strpos($str, '<![CDATA['))
|
||||
? str_replace(array('<![CDATA[', ']]>'), '', $str)
|
||||
: $str;
|
||||
}
|
||||
|
||||
protected function _needsCdata($str)
|
||||
{
|
||||
return ($this->_isXhtml && preg_match('/(?:[<&]|\\-\\-|\\]\\]>)/', $str));
|
||||
}
|
||||
}
|
@@ -1,160 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Class Minify_ImportProcessor
|
||||
* @package Minify
|
||||
*/
|
||||
|
||||
/**
|
||||
* Linearize a CSS/JS file by including content specified by CSS import
|
||||
* declarations. In CSS files, relative URIs are fixed.
|
||||
*
|
||||
* @imports will be processed regardless of where they appear in the source
|
||||
* files; i.e. @imports commented out or in string content will still be
|
||||
* processed!
|
||||
*
|
||||
* This has a unit test but should be considered "experimental".
|
||||
*
|
||||
* @package Minify
|
||||
* @author Stephen Clay <steve@mrclay.org>
|
||||
*/
|
||||
class Minify_ImportProcessor {
|
||||
|
||||
public static $filesIncluded = array();
|
||||
|
||||
public static function process($file)
|
||||
{
|
||||
self::$filesIncluded = array();
|
||||
self::$_isCss = (strtolower(substr($file, -4)) === '.css');
|
||||
$obj = new Minify_ImportProcessor(dirname($file));
|
||||
|
||||
return $obj->_getContent($file);
|
||||
}
|
||||
|
||||
// allows callback funcs to know the current directory
|
||||
private $_currentDir = null;
|
||||
|
||||
// allows _importCB to write the fetched content back to the obj
|
||||
private $_importedContent = '';
|
||||
|
||||
private static $_isCss = null;
|
||||
|
||||
private function __construct($currentDir)
|
||||
{
|
||||
$this->_currentDir = $currentDir;
|
||||
}
|
||||
|
||||
private function _getContent($file)
|
||||
{
|
||||
$file = realpath($file);
|
||||
if (! $file
|
||||
|| in_array($file, self::$filesIncluded)
|
||||
|| false === ($content = @file_get_contents($file))
|
||||
) {
|
||||
// file missing, already included, or failed read
|
||||
return '';
|
||||
}
|
||||
self::$filesIncluded[] = realpath($file);
|
||||
$this->_currentDir = dirname($file);
|
||||
|
||||
// remove UTF-8 BOM if present
|
||||
if (pack("CCC",0xef,0xbb,0xbf) === substr($content, 0, 3)) {
|
||||
$content = substr($content, 3);
|
||||
}
|
||||
// ensure uniform EOLs
|
||||
$content = str_replace("\r\n", "\n", $content);
|
||||
|
||||
// process @imports
|
||||
$content = preg_replace_callback(
|
||||
'/
|
||||
@import\\s+
|
||||
(?:url\\(\\s*)? # maybe url(
|
||||
[\'"]? # maybe quote
|
||||
(.*?) # 1 = URI
|
||||
[\'"]? # maybe end quote
|
||||
(?:\\s*\\))? # maybe )
|
||||
([a-zA-Z,\\s]*)? # 2 = media list
|
||||
; # end token
|
||||
/x'
|
||||
,array($this, '_importCB')
|
||||
,$content
|
||||
);
|
||||
|
||||
if (self::$_isCss) {
|
||||
// rewrite remaining relative URIs
|
||||
$content = preg_replace_callback(
|
||||
'/url\\(\\s*([^\\)\\s]+)\\s*\\)/'
|
||||
,array($this, '_urlCB')
|
||||
,$content
|
||||
);
|
||||
}
|
||||
|
||||
return $this->_importedContent . $content;
|
||||
}
|
||||
|
||||
private function _importCB($m)
|
||||
{
|
||||
$url = $m[1];
|
||||
$mediaList = preg_replace('/\\s+/', '', $m[2]);
|
||||
|
||||
if (strpos($url, '://') > 0) {
|
||||
// protocol, leave in place for CSS, comment for JS
|
||||
return self::$_isCss
|
||||
? $m[0]
|
||||
: "/* Minify_ImportProcessor will not include remote content */";
|
||||
}
|
||||
if ('/' === $url[0]) {
|
||||
// protocol-relative or root path
|
||||
$url = ltrim($url, '/');
|
||||
$file = realpath($_SERVER['DOCUMENT_ROOT']) . DIRECTORY_SEPARATOR
|
||||
. strtr($url, '/', DIRECTORY_SEPARATOR);
|
||||
} else {
|
||||
// relative to current path
|
||||
$file = $this->_currentDir . DIRECTORY_SEPARATOR
|
||||
. strtr($url, '/', DIRECTORY_SEPARATOR);
|
||||
}
|
||||
$obj = new Minify_ImportProcessor(dirname($file));
|
||||
$content = $obj->_getContent($file);
|
||||
if ('' === $content) {
|
||||
// failed. leave in place for CSS, comment for JS
|
||||
return self::$_isCss
|
||||
? $m[0]
|
||||
: "/* Minify_ImportProcessor could not fetch '{$file}' */";;
|
||||
}
|
||||
|
||||
return (!self::$_isCss || preg_match('@(?:^$|\\ball\\b)@', $mediaList))
|
||||
? $content
|
||||
: "@media {$mediaList} {\n{$content}\n}\n";
|
||||
}
|
||||
|
||||
private function _urlCB($m)
|
||||
{
|
||||
// $m[1] is either quoted or not
|
||||
$quote = ($m[1][0] === "'" || $m[1][0] === '"')
|
||||
? $m[1][0]
|
||||
: '';
|
||||
$url = ($quote === '')
|
||||
? $m[1]
|
||||
: substr($m[1], 1, strlen($m[1]) - 2);
|
||||
if ('/' !== $url[0]) {
|
||||
if (strpos($url, '//') > 0) {
|
||||
// probably starts with protocol, do not alter
|
||||
} else {
|
||||
// prepend path with current dir separator (OS-independent)
|
||||
$path = $this->_currentDir
|
||||
. DIRECTORY_SEPARATOR . strtr($url, '/', DIRECTORY_SEPARATOR);
|
||||
// strip doc root
|
||||
$path = substr($path, strlen(realpath($_SERVER['DOCUMENT_ROOT'])));
|
||||
// fix to absolute URL
|
||||
$url = strtr($path, '/\\', '//');
|
||||
// remove /./ and /../ where possible
|
||||
$url = str_replace('/./', '/', $url);
|
||||
// inspired by patch from Oleg Cherniy
|
||||
do {
|
||||
$url = preg_replace('@/[^/]+/\\.\\./@', '/', $url, 1, $changed);
|
||||
} while ($changed);
|
||||
}
|
||||
}
|
||||
|
||||
return "url({$quote}{$url}{$quote})";
|
||||
}
|
||||
}
|
@@ -1,132 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Class Minify_Lines
|
||||
* @package Minify
|
||||
*/
|
||||
|
||||
/**
|
||||
* Add line numbers in C-style comments for easier debugging of combined content
|
||||
*
|
||||
* @package Minify
|
||||
* @author Stephen Clay <steve@mrclay.org>
|
||||
* @author Adam Pedersen (Issue 55 fix)
|
||||
*/
|
||||
class Minify_Lines {
|
||||
|
||||
/**
|
||||
* Add line numbers in C-style comments
|
||||
*
|
||||
* This uses a very basic parser easily fooled by comment tokens inside
|
||||
* strings or regexes, but, otherwise, generally clean code will not be
|
||||
* mangled. URI rewriting can also be performed.
|
||||
*
|
||||
* @param string $content
|
||||
*
|
||||
* @param array $options available options:
|
||||
*
|
||||
* 'id': (optional) string to identify file. E.g. file name/path
|
||||
*
|
||||
* 'currentDir': (default null) if given, this is assumed to be the
|
||||
* directory of the current CSS file. Using this, minify will rewrite
|
||||
* all relative URIs in import/url declarations to correctly point to
|
||||
* the desired files, and prepend a comment with debugging information about
|
||||
* this process.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function minify($content, $options = array())
|
||||
{
|
||||
$id = (isset($options['id']) && $options['id'])
|
||||
? $options['id']
|
||||
: '';
|
||||
$content = str_replace("\r\n", "\n", $content);
|
||||
$lines = explode("\n", $content);
|
||||
$numLines = count($lines);
|
||||
// determine left padding
|
||||
$padTo = strlen($numLines);
|
||||
$inComment = false;
|
||||
$i = 0;
|
||||
$newLines = array();
|
||||
while (null !== ($line = array_shift($lines))) {
|
||||
if (('' !== $id) && (0 == $i % 50)) {
|
||||
array_push($newLines, '', "/* {$id} */", '');
|
||||
}
|
||||
++$i;
|
||||
$newLines[] = self::_addNote($line, $i, $inComment, $padTo);
|
||||
$inComment = self::_eolInComment($line, $inComment);
|
||||
}
|
||||
$content = implode("\n", $newLines) . "\n";
|
||||
|
||||
// check for desired URI rewriting
|
||||
if (isset($options['currentDir'])) {
|
||||
require_once 'Minify/CSS/UriRewriter.php';
|
||||
Minify_CSS_UriRewriter::$debugText = '';
|
||||
$content = Minify_CSS_UriRewriter::rewrite(
|
||||
$content
|
||||
,$options['currentDir']
|
||||
,isset($options['docRoot']) ? $options['docRoot'] : $_SERVER['DOCUMENT_ROOT']
|
||||
,isset($options['symlinks']) ? $options['symlinks'] : array()
|
||||
);
|
||||
$content = "/* Minify_CSS_UriRewriter::\$debugText\n\n"
|
||||
. Minify_CSS_UriRewriter::$debugText . "*/\n"
|
||||
. $content;
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the parser within a C-style comment at the end of this line?
|
||||
*
|
||||
* @param string $line current line of code
|
||||
*
|
||||
* @param bool $inComment was the parser in a comment at the
|
||||
* beginning of the line?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private static function _eolInComment($line, $inComment)
|
||||
{
|
||||
while (strlen($line)) {
|
||||
$search = $inComment
|
||||
? '*/'
|
||||
: '/*';
|
||||
$pos = strpos($line, $search);
|
||||
if (false === $pos) {
|
||||
return $inComment;
|
||||
} else {
|
||||
if ($pos == 0
|
||||
|| ($inComment
|
||||
? substr($line, $pos, 3)
|
||||
: substr($line, $pos-1, 3)) != '*/*')
|
||||
{
|
||||
$inComment = ! $inComment;
|
||||
}
|
||||
$line = substr($line, $pos + 2);
|
||||
}
|
||||
}
|
||||
|
||||
return $inComment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepend a comment (or note) to the given line
|
||||
*
|
||||
* @param string $line current line of code
|
||||
*
|
||||
* @param string $note content of note/comment
|
||||
*
|
||||
* @param bool $inComment was the parser in a comment at the
|
||||
* beginning of the line?
|
||||
*
|
||||
* @param int $padTo minimum width of comment
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private static function _addNote($line, $note, $inComment, $padTo)
|
||||
{
|
||||
return $inComment
|
||||
? '/* ' . str_pad($note, $padTo, ' ', STR_PAD_RIGHT) . ' *| ' . $line
|
||||
: '/* ' . str_pad($note, $padTo, ' ', STR_PAD_RIGHT) . ' */ ' . $line;
|
||||
}
|
||||
}
|
@@ -1,45 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Class Minify_Logger
|
||||
* @package Minify
|
||||
*/
|
||||
|
||||
/**
|
||||
* Message logging class
|
||||
*
|
||||
* @package Minify
|
||||
* @author Stephen Clay <steve@mrclay.org>
|
||||
*/
|
||||
class Minify_Logger {
|
||||
|
||||
/**
|
||||
* Set logger object.
|
||||
*
|
||||
* The object should have a method "log" that accepts a value as 1st argument and
|
||||
* an optional string label as the 2nd.
|
||||
*
|
||||
* @param mixed $obj or a "falsey" value to disable
|
||||
* @return null
|
||||
*/
|
||||
public static function setLogger($obj = null) {
|
||||
self::$_logger = $obj
|
||||
? $obj
|
||||
: null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pass a message to the logger (if set)
|
||||
*
|
||||
* @param string $msg message to log
|
||||
* @return null
|
||||
*/
|
||||
public static function log($msg, $label = 'Minify') {
|
||||
if (! self::$_logger) return;
|
||||
self::$_logger->log($msg, $label);
|
||||
}
|
||||
|
||||
/**
|
||||
* @var mixed logger object (like FirePHP) or null (i.e. no logger available)
|
||||
*/
|
||||
private static $_logger = null;
|
||||
}
|
@@ -1,38 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Class Minify_Packer
|
||||
*
|
||||
* To use this class you must first download the PHP port of Packer
|
||||
* and place the file "class.JavaScriptPacker.php" in /lib (or your
|
||||
* include_path).
|
||||
* @link http://joliclic.free.fr/php/javascript-packer/en/
|
||||
*
|
||||
* Be aware that, as long as HTTP encoding is used, scripts minified with JSMin
|
||||
* will provide better client-side performance, as they need not be unpacked in
|
||||
* client-side code.
|
||||
*
|
||||
* @package Minify
|
||||
*/
|
||||
|
||||
if (false === (@include 'class.JavaScriptPacker.php')) {
|
||||
trigger_error(
|
||||
'The script "class.JavaScriptPacker.php" is required. Please see: http:'
|
||||
.'//code.google.com/p/minify/source/browse/trunk/min/lib/Minify/Packer.php'
|
||||
,E_USER_ERROR
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Minify Javascript using Dean Edward's Packer
|
||||
*
|
||||
* @package Minify
|
||||
*/
|
||||
class Minify_Packer {
|
||||
public static function minify($code, $options = array())
|
||||
{
|
||||
// @todo: set encoding options based on $options :)
|
||||
$packer = new JavascriptPacker($code, 'Normal', true, false);
|
||||
|
||||
return trim($packer->pack());
|
||||
}
|
||||
}
|
@@ -1,190 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Class Minify_Source
|
||||
* @package Minify
|
||||
*/
|
||||
|
||||
/**
|
||||
* A content source to be minified by Minify.
|
||||
*
|
||||
* This allows per-source minification options and the mixing of files with
|
||||
* content from other sources.
|
||||
*
|
||||
* @package Minify
|
||||
* @author Stephen Clay <steve@mrclay.org>
|
||||
*/
|
||||
class Minify_Source {
|
||||
|
||||
/**
|
||||
* @var int time of last modification
|
||||
*/
|
||||
public $lastModified = null;
|
||||
|
||||
/**
|
||||
* @var callback minifier function specifically for this source.
|
||||
*/
|
||||
public $minifier = null;
|
||||
|
||||
/**
|
||||
* @var array minification options specific to this source.
|
||||
*/
|
||||
public $minifyOptions = null;
|
||||
|
||||
/**
|
||||
* @var string full path of file
|
||||
*/
|
||||
public $filepath = null;
|
||||
|
||||
/**
|
||||
* @var string HTTP Content Type (Minify requires one of the constants Minify::TYPE_*)
|
||||
*/
|
||||
public $contentType = null;
|
||||
|
||||
/**
|
||||
* Create a Minify_Source
|
||||
*
|
||||
* In the $spec array(), you can either provide a 'filepath' to an existing
|
||||
* file (existence will not be checked!) or give 'id' (unique string for
|
||||
* the content), 'content' (the string content) and 'lastModified'
|
||||
* (unixtime of last update).
|
||||
*
|
||||
* As a shortcut, the controller will replace "//" at the beginning
|
||||
* of a filepath with $_SERVER['DOCUMENT_ROOT'] . '/'.
|
||||
*
|
||||
* @param array $spec options
|
||||
*/
|
||||
public function __construct($spec)
|
||||
{
|
||||
if (isset($spec['filepath'])) {
|
||||
if (0 === strpos($spec['filepath'], '//')) {
|
||||
$spec['filepath'] = $_SERVER['DOCUMENT_ROOT'] . substr($spec['filepath'], 1);
|
||||
}
|
||||
$segments = explode('.', $spec['filepath']);
|
||||
$ext = strtolower(array_pop($segments));
|
||||
switch ($ext) {
|
||||
case 'js' : $this->contentType = 'application/x-javascript';
|
||||
break;
|
||||
case 'css' : $this->contentType = 'text/css';
|
||||
break;
|
||||
case 'htm' : // fallthrough
|
||||
case 'html' : $this->contentType = 'text/html';
|
||||
break;
|
||||
}
|
||||
$this->filepath = $spec['filepath'];
|
||||
$this->_id = $spec['filepath'];
|
||||
$this->lastModified = filemtime($spec['filepath'])
|
||||
// offset for Windows uploaders with out of sync clocks
|
||||
+ round(Minify::$uploaderHoursBehind * 3600);
|
||||
} elseif (isset($spec['id'])) {
|
||||
$this->_id = 'id::' . $spec['id'];
|
||||
if (isset($spec['content'])) {
|
||||
$this->_content = $spec['content'];
|
||||
} else {
|
||||
$this->_getContentFunc = $spec['getContentFunc'];
|
||||
}
|
||||
$this->lastModified = isset($spec['lastModified'])
|
||||
? $spec['lastModified']
|
||||
: time();
|
||||
}
|
||||
if (isset($spec['contentType'])) {
|
||||
$this->contentType = $spec['contentType'];
|
||||
}
|
||||
if (isset($spec['minifier'])) {
|
||||
$this->minifier = $spec['minifier'];
|
||||
}
|
||||
if (isset($spec['minifyOptions'])) {
|
||||
$this->minifyOptions = $spec['minifyOptions'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get content
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getContent()
|
||||
{
|
||||
$content = (null !== $this->filepath)
|
||||
? file_get_contents($this->filepath)
|
||||
: ((null !== $this->_content)
|
||||
? $this->_content
|
||||
: call_user_func($this->_getContentFunc, $this->_id)
|
||||
);
|
||||
// remove UTF-8 BOM if present
|
||||
return (pack("CCC",0xef,0xbb,0xbf) === substr($content, 0, 3))
|
||||
? substr($content, 3)
|
||||
: $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get id
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies a single minification call can handle all sources
|
||||
*
|
||||
* @param array $sources Minify_Source instances
|
||||
*
|
||||
* @return bool true iff there no sources with specific minifier preferences.
|
||||
*/
|
||||
public static function haveNoMinifyPrefs($sources)
|
||||
{
|
||||
foreach ($sources as $source) {
|
||||
if (null !== $source->minifier
|
||||
|| null !== $source->minifyOptions) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get unique string for a set of sources
|
||||
*
|
||||
* @param array $sources Minify_Source instances
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getDigest($sources)
|
||||
{
|
||||
foreach ($sources as $source) {
|
||||
$info[] = array(
|
||||
$source->_id, $source->minifier, $source->minifyOptions
|
||||
);
|
||||
}
|
||||
|
||||
return md5(serialize($info));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get content type from a group of sources
|
||||
*
|
||||
* This is called if the user doesn't pass in a 'contentType' options
|
||||
*
|
||||
* @param array $sources Minify_Source instances
|
||||
*
|
||||
* @return string content type. e.g. 'text/css'
|
||||
*/
|
||||
public static function getContentType($sources)
|
||||
{
|
||||
foreach ($sources as $source) {
|
||||
if ($source->contentType !== null) {
|
||||
return $source->contentType;
|
||||
}
|
||||
}
|
||||
|
||||
return 'text/plain';
|
||||
}
|
||||
|
||||
protected $_content = null;
|
||||
protected $_getContentFunc = null;
|
||||
protected $_id = null;
|
||||
}
|
||||
|
@@ -1,141 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Class Minify_YUICompressor
|
||||
* @package Minify
|
||||
*/
|
||||
|
||||
/**
|
||||
* Compress Javascript/CSS using the YUI Compressor
|
||||
*
|
||||
* You must set $jarFile and $tempDir before calling the minify functions.
|
||||
* Also, depending on your shell's environment, you may need to specify
|
||||
* the full path to java in $javaExecutable or use putenv() to setup the
|
||||
* Java environment.
|
||||
*
|
||||
* <code>
|
||||
* Minify_YUICompressor::$jarFile = '/path/to/yuicompressor-2.3.5.jar';
|
||||
* Minify_YUICompressor::$tempDir = '/tmp';
|
||||
* $code = Minify_YUICompressor::minifyJs(
|
||||
* $code
|
||||
* ,array('nomunge' => true, 'line-break' => 1000)
|
||||
* );
|
||||
* </code>
|
||||
*
|
||||
* @todo unit tests, $options docs
|
||||
*
|
||||
* @package Minify
|
||||
* @author Stephen Clay <steve@mrclay.org>
|
||||
*/
|
||||
class Minify_YUICompressor {
|
||||
|
||||
/**
|
||||
* Filepath of the YUI Compressor jar file. This must be set before
|
||||
* calling minifyJs() or minifyCss().
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public static $jarFile = null;
|
||||
|
||||
/**
|
||||
* Writable temp directory. This must be set before calling minifyJs()
|
||||
* or minifyCss().
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public static $tempDir = null;
|
||||
|
||||
/**
|
||||
* Filepath of "java" executable (may be needed if not in shell's PATH)
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public static $javaExecutable = 'java';
|
||||
|
||||
/**
|
||||
* Minify a Javascript string
|
||||
*
|
||||
* @param string $js
|
||||
*
|
||||
* @param array $options (verbose is ignored)
|
||||
*
|
||||
* @see http://www.julienlecomte.net/yuicompressor/README
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function minifyJs($js, $options = array())
|
||||
{
|
||||
return self::_minify('js', $js, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Minify a CSS string
|
||||
*
|
||||
* @param string $css
|
||||
*
|
||||
* @param array $options (verbose is ignored)
|
||||
*
|
||||
* @see http://www.julienlecomte.net/yuicompressor/README
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function minifyCss($css, $options = array())
|
||||
{
|
||||
return self::_minify('css', $css, $options);
|
||||
}
|
||||
|
||||
private static function _minify($type, $content, $options)
|
||||
{
|
||||
self::_prepare();
|
||||
if (! ($tmpFile = tempnam(self::$tempDir, 'yuic_'))) {
|
||||
throw new Exception('Minify_YUICompressor : could not create temp file.');
|
||||
}
|
||||
file_put_contents($tmpFile, $content);
|
||||
exec(self::_getCmd($options, $type, $tmpFile), $output);
|
||||
unlink($tmpFile);
|
||||
|
||||
return implode("\n", $output);
|
||||
}
|
||||
|
||||
private static function _getCmd($userOptions, $type, $tmpFile)
|
||||
{
|
||||
$o = array_merge(
|
||||
array(
|
||||
'charset' => ''
|
||||
,'line-break' => 5000
|
||||
,'type' => $type
|
||||
,'nomunge' => false
|
||||
,'preserve-semi' => false
|
||||
,'disable-optimizations' => false
|
||||
)
|
||||
,$userOptions
|
||||
);
|
||||
$cmd = self::$javaExecutable . ' -jar ' . escapeshellarg(self::$jarFile)
|
||||
. " --type {$type}"
|
||||
. (preg_match('/^[a-zA-Z\\-]+$/', $o['charset'])
|
||||
? " --charset {$o['charset']}"
|
||||
: '')
|
||||
. (is_numeric($o['line-break']) && $o['line-break'] >= 0
|
||||
? ' --line-break ' . (int)$o['line-break']
|
||||
: '');
|
||||
if ($type === 'js') {
|
||||
foreach (array('nomunge', 'preserve-semi', 'disable-optimizations') as $opt) {
|
||||
$cmd .= $o[$opt]
|
||||
? " --{$opt}"
|
||||
: '';
|
||||
}
|
||||
}
|
||||
|
||||
return $cmd . ' ' . escapeshellarg($tmpFile);
|
||||
}
|
||||
|
||||
private static function _prepare()
|
||||
{
|
||||
if (! is_file(self::$jarFile)
|
||||
|| ! is_dir(self::$tempDir)
|
||||
|| ! is_writable(self::$tempDir)
|
||||
) {
|
||||
throw new Exception('Minify_YUICompressor : $jarFile and $tempDir must be set.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,201 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* Utility class for static directory methods.
|
||||
*
|
||||
* @category Solar
|
||||
*
|
||||
* @package Solar
|
||||
*
|
||||
* @author Paul M. Jones <pmjones@solarphp.com>
|
||||
*
|
||||
* @license http://opensource.org/licenses/bsd-license.php BSD
|
||||
*
|
||||
* @version $Id: Dir.php 2926 2007-11-09 16:25:44Z pmjones $
|
||||
*
|
||||
*/
|
||||
class Solar_Dir {
|
||||
|
||||
/**
|
||||
*
|
||||
* The OS-specific temporary directory location.
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
*/
|
||||
protected static $_tmp;
|
||||
|
||||
/**
|
||||
*
|
||||
* Hack for [[php::is_dir() | ]] that checks the include_path.
|
||||
*
|
||||
* Use this to see if a directory exists anywhere in the include_path.
|
||||
*
|
||||
* {{code: php
|
||||
* $dir = Solar_Dir::exists('path/to/dir')
|
||||
* if ($dir) {
|
||||
* $files = scandir($dir);
|
||||
* } else {
|
||||
* echo "Not found in the include-path.";
|
||||
* }
|
||||
* }}
|
||||
*
|
||||
* @param string $dir Check for this directory in the include_path.
|
||||
*
|
||||
* @return mixed If the directory exists in the include_path, returns the
|
||||
* absolute path; if not, returns boolean false.
|
||||
*
|
||||
*/
|
||||
public static function exists($dir)
|
||||
{
|
||||
// no file requested?
|
||||
$dir = trim($dir);
|
||||
if (! $dir) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// using an absolute path for the file?
|
||||
// dual check for Unix '/' and Windows '\',
|
||||
// or Windows drive letter and a ':'.
|
||||
$abs = ($dir[0] == '/' || $dir[0] == '\\' || $dir[1] == ':');
|
||||
if ($abs && is_dir($dir)) {
|
||||
return $dir;
|
||||
}
|
||||
|
||||
// using a relative path on the file
|
||||
$path = explode(PATH_SEPARATOR, ini_get('include_path'));
|
||||
foreach ($path as $base) {
|
||||
// strip Unix '/' and Windows '\'
|
||||
$target = rtrim($base, '\\/') . DIRECTORY_SEPARATOR . $dir;
|
||||
if (is_dir($target)) {
|
||||
return $target;
|
||||
}
|
||||
}
|
||||
|
||||
// never found it
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* "Fixes" a directory string for the operating system.
|
||||
*
|
||||
* Use slashes anywhere you need a directory separator. Then run the
|
||||
* string through fixdir() and the slashes will be converted to the
|
||||
* proper separator (for example '\' on Windows).
|
||||
*
|
||||
* Always adds a final trailing separator.
|
||||
*
|
||||
* @param string $dir The directory string to 'fix'.
|
||||
*
|
||||
* @return string The "fixed" directory string.
|
||||
*
|
||||
*/
|
||||
public static function fix($dir)
|
||||
{
|
||||
$dir = str_replace('/', DIRECTORY_SEPARATOR, $dir);
|
||||
|
||||
return rtrim($dir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Convenience method for dirname() and higher-level directories.
|
||||
*
|
||||
* @param string $file Get the dirname() of this file.
|
||||
*
|
||||
* @param int $up Move up in the directory structure this many
|
||||
* times, default 0.
|
||||
*
|
||||
* @return string The dirname() of the file.
|
||||
*
|
||||
*/
|
||||
public static function name($file, $up = 0)
|
||||
{
|
||||
$dir = dirname($file);
|
||||
while ($up --) {
|
||||
$dir = dirname($dir);
|
||||
}
|
||||
|
||||
return $dir;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Returns the OS-specific directory for temporary files.
|
||||
*
|
||||
* @param string $sub Add this subdirectory to the returned temporary
|
||||
* directory name.
|
||||
*
|
||||
* @return string The temporary directory path.
|
||||
*
|
||||
*/
|
||||
public static function tmp($sub = '')
|
||||
{
|
||||
// find the tmp dir if needed
|
||||
if (! Solar_Dir::$_tmp) {
|
||||
|
||||
// use the system if we can
|
||||
if (function_exists('sys_get_temp_dir')) {
|
||||
$tmp = sys_get_temp_dir();
|
||||
} else {
|
||||
$tmp = Solar_Dir::_tmp();
|
||||
}
|
||||
|
||||
// remove trailing separator and save
|
||||
Solar_Dir::$_tmp = rtrim($tmp, DIRECTORY_SEPARATOR);
|
||||
}
|
||||
|
||||
// do we have a subdirectory request?
|
||||
$sub = trim($sub);
|
||||
if ($sub) {
|
||||
// remove leading and trailing separators, and force exactly
|
||||
// one trailing separator
|
||||
$sub = trim($sub, DIRECTORY_SEPARATOR)
|
||||
. DIRECTORY_SEPARATOR;
|
||||
}
|
||||
|
||||
return Solar_Dir::$_tmp . DIRECTORY_SEPARATOR . $sub;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Returns the OS-specific temporary directory location.
|
||||
*
|
||||
* @return string The temp directory path.
|
||||
*
|
||||
*/
|
||||
protected static function _tmp()
|
||||
{
|
||||
// non-Windows system?
|
||||
if (strtolower(substr(PHP_OS, 0, 3)) != 'win') {
|
||||
$tmp = empty($_ENV['TMPDIR']) ? getenv('TMPDIR') : $_ENV['TMPDIR'];
|
||||
if ($tmp) {
|
||||
return $tmp;
|
||||
} else {
|
||||
return '/tmp';
|
||||
}
|
||||
}
|
||||
|
||||
// Windows 'TEMP'
|
||||
$tmp = empty($_ENV['TEMP']) ? getenv('TEMP') : $_ENV['TEMP'];
|
||||
if ($tmp) {
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
// Windows 'TMP'
|
||||
$tmp = empty($_ENV['TMP']) ? getenv('TMP') : $_ENV['TMP'];
|
||||
if ($tmp) {
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
// Windows 'windir'
|
||||
$tmp = empty($_ENV['windir']) ? getenv('windir') : $_ENV['windir'];
|
||||
if ($tmp) {
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
// final fallback for Windows
|
||||
return getenv('SystemRoot') . '\\temp';
|
||||
}
|
||||
}
|
@@ -1,93 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Utility functions for generating group URIs in HTML files
|
||||
*
|
||||
* Before including this file, /min/lib must be in your include_path.
|
||||
*
|
||||
* @package Minify
|
||||
*/
|
||||
|
||||
require_once 'Minify/Build.php';
|
||||
|
||||
|
||||
/**
|
||||
* Get a timestamped URI to a minified resource using the default Minify install
|
||||
*
|
||||
* <code>
|
||||
* <link rel="stylesheet" type="text/css" href="<?php echo Minify_groupUri('css'); ?>" />
|
||||
* <script type="text/javascript" src="<?php echo Minify_groupUri('js'); ?>"></script>
|
||||
* </code>
|
||||
*
|
||||
* If you do not want ampersands as HTML entities, set Minify_Build::$ampersand = "&"
|
||||
* before using this function.
|
||||
*
|
||||
* @param string $group a key from groupsConfig.php
|
||||
* @param boolean $forceAmpersand (default false) Set to true if the RewriteRule
|
||||
* directives in .htaccess are functional. This will remove the "?" from URIs, making them
|
||||
* more cacheable by proxies.
|
||||
* @return string
|
||||
*/
|
||||
function Minify_groupUri($group, $forceAmpersand = false)
|
||||
{
|
||||
$path = $forceAmpersand
|
||||
? "/g={$group}"
|
||||
: "/?g={$group}";
|
||||
|
||||
return _Minify_getBuild($group)->uri(
|
||||
'/' . basename(__DIR__) . $path
|
||||
,$forceAmpersand
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the last modification time of the source js/css files used by Minify to
|
||||
* build the page.
|
||||
*
|
||||
* If you're caching the output of Minify_groupUri(), you'll want to rebuild
|
||||
* the cache if it's older than this timestamp.
|
||||
*
|
||||
* <code>
|
||||
* // simplistic HTML cache system
|
||||
* $file = '/path/to/cache/file';
|
||||
* if (! file_exists($file) || filemtime($file) < Minify_groupsMtime(array('js', 'css'))) {
|
||||
* // (re)build cache
|
||||
* $page = buildPage(); // this calls Minify_groupUri() for js and css
|
||||
* file_put_contents($file, $page);
|
||||
* echo $page;
|
||||
* exit();
|
||||
* }
|
||||
* readfile($file);
|
||||
* </code>
|
||||
*
|
||||
* @param array $groups an array of keys from groupsConfig.php
|
||||
* @return int Unix timestamp of the latest modification
|
||||
*/
|
||||
function Minify_groupsMtime($groups)
|
||||
{
|
||||
$max = 0;
|
||||
foreach ((array)$groups as $group) {
|
||||
$max = max($max, _Minify_getBuild($group)->lastModified);
|
||||
}
|
||||
|
||||
return $max;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $group a key from groupsConfig.php
|
||||
* @return Minify_Build
|
||||
* @private
|
||||
*/
|
||||
function _Minify_getBuild($group)
|
||||
{
|
||||
static $builds = array();
|
||||
static $gc = false;
|
||||
if (false === $gc) {
|
||||
$gc = (require __DIR__ . '/groupsConfig.php');
|
||||
}
|
||||
if (! isset($builds[$group])) {
|
||||
$builds[$group] = new Minify_Build($gc[$group]);
|
||||
}
|
||||
|
||||
return $builds[$group];
|
||||
}
|
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
require_once __DIR__ . "/../vendor/autoload.php";
|
||||
|
||||
$environment = 'prod';
|
||||
$app = require __DIR__ . '/../lib/Alchemy/Phrasea/Application/Root.php';
|
||||
|
||||
$app->run();
|
||||
|
22
www/index_dev.php
Normal file
22
www/index_dev.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2013 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
require_once __DIR__ . "/../vendor/autoload.php";
|
||||
|
||||
$environment = 'dev';
|
||||
$app = require __DIR__ . '/../lib/Alchemy/Phrasea/Application/Root.php';
|
||||
|
||||
$app->run();
|
@@ -1,6 +0,0 @@
|
||||
var p4 = {};
|
||||
|
||||
$(document).ready(function (){
|
||||
|
||||
|
||||
});
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
@@ -844,7 +844,7 @@ function profil(value)
|
||||
|
||||
function setCss(color)
|
||||
{
|
||||
$('#skinCss').attr('href','/include/minify/f=skins/common/main.css,skins/client/'+color+'/clientcolor.css,'+
|
||||
$('#skinCss').attr('href','/include/minify/?f=skins/common/main.css,skins/client/'+color+'/clientcolor.css,'+
|
||||
'skins/client/'+color+'/ui.core.css,'+
|
||||
'skins/client/'+color+'/ui.datepicker.css,'+
|
||||
'skins/client/'+color+'/ui.theme.css');
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user