From 53eec3bc40c99a7995a6e8ac910fe7d9f3ba7331 Mon Sep 17 00:00:00 2001 From: Sebastian Serth Date: Wed, 7 Jul 2021 20:04:33 +0200 Subject: [PATCH 1/4] Add overview of environment variables --- docs/environment_variables.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 docs/environment_variables.md diff --git a/docs/environment_variables.md b/docs/environment_variables.md new file mode 100644 index 00000000..3a1166fe --- /dev/null +++ b/docs/environment_variables.md @@ -0,0 +1,15 @@ +# Environment Variables + +The following environment variables are specifically support in CodeOcean and are used to configure the application in addition to the setting files under `config/`. + +| Environment Variable | Default | Description | +|- |- |- | +| `RAILS_ENV` | `development` | Specifies the Rails environment which can be configured using the files in `config/environments` | +| `RAILS_RELATIVE_URL_ROOT` | `/` | Specifies the subpath of the application, used for links and assets | +| `SENTRY_DSN` | `` | Specifies the Sentry error reporting endpoint for the Rails server | +| `RAILS_LOG_TO_STDOUT` | `false` in `production` | Enables the server to print log output to the command line | +| `RAILS_SERVE_STATIC_FILES` | `true` in `development` and `test`
`false` in `production` and `staging` | Specifies whether the Rails server should be able to handle requests for non-dynamic resources (e.g., assets) | +| `BACKTRACE` | `false` | Enables more verbose log output from framework code during debugging | +| `TRUSTED_IP` | ` ` in `development` | Enables `BetterErrors` for the given IP addresses during development | +| `LISTEN_ADDRESS` | `127.0.0.1` in `development` | Specifies the IP address the server should attach to during development | +| `HEADLESS_TEST` | `false` | Enables the test environment to work without a window manager for feature tests (e.g., using Vagrant) | From 038ffd4afb5608bb60e297e127046e09c902d14b Mon Sep 17 00:00:00 2001 From: Sebastian Serth Date: Wed, 7 Jul 2021 20:04:53 +0200 Subject: [PATCH 2/4] Fix alternative_input toggle text --- app/assets/javascripts/forms.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/forms.js b/app/assets/javascripts/forms.js index 91d19f17..7e469455 100644 --- a/app/assets/javascripts/forms.js +++ b/app/assets/javascripts/forms.js @@ -14,11 +14,11 @@ $(document).on('turbolinks:load', function() { var alternative_input = parent.find('.alternative-input'); if (alternative_input.attr('disabled')) { - $(this).text($(event.target).data('text-toggled')); + $(this).text($(event.target).first().data('text_toggled')); original_input.attr('disabled', true).hide(); alternative_input.attr('disabled', false).show(); } else { - $(this).text($(event.target).data('text-initial')); + $(this).text($(event.target).first().data('text_initial')); alternative_input.attr('disabled', true).hide(); original_input.attr('disabled', false).show(); } From 72e4026d6c9b241cfaffdc164c6e94d023d1aba3 Mon Sep 17 00:00:00 2001 From: Sebastian Serth Date: Wed, 7 Jul 2021 20:05:20 +0200 Subject: [PATCH 3/4] Ensure that the current docker image is listed when editing an execution environment --- app/controllers/execution_environments_controller.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/controllers/execution_environments_controller.rb b/app/controllers/execution_environments_controller.rb index 3576ee99..4449fa41 100644 --- a/app/controllers/execution_environments_controller.rb +++ b/app/controllers/execution_environments_controller.rb @@ -22,7 +22,10 @@ class ExecutionEnvironmentsController < ApplicationController destroy_and_respond(object: @execution_environment) end - def edit; end + def edit + # Add the current execution_environment if not already present in the list + @docker_images |= [@execution_environment.docker_image] + end def execute_command @docker_client = DockerClient.new(execution_environment: @execution_environment) From d7eb5623897cae74fa33613225b91642f1281d6e Mon Sep 17 00:00:00 2001 From: Sebastian Serth Date: Wed, 7 Jul 2021 20:05:57 +0200 Subject: [PATCH 4/4] Prevent underscores from being removed during command substitution --- app/controllers/submissions_controller.rb | 7 +++++-- lib/docker_client.rb | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/controllers/submissions_controller.rb b/app/controllers/submissions_controller.rb index 76582541..fc70f5a8 100644 --- a/app/controllers/submissions_controller.rb +++ b/app/controllers/submissions_controller.rb @@ -37,8 +37,11 @@ class SubmissionsController < ApplicationController end def command_substitutions(filename) - {class_name: File.basename(filename, File.extname(filename)).camelize, filename: filename, -module_name: File.basename(filename, File.extname(filename)).underscore} + { + class_name: File.basename(filename, File.extname(filename)).upcase_first, + filename: filename, + module_name: File.basename(filename, File.extname(filename)).underscore, + } end private :command_substitutions diff --git a/lib/docker_client.rb b/lib/docker_client.rb index 44f96efe..807f2725 100644 --- a/lib/docker_client.rb +++ b/lib/docker_client.rb @@ -46,7 +46,7 @@ class DockerClient def command_substitutions(filename) { - class_name: File.basename(filename, File.extname(filename)).camelize, + class_name: File.basename(filename, File.extname(filename)).upcase_first, filename: filename, module_name: File.basename(filename, File.extname(filename)).underscore, }