Skip to content

Commit 51e2447

Browse files
committed
chore: Remove erb templete requirments from editor
Configurations can be suppied to JavaScript with data attributes. This simplifies the JavaScript migration to Webpack.
1 parent e9d4d79 commit 51e2447

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

app/assets/javascripts/editor/editor.js.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ var CodeOceanEditor = {
3333

3434
lastCopyText: null,
3535

36-
sendEvents: <%= config_file.read['codeocean_events'] ? config_file.read['codeocean_events']['enabled'] : false %>,
36+
sendEvents: document.documentElement.dataset.eventsEnabled === "true",
3737
eventURL: Routes.events_path(),
3838
fileTypeURL: Routes.file_types_path(),
3939

app/assets/javascripts/editor/participantsupport.js.erb renamed to app/assets/javascripts/editor/participantsupport.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
CodeOceanEditorFlowr = {
2-
isFlowrEnabled: <%= CodeOcean::Config.new(:code_ocean).read[:flowr][:enabled] %>,
2+
isFlowrEnabled: document.documentElement.dataset.flowrEnabled === 'true',
33
flowrResultHtml:
44
'<div class="card mb-2">' +
55
'<div id="{{headingId}}" role="tab" class="card-header">' +
@@ -29,7 +29,7 @@ CodeOceanEditorFlowr = {
2929
var stackoverflowRequests = _.map(insights, function (insight) {
3030
var queryParams = {
3131
accepted: true,
32-
pagesize: <%= CodeOcean::Config.new(:code_ocean).read[:flowr][:answers_per_query] or 3 %>,
32+
pagesize: Number(document.documentElement.dataset.flowrAnswersPerQuery),
3333
order: 'desc',
3434
sort: 'relevance',
3535
site: 'stackoverflow',

app/views/layouts/application.html.slim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
doctype html
2-
html lang=I18n.locale data-default-locale=I18n.default_locale
2+
html lang=I18n.locale data-default-locale=I18n.default_locale data-events-enabled=CodeOcean::Config.new(:code_ocean).read.dig('codeocean_events', 'enabled') data-flowr-enabled=CodeOcean::Config.new(:code_ocean).read.dig(:flowr, :enabled) data-flowr-answers-per-query=CodeOcean::Config.new(:code_ocean).read[:flowranswers_per_query] || 3
33
head
44
meta charset='utf-8'
55
meta name='viewport' content='width=device-width, initial-scale=1'

0 commit comments

Comments
 (0)