Merge pull request #76 from openHPI/markup-description

Markup description
This commit is contained in:
rteusner
2016-08-03 15:08:21 +02:00
committed by GitHub
9 changed files with 49 additions and 21 deletions

View File

@ -28,6 +28,8 @@ gem 'rubytree'
gem 'sass-rails', '~> 4.0.3'
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'slim'
gem 'bootstrap_pagedown'
gem 'pagedown-rails', '~> 1.1.4'
gem 'sorcery'
gem 'thread_safe'
gem 'turbolinks'

View File

@ -48,6 +48,8 @@ GEM
debug_inspector (>= 0.0.1)
bootstrap-will_paginate (0.0.10)
will_paginate
bootstrap_pagedown (1.1.0)
rails (>= 3.2)
builder (3.2.2)
byebug (8.2.2)
capistrano (3.3.5)
@ -175,6 +177,8 @@ GEM
multi_json (~> 1.3)
multi_xml (~> 0.5)
rack (>= 1.2, < 3)
pagedown-rails (1.1.4)
railties (> 3.1)
parser (2.3.0.6)
ast (~> 2.2)
pg (0.18.4)
@ -355,6 +359,7 @@ DEPENDENCIES
better_errors
binding_of_caller
bootstrap-will_paginate
bootstrap_pagedown
byebug
capistrano (~> 3.3.0)
capistrano-rails
@ -382,6 +387,7 @@ DEPENDENCIES
newrelic_rpm
nokogiri
nyan-cat-formatter
pagedown-rails (~> 1.1.4)
pg
pry
puma (~> 2.15.3)
@ -411,3 +417,6 @@ DEPENDENCIES
uglifier (>= 1.3.0)
web-console (~> 2.0)
will_paginate (~> 3.0)
BUNDLED WITH
1.12.4

View File

@ -21,3 +21,7 @@
//= require turbolinks
//= require_tree ../../../lib
//= require_tree .
//= require bootstrap_pagedown
//= require markdown.converter
//= require markdown.sanitizer
//= require markdown.editor

View File

@ -173,9 +173,10 @@ $(function() {
} else if ($('.edit_exercise, .new_exercise').isPresent()) {
execution_environments = $('form').data('execution-environments');
file_types = $('form').data('file-types');
// new MarkdownEditor('#exercise_instructions');
new MarkdownEditor('#exercise_description');
// new MarkdownEditor('#exercise_instructions');
// new MarkdownEditor('#exercise_description')
// todo: add an ace editor for each file
new PagedownEditor('#exercise_description');
enableInlineFileCreation();
inferFileAttributes();

View File

@ -0,0 +1,16 @@
(function() {
var ACE_FILES_PATH = '/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('markdown');
session.setUseWrapMode(true);
session.setValue($(selector).val());
};
})();

View File

@ -1,16 +0,0 @@
(function() {
var ACE_FILES_PATH = '/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('markdown');
session.setUseWrapMode(true);
session.setValue($(selector).val());
};
})();

View File

@ -0,0 +1,10 @@
(function() {
var ACE_FILES_PATH = '/assets/ace/';
window.PagedownEditor = function(selector) {
var converter = Markdown.getSanitizingConverter();
var editor = new Markdown.Editor( converter );
editor.run();
};
})();

View File

@ -14,4 +14,6 @@
*= require_tree ../../../lib
*= require_tree ../../../vendor/assets/stylesheets/
*= require_self
*/
*= require bootstrap_pagedown
*= require markdown
*/

View File

@ -8,8 +8,8 @@
= f.text_field(:title, class: 'form-control', required: true)
.form-group
= f.label(:description)
= f.hidden_field(:description)
.form-control.markdown
= f.pagedown_editor :description
.form-group
= f.label(:execution_environment_id)
= f.collection_select(:execution_environment_id, @execution_environments, :id, :name, {}, class: 'form-control')