Add support for running CodeOcean under a subpath

* Also refactor (JavaScript) routes
This commit is contained in:
Sebastian Serth
2021-07-06 17:02:12 +02:00
parent 7914608efe
commit 237c225732
14 changed files with 40 additions and 28 deletions

View File

@ -0,0 +1,16 @@
(function() {
var ACE_FILES_PATH = '<%= "#{Rails.application.config.relative_url_root.chomp('/')}/assets/ace/" %>';
window.MarkdownEditor = function(selector) {
ace.config.set('modePath', ACE_FILES_PATH);
var editor = ace.edit($(selector).next()[0]);
editor.on('change', function() {
$(selector).val(editor.getValue());
});
editor.setShowPrintMargin(false);
var session = editor.getSession();
session.setMode('ace/mode/markdown');
session.setUseWrapMode(true);
session.setValue($(selector).val());
};
})();