# frozen_string_literal: true require 'active_support/json/encoding' module Ckeditor module Utils autoload :JavascriptCode, 'ckeditor/utils/javascript_code' class << self def escape_single_quotes(str) str.gsub('\\', '\0\0').gsub('= Gem::Version.new('4.0.0') defined?(Sprockets::Rails) elsif Gem::Version.new(::Rails.version.to_s) >= Gem::Version.new('3.0.0') Rails.application.config.assets.enabled else false end end def select_assets(path, relative_path) relative_folder = Ckeditor.root_path.join(relative_path) folder = relative_folder.join(path) extensions = '*.{js,css,png,gif,jpg,html}' # Files at root files = Dir[folder.join(extensions)] files += Dir[folder.join('plugins', '**', extensions)] # Other folders Dir[folder.join('*/')].each do |subfolder| path = Pathname.new(subfolder) next if ['plugins'].include?(path.basename.to_s) files += Dir[path.join('**', extensions)] end files.inject([]) do |items, name| file = Pathname.new(name) base = file.basename('.*').to_s items << file.relative_path_from(relative_folder).to_s items end end end end end