render notes preview on server-side
This commit is contained in:
parent
1ec3bd3f8d
commit
9639780359
5 changed files with 18 additions and 1341 deletions
|
@ -18,7 +18,6 @@
|
|||
//= require chosen-jquery
|
||||
//= require raphael
|
||||
//= require branch-graph
|
||||
//= require Markdown.Converter
|
||||
//= require_tree .
|
||||
|
||||
$(document).ready(function(){
|
||||
|
@ -76,15 +75,17 @@ $(document).ready(function(){
|
|||
*
|
||||
*/
|
||||
$('#preview-link').on('click', function(e) {
|
||||
var note = $('#note_note').val();
|
||||
if (note.trim().length === 0) { note = 'Nothing to preview'; }
|
||||
var converter = new Markdown.Converter();
|
||||
var md_preview = converter.makeHtml(note);
|
||||
$('#preview-note').html(md_preview);
|
||||
$('#preview-note').text('Loading...');
|
||||
|
||||
var previewLinkText = ($(this).text() == 'Preview' ? 'Edit' : 'Preview');
|
||||
$(this).text(previewLinkText);
|
||||
|
||||
var note = $('#note_note').val();
|
||||
if (note.trim().length === 0) { note = 'Nothing to preview'; }
|
||||
$.post($(this).attr('href'), {note: note}, function(data) {
|
||||
$('#preview-note').html(data);
|
||||
});
|
||||
|
||||
$('#preview-note, #note_note').toggle();
|
||||
e.preventDefault();
|
||||
});
|
||||
|
|
|
@ -33,7 +33,11 @@ class NotesController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
protected
|
||||
def preview
|
||||
render :text => view_context.markdown(params[:note])
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def notes
|
||||
@notes = Notes::LoadContext.new(project, current_user, params).execute
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
%p.hint
|
||||
= link_to "Gitlab Markdown", help_markdown_path, :target => '_blank'
|
||||
is enabled.
|
||||
= link_to 'Preview', '#', :id => 'preview-link'
|
||||
= link_to 'Preview', preview_project_notes_path(@project), :id => 'preview-link'
|
||||
|
||||
.row.note_advanced_opts.hide
|
||||
.span4
|
||||
|
|
|
@ -199,7 +199,11 @@ Gitlab::Application.routes.draw do
|
|||
get :search
|
||||
end
|
||||
end
|
||||
resources :notes, :only => [:index, :create, :destroy]
|
||||
resources :notes, :only => [:index, :create, :destroy] do
|
||||
collection do
|
||||
post :preview
|
||||
end
|
||||
end
|
||||
end
|
||||
root :to => "dashboard#index"
|
||||
end
|
||||
|
|
1332
vendor/assets/javascripts/Markdown.Converter.js
vendored
1332
vendor/assets/javascripts/Markdown.Converter.js
vendored
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue