Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,6 @@
//= require rails-timeago
//= require locales/jquery.timeago.de.js
//
// lib/assets
//= require flash
//= require color_mode_picker
//
// app/assets
// --> Include some assets first, as they are used by other assets.
// --> Hence, the order specified here is important.
//
// 1. Some common base functions and monkey patches
//= require base
// 2. Programming groups are required by "channels/synchronized_editor_channel.js"
//= require programming_groups
// 3. The turtle library is required by "editor/turtle.js"
//= require turtle
// 4. Some channels are required by "editor/editor.js.erb"
//= require_tree ./channels
// 5. Require the editor components, as needed by "./editor.js" and "./community_solution.js"
//= require_tree ./editor
//
// All remaining assets are loaded in alphabetical order
//= require_tree .
//
// Finally, we dispatch a custom event to signal that all assets are loaded.
// This is used by our custom migration for Turbo to trigger the `turbo-migration:load` event
const sprocketsLoad = new Event('sprockets:load');
Expand Down
8 changes: 8 additions & 0 deletions app/javascript/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,11 @@ window.ace = ace; // Publish ace in global namespace
// Turbo
import '@hotwired/turbo-rails';
import './turbo-migration';

// ActionCable
import "@rails/actioncable"
import "./channels"

// Import of Rails sprocket assets with minimal changes. After the initial migration these files should
// be moved to an appropriate place after some adjustments to fit modern Rails JS.
import 'sprocket_asset_import';
6 changes: 6 additions & 0 deletions app/javascript/channels/consumer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Action Cable provides the framework to deal with WebSockets in Rails.
// You can generate new channels where WebSocket features live using the `bin/rails generate channel` command.

import { createConsumer } from "@rails/actioncable"

export default createConsumer()
3 changes: 3 additions & 0 deletions app/javascript/channels/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Import all the channels to be used by Action Cable
const channels = require.context(".", true, /_channel\.js$/)
channels.keys().forEach(channels)
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import consumer from "./consumer"

$(document).on('turbo-migration:load', function() {
if ($.isController('exercises') && $('.teacher_dashboard').isPresent()) {

Expand All @@ -18,7 +20,7 @@ $(document).on('turbo-migration:load', function() {
const specific_channel = { channel: "LaExercisesChannel", exercise_id: exercise_id, study_group_id: study_group_id };


App.la_exercise = App.cable.subscriptions.create(specific_channel, {
consumer.subscriptions.create(specific_channel, {
connected: function () {
// Called when the subscription is ready for use on the server
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import consumer from "./consumer";

$(document).on('turbo-migration:load', function () {

if ($.isController('programming_groups') && window.location.pathname.includes('programming_groups/new')) {
const matching_page = $('#matching');
const exercise_id = matching_page.data('exercise-id');
const specific_channel = { channel: "PgMatchingChannel", exercise_id: exercise_id};

App.pg_matching = App.cable.subscriptions.create(specific_channel, {
consumer.subscriptions.create(specific_channel, {
connected() {
// Called when the subscription is ready for use on the server
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import consumer from "./consumer"
import ProgrammingGroups from '../sprocket_asset_import/programming_groups';
import CodeOceanEditor from '../sprocket_asset_import/editor/evaluation';

$(document).on('turbo-migration:load', function () {

if (window.location.pathname.includes('/implement')) {
Expand All @@ -6,7 +10,7 @@ $(document).on('turbo-migration:load', function () {

if ($.isController('exercises') && ProgrammingGroups.is_other_user(current_contributor)) {

App.synchronized_editor = App.cable.subscriptions.create({
consumer.subscriptions.create({
channel: "SynchronizedEditorChannel", exercise_id: exercise_id
}, {
connected() {
Expand Down Expand Up @@ -70,7 +74,7 @@ $(document).on('turbo-migration:load', function () {
},

is_connected() {
return App.cable.subscriptions.findAll(App.synchronized_editor.identifier).length > 0
return consumer.subscriptions.findAll(App.synchronized_editor.identifier).length > 0
},

disconnect() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CodeOceanEditorAJAX = {
window.CodeOceanEditorAJAX = {
ajax: function(options) {
return $.ajax(_.extend({
dataType: 'json',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var CodeOceanEditor = {
window.CodeOceanEditor = {
THEME: window.getCurrentTheme() === 'dark' ? 'ace/theme/tomorrow_night' : 'ace/theme/tomorrow',

//Color-Encoding for Percentages in Progress Bars (For submissions)
Expand Down Expand Up @@ -28,8 +28,8 @@ var CodeOceanEditor = {
lastCopyText: null,

sendEvents: null,
eventURL: Routes.events_path(),
fileTypeURL: Routes.file_types_path(),
eventURL: () => Routes.events_path(),
fileTypeURL: () => Routes.file_types_path(),

confirmDestroy: function (event) {
event.preventDefault();
Expand Down Expand Up @@ -389,7 +389,7 @@ var CodeOceanEditor = {
updateEditorModeToFileTypeID: function (editor, fileTypeID) {
var newMode = 'ace/mode/text'

$.ajax(this.fileTypeURL + '/' + fileTypeID, {
$.ajax(this.fileTypeURL() + '/' + fileTypeID, {
dataType: 'json'
}).done(function (data) {
if (data['editor_mode'] !== null) {
Expand Down Expand Up @@ -668,7 +668,7 @@ var CodeOceanEditor = {

publishCodeOceanEvent: function (payload) {
if (this.sendEvents) {
$.ajax(this.eventURL, {
$.ajax(this.eventURL(), {
type: 'POST',
cache: false,
dataType: 'JSON',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
CodeOceanEditorEvaluation = {
<<<<<<< HEAD
window.CodeOceanEditorEvaluation = {
=======
const CodeOceanEditorEvaluation = {
>>>>>>> 787f0509 (refactor: Move Sprocket JS files to Webpack)
// A list of non-printable characters that are not allowed in the code output.
// Taken from https://stackoverflow.com/a/69024306
nonPrintableRegEx: /[\u0000-\u0008\u000B\u000C\u000F-\u001F\u007F-\u009F\u2000-\u200F\u2028-\u202F\u205F-\u206F\u3000\uFEFF]/g,
Expand Down Expand Up @@ -295,3 +299,5 @@ CodeOceanEditorEvaluation = {
}
}
};

export default CodeOceanEditor;
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CodeOceanEditorWebsocket = {
window.CodeOceanEditorWebsocket = {
websocket: null,
// Replace `http` with `ws` for the WebSocket connection. This also works with `https` and `wss`.
webSocketProtocol: window.location.protocol.replace(/^http/, 'ws').split(':')[0],
Expand Down
10 changes: 10 additions & 0 deletions app/javascript/sprocket_asset_import/editor/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import './ajax';
import './editor';
import './evaluation';
import './execution';
import './participantsupport';
import './prompt';
import './submissions';
import './turtle';
import './websocket';

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CodeOceanEditorFlowr = {
window.CodeOceanEditorFlowr = {
flowrResultHtml:
'<div class="card mb-2">' +
'<div id="{{headingId}}" role="tab" class="card-header">' +
Expand Down Expand Up @@ -111,7 +111,7 @@ CodeOceanEditorFlowr = {
}
};

CodeOceanEditorRequestForComments = {
window.CodeOceanEditorRequestForComments = {
requestComments: function () {
const cause = $('#requestComments');
this.newSentryTransaction(cause, async () => {
Expand Down Expand Up @@ -172,7 +172,7 @@ CodeOceanEditorRequestForComments = {
}
};

CodeOceanEditorTips = {
window.CodeOceanEditorTips = {
initializeEventHandlers: function() {
const card_headers = $('#tips .card-collapse');
for (let tip of card_headers) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CodeOceanEditorPrompt = {
window.CodeOceanEditorPrompt = {
prompt: '#prompt',

showPrompt: function(msg) {
Expand Down Expand Up @@ -42,4 +42,4 @@ CodeOceanEditorPrompt = {
this.submitPromptInput();
}
}
};
};
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CodeOceanEditorSubmissions = {
window.CodeOceanEditorSubmissions = {
AUTOSAVE_INTERVAL: 15 * 1000,
autosaveTimer: null,
autosaveLabel: "#statusbar #autosave",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
CodeOceanEditorTurtle = {
<<<<<<< HEAD
import Turtle from '../turtle';

=======
>>>>>>> 787f0509 (refactor: Move Sprocket JS files to Webpack)
window.CodeOceanEditorTurtle = {
turtlecanvas: null,
turtlescreen: null,
resetTurtle: true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CommandSocket = function(url, onOpen) {
window.CommandSocket = function(url, onOpen) {
this.handlers = {};
this.websocket = new WebSocket(url);
this.websocket.onopen = onOpen;
Expand Down
11 changes: 11 additions & 0 deletions app/javascript/sprocket_asset_import/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import './flash';
import './color_mode_picker';

<<<<<<< HEAD
import './editor';
import './request_for_comments';
=======
import './base'

import './request_for_comments'
>>>>>>> 787f0509 (refactor: Move Sprocket JS files to Webpack)
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,5 @@ $(document).on('turbo-migration:load', function (event) {
});
}
});

export default ProgrammingGroups;
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
var height;
var width;

function Turtle(canvas) {
window.Turtle = function (canvas) {
var dx, dy, xpos, ypos;
this.canvas = canvas; // jQuery object

Expand Down Expand Up @@ -217,3 +217,5 @@ Turtle.prototype.css = function (key, value) {
this.canvas.css(key, value);
}
};

export default Turtle;
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"@github/webauthn-json": "^2.1.1",
"@hotwired/turbo-rails": "^8.0.16",
"@popperjs/core": "^2.11.8",
"@sentry/browser": "^9.40.0",
"@rails/actioncable": "^8.0.200",
"@sentry/browser": "^9.39.0",
"@toast-ui/editor": "^3.2.2",
"@webpack-cli/serve": "^3.0.1",
"ace-builds": "^1.43.2",
Expand Down
7 changes: 4 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1511,7 +1511,7 @@ __metadata:
languageName: node
linkType: hard

"@rails/actioncable@npm:>=7.0":
"@rails/actioncable@npm:>=7.0, @rails/actioncable@npm:^8.0.200":
version: 8.0.200
resolution: "@rails/actioncable@npm:8.0.200"
checksum: 10c0/42c861f3b43131ab523d37125e30e802bd5bab98bf8150a780531f82f05177cd0071a75a7f1341eac9de772732625194ac16205a40b82dc567cc05c21c56e412
Expand Down Expand Up @@ -1570,7 +1570,7 @@ __metadata:
languageName: node
linkType: hard

"@sentry/browser@npm:^9.40.0":
"@sentry/browser@npm:^9.39.0":
version: 9.40.0
resolution: "@sentry/browser@npm:9.40.0"
dependencies:
Expand Down Expand Up @@ -2612,7 +2612,8 @@ __metadata:
"@github/webauthn-json": "npm:^2.1.1"
"@hotwired/turbo-rails": "npm:^8.0.16"
"@popperjs/core": "npm:^2.11.8"
"@sentry/browser": "npm:^9.40.0"
"@rails/actioncable": "npm:^8.0.200"
"@sentry/browser": "npm:^9.39.0"
"@toast-ui/editor": "npm:^3.2.2"
"@webpack-cli/serve": "npm:^3.0.1"
ace-builds: "npm:^1.43.2"
Expand Down
Loading