Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
96397803
Commit
96397803
authored
Aug 08, 2012
by
Nihad Abbasov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
render notes preview on server-side
parent
1ec3bd3f
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
18 additions
and
1341 deletions
+18
-1341
app/assets/javascripts/application.js
app/assets/javascripts/application.js
+7
-6
app/controllers/notes_controller.rb
app/controllers/notes_controller.rb
+5
-1
app/views/notes/_form.html.haml
app/views/notes/_form.html.haml
+1
-1
config/routes.rb
config/routes.rb
+5
-1
vendor/assets/javascripts/Markdown.Converter.js
vendor/assets/javascripts/Markdown.Converter.js
+0
-1332
No files found.
app/assets/javascripts/application.js
View file @
96397803
...
@@ -18,7 +18,6 @@
...
@@ -18,7 +18,6 @@
//= require chosen-jquery
//= require chosen-jquery
//= require raphael
//= require raphael
//= require branch-graph
//= require branch-graph
//= require Markdown.Converter
//= require_tree .
//= require_tree .
$
(
document
).
ready
(
function
(){
$
(
document
).
ready
(
function
(){
...
@@ -76,15 +75,17 @@ $(document).ready(function(){
...
@@ -76,15 +75,17 @@ $(document).ready(function(){
*
*
*/
*/
$
(
'
#preview-link
'
).
on
(
'
click
'
,
function
(
e
)
{
$
(
'
#preview-link
'
).
on
(
'
click
'
,
function
(
e
)
{
var
note
=
$
(
'
#note_note
'
).
val
();
$
(
'
#preview-note
'
).
text
(
'
Loading...
'
);
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
);
var
previewLinkText
=
(
$
(
this
).
text
()
==
'
Preview
'
?
'
Edit
'
:
'
Preview
'
);
var
previewLinkText
=
(
$
(
this
).
text
()
==
'
Preview
'
?
'
Edit
'
:
'
Preview
'
);
$
(
this
).
text
(
previewLinkText
);
$
(
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
();
$
(
'
#preview-note, #note_note
'
).
toggle
();
e
.
preventDefault
();
e
.
preventDefault
();
});
});
...
...
app/controllers/notes_controller.rb
View file @
96397803
...
@@ -33,7 +33,11 @@ class NotesController < ApplicationController
...
@@ -33,7 +33,11 @@ class NotesController < ApplicationController
end
end
end
end
protected
def
preview
render
:text
=>
view_context
.
markdown
(
params
[
:note
])
end
protected
def
notes
def
notes
@notes
=
Notes
::
LoadContext
.
new
(
project
,
current_user
,
params
).
execute
@notes
=
Notes
::
LoadContext
.
new
(
project
,
current_user
,
params
).
execute
...
...
app/views/notes/_form.html.haml
View file @
96397803
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
%p
.hint
%p
.hint
=
link_to
"Gitlab Markdown"
,
help_markdown_path
,
:target
=>
'_blank'
=
link_to
"Gitlab Markdown"
,
help_markdown_path
,
:target
=>
'_blank'
is enabled.
is enabled.
=
link_to
'Preview'
,
'#'
,
:id
=>
'preview-link'
=
link_to
'Preview'
,
preview_project_notes_path
(
@project
)
,
:id
=>
'preview-link'
.row.note_advanced_opts.hide
.row.note_advanced_opts.hide
.span4
.span4
...
...
config/routes.rb
View file @
96397803
...
@@ -199,7 +199,11 @@ Gitlab::Application.routes.draw do
...
@@ -199,7 +199,11 @@ Gitlab::Application.routes.draw do
get
:search
get
:search
end
end
end
end
resources
:notes
,
:only
=>
[
:index
,
:create
,
:destroy
]
resources
:notes
,
:only
=>
[
:index
,
:create
,
:destroy
]
do
collection
do
post
:preview
end
end
end
end
root
:to
=>
"dashboard#index"
root
:to
=>
"dashboard#index"
end
end
vendor/assets/javascripts/Markdown.Converter.js
deleted
100644 → 0
View file @
1ec3bd3f
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment