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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tatuya Kamada
gitlab-ce
Commits
bca7bddd
Commit
bca7bddd
authored
Dec 12, 2012
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add ace editor to snippets
parent
273c0d2a
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
49 additions
and
27 deletions
+49
-27
app/assets/stylesheets/main.scss
app/assets/stylesheets/main.scss
+1
-0
app/assets/stylesheets/sections/snippets.scss
app/assets/stylesheets/sections/snippets.scss
+9
-0
app/views/snippets/_form.html.haml
app/views/snippets/_form.html.haml
+36
-23
app/views/snippets/show.html.haml
app/views/snippets/show.html.haml
+1
-1
spec/requests/snippets_spec.rb
spec/requests/snippets_spec.rb
+2
-3
No files found.
app/assets/stylesheets/main.scss
View file @
bca7bddd
...
...
@@ -89,6 +89,7 @@ $baseLineHeight: 18px !default;
@import
"sections/commits.scss"
;
@import
"sections/issues.scss"
;
@import
"sections/projects.scss"
;
@import
"sections/snippets.scss"
;
@import
"sections/merge_requests.scss"
;
@import
"sections/graph.scss"
;
@import
"sections/events.scss"
;
...
...
app/assets/stylesheets/sections/snippets.scss
0 → 100644
View file @
bca7bddd
.snippet.file_holder
{
.file_title
{
.snippet-file-name
{
position
:
relative
;
top
:
-4px
;
left
:
-4px
;
}
}
}
app/views/snippets/_form.html.haml
View file @
bca7bddd
%h3
.page_title
=
@snippet
.
new_record?
?
"New Snippet"
:
"Edit Snippet #
#{
@snippet
.
id
}
"
%hr
=
form_for
[
@project
,
@snippet
]
do
|
f
|
.snippet-form-holder
=
form_for
[
@project
,
@snippet
]
do
|
f
|
-
if
@snippet
.
errors
.
any?
.alert-message.block-message.error
%ul
...
...
@@ -10,19 +11,31 @@
.clearfix
=
f
.
label
:title
.input
=
f
.
text_field
:title
,
placeholder:
"Example Snippet"
.clearfix
=
f
.
label
:file_name
.input
=
f
.
text_field
:file_name
,
placeholder:
"example.rb"
.input
=
f
.
text_field
:title
,
placeholder:
"Example Snippet"
,
class:
'input-xlarge'
,
required:
true
.clearfix
=
f
.
label
"Lifetime"
.input
=
f
.
select
:expires_at
,
lifetime_select_options
,
{},
{
class:
'chosen span2'
}
.clearfix
=
f
.
label
:content
,
"Code"
.input
=
f
.
text_area
:content
,
class:
"span8"
.file-editor
=
f
.
label
:file_name
,
"File"
.input
.file_holder.snippet
.file_title
=
f
.
text_field
:file_name
,
placeholder:
"example.rb"
,
class:
'snippet-file-name'
,
required:
true
.file_content.code
%pre
#editor
=
@snippet
.
content
=
f
.
hidden_field
:content
,
class:
'snippet-file-content'
.form-actions
=
f
.
submit
'Save'
,
class:
"primary
btn"
=
f
.
submit
'Save'
,
class:
"save-btn
btn"
=
link_to
"Cancel"
,
project_snippets_path
(
@project
),
class:
" btn"
-
unless
@snippet
.
new_record?
.right
=
link_to
'Destroy'
,
[
@project
,
@snippet
],
confirm:
'Are you sure?'
,
method: :delete
,
class:
"btn right danger delete-snippet"
,
id:
"destroy_snippet_
#{
@snippet
.
id
}
"
:javascript
var
editor
=
ace
.
edit
(
"
editor
"
);
$
(
"
.snippet-form-holder form
"
).
submit
(
function
(){
$
(
"
.snippet-file-content
"
).
val
(
editor
.
getValue
());
});
app/views/snippets/show.html.haml
View file @
bca7bddd
=
render
"projects/project_head"
%h3
%h3
.page_title
=
@snippet
.
title
%small
=
@snippet
.
file_name
-
if
can?
(
current_user
,
:admin_snippet
,
@project
)
||
@snippet
.
author
==
current_user
...
...
spec/requests/snippets_spec.rb
View file @
bca7bddd
...
...
@@ -48,11 +48,11 @@ describe "Snippets" do
page
.
current_path
.
should
==
new_project_snippet_path
(
project
)
end
describe
"fill in"
do
describe
"fill in"
,
js:
true
do
before
do
fill_in
"snippet_title"
,
with:
"login function"
fill_in
"snippet_file_name"
,
with:
"test.rb"
fill_in
"snippet_content"
,
with:
"def login; end"
page
.
execute_script
(
"editor.insert('def login; end');"
)
end
it
{
expect
{
click_button
"Save"
}.
to
change
{
Snippet
.
count
}.
by
(
1
)
}
...
...
@@ -83,7 +83,6 @@ describe "Snippets" do
before
do
fill_in
"snippet_title"
,
with:
"login function"
fill_in
"snippet_file_name"
,
with:
"test.rb"
fill_in
"snippet_content"
,
with:
"def login; end"
end
it
{
expect
{
click_button
"Save"
}.
to_not
change
{
Snippet
.
count
}
}
...
...
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