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
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
5fd0e7ba
Commit
5fd0e7ba
authored
Aug 10, 2012
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1198 from NARKOZ/preview_notes
ability to preview notes
parents
35b45da6
96397803
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
6 deletions
+35
-6
app/assets/javascripts/application.js
app/assets/javascripts/application.js
+22
-3
app/controllers/notes_controller.rb
app/controllers/notes_controller.rb
+5
-1
app/views/notes/_form.html.haml
app/views/notes/_form.html.haml
+3
-1
config/routes.rb
config/routes.rb
+5
-1
No files found.
app/assets/javascripts/application.js
View file @
5fd0e7ba
...
@@ -26,7 +26,6 @@ $(document).ready(function(){
...
@@ -26,7 +26,6 @@ $(document).ready(function(){
$
(
this
).
select
();
$
(
this
).
select
();
});
});
$
(
'
body
'
).
on
(
'
ajax:complete, ajax:beforeSend, submit
'
,
'
form
'
,
function
(
e
){
$
(
'
body
'
).
on
(
'
ajax:complete, ajax:beforeSend, submit
'
,
'
form
'
,
function
(
e
){
var
buttons
=
$
(
'
[type="submit"]
'
,
this
);
var
buttons
=
$
(
'
[type="submit"]
'
,
this
);
switch
(
e
.
type
){
switch
(
e
.
type
){
...
@@ -70,6 +69,26 @@ $(document).ready(function(){
...
@@ -70,6 +69,26 @@ $(document).ready(function(){
$
(
"
.supp_diff_link
"
).
bind
(
"
click
"
,
function
()
{
$
(
"
.supp_diff_link
"
).
bind
(
"
click
"
,
function
()
{
showDiff
(
this
);
showDiff
(
this
);
});
});
/**
* Note markdown preview
*
*/
$
(
'
#preview-link
'
).
on
(
'
click
'
,
function
(
e
)
{
$
(
'
#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
();
});
});
});
function
focusSearch
()
{
function
focusSearch
()
{
...
@@ -108,6 +127,6 @@ function showDiff(link) {
...
@@ -108,6 +127,6 @@ function showDiff(link) {
})(
jQuery
);
})(
jQuery
);
function
ajaxGet
(
url
)
{
function
ajaxGet
(
url
)
{
$
.
ajax
({
type
:
"
GET
"
,
url
:
url
,
dataType
:
"
script
"
});
$
.
ajax
({
type
:
"
GET
"
,
url
:
url
,
dataType
:
"
script
"
});
}
}
app/controllers/notes_controller.rb
View file @
5fd0e7ba
...
@@ -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 @
5fd0e7ba
...
@@ -7,10 +7,12 @@
...
@@ -7,10 +7,12 @@
=
f
.
hidden_field
:noteable_id
=
f
.
hidden_field
:noteable_id
=
f
.
hidden_field
:noteable_type
=
f
.
hidden_field
:noteable_type
=
f
.
text_area
:note
,
:size
=>
255
=
f
.
text_area
:note
,
:size
=>
255
#preview-note
.well.hide
%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'
,
preview_project_notes_path
(
@project
),
:id
=>
'preview-link'
.row.note_advanced_opts.hide
.row.note_advanced_opts.hide
.span2
.span2
...
...
config/routes.rb
View file @
5fd0e7ba
...
@@ -203,7 +203,11 @@ Gitlab::Application.routes.draw do
...
@@ -203,7 +203,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
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