From c257c48b8a34bc7c497019ccabdf28a19a7e3879 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Thu, 23 Jul 2020 17:58:22 +0000 Subject: [PATCH] Bug 22660: (follow-up) Improve asset handling, add linting This patch makes some changes to the way assets are included based on the value of the system preferece in order to minimize unnecessary JavaScript includes. The patch also adds HTML syntax-highlighting and linting like we have in the system preferences editor. Removed are two JS files which were not required. To test, apply the patch and set the NewsToolEditor preference to "CodeMirror." - Edit a news item and confirm that the contents of the editor show HTML syntax highlighting. - Test HTML linting by adding some malformed HTML (missing closing tag, for instance). The error should be highlighted. - Set the NewsToolEditor to "TinyMCE" and confirm that WYSIWYG editing still works correctly. https://bugs.koha-community.org/show_bug.cgi?id=22600 Signed-off-by: Lisette Scheer Signed-off-by: Katrin Fischer --- .../prog/en/modules/tools/koha-news.tt | 87 +++++++++++++--------- 1 file changed, 50 insertions(+), 37 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tt index 80d6d68dff..9cc58f371d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tt @@ -1,19 +1,23 @@ [% USE raw %] [% USE Asset %] +[% USE Koha %] [% USE KohaDates %] [% USE Branches %] [% SET footerjs = 1 %] [% INCLUDE 'doc-head-open.inc' %] -[% Asset.css("lib/codemirror/codemirror.css") | $raw %] - Koha › Tools › News [% INCLUDE 'doc-head-close.inc' %] [% IF ( opac_news_count ) %] [% END %] +[% IF Koha.Preference('NewsToolEditor') == 'codemirror' %] + [% Asset.css("lib/codemirror/codemirror.css") | $raw %] + [% Asset.css("lib/codemirror/lint.min.css") | $raw %] + +[% END %] @@ -208,12 +212,12 @@ Edit news item[% ELSE %]Add news item[% END %][% ELSE %]News[% END %] [% END %] + + [% MACRO jsinclude BLOCK %] [% INCLUDE 'calendar.inc' %] [% Asset.js("js/tools-menu.js") | $raw %] - [% Asset.js("lib/d3c3/d3.min.js") | $raw %] - [% Asset.js("lib/d3c3/c3.min.js") | $raw %] [% IF ( opac_news_count ) %] [% INCLUDE 'datatables.inc' %] [% END %] - [% Asset.js( "lib/codemirror/codemirror.min.js" ) | $raw %] - [% Asset.js("lib/tiny_mce/tinymce.min.js") | $raw %] - [% INCLUDE 'str/tinymce_i18n.inc' %] - + [% IF Koha.Preference('NewsToolEditor') == 'codemirror' %] + [% Asset.js( "lib/codemirror/codemirror.min.js" ) | $raw %] + [% Asset.js( "lib/codemirror/xml.min.js" ) | $raw %] + [% Asset.js( "lib/codemirror/lint.min.js" ) | $raw %] + [% Asset.js( "lib/linters/htmlhint.min.js" ) | $raw %] + [% Asset.js( "lib/codemirror/html-lint.min.js" ) | $raw %] + + [% ELSE %] + [% INCLUDE 'str/tinymce_i18n.inc' %] + [% Asset.js("lib/tiny_mce/tinymce.min.js") | $raw %] + + [% END # /IF NewsToolEditor %] [% END %] [% BLOCK lang_locations %] -- 2.11.0