window['CKEDITOR_BASEPATH'] = "/assets/ckeditor/"; <% sprockets = (Rails.application.assets || environment) %> <% whitelist = ['ckeditor/plugins/', 'ckeditor/skins/', 'effective/snippets/', 'effective/templates/', 'ckeditor/contents.css'] %> <% blacklist = ['effective_ckeditor'] %> window.CKEDITOR_ASSETS_MAPPING = { <% if sprockets.respond_to?(:each_file) %> <% sprockets.each_file.select { |path| whitelist.any? { |str| path.include?(str) } && blacklist.none? { |str| path.include?(str) } }.each do |asset| %> "<%= asset %>": "<%= asset_path(asset) %>", <% end %> <% else %> <% sprockets.each_logical_path(->(path, _) { whitelist.any? { |str| path.include?(str) } && blacklist.none? { |str| path.include?(str) } }) do |asset| %> "<%= asset %>": "<%= asset_path(asset) %>", <% end %> <% end %> } window.CKEDITOR_GETURL = function( resource ) { // If this is not a full or absolute path. if ( resource.indexOf( ':/' ) == -1 && resource.indexOf( '/' ) !== 0 ) resource = this.basePath + resource; // Add the timestamp, except for directories. if ( resource.charAt( resource.length - 1 ) != '/' ) { var url = resource.match( /^(.*?:\/\/[^\/]*)\/assets\/(.+)/ ); if(url) resource = (CKEDITOR_ASSETS_MAPPING[url[2]] || '/assets/' + url[2]); } return resource; } <% if defined?(EffectiveAssets) %> window.CKEDITOR_FILE_BROWSE_URL = '/effective/assets' <% else %> window.CKEDITOR_FILE_BROWSE_URL = '/effective/ck_assets' <% end %>