mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-24 02:13:15 +00:00
Cleanup minification controller
This commit is contained in:
@@ -5,10 +5,6 @@
|
||||
"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",
|
||||
|
||||
@@ -121,8 +121,10 @@ use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
|
||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
use Symfony\Component\HttpKernel\KernelEvents;
|
||||
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Generator\UrlGenerator;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
|
||||
class Application extends SilexApplication
|
||||
{
|
||||
@@ -608,8 +610,112 @@ 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->get('/include/minify/', function (Application $app, Request $request) {
|
||||
|
||||
// cache directory path
|
||||
$min_cachePath = __DIR__ . '/../../../tmp/cache_minify';
|
||||
|
||||
/**
|
||||
* Cache file locking. Set to false if filesystem is NFS. On at least one
|
||||
* NFS system flock-ing attempts stalled PHP for 30 seconds!
|
||||
*/
|
||||
$min_cacheFileLocking = true;
|
||||
|
||||
/**
|
||||
* Combining multiple CSS files can place @import declarations after rules, which
|
||||
* is invalid. Minify will attempt to detect when this happens and place a
|
||||
* warning comment at the top of the CSS output. To resolve this you can either
|
||||
* move the @imports within your CSS files, or enable this option, which will
|
||||
* move all @imports to the top of the output. Note that moving @imports could
|
||||
* affect CSS values (which is why this option is disabled by default).
|
||||
*/
|
||||
$min_serveOptions['bubbleCssImports'] = false;
|
||||
|
||||
/**
|
||||
* Set to true to disable the "f" GET parameter for specifying files.
|
||||
* Only the "g" parameter will be considered.
|
||||
*/
|
||||
$min_serveOptions['minApp']['groupsOnly'] = false;
|
||||
|
||||
/**
|
||||
* Maximum # of files that can be specified in the "f" GET parameter
|
||||
*/
|
||||
$min_serveOptions['minApp']['maxFiles'] = 10;
|
||||
|
||||
/**
|
||||
* If you minify CSS files stored in symlink-ed directories, the URI rewriting
|
||||
* algorithm can fail. To prevent this, 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>
|
||||
*/
|
||||
$min_symlinks = array();
|
||||
|
||||
/**
|
||||
* If you upload files from Windows to a non-Windows server, Windows may report
|
||||
* incorrect mtimes for the files. This may cause Minify to keep serving stale
|
||||
* cache files when source file changes are made too frequently (e.g. more than
|
||||
* once an hour).
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* In the Windows SFTP client WinSCP, there's an option that may fix this
|
||||
* issue without changing the variable below. Under login > environment,
|
||||
* select the option "Adjust remote timestamp with DST".
|
||||
* @link http://winscp.net/eng/docs/ui_login_environment#daylight_saving_time
|
||||
*/
|
||||
$min_uploaderHoursBehind = 0;
|
||||
|
||||
// return an array instead of echoing output
|
||||
$min_serveOptions['quiet'] = true;
|
||||
|
||||
\Minify::$uploaderHoursBehind = $min_uploaderHoursBehind;
|
||||
\Minify::setCache(
|
||||
isset($min_cachePath) ? $min_cachePath : ''
|
||||
,$min_cacheFileLocking
|
||||
);
|
||||
|
||||
// require to work well :(
|
||||
$_SERVER['DOCUMENT_ROOT'] = __DIR__ . '/../../../www/';
|
||||
\Minify::$isDocRootSet = true;
|
||||
|
||||
$min_serveOptions['minifierOptions']['text/css']['symlinks'] = $min_symlinks;
|
||||
// auto-add targets to allowDirs
|
||||
foreach ($min_symlinks as $uri => $target) {
|
||||
$min_serveOptions['minApp']['allowDirs'][] = $target;
|
||||
}
|
||||
|
||||
if (isset($_GET['g'])) {
|
||||
// well need groups config
|
||||
$min_serveOptions['minApp']['groups'] = require __DIR__ . '/../../conf.d/minifyGroupsConfig.php';
|
||||
}
|
||||
|
||||
if (null === $request->query->get('f') && null === $request->query->get('g')) {
|
||||
throw new HttpException(400, 'Please provide an argument');
|
||||
}
|
||||
|
||||
$ret = \Minify::serve(new \Minify_Controller_MinApp(), $min_serveOptions);
|
||||
|
||||
if (!$ret['success']) {
|
||||
throw new HttpException(500, 'Unable to generate data');
|
||||
}
|
||||
|
||||
$response = new Response($ret['content'], $ret['statusCode']);
|
||||
$response->setMaxAge(1800);
|
||||
|
||||
foreach ($ret['headers'] as $key => $value) {
|
||||
$response->headers->set($key, $value);
|
||||
}
|
||||
|
||||
return $response;
|
||||
});
|
||||
|
||||
$this->mount('/admin/', new Root());
|
||||
|
||||
@@ -1,181 +0,0 @@
|
||||
<?php
|
||||
$_SERVER["DOCUMENT_ROOT"] = __DIR__ . '/../../../../www/';
|
||||
/**
|
||||
* Configuration for "min", the default application built with the Minify
|
||||
* library
|
||||
*
|
||||
* @package Minify
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Allow use of the Minify URI Builder app. Only set this to true while you need it.
|
||||
*/
|
||||
$min_enableBuilder = true;
|
||||
|
||||
/**
|
||||
* If non-empty, the Builder will be protected with HTTP Digest auth.
|
||||
* The username is "admin".
|
||||
*/
|
||||
//$min_builderPassword = 'admin';
|
||||
|
||||
|
||||
/**
|
||||
* Set to true to log messages to FirePHP (Firefox Firebug addon).
|
||||
* Set to false for no error logging (Minify may be slightly faster).
|
||||
* @link http://www.firephp.org/
|
||||
*
|
||||
* If you want to use a custom error logger, set this to your logger
|
||||
* instance. Your object should have a method log(string $message).
|
||||
*/
|
||||
$min_errorLogger = false;
|
||||
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
|
||||
/**
|
||||
* For best performance, specify your temp directory here. Otherwise Minify
|
||||
* will have to load extra code to guess. Some examples below:
|
||||
*/
|
||||
//$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();
|
||||
|
||||
|
||||
/**
|
||||
* Leave an empty string to use PHP's $_SERVER['DOCUMENT_ROOT'].
|
||||
*
|
||||
* On some servers, this value may be misconfigured or missing. If so, set this
|
||||
* to your full document root path with no trailing slash.
|
||||
* E.g. '/home/accountname/public_html' or 'c:\\xampp\\htdocs'
|
||||
*
|
||||
* If /min/ is directly inside your document root, just uncomment the
|
||||
* second line. The third line might work on some Apache servers.
|
||||
*/
|
||||
$min_documentRoot = '';
|
||||
//$min_documentRoot = substr(__FILE__, 0, -15);
|
||||
//$min_documentRoot = $_SERVER['SUBDOMAIN_DOCUMENT_ROOT'];
|
||||
|
||||
|
||||
/**
|
||||
* Cache file locking. Set to false if filesystem is NFS. On at least one
|
||||
* NFS system flock-ing attempts stalled PHP for 30 seconds!
|
||||
*/
|
||||
$min_cacheFileLocking = true;
|
||||
|
||||
|
||||
/**
|
||||
* Combining multiple CSS files can place @import declarations after rules, which
|
||||
* is invalid. Minify will attempt to detect when this happens and place a
|
||||
* warning comment at the top of the CSS output. To resolve this you can either
|
||||
* move the @imports within your CSS files, or enable this option, which will
|
||||
* move all @imports to the top of the output. Note that moving @imports could
|
||||
* affect CSS values (which is why this option is disabled by default).
|
||||
*/
|
||||
$min_serveOptions['bubbleCssImports'] = false;
|
||||
|
||||
|
||||
/**
|
||||
* 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
|
||||
* querystring, maxAge will be set to one year. E.g. /min/f=hello.css&123456
|
||||
*/
|
||||
$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.
|
||||
* You will still need to include the directory in the
|
||||
* f or b GET parameters.
|
||||
*
|
||||
* // = shortcut for DOCUMENT_ROOT
|
||||
*/
|
||||
//$min_serveOptions['minApp']['allowDirs'] = array('//js', '//css');
|
||||
|
||||
/**
|
||||
* Set to true to disable the "f" GET parameter for specifying files.
|
||||
* Only the "g" parameter will be considered.
|
||||
*/
|
||||
$min_serveOptions['minApp']['groupsOnly'] = false;
|
||||
|
||||
|
||||
/**
|
||||
* Maximum # of files that can be specified in the "f" GET parameter
|
||||
*/
|
||||
$min_serveOptions['minApp']['maxFiles'] = 10;
|
||||
|
||||
|
||||
/**
|
||||
* If you minify CSS files stored in symlink-ed directories, the URI rewriting
|
||||
* algorithm can fail. To prevent this, 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>
|
||||
*/
|
||||
$min_symlinks = array();
|
||||
|
||||
|
||||
/**
|
||||
* If you upload files from Windows to a non-Windows server, Windows may report
|
||||
* incorrect mtimes for the files. This may cause Minify to keep serving stale
|
||||
* cache files when source file changes are made too frequently (e.g. more than
|
||||
* once an hour).
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* In the Windows SFTP client WinSCP, there's an option that may fix this
|
||||
* issue without changing the variable below. Under login > environment,
|
||||
* select the option "Adjust remote timestamp with DST".
|
||||
* @link http://winscp.net/eng/docs/ui_login_environment#daylight_saving_time
|
||||
*/
|
||||
$min_uploaderHoursBehind = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Path to Minify's lib folder. If you happen to move it, change
|
||||
* this accordingly.
|
||||
*/
|
||||
$min_libPath = __DIR__ . '/lib';
|
||||
$min_cachePath = __DIR__ . '/../../../../tmp/cache_minify';
|
||||
|
||||
// try to disable output_compression (may not have an effect)
|
||||
ini_set('zlib.output_compression', '0');
|
||||
@@ -35,9 +35,9 @@ $groups = array(
|
||||
, '//include/account/geonames.js'
|
||||
, '//include/jquery.tooltip.js'
|
||||
, '//include/jslibs/jquery.contextmenu_scroll.js'
|
||||
, '//include/vendor/javascript-load-image/load-image.js'
|
||||
, '//include/vendor/jquery-file-upload/js/jquery.iframe-transport.js'
|
||||
, '//include/vendor/jquery-file-upload/js/jquery.fileupload.js'
|
||||
, '//assets/javascript-load-image/load-image.js'
|
||||
, '//assets/jquery-file-upload/js/jquery.iframe-transport.js'
|
||||
, '//assets/jquery-file-upload/js/jquery.fileupload.js'
|
||||
),
|
||||
'report' => array(
|
||||
'//include/jslibs/jquery-ui-1.8.17/jquery-ui-i18n.js'
|
||||
@@ -63,12 +63,12 @@ $groups = array(
|
||||
, '//include/jslibs/jquery-ui-1.8.17/jquery-ui-i18n.js'
|
||||
, '//include/jslibs/jquery.cookie.js'
|
||||
, '//include/jquery.common.js'
|
||||
, '//include/vendor/humane-js/humane.js'
|
||||
, '//include/vendor/mustache-js/mustache.js'
|
||||
, '//include/vendor/javascript-load-image/load-image.js'
|
||||
, '//include/vendor/jquery-file-upload/js/vendor/jquery.ui.widget.js'
|
||||
, '//include/vendor/jquery-file-upload/js/jquery.iframe-transport.js'
|
||||
, '//include/vendor/jquery-file-upload/js/jquery.fileupload.js'
|
||||
, '//assets/humane-js/humane.js'
|
||||
, '//assets/mustache/mustache.js'
|
||||
, '//assets/blueimp-load-image/load-image.js'
|
||||
, '//assets/jquery-file-upload/js/vendor/jquery.ui.widget.js'
|
||||
, '//assets/jquery-file-upload/js/jquery.iframe-transport.js'
|
||||
, '//assets/jquery-file-upload/js/jquery.fileupload.js'
|
||||
, '//include/account/geonames.js'
|
||||
, '//include/jslibs/jquery.form.2.49.js'
|
||||
, '//include/jslibs/jquery.vertical.buttonset.js'
|
||||
Reference in New Issue
Block a user