(ezc): generate only requested frames

This commit is contained in:
2024-07-07 22:10:29 +02:00
parent b2f4c065ea
commit 2490e2cc68
7 changed files with 28 additions and 27 deletions

View File

@@ -637,7 +637,7 @@ void Item::execute(EzcEnv & env)
Ezc::Pattern * p = pattern_cacher->GetPattern(*this);
TemplatesFunctions::InitGenerator(ezc_generator, request->models);
TemplatesFunctions::InitGenerator(ezc_generator, *request);
ezc_generator.SetPattern(*p);
if( config->allow_ezc_frames_in_executable_items )

View File

@@ -354,7 +354,7 @@ void thread_sort_tab_run(Info & i)
Ezc::Pattern * p = pattern_cacher.GetPattern(*thread_info.item_sort_tab[item_sort_index]);
item_run_content.clear();
InitGenerator(ezc_generator, cur->request->models);
InitGenerator(ezc_generator, *cur->request);
ezc_generator.SetPattern(*p);
ezc_generator.Generate(item_run_content);

View File

@@ -74,7 +74,7 @@ void insert_page_run(Info & i)
info.run_content.clear();
InitGenerator(info.ezc_gen, cur->request->models);
InitGenerator(info.ezc_gen, *cur->request);
info.ezc_gen.SetPattern(*pat);
info.ezc_gen.Generate(info.run_content);
ItemContent::print_content(i.out, info.run_content.get_buffer(), info.item.item_content.content_raw_type, config->html_filter);

View File

@@ -40,8 +40,6 @@
namespace Winix
{
namespace TemplatesFunctions
{
@@ -92,7 +90,7 @@ int was_enter = 0; // how many enteres there were before
void InitGenerator(EzcGen & gen, Ezc::Models & ezc_models)
void InitGenerator(EzcGen & gen, Request & request)
{
gen.TrimWhite(gen_trim_white);
gen.SkipNewLine(gen_skip_new_line);
@@ -108,8 +106,17 @@ void InitGenerator(EzcGen & gen, Ezc::Models & ezc_models)
gen.SetFunctions(ezc_functions);
gen.SetVariables(ezc_vars);
gen.SetModels(ezc_models);
gen.SetModels(request.models);
gen.SetLogger(log);
if( request.send_all_frames )
{
gen.OnlyFrames(nullptr);
}
else
{
gen.OnlyFrames(request.send_frames);
}
}

View File

@@ -43,9 +43,8 @@
namespace Winix
{
class User;
class Request;
// Ezc::FunInfo<> will be renamed to Ezc::Env<> in the future
typedef Ezc::FunInfo<HtmlTextStream> EzcEnv;
@@ -66,7 +65,7 @@ HtmlTextStream::RawText<RawType> R(const RawType & par)
}
void InitGenerator(EzcGen & gen, Ezc::Models & ezc_models);
void InitGenerator(EzcGen & gen, Request & request);
void HtmlEscapeFormTxt(HtmlTextStream & out, const std::wstring & in);

View File

@@ -168,7 +168,7 @@ Ezc::Pattern * pattern = 0;
if( pattern )
{
InitGenerator(content_gen, cur->request->models);
InitGenerator(content_gen, *cur->request);
content_gen.SetPattern(*pattern);
content_gen.Generate(env.out, cur->request->out_streams);
}
@@ -1004,9 +1004,19 @@ using namespace TemplatesFunctions;
if( index )
{
InitGenerator(generator, cur->request->models);
InitGenerator(generator, *cur->request);
generator.SetPattern(*index);
generator.UseMainStream(cur->request->send_main_stream);
generator.Generate(cur->request->out_main_stream, cur->request->out_streams);
// for debug purposes:
// log << log4 << "Templates: main stream size: " << cur->request->out_main_stream.size() << logend;
// log << log4 << "Templates: produced frames: " << logend;
// for(auto i=cur->request->out_streams.streams_map.begin() ; i != cur->request->out_streams.streams_map.end() ; ++i)
// {
// log << log4 << " frame name: " << i->first << ", size: " << i->second->size() << logend;
// }
}
else
{
@@ -1016,20 +1026,6 @@ using namespace TemplatesFunctions;
void Templates::Generate(Ezc::Pattern & pattern)
{
using namespace TemplatesFunctions;
ezc_vars.clear();
InitGenerator(generator, cur->request->models);
generator.SetPattern(pattern);
generator.Generate(cur->request->out_main_stream, cur->request->out_streams);
}
void Templates::SetConfig(Config * pconfig)
{
TemplatesFunctions::config = pconfig;

View File

@@ -584,7 +584,6 @@ public:
void SetEzcParameters(bool trim_white, bool skip_new_line, bool use_special_chars);
void Generate();
void Generate(Ezc::Pattern & pattern);
private: