mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-24 04:42:14 +09:00
Merge branch 'develop' into pr/advanced-mailer
This commit is contained in:
commit
062969ae25
14 changed files with 94 additions and 32 deletions
|
|
@ -10,8 +10,8 @@
|
|||
var ip_re = '(?:'+max_255_re+'\\.){3}'+max_255_re;
|
||||
var port_re = '(?::([0-9]+))?';
|
||||
var user_re = '(?:/~\\w+)?';
|
||||
var path_re = '(?:/[\\w!@$%&!?="/.,:;-]+)*';
|
||||
var hash_re = '(?:#[\\w!@$%&!?="/.,:;-]*)?';
|
||||
var path_re = '(?:/[\\w!@$%&!?+=_~"/.,:;-]*)?';
|
||||
var hash_re = '(?:#[\\w!@$%&!?+=_~"/.,:;-]*)?';
|
||||
|
||||
var url_regex = new RegExp('('+protocol_re+'('+domain_re+'|'+ip_re+'|localhost'+')'+port_re+user_re+path_re+hash_re+')', 'ig');
|
||||
|
||||
|
|
|
|||
|
|
@ -2270,11 +2270,12 @@ class Context
|
|||
* Returns the list of javascripts that matches the given type.
|
||||
*
|
||||
* @param string $type Added position. (head:<head>..</head>, body:<body>..</body>)
|
||||
* @param bool $finalize (optional)
|
||||
* @return array Returns javascript file list. Array contains file, targetie.
|
||||
*/
|
||||
public static function getJsFile($type = 'head')
|
||||
public static function getJsFile($type = 'head', $finalize = false)
|
||||
{
|
||||
return self::$_instance->oFrontEndFileHandler->getJsFileList($type);
|
||||
return self::$_instance->oFrontEndFileHandler->getJsFileList($type, $finalize);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -2322,11 +2323,12 @@ class Context
|
|||
/**
|
||||
* Return a list of css files
|
||||
*
|
||||
* @param bool $finalize (optional)
|
||||
* @return array Returns css file list. Array contains file, media, targetie.
|
||||
*/
|
||||
public static function getCSSFile()
|
||||
public static function getCSSFile($finalize = false)
|
||||
{
|
||||
return self::$_instance->oFrontEndFileHandler->getCssFileList();
|
||||
return self::$_instance->oFrontEndFileHandler->getCssFileList($finalize);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -359,9 +359,10 @@ class FrontEndFileHandler extends Handler
|
|||
/**
|
||||
* Get css file list
|
||||
*
|
||||
* @param bool $finalize (optional)
|
||||
* @return array Returns css file list. Array contains file, media, targetie.
|
||||
*/
|
||||
public function getCssFileList()
|
||||
public function getCssFileList($finalize = false)
|
||||
{
|
||||
$map = &$this->cssMap;
|
||||
$mapIndex = &$this->cssMapIndex;
|
||||
|
|
@ -370,25 +371,28 @@ class FrontEndFileHandler extends Handler
|
|||
$this->_sortMap($map, $mapIndex);
|
||||
|
||||
// Minify all scripts, and compile LESS/SCSS into CSS.
|
||||
foreach ($map as $indexedMap)
|
||||
if ($finalize)
|
||||
{
|
||||
foreach ($indexedMap as $file)
|
||||
foreach ($map as $indexedMap)
|
||||
{
|
||||
$minify_this_file = !$file->isMinified && !$file->isExternalURL && !$file->isCachedScript && (($file->isCommon && $minify !== 'none') || $minify === 'all');
|
||||
if ($file->fileExtension === 'css')
|
||||
foreach ($indexedMap as $file)
|
||||
{
|
||||
$this->proc_CSS_JS($file, $minify_this_file);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->proc_LESS_SCSS($file, $minify_this_file);
|
||||
$minify_this_file = !$file->isMinified && !$file->isExternalURL && !$file->isCachedScript && (($file->isCommon && $minify !== 'none') || $minify === 'all');
|
||||
if ($file->fileExtension === 'css')
|
||||
{
|
||||
$this->proc_CSS_JS($file, $minify_this_file);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->proc_LESS_SCSS($file, $minify_this_file);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add all files to the final result.
|
||||
$result = array();
|
||||
if ($concat && count($concat_list = $this->_concatMap($map)))
|
||||
if ($concat && $finalize && count($concat_list = $this->_concatMap($map)))
|
||||
{
|
||||
foreach ($concat_list as $concat_fileset)
|
||||
{
|
||||
|
|
@ -436,6 +440,18 @@ class FrontEndFileHandler extends Handler
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Enable HTTP/2 server push for CSS resources.
|
||||
if ($finalize && config('view.server_push') && strncmp($_SERVER['SERVER_PROTOCOL'], 'HTTP/2', 6) === 0)
|
||||
{
|
||||
foreach ($result as $resource)
|
||||
{
|
||||
if ($resource['file'][0] === '/' && $resource['file'][1] !== '/')
|
||||
{
|
||||
header(sprintf('Link: <%s>; rel=preload; as=style', $resource['file']), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
|
@ -443,9 +459,10 @@ class FrontEndFileHandler extends Handler
|
|||
* Get javascript file list
|
||||
*
|
||||
* @param string $type Type of javascript. head, body
|
||||
* @param bool $finalize (optional)
|
||||
* @return array Returns javascript file list. Array contains file, targetie.
|
||||
*/
|
||||
public function getJsFileList($type = 'head')
|
||||
public function getJsFileList($type = 'head', $finalize = false)
|
||||
{
|
||||
if($type == 'head')
|
||||
{
|
||||
|
|
@ -463,20 +480,23 @@ class FrontEndFileHandler extends Handler
|
|||
$this->_sortMap($map, $mapIndex);
|
||||
|
||||
// Minify all scripts.
|
||||
foreach ($map as $indexedMap)
|
||||
if ($finalize)
|
||||
{
|
||||
foreach ($indexedMap as $file)
|
||||
foreach ($map as $indexedMap)
|
||||
{
|
||||
if (!$file->isMinified && !$file->isExternalURL && !$file->isCachedScript && (($file->isCommon && $minify !== 'none') || $minify === 'all'))
|
||||
foreach ($indexedMap as $file)
|
||||
{
|
||||
$this->proc_CSS_JS($file, true);
|
||||
if (!$file->isMinified && !$file->isExternalURL && !$file->isCachedScript && (($file->isCommon && $minify !== 'none') || $minify === 'all'))
|
||||
{
|
||||
$this->proc_CSS_JS($file, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add all files to the final result.
|
||||
$result = array();
|
||||
if ($concat && $type === 'head' && count($concat_list = $this->_concatMap($map)))
|
||||
if ($concat && $finalize && $type === 'head' && count($concat_list = $this->_concatMap($map)))
|
||||
{
|
||||
foreach ($concat_list as $concat_fileset)
|
||||
{
|
||||
|
|
@ -524,6 +544,18 @@ class FrontEndFileHandler extends Handler
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Enable HTTP/2 server push for JS resources.
|
||||
if ($type === 'head' && $finalize && config('view.server_push') && strncmp($_SERVER['SERVER_PROTOCOL'], 'HTTP/2', 6) === 0)
|
||||
{
|
||||
foreach ($result as $resource)
|
||||
{
|
||||
if ($resource['file'][0] === '/' && $resource['file'][1] !== '/')
|
||||
{
|
||||
header(sprintf('Link: <%s>; rel=preload; as=script', $resource['file']), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -151,6 +151,7 @@ class TemplateHandler
|
|||
}
|
||||
}
|
||||
|
||||
Rhymix\Framework\Debug::addFilenameAlias($this->file, $this->compiled_file);
|
||||
$output = $this->_fetch($this->compiled_file);
|
||||
|
||||
// delete tmpfile
|
||||
|
|
|
|||
|
|
@ -75,6 +75,7 @@ return array(
|
|||
'view' => array(
|
||||
'minify_scripts' => 'common',
|
||||
'concat_scripts' => 'none',
|
||||
'server_push' => false,
|
||||
'use_gzip' => false,
|
||||
),
|
||||
'admin' => array(
|
||||
|
|
|
|||
|
|
@ -333,7 +333,21 @@ class Formatter
|
|||
$import_content = '';
|
||||
$import_files = array_map(function($str) use($filename, $import_type) {
|
||||
$str = trim(trim(trim(preg_replace('/^url\\(([^()]+)\\)$/', '$1', trim($str))), '"\''));
|
||||
return dirname($filename) . '/' . ($import_type === 'scss' ? "_$str.scss" : $str);
|
||||
if ($import_type === 'scss')
|
||||
{
|
||||
if (($dirpos = strrpos($str, '/')) !== false)
|
||||
{
|
||||
return dirname($filename) . '/' . substr($str, 0, $dirpos) . '/_' . substr($str, $dirpos + 1) . '.scss';
|
||||
}
|
||||
else
|
||||
{
|
||||
return dirname($filename) . "/_$str.scss";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return dirname($filename) . '/' . $str;
|
||||
}
|
||||
}, explode(',', $matches[1]));
|
||||
foreach ($import_files as $import_filename)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -15,14 +15,14 @@
|
|||
<title>{Context::getBrowserTitle()}</title>
|
||||
|
||||
<!-- CSS -->
|
||||
<block loop="Context::getCssFile() => $key, $css_file">
|
||||
<block loop="Context::getCssFile(true) => $key, $css_file">
|
||||
<block cond="$css_file['targetie']"><!--[if {$css_file['targetie']}]><block cond="stripos($css_file['targetie'], 'gt') === 0"><!--></block></block>
|
||||
<link rel="stylesheet" href="{$css_file['file']}" media="{$css_file['media']}"|cond="$css_file['media'] != 'all'" />
|
||||
<block cond="$css_file['targetie']"><block cond="stripos($css_file['targetie'], 'gt') === 0"><!--</block><![endif]-->{"\n"}</block>
|
||||
</block>
|
||||
|
||||
<!-- JS -->
|
||||
<block loop="Context::getJsFile() => $key, $js_file">
|
||||
<block loop="Context::getJsFile('head', true) => $key, $js_file">
|
||||
<block cond="$js_file['targetie']"><!--[if {$js_file['targetie']}]><block cond="stripos($js_file['targetie'], 'gt') === 0"><!--></block></block>
|
||||
<script src="{$js_file['file']}"></script>
|
||||
<block cond="$js_file['targetie']"><block cond="stripos($js_file['targetie'], 'gt') === 0"><!--</block><![endif]-->{"\n"}</block>
|
||||
|
|
@ -70,7 +70,7 @@
|
|||
<div id="rhymix_debug_button"></div>
|
||||
|
||||
<!-- BODY JS -->
|
||||
<block loop="Context::getJsFile('body') => $key, $js_file">
|
||||
<block loop="Context::getJsFile('body', true) => $key, $js_file">
|
||||
<block cond="$js_file['targetie']"><!--[if {$js_file['targetie']}]></block>
|
||||
<script src="{$js_file['file']}"></script>
|
||||
<block cond="$js_file['targetie']"><![endif]-->{"\n"}</block>
|
||||
|
|
|
|||
|
|
@ -700,6 +700,7 @@ class adminAdminController extends admin
|
|||
Rhymix\Framework\Config::set('session.use_db', $vars->use_db_session === 'Y');
|
||||
Rhymix\Framework\Config::set('view.minify_scripts', $vars->minify_scripts ?: 'common');
|
||||
Rhymix\Framework\Config::set('view.concat_scripts', $vars->concat_scripts ?: 'none');
|
||||
Rhymix\Framework\Config::set('view.server_push', $vars->use_server_push === 'Y');
|
||||
Rhymix\Framework\Config::set('view.gzip', $vars->use_gzip === 'Y');
|
||||
|
||||
// Save
|
||||
|
|
|
|||
|
|
@ -531,6 +531,7 @@ class adminAdminView extends admin
|
|||
Context::set('use_db_session', Rhymix\Framework\Config::get('session.use_db'));
|
||||
Context::set('minify_scripts', Rhymix\Framework\Config::get('view.minify_scripts'));
|
||||
Context::set('concat_scripts', Rhymix\Framework\Config::get('view.concat_scripts'));
|
||||
Context::set('use_server_push', Rhymix\Framework\Config::get('view.server_push'));
|
||||
Context::set('use_gzip', Rhymix\Framework\Config::get('view.gzip'));
|
||||
|
||||
$this->setTemplateFile('config_advanced');
|
||||
|
|
|
|||
|
|
@ -92,6 +92,7 @@ $lang->cmd_concat_css_only = 'Combine all CSS';
|
|||
$lang->cmd_concat_js_only = 'Combine all JS';
|
||||
$lang->cmd_concat_css_js = 'Combine both CSS and JS';
|
||||
$lang->about_concat_scripts = 'Automatically combine CSS and JS scripts into as few files as possible. External scripts are not combined.';
|
||||
$lang->use_server_push = 'Use HTTP/2 Server Push';
|
||||
$lang->use_gzip = 'gzip Compression';
|
||||
$lang->delay_session = 'Delay session start';
|
||||
$lang->about_delay_session = 'To improve performance when using a caching proxy server such as Varnish, do not issue sessions to visitors until they log in.<br>Selecting this option may cause view counts and visitor counts to become inaccurate.';
|
||||
|
|
|
|||
|
|
@ -89,6 +89,7 @@ $lang->cmd_concat_css_only = 'CSSのみ結合';
|
|||
$lang->cmd_concat_js_only = 'JSのみ結合';
|
||||
$lang->cmd_concat_css_js = 'CSSやJSの両方を結合';
|
||||
$lang->about_concat_scripts = 'CSS、JSファイルを一つにまとめて送信されます。外部からロードするスクリプトは、合わせてされません.';
|
||||
$lang->use_server_push = 'HTTP/2 Server Push使用';
|
||||
$lang->use_gzip = 'gzip 圧縮';
|
||||
$lang->delay_session = 'セッションの開始を遅延';
|
||||
$lang->about_delay_session = 'Varnishなどのプロキシキャッシュサーバ使用時のパフォーマンスを向上させるために、ログインしていないユーザーには、認証セッションを付与しません。<br>このオプションを選択した場合、訪問者数とヒット集計が正確でない場合があります。';
|
||||
|
|
|
|||
|
|
@ -92,6 +92,7 @@ $lang->cmd_concat_css_only = 'CSS만 합침';
|
|||
$lang->cmd_concat_js_only = 'JS만 합침';
|
||||
$lang->cmd_concat_css_js = 'CSS와 JS를 모두 합침';
|
||||
$lang->about_concat_scripts = 'CSS, JS 파일들을 하나로 합쳐서 전송합니다. 외부에서 로딩하는 스크립트는 합쳐지지 않습니다.';
|
||||
$lang->use_server_push = 'Server Push 사용';
|
||||
$lang->use_gzip = 'gzip 압축';
|
||||
$lang->delay_session = '세션 시작 지연';
|
||||
$lang->about_delay_session = 'Varnish 등의 프록시 캐싱 서버 사용시 성능 개선을 위해, 로그인하지 않은 사용자에게는 인증 세션을 부여하지 않습니다.<br>이 옵션을 선택할 경우 방문자 수 및 조회수 집계가 정확하게 이루어지지 않을 수 있습니다.';
|
||||
|
|
|
|||
|
|
@ -97,6 +97,13 @@
|
|||
<p class="x_help-block">{$lang->about_concat_scripts}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="x_control-group">
|
||||
<label class="x_control-label">{$lang->use_server_push}</label>
|
||||
<div class="x_controls">
|
||||
<label for="use_server_push_y" class="x_inline"><input type="radio" name="use_server_push" id="use_server_push_y" value="Y" checked="checked"|cond="$use_server_push" /> {$lang->cmd_yes}</label>
|
||||
<label for="use_server_push_n" class="x_inline"><input type="radio" name="use_server_push" id="use_server_push_n" value="N" checked="checked"|cond="!$use_server_push" /> {$lang->cmd_no}</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="x_control-group">
|
||||
<label class="x_control-label">{$lang->use_gzip}</label>
|
||||
<div class="x_controls">
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ class FrontEndFileHandlerTest extends \Codeception\TestCase\Test
|
|||
$handler = new FrontEndFileHandler();
|
||||
$handler->loadFile(array('./common/css/rhymix.scss'));
|
||||
$handler->loadFile(array('./common/css/mobile.css'));
|
||||
$result = $handler->getCssFileList();
|
||||
$result = $handler->getCssFileList(true);
|
||||
$this->assertRegexp('/\.rhymix\.scss\.css\?\d+$/', $result[0]['file']);
|
||||
$this->assertEquals('all', $result[0]['media']);
|
||||
$this->assertEmpty($result[0]['targetie']);
|
||||
|
|
@ -155,7 +155,7 @@ class FrontEndFileHandlerTest extends \Codeception\TestCase\Test
|
|||
$handler = new FrontEndFileHandler();
|
||||
$handler->loadFile(array('./common/css/rhymix.scss'));
|
||||
$handler->loadFile(array('./common/css/mobile.css'));
|
||||
$result = $handler->getCssFileList();
|
||||
$result = $handler->getCssFileList(true);
|
||||
$this->assertRegexp('/\.rhymix\.scss\.min\.css\b/', $result[0]['file']);
|
||||
$this->assertEquals('all', $result[0]['media']);
|
||||
$this->assertEmpty($result[0]['targetie']);
|
||||
|
|
@ -167,7 +167,7 @@ class FrontEndFileHandlerTest extends \Codeception\TestCase\Test
|
|||
$this->specify("minify (js)", function() {
|
||||
$handler = new FrontEndFileHandler();
|
||||
$handler->loadFile(array('./common/js/common.js', 'head'));
|
||||
$result = $handler->getJsFileList();
|
||||
$result = $handler->getJsFileList('head', true);
|
||||
$this->assertRegexp('/minified\/common\.js\.common\.min\.js\?\d+$/', $result[0]['file']);
|
||||
$this->assertEmpty($result[0]['targetie']);
|
||||
});
|
||||
|
|
@ -186,7 +186,7 @@ class FrontEndFileHandlerTest extends \Codeception\TestCase\Test
|
|||
$handler->loadFile(array('./tests/_data/formatter/concat.source2.css'));
|
||||
$handler->loadFile(array('./tests/_data/formatter/concat.target1.css'));
|
||||
$handler->loadFile(array('./tests/_data/formatter/concat.target2.css'));
|
||||
$result = $handler->getCssFileList();
|
||||
$result = $handler->getCssFileList(true);
|
||||
$this->assertEquals(4, count($result));
|
||||
$this->assertRegexp('/combined\/[0-9a-f]+\.css\?\d+$/', $result[0]['file']);
|
||||
$this->assertEquals('http://external.host/style.css', $result[1]['file']);
|
||||
|
|
@ -207,7 +207,7 @@ class FrontEndFileHandlerTest extends \Codeception\TestCase\Test
|
|||
$handler->loadFile(array('./tests/_data/formatter/concat.source2.js', 'head', 'gt IE 7'));
|
||||
$handler->loadFile(array('./tests/_data/formatter/concat.target1.js'));
|
||||
$handler->loadFile(array('./tests/_data/formatter/concat.target2.js'));
|
||||
$result = $handler->getJsFileList();
|
||||
$result = $handler->getJsFileList('head', true);
|
||||
$this->assertEquals(3, count($result));
|
||||
$this->assertRegexp('/combined\/[0-9a-f]+\.js\?\d+$/', $result[0]['file']);
|
||||
$this->assertEquals('//external.host/js/script.js', $result[1]['file']);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue