allow to use multiple directories in html and txt templates
remove from the config: templates_dir, templates_dir_default, txt_templates_dir, txt_templates_dir_default add to the config: html_templates_dirs - a list of directories with html templates txt_templates_dirs - a list of directories with txt templates We search from the last directory to the first one.
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2022, Tomasz Sowa
|
||||
* Copyright (c) 2008-2026, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -180,10 +180,9 @@ void Config::AssignValues()
|
||||
image_quality = Int(L"image_quality", 92);
|
||||
convert_cmd = Text(L"convert_cmd", L"/usr/local/bin/convert");
|
||||
|
||||
templates_dir = Text(L"templates_dir");
|
||||
templates_dir_default = Text(L"templates_dir_default");
|
||||
txt_templates_dir = Text(L"txt_templates_dir");
|
||||
txt_templates_dir_default = Text(L"txt_templates_dir_default");
|
||||
ListText(L"html_templates_dirs", html_templates_dirs);
|
||||
ListText(L"txt_templates_dirs", txt_templates_dirs);
|
||||
|
||||
templates_fun_prefix = Text(L"templates_fun_prefix", L"fun_");
|
||||
templates_fun_postfix = Text(L"templates_fun_postfix", L".html");
|
||||
templates_index = Text(L"templates_index", L"index.html");
|
||||
@@ -523,6 +522,8 @@ bool Config::ListText(const std::wstring & name, std::vector<std::wstring> & lis
|
||||
return space.to_list(name, list);
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Config::HasValue(const wchar_t * name, const wchar_t * value)
|
||||
{
|
||||
return space.has_value(name, value);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2022, Tomasz Sowa
|
||||
* Copyright (c) 2008-2026, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -186,11 +186,13 @@ public:
|
||||
// default: 3
|
||||
size_t fcgi_cannot_create_request_delay;
|
||||
|
||||
std::wstring templates_dir;
|
||||
std::wstring templates_dir_default; // html templates from winix
|
||||
// html templates directories
|
||||
// by default a file from the last directory is chosen
|
||||
std::vector<std::wstring> html_templates_dirs;
|
||||
|
||||
std::wstring txt_templates_dir;
|
||||
std::wstring txt_templates_dir_default; // txt (notifications) templates from winix
|
||||
// txt (notifications) templates directories
|
||||
// by default a file from the last directory is chosen
|
||||
std::vector<std::wstring> txt_templates_dirs;
|
||||
|
||||
// prefix and postfix for functions templates
|
||||
// default:
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2024, Tomasz Sowa
|
||||
* Copyright (c) 2008-2026, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -97,7 +97,7 @@ bool Notify::Init()
|
||||
if( !thread_manager->Add(¬ify_thread, L"notifications") )
|
||||
return false;
|
||||
|
||||
patterns.SetDirectories(config->txt_templates_dir, config->txt_templates_dir_default);
|
||||
patterns.SetDirectories(config->txt_templates_dirs);
|
||||
patterns.SetLocale(&TemplatesFunctions::locale);
|
||||
patterns.SetLocaleFilter(&TemplatesFunctions::locale_filter);
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2011-2015, Tomasz Sowa
|
||||
* Copyright (c) 2011-2026, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -59,13 +59,16 @@ void Patterns::SetDeleteWhiteItems(bool del_white)
|
||||
}
|
||||
|
||||
|
||||
void Patterns::SetDirectories(const std::wstring & tmpl_dir, const std::wstring & tmpl_dir_def)
|
||||
void Patterns::SetDirectories(const std::vector<std::wstring> & tmpl_dirs)
|
||||
{
|
||||
templates_dir = tmpl_dir;
|
||||
templates_dir_def = tmpl_dir_def;
|
||||
templates_dirs = tmpl_dirs;
|
||||
}
|
||||
|
||||
|
||||
void Patterns::ClearDirectories()
|
||||
{
|
||||
templates_dirs.clear();
|
||||
}
|
||||
|
||||
|
||||
void Patterns::SetLocale(Locale * plocale)
|
||||
@@ -138,7 +141,7 @@ void Patterns::ReadPatterns(Template & templ)
|
||||
* pattern_parser.SetCommentary() is set beforehand
|
||||
*/
|
||||
pattern_parser.DeleteWhiteTextItems(del_white_items);
|
||||
pattern_parser.Directory(templates_dir, templates_dir_def);
|
||||
pattern_parser.SetDirectories(templates_dirs);
|
||||
pattern_parser.SetLogger(&log);
|
||||
|
||||
if( ezc_blocks )
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2011-2018, Tomasz Sowa
|
||||
* Copyright (c) 2011-2026, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -53,7 +53,8 @@ public:
|
||||
Patterns();
|
||||
|
||||
void SetDeleteWhiteItems(bool del_white);
|
||||
void SetDirectories(const std::wstring & tmpl_dir, const std::wstring & tmpl_dir_def);
|
||||
void SetDirectories(const std::vector<std::wstring> & tmpl_dirs);
|
||||
void ClearDirectories();
|
||||
|
||||
/*
|
||||
setting locale and locale_filter
|
||||
@@ -151,7 +152,7 @@ public:
|
||||
private:
|
||||
|
||||
bool del_white_items;
|
||||
std::wstring templates_dir, templates_dir_def;
|
||||
std::vector<std::wstring> templates_dirs;
|
||||
Locale * locale;
|
||||
LocaleFilter * locale_filter;
|
||||
|
||||
|
||||
@@ -868,7 +868,7 @@ void Templates::Init()
|
||||
{
|
||||
using namespace TemplatesFunctions;
|
||||
|
||||
patterns.SetDirectories(config->templates_dir, config->templates_dir_default);
|
||||
patterns.SetDirectories(config->html_templates_dirs);
|
||||
pattern_cacher.SetWhenDelete(config->pattern_cacher_when_delete, config->pattern_cacher_how_many_delete);
|
||||
CreateFunctions(); // create functions first (functions will be cached by patterns)
|
||||
ReadTemplates();
|
||||
|
||||
Reference in New Issue
Block a user