From ba3a08b568c8d6de658e33b432af8510632f89ae Mon Sep 17 00:00:00 2001 From: ievgenii vdovenko Date: Wed, 10 Dec 2025 12:59:05 +0100 Subject: [PATCH] refactoring: moves codemirror scripts to a separate file --- .gitignore | 2 ++ Gruntfile.js | 2 +- grunt_config.json | 31 +++++++++++++------ rhodecode/templates/base/root.mako | 2 -- rhodecode/templates/compare/compare_diff.mako | 2 ++ .../templates/data_table/_dt_elements.mako | 3 ++ rhodecode/templates/files/files_add.mako | 3 ++ 7 files changed, 33 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index 9a85fda7..fface4c7 100644 --- a/.gitignore +++ b/.gitignore @@ -45,6 +45,8 @@ rhodecode/public/js/src/components/**/*.css /rhodecode/public/js/rhodecode-components.js /rhodecode/public/js/scripts.js /rhodecode/public/js/scripts.min.js +/rhodecode/public/js/codemirror-dist.js +/rhodecode/public/js/codemirror-dist.min.js /rhodecode/public/js/src/components/root-styles.gen.html /rhodecode/public/js/vendors/webcomponentsjs/ /rhodecode.db diff --git a/Gruntfile.js b/Gruntfile.js index e5697203..b4e04c60 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -18,5 +18,5 @@ module.exports = function(grunt) { grunt.loadNpmTasks('grunt-contrib-jshint'); grunt.loadNpmTasks('grunt-contrib-copy'); grunt.loadNpmTasks('grunt-webpack'); - grunt.registerTask('default', ['less:production', 'less:components', 'copy', 'webpack', 'concat:dist', 'terser:dist']); + grunt.registerTask('default', ['less:production', 'less:components', 'copy', 'webpack', 'concat:dist', 'terser:dist', 'concat:ext', 'uglify:ext']); }; diff --git a/grunt_config.json b/grunt_config.json index bf4e66fc..2ee41c68 100644 --- a/grunt_config.json +++ b/grunt_config.json @@ -64,14 +64,6 @@ "<%= dirs.js.src %>/plugins/jquery.timeago.js", "<%= dirs.js.src %>/plugins/jquery.timeago-extension.js", "<%= dirs.js.src %>/select2/select2.js", - "<%= dirs.js.src %>/codemirror/codemirror.js", - "<%= dirs.js.src %>/codemirror/codemirror_loadmode.js", - "<%= dirs.js.src %>/codemirror/codemirror_hint.js", - "<%= dirs.js.src %>/codemirror/codemirror_overlay.js", - "<%= dirs.js.src %>/codemirror/codemirror_placeholder.js", - "<%= dirs.js.src %>/codemirror/codemirror_simplemode.js", - "<%= dirs.js.dest %>/mode/meta.js", - "<%= dirs.js.dest %>/mode/meta_ext.js", "<%= dirs.js.src_rc %>/i18n/select2/translations.js", "<%= dirs.js.src %>/rhodecode/utils/array.js", "<%= dirs.js.src %>/rhodecode/utils/string.js", @@ -84,7 +76,6 @@ "<%= dirs.js.src %>/rhodecode/utils/topics.js", "<%= dirs.js.src %>/rhodecode/init.js", "<%= dirs.js.src %>/rhodecode/changelog.js", - "<%= dirs.js.src %>/rhodecode/codemirror.js", "<%= dirs.js.src %>/rhodecode/comments.js", "<%= dirs.js.src %>/rhodecode/constants.js", "<%= dirs.js.src %>/rhodecode/files.js", @@ -104,6 +95,21 @@ ], "dest": "<%= dirs.js.dest %>/scripts.js", "nonull": true + }, + "ext": { + "src": [ + "<%= dirs.js.src %>/codemirror/codemirror.js", + "<%= dirs.js.src %>/codemirror/codemirror_loadmode.js", + "<%= dirs.js.src %>/codemirror/codemirror_hint.js", + "<%= dirs.js.src %>/codemirror/codemirror_overlay.js", + "<%= dirs.js.src %>/codemirror/codemirror_placeholder.js", + "<%= dirs.js.src %>/codemirror/codemirror_simplemode.js", + "<%= dirs.js.dest %>/mode/meta.js", + "<%= dirs.js.dest %>/mode/meta_ext.js", + "<%= dirs.js.src %>/rhodecode/codemirror.js" + ], + "dest": "<%= dirs.js.dest %>/codemirror-dist.js", + "nonull": true } }, "terser": { @@ -147,7 +153,14 @@ "files": { "<%= dirs.js.dest %>/scripts.min.js": "<%= dirs.js.dest %>/scripts.js" } + "src": "<%= dirs.js.dest %>/scripts.js", + "dest": "<%= dirs.js.dest %>/scripts.min.js" + }, + "ext": { + "src": "<%= dirs.js.dest %>/codemirror-dist.js", + "dest": "<%= dirs.js.dest %>/codemirror-dist.min.js" } + }, "less": { "development": { diff --git a/rhodecode/templates/base/root.mako b/rhodecode/templates/base/root.mako index 3046807b..4b3384c6 100644 --- a/rhodecode/templates/base/root.mako +++ b/rhodecode/templates/base/root.mako @@ -144,8 +144,6 @@ c.template_context['attachment_store'] = { ## avoide escaping the %N - - ## JAVASCRIPT EXTRA - optionally inject some extra JS for specificed templates ${self.js_extra()} diff --git a/rhodecode/templates/compare/compare_diff.mako b/rhodecode/templates/compare/compare_diff.mako index 569a7677..e42f62a0 100644 --- a/rhodecode/templates/compare/compare_diff.mako +++ b/rhodecode/templates/compare/compare_diff.mako @@ -27,6 +27,8 @@ // set fake commitId on this commit-range page templateContext.commit_data.commit_id = "${h.EmptyCommit().raw_id}"; + +
diff --git a/rhodecode/templates/data_table/_dt_elements.mako b/rhodecode/templates/data_table/_dt_elements.mako index d5835c06..cde395da 100644 --- a/rhodecode/templates/data_table/_dt_elements.mako +++ b/rhodecode/templates/data_table/_dt_elements.mako @@ -535,6 +535,9 @@ ${h.style_metatag(tag_type, tag)|n,trim} % endif
+ + + diff --git a/rhodecode/templates/files/files_add.mako b/rhodecode/templates/files/files_add.mako index ffe4f3a3..864d5fcc 100644 --- a/rhodecode/templates/files/files_add.mako +++ b/rhodecode/templates/files/files_add.mako @@ -19,6 +19,9 @@ <%def name="main()"> + + +