From e57de027e1b7077e7530ec60a7c4268ab90f3876 Mon Sep 17 00:00:00 2001 From: Robert Date: Sun, 27 Jul 2025 20:52:03 -0400 Subject: [PATCH] init 8 --- protected/src/composer.json | 3 +- protected/src/configs/on_footer_banner.php | 32 +++++++++++++++++++ protected/src/configs/on_html_purifier.php | 15 +++++++++ protected/src/configs/on_liquid.php | 15 +++++++++ .../configs/{off_hello.php => on_twig.php} | 6 +++- protected/src/controllers/app/home_ctrl.php | 3 +- protected/src/services/on_html_filter.php | 20 ++++++++++++ protected/src/services/on_liquid.php | 8 +++-- protected/src/services/on_twig.php | 8 +++-- .../src/views/default/app/home_index.php | 8 ++++- 10 files changed, 109 insertions(+), 9 deletions(-) create mode 100644 protected/src/configs/on_footer_banner.php create mode 100644 protected/src/configs/on_html_purifier.php create mode 100644 protected/src/configs/on_liquid.php rename protected/src/configs/{off_hello.php => on_twig.php} (55%) create mode 100644 protected/src/services/on_html_filter.php diff --git a/protected/src/composer.json b/protected/src/composer.json index e07dc5d..d92b1d8 100644 --- a/protected/src/composer.json +++ b/protected/src/composer.json @@ -1,6 +1,7 @@ { "require": { "twig/twig": "^3.0", - "liquid/liquid": "^1.4" + "liquid/liquid": "^1.4", + "ezyang/htmlpurifier": "^4.18" } } diff --git a/protected/src/configs/on_footer_banner.php b/protected/src/configs/on_footer_banner.php new file mode 100644 index 0000000..bf45f34 --- /dev/null +++ b/protected/src/configs/on_footer_banner.php @@ -0,0 +1,32 @@ + + * @copyright (c) 2025, Robert Strutts + * @license MIT + */ + +?> + + \ No newline at end of file diff --git a/protected/src/configs/on_html_purifier.php b/protected/src/configs/on_html_purifier.php new file mode 100644 index 0000000..1b64cfb --- /dev/null +++ b/protected/src/configs/on_html_purifier.php @@ -0,0 +1,15 @@ + + * @copyright (c) 2025, Robert Strutts + * @license MIT + */ + +use CodeHydrater\bootstrap\configure as Config; + +Config::set('html_purifier', [ + "enable_file_caching" => false +]); \ No newline at end of file diff --git a/protected/src/configs/on_liquid.php b/protected/src/configs/on_liquid.php new file mode 100644 index 0000000..6291f49 --- /dev/null +++ b/protected/src/configs/on_liquid.php @@ -0,0 +1,15 @@ + + * @copyright (c) 2025, Robert Strutts + * @license MIT + */ + +use CodeHydrater\bootstrap\configure as Config; + +Config::set('liquid', [ + "enable_file_caching" => false +]); \ No newline at end of file diff --git a/protected/src/configs/off_hello.php b/protected/src/configs/on_twig.php similarity index 55% rename from protected/src/configs/off_hello.php rename to protected/src/configs/on_twig.php index ce11f7e..7536abd 100644 --- a/protected/src/configs/off_hello.php +++ b/protected/src/configs/on_twig.php @@ -8,4 +8,8 @@ declare(strict_types=1); * @license MIT */ -echo "Hello, Loaded Test Config file..."; \ No newline at end of file +use CodeHydrater\bootstrap\configure as Config; + +Config::set('twig', [ + "enable_file_caching" => false +]); \ No newline at end of file diff --git a/protected/src/controllers/app/home_ctrl.php b/protected/src/controllers/app/home_ctrl.php index 5c4f1f7..ee658d8 100644 --- a/protected/src/controllers/app/home_ctrl.php +++ b/protected/src/controllers/app/home_ctrl.php @@ -10,7 +10,6 @@ declare(strict_types = 1); namespace Project\controllers\app; use CodeHydrater\enums\view_type as ViewType; -use CodeHydrater\bootstrap\registry as Reg; /** * Description of home_ctrl @@ -62,7 +61,7 @@ class home_ctrl { } public function demo(?string $name="Test", ?int $limit=10, ?int $page=1) { - echo "DEMO Name: ". $name; + echo "DEMO Name: ". \CodeHydrater\bootstrap\safer_io::p($name); echo "LIMIT = ". $limit; echo "PAGE = ". $page; } diff --git a/protected/src/services/on_html_filter.php b/protected/src/services/on_html_filter.php new file mode 100644 index 0000000..c67d20f --- /dev/null +++ b/protected/src/services/on_html_filter.php @@ -0,0 +1,20 @@ + + * @copyright (c) 2025, Robert Strutts + * @license MIT + */ + +use CodeHydrater\bootstrap\registry as Reg; +use CodeHydrater\bootstrap\configure as Config; + +Reg::get('di')->register('html_filter', function() { + + $use_file_cache = Config::get('html_purifier', "enable_file_caching") ?? false; + return new \CodeHydrater\services\html_filter( + $use_file_cache + ); +}); \ No newline at end of file diff --git a/protected/src/services/on_liquid.php b/protected/src/services/on_liquid.php index 26605d0..e623709 100644 --- a/protected/src/services/on_liquid.php +++ b/protected/src/services/on_liquid.php @@ -8,8 +8,12 @@ declare(strict_types=1); * @license MIT */ -use CodeHydrater\bootstrap\registry as Reg; +use CodeHydrater\bootstrap\registry as Reg; +use CodeHydrater\bootstrap\configure as Config; Reg::get('di')->register('liquid', function() { - return new \CodeHydrater\services\liquid_templates(); + + $use_file_cache = Config::get('liquid', "enable_file_caching") ?? false; + + return new \CodeHydrater\services\liquid_templates($use_file_cache); }); diff --git a/protected/src/services/on_twig.php b/protected/src/services/on_twig.php index a550f11..e3d7762 100644 --- a/protected/src/services/on_twig.php +++ b/protected/src/services/on_twig.php @@ -8,8 +8,12 @@ declare(strict_types=1); * @license MIT */ -use CodeHydrater\bootstrap\registry as Reg; +use CodeHydrater\bootstrap\registry as Reg; +use CodeHydrater\bootstrap\configure as Config; Reg::get('di')->register('twig', function() { - return \CodeHydrater\services\twig::init(); + + $use_file_cache = Config::get('twig', "enable_file_caching") ?? false; + + return \CodeHydrater\services\twig::init($use_file_cache); }); diff --git a/protected/src/views/default/app/home_index.php b/protected/src/views/default/app/home_index.php index eae20cb..1081133 100644 --- a/protected/src/views/default/app/home_index.php +++ b/protected/src/views/default/app/home_index.php @@ -1,11 +1,17 @@

Welcome...to your M0ck Ups

-View Name Demo

\ No newline at end of file +View Twig Demo

+ +View Liquid Demo

\ No newline at end of file