diff --git a/app/assets/javascripts/editor/editor.js.erb b/app/assets/javascripts/editor/editor.js.erb index 02438818..dd354df8 100644 --- a/app/assets/javascripts/editor/editor.js.erb +++ b/app/assets/javascripts/editor/editor.js.erb @@ -1,3 +1,9 @@ +// Note: Directives are only processed if they come before any application code. +// Once you have a line that does not include a comment or whitespace then Sprockets will stop looking for directives. +// If you use a directive outside of the "header" of the document it will not do anything, and won't raise any errors. +// <% config_file = CodeOcean::Config.new(:code_ocean, erb: false) %> +//= depend_on <%= config_file.path.basename %> + var CodeOceanEditor = { THEME: window.getCurrentTheme() === 'dark' ? 'ace/theme/tomorrow_night' : 'ace/theme/tomorrow', @@ -27,12 +33,7 @@ var CodeOceanEditor = { lastCopyText: null, - <% @config ||= CodeOcean::Config.new(:code_ocean, erb: false).read %> - // Important notice: Changing the config values requires any content-wise - // modification for this file in the development environment. Lacking to do so - // will result in the old, server-side cached serving of this file even across - // server restarts! - sendEvents: <%= @config['codeocean_events'] ? @config['codeocean_events']['enabled'] : false %>, + sendEvents: <%= config_file.read['codeocean_events'] ? config_file.read['codeocean_events']['enabled'] : false %>, eventURL: Routes.events_path(), fileTypeURL: Routes.file_types_path(), diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index 0bd9cf75..09402920 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -6,7 +6,8 @@ Rails.application.config.assets.version = '1.1' # Add additional assets to the asset load path. -# Rails.application.config.assets.paths << Emoji.images_path +# We require the config directory to enable asset dependencies on CodeOcean::Config values (stored as YML files in `config`). +Rails.application.config.assets.paths << Rails.root.join('config') # Precompile additional assets. # application.js, application.css, and all non-JS/CSS in the app/assets