remove hard-coded assets path for ace editor modules
This commit is contained in:
parent
763d7ad2d9
commit
75663d101d
2 changed files with 27 additions and 1 deletions
|
@ -1,2 +1,3 @@
|
||||||
/*= require ace-rails-ap */
|
/*= require ace/ace */
|
||||||
/*= require ace/ext-searchbox */
|
/*= require ace/ext-searchbox */
|
||||||
|
/*= require ./ace/ace_config_paths */
|
||||||
|
|
25
app/assets/javascripts/lib/ace/ace_config_paths.js.erb
Normal file
25
app/assets/javascripts/lib/ace/ace_config_paths.js.erb
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
<%
|
||||||
|
ace_gem_path = Bundler.rubygems.find_name('ace-rails-ap').first.full_gem_path
|
||||||
|
ace_workers = Dir[ace_gem_path + '/vendor/assets/javascripts/ace/worker-*.js'].sort.map do |file|
|
||||||
|
File.basename(file, '.js').sub(/^worker-/, '')
|
||||||
|
end
|
||||||
|
ace_modes = Dir[ace_gem_path + '/vendor/assets/javascripts/ace/mode-*.js'].sort.map do |file|
|
||||||
|
File.basename(file, '.js').sub(/^mode-/, '')
|
||||||
|
end
|
||||||
|
%>
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
window.gon = window.gon || {};
|
||||||
|
var basePath = (window.gon.relative_url_root || '').replace(/\/$/, '') + '/assets/ace';
|
||||||
|
ace.config.set('basePath', basePath);
|
||||||
|
|
||||||
|
// configure paths for all worker modules
|
||||||
|
<% ace_workers.each do |worker| %>
|
||||||
|
ace.config.setModuleUrl('ace/mode/<%= worker %>_worker', basePath + '/worker-<%= worker %>.js');
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
// configure paths for all mode modules
|
||||||
|
<% ace_modes.each do |mode| %>
|
||||||
|
ace.config.setModuleUrl('ace/mode/<%= mode %>', basePath + '/mode-<%= mode %>.js');
|
||||||
|
<% end %>
|
||||||
|
})();
|
Loading…
Reference in a new issue