A platform for community discussion. Free, open, simple.
Migrate pretty-text to `.js` extensions (#9243)
Robin Wardc15056650647
diff --git a/app/assets/javascripts/pretty-text/censored-words.js.es6 b/app/assets/javascripts/pretty-text/censored-words.jssimilarity index 100%rename from app/assets/javascripts/pretty-text/censored-words.js.es6rename to app/assets/javascripts/pretty-text/censored-words.jsdiff --git a/app/assets/javascripts/pretty-text/context/inline-onebox-css-classes.js.es6.erb b/app/assets/javascripts/pretty-text/context/inline-onebox-css-classes.js.erbsimilarity index 100%rename from app/assets/javascripts/pretty-text/context/inline-onebox-css-classes.js.es6.erbrename to app/assets/javascripts/pretty-text/context/inline-onebox-css-classes.js.erbdiff --git a/app/assets/javascripts/pretty-text/emoji.js.es6 b/app/assets/javascripts/pretty-text/emoji.jssimilarity index 100%rename from app/assets/javascripts/pretty-text/emoji.js.es6rename to app/assets/javascripts/pretty-text/emoji.jsdiff --git a/app/assets/javascripts/pretty-text/emoji/data.js.es6.erb b/app/assets/javascripts/pretty-text/emoji/data.js.erbsimilarity index 100%rename from app/assets/javascripts/pretty-text/emoji/data.js.es6.erbrename to app/assets/javascripts/pretty-text/emoji/data.js.erbdiff --git a/app/assets/javascripts/pretty-text/emoji/version.js.es6.erb b/app/assets/javascripts/pretty-text/emoji/version.js.erbsimilarity index 100%rename from app/assets/javascripts/pretty-text/emoji/version.js.es6.erbrename to app/assets/javascripts/pretty-text/emoji/version.js.erbdiff --git a/app/assets/javascripts/pretty-text/engines/discourse-markdown-it.js.es6 b/app/assets/javascripts/pretty-text/engines/discourse-markdown-it.jssimilarity index 100%rename from app/assets/javascripts/pretty-text/engines/discourse-markdown-it.js.es6rename to app/assets/javascripts/pretty-text/engines/discourse-markdown-it.jsdiff --git a/app/assets/javascripts/pretty-text/engines/discourse-markdown/bbcode-block.js.es6 b/app/assets/javascripts/pretty-text/engines/discourse-markdown/bbcode-block.jssimilarity index 100%rename from app/assets/javascripts/pretty-text/engines/discourse-markdown/bbcode-block.js.es6rename to app/assets/javascripts/pretty-text/engines/discourse-markdown/bbcode-block.jsdiff --git a/app/assets/javascripts/pretty-text/engines/discourse-markdown/bbcode-inline.js.es6 b/app/assets/javascripts/pretty-text/engines/discourse-markdown/bbcode-inline.jssimilarity index 100%rename from app/assets/javascripts/pretty-text/engines/discourse-markdown/bbcode-inline.js.es6rename to app/assets/javascripts/pretty-text/engines/discourse-markdown/bbcode-inline.jsdiff --git a/app/assets/javascripts/pretty-text/engines/discourse-markdown/category-hashtag.js.es6 b/app/assets/javascripts/pretty-text/engines/discourse-markdown/category-hashtag.jssimilarity index 100%rename from app/assets/javascripts/pretty-text/engines/discourse-markdown/category-hashtag.js.es6rename to app/assets/javascripts/pretty-text/engines/discourse-markdown/category-hashtag.jsdiff --git a/app/assets/javascripts/pretty-text/engines/discourse-markdown/censored.js.es6 b/app/assets/javascripts/pretty-text/engines/discourse-markdown/censored.jssimilarity index 100%rename from app/assets/javascripts/pretty-text/engines/discourse-markdown/censored.js.es6rename to app/assets/javascripts/pretty-text/engines/discourse-markdown/censored.jsdiff --git a/app/assets/javascripts/pretty-text/engines/discourse-markdown/code.js.es6 b/app/assets/javascripts/pretty-text/engines/discourse-markdown/code.jssimilarity index 100%rename from app/assets/javascripts/pretty-text/engines/discourse-markdown/code.js.es6rename to app/assets/javascripts/pretty-text/engines/discourse-markdown/code.jsdiff --git a/app/assets/javascripts/pretty-text/engines/discourse-markdown/d-wrap.js.es6 b/app/assets/javascripts/pretty-text/engines/discourse-markdown/d-wrap.jssimilarity index 100%rename from app/assets/javascripts/pretty-text/engines/discourse-markdown/d-wrap.js.es6rename to app/assets/javascripts/pretty-text/engines/discourse-markdown/d-wrap.jsdiff --git a/app/assets/javascripts/pretty-text/engines/discourse-markdown/emoji.js.es6 b/app/assets/javascripts/pretty-text/engines/discourse-markdown/emoji.jssimilarity index 100%rename from app/assets/javascripts/pretty-text/engines/discourse-markdown/emoji.js.es6rename to app/assets/javascripts/pretty-text/engines/discourse-markdown/emoji.jsdiff --git a/app/assets/javascripts/pretty-text/engines/discourse-markdown/helpers.js.es6 b/app/assets/javascripts/pretty-text/engines/discourse-markdown/helpers.jssimilarity index 100%rename from app/assets/javascripts/pretty-text/engines/discourse-markdown/helpers.js.es6rename to app/assets/javascripts/pretty-text/engines/discourse-markdown/helpers.jsdiff --git a/app/assets/javascripts/pretty-text/engines/discourse-markdown/html-img.js.es6 b/app/assets/javascripts/pretty-text/engines/discourse-markdown/html-img.jssimilarity index 100%rename from app/assets/javascripts/pretty-text/engines/discourse-markdown/html-img.js.es6rename to app/assets/javascripts/pretty-text/engines/discourse-markdown/html-img.jsdiff --git a/app/assets/javascripts/pretty-text/engines/discourse-markdown/inject-line-number.js.es6 b/app/assets/javascripts/pretty-text/engines/discourse-markdown/inject-line-number.jssimilarity index 100%rename from app/assets/javascripts/pretty-text/engines/discourse-markdown/inject-line-number.js.es6rename to app/assets/javascripts/pretty-text/engines/discourse-markdown/inject-line-number.jsdiff --git a/app/assets/javascripts/pretty-text/engines/discourse-markdown/mentions.js.es6 b/app/assets/javascripts/pretty-text/engines/discourse-markdown/mentions.jssimilarity index 100%rename from app/assets/javascripts/pretty-text/engines/discourse-markdown/mentions.js.es6rename to app/assets/javascripts/pretty-text/engines/discourse-markdown/mentions.jsdiff --git a/app/assets/javascripts/pretty-text/engines/discourse-markdown/newline.js.es6 b/app/assets/javascripts/pretty-text/engines/discourse-markdown/newline.jssimilarity index 100%rename from app/assets/javascripts/pretty-text/engines/discourse-markdown/newline.js.es6rename to app/assets/javascripts/pretty-text/engines/discourse-markdown/newline.jsdiff --git a/app/assets/javascripts/pretty-text/engines/discourse-markdown/onebox.js.es6 b/app/assets/javascripts/pretty-text/engines/discourse-markdown/onebox.jssimilarity index 100%rename from app/assets/javascripts/pretty-text/engines/discourse-markdown/onebox.js.es6rename to app/assets/javascripts/pretty-text/engines/discourse-markdown/onebox.jsdiff --git a/app/assets/javascripts/pretty-text/engines/discourse-markdown/paragraph.js.es6 b/app/assets/javascripts/pretty-text/engines/discourse-markdown/paragraph.jssimilarity index 100%rename from app/assets/javascripts/pretty-text/engines/discourse-markdown/paragraph.js.es6rename to app/assets/javascripts/pretty-text/engines/discourse-markdown/paragraph.jsdiff --git a/app/assets/javascripts/pretty-text/engines/discourse-markdown/quotes.js.es6 b/app/assets/javascripts/pretty-text/engines/discourse-markdown/quotes.jssimilarity index 100%rename from app/assets/javascripts/pretty-text/engines/discourse-markdown/quotes.js.es6rename to app/assets/javascripts/pretty-text/engines/discourse-markdown/quotes.jsdiff --git a/app/assets/javascripts/pretty-text/engines/discourse-markdown/resize-controls.js.es6 b/app/assets/javascripts/pretty-text/engines/discourse-markdown/resize-controls.jssimilarity index 100%rename from app/assets/javascripts/pretty-text/engines/discourse-markdown/resize-controls.js.es6rename to app/assets/javascripts/pretty-text/engines/discourse-markdown/resize-controls.jsdiff --git a/app/assets/javascripts/pretty-text/engines/discourse-markdown/table.js.es6 b/app/assets/javascripts/pretty-text/engines/discourse-markdown/table.jssimilarity index 100%rename from app/assets/javascripts/pretty-text/engines/discourse-markdown/table.js.es6rename to app/assets/javascripts/pretty-text/engines/discourse-markdown/table.jsdiff --git a/app/assets/javascripts/pretty-text/engines/discourse-markdown/text-post-process.js.es6 b/app/assets/javascripts/pretty-text/engines/discourse-markdown/text-post-process.jssimilarity index 100%rename from app/assets/javascripts/pretty-text/engines/discourse-markdown/text-post-process.js.es6rename to app/assets/javascripts/pretty-text/engines/discourse-markdown/text-post-process.jsdiff --git a/app/assets/javascripts/pretty-text/engines/discourse-markdown/upload-protocol.js.es6 b/app/assets/javascripts/pretty-text/engines/discourse-markdown/upload-protocol.jssimilarity index 100%rename from app/assets/javascripts/pretty-text/engines/discourse-markdown/upload-protocol.js.es6rename to app/assets/javascripts/pretty-text/engines/discourse-markdown/upload-protocol.jsdiff --git a/app/assets/javascripts/pretty-text/guid.js.es6 b/app/assets/javascripts/pretty-text/guid.jssimilarity index 100%rename from app/assets/javascripts/pretty-text/guid.js.es6rename to app/assets/javascripts/pretty-text/guid.jsdiff --git a/app/assets/javascripts/pretty-text/inline-oneboxer.js.es6 b/app/assets/javascripts/pretty-text/inline-oneboxer.jssimilarity index 100%rename from app/assets/javascripts/pretty-text/inline-oneboxer.js.es6rename to app/assets/javascripts/pretty-text/inline-oneboxer.jsdiff --git a/app/assets/javascripts/pretty-text/oneboxer-cache.js.es6 b/app/assets/javascripts/pretty-text/oneboxer-cache.jssimilarity index 100%rename from app/assets/javascripts/pretty-text/oneboxer-cache.js.es6rename to app/assets/javascripts/pretty-text/oneboxer-cache.jsdiff --git a/app/assets/javascripts/pretty-text/oneboxer.js.es6 b/app/assets/javascripts/pretty-text/oneboxer.jssimilarity index 100%rename from app/assets/javascripts/pretty-text/oneboxer.js.es6rename to app/assets/javascripts/pretty-text/oneboxer.jsdiff --git a/app/assets/javascripts/pretty-text/pretty-text.js.es6 b/app/assets/javascripts/pretty-text/pretty-text.jssimilarity index 100%rename from app/assets/javascripts/pretty-text/pretty-text.js.es6rename to app/assets/javascripts/pretty-text/pretty-text.jsdiff --git a/app/assets/javascripts/pretty-text/sanitizer.js.es6 b/app/assets/javascripts/pretty-text/sanitizer.jssimilarity index 100%rename from app/assets/javascripts/pretty-text/sanitizer.js.es6rename to app/assets/javascripts/pretty-text/sanitizer.jsdiff --git a/app/assets/javascripts/pretty-text/upload-short-url.js.es6 b/app/assets/javascripts/pretty-text/upload-short-url.jssimilarity index 100%rename from app/assets/javascripts/pretty-text/upload-short-url.js.es6rename to app/assets/javascripts/pretty-text/upload-short-url.jsdiff --git a/app/assets/javascripts/pretty-text/white-lister.js.es6 b/app/assets/javascripts/pretty-text/white-lister.jssimilarity index 100%rename from app/assets/javascripts/pretty-text/white-lister.js.es6rename to app/assets/javascripts/pretty-text/white-lister.jsdiff --git a/app/assets/javascripts/pretty-text/xss.js.es6 b/app/assets/javascripts/pretty-text/xss.jssimilarity index 100%rename from app/assets/javascripts/pretty-text/xss.js.es6rename to app/assets/javascripts/pretty-text/xss.jsdiff --git a/lib/discourse_js_processor.rb b/lib/discourse_js_processor.rbindex 4056dffc468..68bc75ae9a4 100644--- a/lib/discourse_js_processor.rb+++ b/lib/discourse_js_processor.rb@@ -37,7 +37,8 @@ class DiscourseJsProcessorrelative_path = filename.sub(Rails.root.to_s, '').sub(/^\/*/, '')relative_path.start_with?("app/assets/javascripts/discourse/") ||- relative_path.start_with?("app/assets/javascripts/admin/")+ relative_path.start_with?("app/assets/javascripts/admin/") ||+ relative_path.start_with?("app/assets/javascripts/pretty-text/")enddef self.skip_module?(data)diff --git a/lib/pretty_text.rb b/lib/pretty_text.rbindex 55faf8d4c11..d29f4e84eed 100644--- a/lib/pretty_text.rb+++ b/lib/pretty_text.rb@@ -23,6 +23,9 @@ module PrettyTexterb_name = "#{filename}.js.es6.erb"return erb_name if File.file?("#{root}#{erb_name}")++ erb_name = "#{filename}.js.erb"+ return erb_name if File.file?("#{root}#{erb_name}")enddef self.apply_es6_file(ctx, root_path, part_name)@@ -55,7 +58,7 @@ module PrettyTextelsif l =~ /\/\/= require_tree (\.\/)?(.*)$/path = Regexp.last_match[2]Dir["#{root_path}/#{path}/**"].sort.each do |f|- apply_es6_file(ctx, root_path, f.sub(root_path, '')[1..-1].sub(/\.js.es6$/, ''))+ apply_es6_file(ctx, root_path, f.sub(root_path, '')[1..-1].sub(/\.js(.es6)?$/, ''))endendend@@ -94,7 +97,7 @@ module PrettyTextto_load.uniq.each do |f|if f =~ /^.+assets\/javascripts\//root = Regexp.last_match[0]- apply_es6_file(ctx, root, f.sub(root, '').sub(/\.js\.es6$/, ''))+ apply_es6_file(ctx, root, f.sub(root, '').sub(/\.js(\.es6)?$/, ''))endend