Merge pull request #11820 from fabrixxm/feat/smarty3foldersconfig

Add smarty3 dirs config
This commit is contained in:
Philipp 2022-08-08 19:00:12 +02:00 committed by GitHub
commit 0e22120cd2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 85 additions and 76 deletions

View file

@ -33,7 +33,7 @@ class FriendicaSmarty extends Smarty
public $filename; public $filename;
function __construct(string $theme, array $theme_info) public function __construct(string $theme, array $theme_info, string $work_dir)
{ {
parent::__construct(); parent::__construct();
@ -47,12 +47,27 @@ class FriendicaSmarty extends Smarty
$template_dirs = $template_dirs + ['base' => 'view/' . self::SMARTY3_TEMPLATE_FOLDER . '/']; $template_dirs = $template_dirs + ['base' => 'view/' . self::SMARTY3_TEMPLATE_FOLDER . '/'];
$this->setTemplateDir($template_dirs); $this->setTemplateDir($template_dirs);
$this->setCompileDir('view/smarty3/compiled/'); $work_dir = rtrim($work_dir, '/');
$this->setConfigDir('view/smarty3/');
$this->setCacheDir('view/smarty3/');
$this->left_delimiter = Renderer::getTemplateLeftDelimiter('smarty3'); $this->setCompileDir($work_dir . '/compiled');
$this->right_delimiter = Renderer::getTemplateRightDelimiter('smarty3'); $this->setConfigDir($work_dir . '/');
$this->setCacheDir($work_dir . '/');
/*
* Enable sub-directory splitting for reducing directory descriptor
* size. The default behavior is to put all compiled/cached files into
* one single directory. Under Linux and EXT4 (and maybe other FS) this
* will increase the descriptor's size (which contains information
* about entries inside the described directory. If the descriptor is
* getting to big, the system will slow down as it has to read the
* whole directory descriptor all over again (unless you have tons of
* RAM available + have enabled caching inode tables (aka.
* "descriptors"). Still it won't hurt you.
*/
$this->setUseSubDirs(true);
$this->left_delimiter = Renderer::getTemplateLeftDelimiter();
$this->right_delimiter = Renderer::getTemplateRightDelimiter();
$this->escape_html = true; $this->escape_html = true;

View file

@ -46,23 +46,11 @@ final class FriendicaSmartyEngine extends TemplateEngine
{ {
$this->theme = $theme; $this->theme = $theme;
$this->theme_info = $theme_info; $this->theme_info = $theme_info;
$this->smarty = new FriendicaSmarty($this->theme, $this->theme_info); $work_dir = DI::config()->get('smarty3', 'config_dir');
$this->smarty = new FriendicaSmarty($this->theme, $this->theme_info, $work_dir);
/* if (!is_writable($work_dir)) {
* Enable sub-directory splitting for reducing directory descriptor $admin_message = DI::l10n()->t('The folder %s must be writable by webserver.', $work_dir);
* size. The default behavior is to put all compiled/cached files into
* one single directory. Under Linux and EXT4 (and maybe other FS) this
* will increase the descriptor's size (which contains information
* about entries inside the described directory. If the descriptor is
* getting to big, the system will slow down as it has to read the
* whole directory descriptor all over again (unless you have tons of
* RAM available + have enabled caching inode tables (aka.
* "descriptors"). Still it won't hurt you.
*/
$this->smarty->setUseSubDirs(true);
if (!is_writable(DI::basePath() . '/view/smarty3')) {
$admin_message = DI::l10n()->t('The folder view/smarty3/ must be writable by webserver.');
DI::logger()->critical($admin_message); DI::logger()->critical($admin_message);
$message = DI::app()->isSiteAdmin() ? $message = DI::app()->isSiteAdmin() ?
$admin_message : $admin_message :

View file

@ -701,5 +701,10 @@ return [
// ap_log_failure (Boolean) // ap_log_failure (Boolean)
// Logs every ActivityPub activity that couldn't be compacted // Logs every ActivityPub activity that couldn't be compacted
'ap_log_failure' => false, 'ap_log_failure' => false,
] ],
'smarty3' => [
// config_dir (String)
// Base working directory for the templating engine, must be writeable by the webserver user
'config_dir' => 'view/smarty3',
],
]; ];

View file

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: 2022.09-dev\n" "Project-Id-Version: 2022.09-dev\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-08-08 02:12-0400\n" "POT-Creation-Date: 2022-08-08 12:31-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -3246,206 +3246,206 @@ msgstr ""
msgid "Could not connect to database." msgid "Could not connect to database."
msgstr "" msgstr ""
#: src/Core/L10n.php:402 src/Model/Event.php:428 #: src/Core/L10n.php:403 src/Model/Event.php:428
#: src/Module/Settings/Display.php:182 #: src/Module/Settings/Display.php:182
msgid "Monday" msgid "Monday"
msgstr "" msgstr ""
#: src/Core/L10n.php:402 src/Model/Event.php:429 #: src/Core/L10n.php:403 src/Model/Event.php:429
msgid "Tuesday" msgid "Tuesday"
msgstr "" msgstr ""
#: src/Core/L10n.php:402 src/Model/Event.php:430 #: src/Core/L10n.php:403 src/Model/Event.php:430
msgid "Wednesday" msgid "Wednesday"
msgstr "" msgstr ""
#: src/Core/L10n.php:402 src/Model/Event.php:431 #: src/Core/L10n.php:403 src/Model/Event.php:431
msgid "Thursday" msgid "Thursday"
msgstr "" msgstr ""
#: src/Core/L10n.php:402 src/Model/Event.php:432 #: src/Core/L10n.php:403 src/Model/Event.php:432
msgid "Friday" msgid "Friday"
msgstr "" msgstr ""
#: src/Core/L10n.php:402 src/Model/Event.php:433 #: src/Core/L10n.php:403 src/Model/Event.php:433
msgid "Saturday" msgid "Saturday"
msgstr "" msgstr ""
#: src/Core/L10n.php:402 src/Model/Event.php:427 #: src/Core/L10n.php:403 src/Model/Event.php:427
#: src/Module/Settings/Display.php:182 #: src/Module/Settings/Display.php:182
msgid "Sunday" msgid "Sunday"
msgstr "" msgstr ""
#: src/Core/L10n.php:406 src/Model/Event.php:448 #: src/Core/L10n.php:407 src/Model/Event.php:448
msgid "January" msgid "January"
msgstr "" msgstr ""
#: src/Core/L10n.php:406 src/Model/Event.php:449 #: src/Core/L10n.php:407 src/Model/Event.php:449
msgid "February" msgid "February"
msgstr "" msgstr ""
#: src/Core/L10n.php:406 src/Model/Event.php:450 #: src/Core/L10n.php:407 src/Model/Event.php:450
msgid "March" msgid "March"
msgstr "" msgstr ""
#: src/Core/L10n.php:406 src/Model/Event.php:451 #: src/Core/L10n.php:407 src/Model/Event.php:451
msgid "April" msgid "April"
msgstr "" msgstr ""
#: src/Core/L10n.php:406 src/Core/L10n.php:425 src/Model/Event.php:439 #: src/Core/L10n.php:407 src/Core/L10n.php:426 src/Model/Event.php:439
msgid "May" msgid "May"
msgstr "" msgstr ""
#: src/Core/L10n.php:406 src/Model/Event.php:452 #: src/Core/L10n.php:407 src/Model/Event.php:452
msgid "June" msgid "June"
msgstr "" msgstr ""
#: src/Core/L10n.php:406 src/Model/Event.php:453 #: src/Core/L10n.php:407 src/Model/Event.php:453
msgid "July" msgid "July"
msgstr "" msgstr ""
#: src/Core/L10n.php:406 src/Model/Event.php:454 #: src/Core/L10n.php:407 src/Model/Event.php:454
msgid "August" msgid "August"
msgstr "" msgstr ""
#: src/Core/L10n.php:406 src/Model/Event.php:455 #: src/Core/L10n.php:407 src/Model/Event.php:455
msgid "September" msgid "September"
msgstr "" msgstr ""
#: src/Core/L10n.php:406 src/Model/Event.php:456 #: src/Core/L10n.php:407 src/Model/Event.php:456
msgid "October" msgid "October"
msgstr "" msgstr ""
#: src/Core/L10n.php:406 src/Model/Event.php:457 #: src/Core/L10n.php:407 src/Model/Event.php:457
msgid "November" msgid "November"
msgstr "" msgstr ""
#: src/Core/L10n.php:406 src/Model/Event.php:458 #: src/Core/L10n.php:407 src/Model/Event.php:458
msgid "December" msgid "December"
msgstr "" msgstr ""
#: src/Core/L10n.php:421 src/Model/Event.php:420 #: src/Core/L10n.php:422 src/Model/Event.php:420
msgid "Mon" msgid "Mon"
msgstr "" msgstr ""
#: src/Core/L10n.php:421 src/Model/Event.php:421 #: src/Core/L10n.php:422 src/Model/Event.php:421
msgid "Tue" msgid "Tue"
msgstr "" msgstr ""
#: src/Core/L10n.php:421 src/Model/Event.php:422 #: src/Core/L10n.php:422 src/Model/Event.php:422
msgid "Wed" msgid "Wed"
msgstr "" msgstr ""
#: src/Core/L10n.php:421 src/Model/Event.php:423 #: src/Core/L10n.php:422 src/Model/Event.php:423
msgid "Thu" msgid "Thu"
msgstr "" msgstr ""
#: src/Core/L10n.php:421 src/Model/Event.php:424 #: src/Core/L10n.php:422 src/Model/Event.php:424
msgid "Fri" msgid "Fri"
msgstr "" msgstr ""
#: src/Core/L10n.php:421 src/Model/Event.php:425 #: src/Core/L10n.php:422 src/Model/Event.php:425
msgid "Sat" msgid "Sat"
msgstr "" msgstr ""
#: src/Core/L10n.php:421 src/Model/Event.php:419 #: src/Core/L10n.php:422 src/Model/Event.php:419
msgid "Sun" msgid "Sun"
msgstr "" msgstr ""
#: src/Core/L10n.php:425 src/Model/Event.php:435 #: src/Core/L10n.php:426 src/Model/Event.php:435
msgid "Jan" msgid "Jan"
msgstr "" msgstr ""
#: src/Core/L10n.php:425 src/Model/Event.php:436 #: src/Core/L10n.php:426 src/Model/Event.php:436
msgid "Feb" msgid "Feb"
msgstr "" msgstr ""
#: src/Core/L10n.php:425 src/Model/Event.php:437 #: src/Core/L10n.php:426 src/Model/Event.php:437
msgid "Mar" msgid "Mar"
msgstr "" msgstr ""
#: src/Core/L10n.php:425 src/Model/Event.php:438 #: src/Core/L10n.php:426 src/Model/Event.php:438
msgid "Apr" msgid "Apr"
msgstr "" msgstr ""
#: src/Core/L10n.php:425 src/Model/Event.php:440 #: src/Core/L10n.php:426 src/Model/Event.php:440
msgid "Jun" msgid "Jun"
msgstr "" msgstr ""
#: src/Core/L10n.php:425 src/Model/Event.php:441 #: src/Core/L10n.php:426 src/Model/Event.php:441
msgid "Jul" msgid "Jul"
msgstr "" msgstr ""
#: src/Core/L10n.php:425 src/Model/Event.php:442 #: src/Core/L10n.php:426 src/Model/Event.php:442
msgid "Aug" msgid "Aug"
msgstr "" msgstr ""
#: src/Core/L10n.php:425 #: src/Core/L10n.php:426
msgid "Sep" msgid "Sep"
msgstr "" msgstr ""
#: src/Core/L10n.php:425 src/Model/Event.php:444 #: src/Core/L10n.php:426 src/Model/Event.php:444
msgid "Oct" msgid "Oct"
msgstr "" msgstr ""
#: src/Core/L10n.php:425 src/Model/Event.php:445 #: src/Core/L10n.php:426 src/Model/Event.php:445
msgid "Nov" msgid "Nov"
msgstr "" msgstr ""
#: src/Core/L10n.php:425 src/Model/Event.php:446 #: src/Core/L10n.php:426 src/Model/Event.php:446
msgid "Dec" msgid "Dec"
msgstr "" msgstr ""
#: src/Core/L10n.php:444 #: src/Core/L10n.php:445
msgid "poke" msgid "poke"
msgstr "" msgstr ""
#: src/Core/L10n.php:444 #: src/Core/L10n.php:445
msgid "poked" msgid "poked"
msgstr "" msgstr ""
#: src/Core/L10n.php:445 #: src/Core/L10n.php:446
msgid "ping" msgid "ping"
msgstr "" msgstr ""
#: src/Core/L10n.php:445 #: src/Core/L10n.php:446
msgid "pinged" msgid "pinged"
msgstr "" msgstr ""
#: src/Core/L10n.php:446 #: src/Core/L10n.php:447
msgid "prod" msgid "prod"
msgstr "" msgstr ""
#: src/Core/L10n.php:446 #: src/Core/L10n.php:447
msgid "prodded" msgid "prodded"
msgstr "" msgstr ""
#: src/Core/L10n.php:447 #: src/Core/L10n.php:448
msgid "slap" msgid "slap"
msgstr "" msgstr ""
#: src/Core/L10n.php:447 #: src/Core/L10n.php:448
msgid "slapped" msgid "slapped"
msgstr "" msgstr ""
#: src/Core/L10n.php:448 #: src/Core/L10n.php:449
msgid "finger" msgid "finger"
msgstr "" msgstr ""
#: src/Core/L10n.php:448 #: src/Core/L10n.php:449
msgid "fingered" msgid "fingered"
msgstr "" msgstr ""
#: src/Core/L10n.php:449 #: src/Core/L10n.php:450
msgid "rebuff" msgid "rebuff"
msgstr "" msgstr ""
#: src/Core/L10n.php:449 #: src/Core/L10n.php:450
msgid "rebuffed" msgid "rebuffed"
msgstr "" msgstr ""
#: src/Core/Renderer.php:89 src/Core/Renderer.php:118 src/Core/Renderer.php:145 #: src/Core/Renderer.php:89 src/Core/Renderer.php:118 src/Core/Renderer.php:145
#: src/Core/Renderer.php:179 src/Render/FriendicaSmartyEngine.php:69 #: src/Core/Renderer.php:179 src/Render/FriendicaSmartyEngine.php:57
msgid "" msgid ""
"Friendica can't display this page at the moment, please contact the " "Friendica can't display this page at the moment, please contact the "
"administrator." "administrator."
@ -11051,8 +11051,9 @@ msgstr ""
msgid "stopped following" msgid "stopped following"
msgstr "" msgstr ""
#: src/Render/FriendicaSmartyEngine.php:65 #: src/Render/FriendicaSmartyEngine.php:53
msgid "The folder view/smarty3/ must be writable by webserver." #, php-format
msgid "The folder %s must be writable by webserver."
msgstr "" msgstr ""
#: src/Security/Authentication.php:226 #: src/Security/Authentication.php:226