mirror of
https://github.com/discourse/discourse.git
synced 2025-04-23 21:24:28 +08:00
Migrate pretty-text to .js
extensions (#9243)
This commit is contained in:
parent
8174f1551c
commit
c150566506
app/assets/javascripts/pretty-text
censored-words.js
context
emoji.jsemoji
engines
discourse-markdown-it.js
guid.jsinline-oneboxer.jsoneboxer-cache.jsoneboxer.jspretty-text.jssanitizer.jsupload-short-url.jswhite-lister.jsxss.jsdiscourse-markdown
lib
0
app/assets/javascripts/pretty-text/oneboxer.js.es6 → app/assets/javascripts/pretty-text/oneboxer.js
0
app/assets/javascripts/pretty-text/oneboxer.js.es6 → app/assets/javascripts/pretty-text/oneboxer.js
@ -37,7 +37,8 @@ class DiscourseJsProcessor
|
||||
|
||||
relative_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/")
|
||||
end
|
||||
|
||||
def self.skip_module?(data)
|
||||
|
@ -23,6 +23,9 @@ module PrettyText
|
||||
|
||||
erb_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}")
|
||||
end
|
||||
|
||||
def self.apply_es6_file(ctx, root_path, part_name)
|
||||
@ -55,7 +58,7 @@ module PrettyText
|
||||
elsif 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)?$/, ''))
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -94,7 +97,7 @@ module PrettyText
|
||||
to_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)?$/, ''))
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user