Add option to control how many seconds to wait before compiling updated template file

This commit is contained in:
Kijin Sung 2023-06-18 23:01:59 +09:00
parent c2f0e4fad9
commit de2a9288f2
6 changed files with 22 additions and 1 deletions

View file

@ -16,6 +16,7 @@ class TemplateHandler
private $config = NULL;
private $skipTags = NULL;
private $handler_mtime = 0;
private $delay_compile = 0;
private static $rootTpl = NULL;
/**
@ -32,6 +33,7 @@ class TemplateHandler
ini_set('pcre.jit', false);
$this->config = new stdClass;
$this->handler_mtime = filemtime(__FILE__);
$this->delay_compile = config('view.delay_compile') ?? 0;
$this->user = Rhymix\Framework\Session::getMemberInfo();
}
@ -163,7 +165,7 @@ class TemplateHandler
// Don't try to compile files that are less than 1 second old
$filemtime = filemtime($this->file);
if ($filemtime > time() - 1)
if ($filemtime > time() - $this->delay_compile)
{
$latest_mtime = $this->handler_mtime;
}

View file

@ -77,6 +77,7 @@ return array(
'manager_layout' => 'module',
'minify_scripts' => 'common',
'concat_scripts' => 'none',
'delay_compile' => 0,
'jquery_version' => 2,
'server_push' => false,
'use_gzip' => false,

View file

@ -101,6 +101,7 @@ class Advanced extends Base
Context::set('mobile_viewport', config('mobile.viewport') ?? HTMLDisplayHandler::DEFAULT_VIEWPORT);
Context::set('use_ssl', Config::get('url.ssl'));
Context::set('delay_session', Config::get('session.delay'));
Context::set('delay_template_compile', Config::get('view.delay_compile'));
Context::set('use_db_session', Config::get('session.use_db'));
Context::set('manager_layout', Config::get('view.manager_layout'));
Context::set('minify_scripts', Config::get('view.minify_scripts'));
@ -212,6 +213,7 @@ class Advanced extends Base
Config::set('view.manager_layout', $vars->manager_layout ?: 'module');
Config::set('view.minify_scripts', $vars->minify_scripts ?: 'common');
Config::set('view.concat_scripts', $vars->concat_scripts ?: 'none');
Config::set('view.delay_compile', intval($vars->delay_template_compile));
Config::set('view.jquery_version', $vars->jquery_version == 3 ? 3 : 2);
Config::set('view.server_push', $vars->use_server_push === 'Y');
Config::set('view.use_gzip', $vars->use_gzip === 'Y');

View file

@ -157,6 +157,8 @@ $lang->use_gzip = 'gzip Compression';
$lang->about_use_gzip = 'This option should be left off unless you know for sure that your webserver doesn\'t compress output by default.';
$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 interfere with autologin, and visitor counts may become inaccurate.';
$lang->delay_template_compile = 'Delay template compile';
$lang->about_delay_template_compile = 'Wait a few seconds before compiling an updated template file. This may help avoid errors when you are editing templates over a slow connection.';
$lang->mediafilter_whitelist = 'Allow external media';
$lang->about_mediafilter_whitelist = 'This list defines other websites from which users are allowed to embed multimedia content using &lt;iframe&gt; or &lt;video&gt; tags.<br />The restriction does not apply to attachments or any media embedded by the administrator.';
$lang->mediafilter_classes = 'Allow HTML class';

View file

@ -158,6 +158,8 @@ $lang->use_gzip = 'gzip 압축';
$lang->about_use_gzip = '웹서버가 gzip을 지원하지 않더라도 페이지를 강제로 압축하는 기능입니다. 대부분의 서버에는 필요하지 않습니다.';
$lang->delay_session = '세션 시작 지연';
$lang->about_delay_session = 'Varnish 등의 프록시 캐싱 서버 사용시 성능 개선을 위해, 로그인하지 않은 사용자에게는 인증 세션을 부여하지 않습니다.<br>이 옵션을 사용하면 자동 로그인이 되지 않으며, 방문자 수 집계가 정확하게 이루어지지 않을 수 있습니다.';
$lang->delay_template_compile = '템플릿 변환 지연';
$lang->about_delay_template_compile = '템플릿 파일이 업데이트되었을 때 즉시 변환하지 않고 몇 초간 기다립니다. 업로드 중인 템플릿을 로딩하려고 시도하다가 오류가 발생하는 것을 막을 수 있습니다.';
$lang->mediafilter_whitelist = '외부 멀티미디어 허용';
$lang->about_mediafilter_whitelist = '&lt;iframe&gt;, &lt;video&gt; 등으로 본문 삽입을 허용할 주소 목록입니다. 서비스마다 공통으로 사용하는 앞부분만 입력하면 됩니다.<br />직접 첨부한 파일이나 관리자가 작성한 글은 제한을 받지 않습니다.';
$lang->mediafilter_classes = 'HTML class 허용';

View file

@ -110,6 +110,18 @@
<p class="x_help-block">{$lang->about_delay_session}</p>
</div>
</div>
<div class="x_control-group">
<label class="x_control-label" for="delay_template_compile">{$lang->delay_template_compile}</label>
<div class="x_controls">
<select name="delay_template_compile" id="delay_template_compile">
<option value="0" selected="selected"|cond="$delay_template_compile == 0">0 {$lang->unit_sec}</option>
<option value="1" selected="selected"|cond="$delay_template_compile == 1">1 {$lang->unit_sec}</option>
<option value="2" selected="selected"|cond="$delay_template_compile == 2">2 {$lang->unit_sec}</option>
<option value="3" selected="selected"|cond="$delay_template_compile == 3">3 {$lang->unit_sec}</option>
</select>
<p class="x_help-block">{$lang->about_delay_template_compile}</p>
</div>
</div>
<div class="x_control-group">
<label class="x_control-label">{$lang->thumbnail_target}</label>
<div class="x_controls">