From f4ca5293d4d2c5dc3e0d31382dd9f7ed7269123d Mon Sep 17 00:00:00 2001 From: Merci Jacob Date: Wed, 2 Oct 2024 11:09:35 +0200 Subject: [PATCH 1/2] Include js_modules files content in the final generated site.js --- modules/core/output_modules.php | 4 +--- scripts/config_gen.php | 7 +++++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/modules/core/output_modules.php b/modules/core/output_modules.php index 0354f9cd16..c745a67b3d 100644 --- a/modules/core/output_modules.php +++ b/modules/core/output_modules.php @@ -561,11 +561,9 @@ protected function output() { $mod = str_replace(array('modules', DIRECTORY_SEPARATOR), '', $rel_name); if (in_array($mod, $mods, true) && is_readable(sprintf("%ssite.js", $name))) { $res .= ''; - $res .= ''; } - $res .= ''; } } if ($core) { diff --git a/scripts/config_gen.php b/scripts/config_gen.php index ae703527d6..2299c9ecdd 100644 --- a/scripts/config_gen.php +++ b/scripts/config_gen.php @@ -183,9 +183,12 @@ function get_module_assignments($settings) { $mods = get_modules($settings); foreach ($mods as $mod) { printf("scanning module %s ...\n", $mod); - if (is_readable(sprintf("modules/%s/site.js", $mod))) { - $js .= str_replace("'use strict';", '', file_get_contents(sprintf("modules/%s/site.js", $mod))); + foreach (glob('modules' . DIRECTORY_SEPARATOR . $mod . DIRECTORY_SEPARATOR . 'js_modules' . DIRECTORY_SEPARATOR . '*.js') as $js_module) { + $js .= file_get_contents($js_module); } + if (is_readable(sprintf("modules/%s/site.js", $mod))) { + $js .= str_replace("'use strict';", '', file_get_contents(sprintf("modules/%s/site.js", $mod))); + } if (is_readable(sprintf("modules/%s/site.css", $mod))) { $css .= file_get_contents(sprintf("modules/%s/site.css", $mod)); } From 13507e41c14320c36772368267ce3949f8d9fd62 Mon Sep 17 00:00:00 2001 From: Merci Jacob Date: Wed, 2 Oct 2024 11:18:32 +0200 Subject: [PATCH 2/2] Fix unit test --- tests/phpunit/modules/core/output_modules_debug.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/phpunit/modules/core/output_modules_debug.php b/tests/phpunit/modules/core/output_modules_debug.php index 14ae83e486..72087b7376 100644 --- a/tests/phpunit/modules/core/output_modules_debug.php +++ b/tests/phpunit/modules/core/output_modules_debug.php @@ -30,7 +30,7 @@ public function test_page_js_debug() { $this->assertEquals(array(''), $res->output_response); $test->handler_response = array('encrypt_ajax_requests' => true, 'router_module_list' => array('imap')); $res = $test->run(); - $this->assertEquals(array(''), $res->output_response); + $this->assertEquals(array(''), $res->output_response); } /** * @preserveGlobalState disabled