From 61fe6ea2195e18787b039a43d86e50ba5718d113 Mon Sep 17 00:00:00 2001 From: Tomasz Sowa Date: Sun, 23 May 2021 10:14:08 +0200 Subject: [PATCH] updated to the new api from ezc: changed semantic of [def] and Vars moved outside of Generator --- winixd/html/index_head_adder.html | 52 +++++++++++++++++++++---------- winixd/templates/misc.cpp | 3 +- winixd/templates/templates.cpp | 3 ++ 3 files changed, 40 insertions(+), 18 deletions(-) diff --git a/winixd/html/index_head_adder.html b/winixd/html/index_head_adder.html index 5fb5692..b43e362 100644 --- a/winixd/html/index_head_adder.html +++ b/winixd/html/index_head_adder.html @@ -1,19 +1,37 @@ -[def winix_has_uikit "true"] -[def winix_has_jquery "false"] +[# def? means define a variable if such a variable does not exist yet] +[# true and false are ezc functions defined by winix] + +[def? winix_has_uikit false] +[def? winix_has_jquery false] + +[def? winix_load_uikit true] +[def? winix_set_charset true] +[def? winix_set_viewport true] -[# IMPROME ME we can add some conditionales such as 'do_not_set_charset'] - - -[# UIkit CSS] - -[# UIkit JS] - - +[if winix_set_charset] + +[end] +[if winix_set_viewport] + +[end] + + +[if winix_load_uikit] + [def winix_has_uikit true] + + [# UIkit CSS] + + + [# UIkit JS] + + +[end] + [if winix_function_is "emacs"] @@ -106,7 +124,7 @@ cm.save() [if winix_function_is "ckeditor"] - [def winix_has_jquery "true"] + [def winix_has_jquery true] @@ -119,7 +137,7 @@ cm.save() [# tinymce can use a special theme called 'mobile' - it is used when /mobile param is provided] - [def winix_has_jquery "true"] + [def winix_has_jquery true] [end] @@ -136,7 +154,7 @@ cm.save() [# info from version 0.5-rc1: this editor doesn't work on different domains by default, solution: http://forum.wymeditor.org/forum/viewtopic.php?f=2&t=731&p=2507#p2504 ] [# you should add one file to winix: wymiframe.html ] - [def winix_has_jquery "true"] + [def winix_has_jquery true] @@ -152,7 +170,7 @@ cm.save() [if gallery_mount_type_arg_is "lightbox"] [# https://lokeshdhakar.com/projects/lightbox2/ ] - [def winix_has_jquery "true"] + [def winix_has_jquery true] @@ -162,7 +180,7 @@ cm.save() [# https://galleriajs.github.io/ ] [# formerly called aino-gallery ] - [def winix_has_jquery "true"] + [def winix_has_jquery true] [end] @@ -198,7 +216,7 @@ cm.save() - [def winix_has_jquery "true"] + [def winix_has_jquery true] @@ -256,7 +274,7 @@ cm.save() [if winix_function_is "imgcrop"] - [def winix_has_jquery "true"] + [def winix_has_jquery true] diff --git a/winixd/templates/misc.cpp b/winixd/templates/misc.cpp index f65ec6f..ac06032 100644 --- a/winixd/templates/misc.cpp +++ b/winixd/templates/misc.cpp @@ -47,7 +47,7 @@ namespace TemplatesFunctions extern EzcFun ezc_functions; extern Ezc::Blocks ezc_blocks; - +extern Ezc::Vars ezc_vars; void HtmlEscapeFormTxt(HtmlTextStream & out, const std::wstring & in) @@ -107,6 +107,7 @@ void InitGenerator(EzcGen & gen) */ gen.SetBlocks(ezc_blocks); gen.SetFunctions(ezc_functions); + gen.SetVariables(ezc_vars); } diff --git a/winixd/templates/templates.cpp b/winixd/templates/templates.cpp index 4dd67dc..1a74c55 100644 --- a/winixd/templates/templates.cpp +++ b/winixd/templates/templates.cpp @@ -62,6 +62,7 @@ Locale locale; // IMPROVE ME will be moved to a better place EzcFun ezc_functions; Ezc::Blocks ezc_blocks; Ezc::Objects ezc_objects; +Ezc::Vars ezc_vars; LocaleFilter locale_filter; HTMLFilter html_filter; @@ -1118,6 +1119,7 @@ void Templates::Generate() { using namespace TemplatesFunctions; + ezc_vars.clear(); Ezc::Pattern * index = SelectIndexPattern(); if( index ) @@ -1140,6 +1142,7 @@ void Templates::Generate(Ezc::Pattern & pattern) { using namespace TemplatesFunctions; + ezc_vars.clear(); InitGenerator(generator); generator.SetPattern(pattern); generator.Generate(cur->request->out_main_stream, cur->request->out_streams);