added: generic html template: index_generic.html
(config option: templates_index_generic) this is a generic template without additional site-css (only uikit), at the moment used only in ckeditor file browser added: to Request class: index_template (std::wstring) - a name of an index html template
This commit is contained in:
parent
7a25e333db
commit
10e291bb39
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008-2018, Tomasz Sowa
|
* Copyright (c) 2008-2021, Tomasz Sowa
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -186,6 +186,7 @@ void Config::AssignValues(bool stdout_is_closed)
|
||||||
templates_fun_prefix = Text(L"templates_fun_prefix", L"fun_");
|
templates_fun_prefix = Text(L"templates_fun_prefix", L"fun_");
|
||||||
templates_fun_postfix = Text(L"templates_fun_postfix", L".html");
|
templates_fun_postfix = Text(L"templates_fun_postfix", L".html");
|
||||||
templates_index = Text(L"templates_index", L"index.html");
|
templates_index = Text(L"templates_index", L"index.html");
|
||||||
|
templates_index_generic = Text(L"templates_index_generic", L"index_generic.html");
|
||||||
templates_index_raw = Text(L"templates_index_raw", L"index_raw.html");
|
templates_index_raw = Text(L"templates_index_raw", L"index_raw.html");
|
||||||
template_only_root_use_template_fun = Bool(L"template_only_root_use_template_fun", false);
|
template_only_root_use_template_fun = Bool(L"template_only_root_use_template_fun", false);
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008-2018, Tomasz Sowa
|
* Copyright (c) 2008-2021, Tomasz Sowa
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -181,6 +181,10 @@ public:
|
||||||
// default: index.html
|
// default: index.html
|
||||||
std::wstring templates_index;
|
std::wstring templates_index;
|
||||||
|
|
||||||
|
// html template used to send generic content - without site-css styles and markup (only uikit)
|
||||||
|
// default: index_generic.html
|
||||||
|
std::wstring templates_index_generic;
|
||||||
|
|
||||||
// html template used to send raw content
|
// html template used to send raw content
|
||||||
// default: index_raw.html
|
// default: index_raw.html
|
||||||
std::wstring templates_index_raw;
|
std::wstring templates_index_raw;
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008-2015, Tomasz Sowa
|
* Copyright (c) 2008-2021, Tomasz Sowa
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -153,6 +153,8 @@ void Request::Clear()
|
||||||
ip = 0;
|
ip = 0;
|
||||||
ip_str.clear();
|
ip_str.clear();
|
||||||
use_200_status_for_not_found_and_permission_denied = false;
|
use_200_status_for_not_found_and_permission_denied = false;
|
||||||
|
|
||||||
|
html_template.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008-2018, Tomasz Sowa
|
* Copyright (c) 2008-2021, Tomasz Sowa
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -339,6 +339,8 @@ struct Request
|
||||||
bool gen_use_special_chars;
|
bool gen_use_special_chars;
|
||||||
|
|
||||||
|
|
||||||
|
// index template name
|
||||||
|
std::wstring html_template;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -51,6 +51,9 @@ Cat::Cat()
|
||||||
|
|
||||||
void Cat::MakeGet()
|
void Cat::MakeGet()
|
||||||
{
|
{
|
||||||
|
// IMPROVE ME this probably should be set for all winix functions
|
||||||
|
cur->request->html_template = cur->request->last_item->html_template;
|
||||||
|
|
||||||
if( !cur->request->is_item )
|
if( !cur->request->is_item )
|
||||||
{
|
{
|
||||||
log << log1 << "Content: cat function requires an item" << logend;
|
log << log1 << "Content: cat function requires an item" << logend;
|
||||||
|
|
|
@ -56,7 +56,7 @@ void Ls::MakeGet()
|
||||||
// this should be moved to ckeditor function (similarly the html content from fun_ls.html)
|
// this should be moved to ckeditor function (similarly the html content from fun_ls.html)
|
||||||
if( cur->request->IsParam(L"ckeditor_browse") )
|
if( cur->request->IsParam(L"ckeditor_browse") )
|
||||||
{
|
{
|
||||||
cur->request->index_template = config->templates_index_generic;
|
cur->request->html_template = config->templates_index_generic;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !cur->request->is_item )
|
if( !cur->request->is_item )
|
||||||
|
|
|
@ -60,6 +60,9 @@ void Run::MakePost()
|
||||||
|
|
||||||
void Run::MakeGet()
|
void Run::MakeGet()
|
||||||
{
|
{
|
||||||
|
// IMPROVE ME this probably should be set for all winix functions
|
||||||
|
cur->request->html_template = cur->request->last_item->html_template;
|
||||||
|
|
||||||
if( !cur->request->is_item )
|
if( !cur->request->is_item )
|
||||||
{
|
{
|
||||||
log << log1 << "Content: Run function requires an item" << logend;
|
log << log1 << "Content: Run function requires an item" << logend;
|
||||||
|
|
|
@ -97,12 +97,17 @@ void Template::CreateTemplateFileName(const std::wstring & index_str)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if( index == 1 )
|
if( index == 1 )
|
||||||
|
{
|
||||||
|
html_template = config->templates_index_generic;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if( index == 2 )
|
||||||
{
|
{
|
||||||
html_template = config->templates_index_raw;
|
html_template = config->templates_index_raw;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
index -= 2;
|
index -= 3;
|
||||||
Mount::ParamRow & par = system->mounts.pmount->param[system->mounts.MountParHtmlTemplate()];
|
Mount::ParamRow & par = system->mounts.pmount->param[system->mounts.MountParHtmlTemplate()];
|
||||||
|
|
||||||
if( !par.defined || (size_t)index >= par.arg.size() )
|
if( !par.defined || (size_t)index >= par.arg.size() )
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
[# minimalistic template]
|
||||||
|
|
||||||
|
<html lang="{language}">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
[include "index_head_functions_add.html"]
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>[doc_title]</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
[include "slog.html"]
|
||||||
|
[content]
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -91,8 +91,9 @@ void template_init()
|
||||||
// the first item in the html template is an empty string
|
// the first item in the html template is an empty string
|
||||||
// added in the html template
|
// added in the html template
|
||||||
temp_tab.clear();
|
temp_tab.clear();
|
||||||
temp_tab.push_back(config->templates_index); // index: 0
|
temp_tab.push_back(config->templates_index); // index: 0 (indices are used in template.cpp in functions) !! IMPROVE ME it should be done better
|
||||||
temp_tab.push_back(config->templates_index_raw); // index: 1
|
temp_tab.push_back(config->templates_index_generic);// index: 1
|
||||||
|
temp_tab.push_back(config->templates_index_raw); // index: 2
|
||||||
|
|
||||||
Mount::ParamRow & par = system->mounts.pmount->param[system->mounts.MountParHtmlTemplate()];
|
Mount::ParamRow & par = system->mounts.pmount->param[system->mounts.MountParHtmlTemplate()];
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008-2018, Tomasz Sowa
|
* Copyright (c) 2008-2021, Tomasz Sowa
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -46,7 +46,8 @@ namespace TemplatesFunctions
|
||||||
{
|
{
|
||||||
|
|
||||||
size_t pat_index; // main index pattern
|
size_t pat_index; // main index pattern
|
||||||
size_t pat_index_raw; // pattern for a raw content
|
size_t pat_index_generic; // generic index pattern, without any css-site styles, only main css (uikit)
|
||||||
|
size_t pat_index_raw; // pattern for a raw content (raw content without html, body markup)
|
||||||
size_t pat_err_404; // 404 error
|
size_t pat_err_404; // 404 error
|
||||||
size_t pat_err_per_denied; // permission denied error
|
size_t pat_err_per_denied; // permission denied error
|
||||||
|
|
||||||
|
@ -964,6 +965,7 @@ using namespace TemplatesFunctions;
|
||||||
ezc_blocks.Clear();
|
ezc_blocks.Clear();
|
||||||
|
|
||||||
pat_index = patterns.Add(config->templates_index);
|
pat_index = patterns.Add(config->templates_index);
|
||||||
|
pat_index_generic = patterns.Add(config->templates_index_generic);
|
||||||
pat_index_raw = patterns.Add(config->templates_index_raw);
|
pat_index_raw = patterns.Add(config->templates_index_raw);
|
||||||
pat_err_404 = patterns.Add(L"err_404.html"); // !! IMPROVE ME name to the config
|
pat_err_404 = patterns.Add(L"err_404.html"); // !! IMPROVE ME name to the config
|
||||||
pat_err_per_denied = patterns.Add(L"err_per_denied.html"); // !! IMPROVE ME name to the config
|
pat_err_per_denied = patterns.Add(L"err_per_denied.html"); // !! IMPROVE ME name to the config
|
||||||
|
@ -1031,6 +1033,11 @@ using namespace TemplatesFunctions;
|
||||||
index = patterns.Get(pat_index, TemplatesFunctions::locale.GetCurLang());
|
index = patterns.Get(pat_index, TemplatesFunctions::locale.GetCurLang());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
if( template_name == config->templates_index_generic )
|
||||||
|
{
|
||||||
|
index = patterns.Get(pat_index_generic, TemplatesFunctions::locale.GetCurLang());
|
||||||
|
}
|
||||||
|
else
|
||||||
if( template_name == config->templates_index_raw )
|
if( template_name == config->templates_index_raw )
|
||||||
{
|
{
|
||||||
index = patterns.Get(pat_index_raw, TemplatesFunctions::locale.GetCurLang());
|
index = patterns.Get(pat_index_raw, TemplatesFunctions::locale.GetCurLang());
|
||||||
|
@ -1058,9 +1065,9 @@ using namespace TemplatesFunctions;
|
||||||
|
|
||||||
Ezc::Pattern * index = 0;
|
Ezc::Pattern * index = 0;
|
||||||
|
|
||||||
if( (cur->request->function == &functions->fun_cat || cur->request->function == &functions->fun_run) && !cur->request->last_item->html_template.empty() )
|
if( !cur->request->html_template.empty() )
|
||||||
{
|
{
|
||||||
index = SelectIndexPattern(cur->request->last_item->html_template);
|
index = SelectIndexPattern(cur->request->html_template);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008-2018, Tomasz Sowa
|
* Copyright (c) 2008-2021, Tomasz Sowa
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -67,7 +67,8 @@ class Functions;
|
||||||
namespace TemplatesFunctions
|
namespace TemplatesFunctions
|
||||||
{
|
{
|
||||||
extern size_t pat_index;
|
extern size_t pat_index;
|
||||||
extern size_t pat_index_fullscreen;
|
extern size_t pat_index_generic;
|
||||||
|
extern size_t pat_index_raw;
|
||||||
extern size_t pat_err_404;
|
extern size_t pat_err_404;
|
||||||
extern size_t pat_err_per_denied;
|
extern size_t pat_err_per_denied;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue