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
Kazuhiko Shiozaki
gitlab-ce
Commits
b49cfbc1
Commit
b49cfbc1
authored
Mar 23, 2013
by
Andrew8xx8
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Project snippets moved to /projects
parent
cc869d5d
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
130 additions
and
8 deletions
+130
-8
app/controllers/projects/snippets_controller.rb
app/controllers/projects/snippets_controller.rb
+1
-1
app/views/projects/snippets/_blob.html.haml
app/views/projects/snippets/_blob.html.haml
+12
-0
app/views/projects/snippets/_form.html.haml
app/views/projects/snippets/_form.html.haml
+41
-0
app/views/projects/snippets/_snippet.html.haml
app/views/projects/snippets/_snippet.html.haml
+13
-0
app/views/projects/snippets/edit.html.haml
app/views/projects/snippets/edit.html.haml
+1
-0
app/views/projects/snippets/index.html.haml
app/views/projects/snippets/index.html.haml
+19
-0
app/views/projects/snippets/new.html.haml
app/views/projects/snippets/new.html.haml
+1
-0
app/views/projects/snippets/show.html.haml
app/views/projects/snippets/show.html.haml
+9
-0
config/routes.rb
config/routes.rb
+5
-3
spec/routing/project_routing_spec.rb
spec/routing/project_routing_spec.rb
+28
-4
No files found.
app/controllers/projects/snippets_controller.rb
View file @
b49cfbc1
class
SnippetsController
<
ProjectResource
Controller
class
Projects::SnippetsController
<
Projects
::
Application
Controller
before_filter
:module_enabled
before_filter
:module_enabled
before_filter
:snippet
,
only:
[
:show
,
:edit
,
:destroy
,
:update
,
:raw
]
before_filter
:snippet
,
only:
[
:show
,
:edit
,
:destroy
,
:update
,
:raw
]
...
...
app/views/projects/snippets/_blob.html.haml
0 → 100644
View file @
b49cfbc1
.file_holder
.file_title
%i
.icon-file
%strong
=
@snippet
.
file_name
%span
.options
=
link_to
"raw"
,
raw_project_snippet_path
(
@project
,
@snippet
),
class:
"btn btn-tiny"
,
target:
"_blank"
.file_content.code
-
unless
@snippet
.
content
.
empty?
%div
{
class:
user_color_scheme_class
}
=
raw
@snippet
.
colorize
(
formatter: :gitlab
)
-
else
%p
.nothing_here_message
Empty file
app/views/projects/snippets/_form.html.haml
0 → 100644
View file @
b49cfbc1
%h3
.page_title
=
@snippet
.
new_record?
?
"New Snippet"
:
"Edit Snippet #
#{
@snippet
.
id
}
"
%hr
.snippet-form-holder
=
form_for
[
@project
,
@snippet
]
do
|
f
|
-
if
@snippet
.
errors
.
any?
.alert.alert-error
%ul
-
@snippet
.
errors
.
full_messages
.
each
do
|
msg
|
%li
=
msg
.clearfix
=
f
.
label
:title
.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
.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:
"btn-save btn"
=
link_to
"Cancel"
,
project_snippets_path
(
@project
),
class:
" btn"
-
unless
@snippet
.
new_record?
.pull-right
=
link_to
'Destroy'
,
[
@project
,
@snippet
],
confirm:
'Are you sure?'
,
method: :delete
,
class:
"btn pull-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/projects/snippets/_snippet.html.haml
0 → 100644
View file @
b49cfbc1
%tr
%td
=
image_tag
gravatar_icon
(
snippet
.
author_email
),
class:
"avatar s24"
%a
{
href:
project_snippet_path
(
snippet
.
project
,
snippet
)}
%strong
=
truncate
(
snippet
.
title
,
length:
60
)
%td
=
snippet
.
file_name
%td
%span
.cgray
-
if
snippet
.
expires_at
=
snippet
.
expires_at
.
to_date
.
to_s
(
:short
)
-
else
Never
app/views/projects/snippets/edit.html.haml
0 → 100644
View file @
b49cfbc1
=
render
"snippets/form"
app/views/projects/snippets/index.html.haml
0 → 100644
View file @
b49cfbc1
%h3
.page_title
Snippets
%small
share code pastes with others out of git repository
-
if
can?
current_user
,
:write_snippet
,
@project
=
link_to
new_project_snippet_path
(
@project
),
class:
"btn btn-small add_new pull-right"
,
title:
"New Snippet"
do
Add new snippet
%br
%table
%thead
%tr
%th
Title
%th
File Name
%th
Expires At
=
render
@snippets
-
if
@snippets
.
empty?
%tr
%td
{
colspan:
3
}
%h3
.nothing_here_message
Nothing here.
app/views/projects/snippets/new.html.haml
0 → 100644
View file @
b49cfbc1
=
render
"snippets/form"
app/views/projects/snippets/show.html.haml
0 → 100644
View file @
b49cfbc1
%h3
.page_title
=
@snippet
.
title
%small
=
@snippet
.
file_name
-
if
can?
(
current_user
,
:admin_snippet
,
@project
)
||
@snippet
.
author
==
current_user
=
link_to
"Edit"
,
edit_project_snippet_path
(
@project
,
@snippet
),
class:
"btn btn-small pull-right"
,
title:
'Edit Snippet'
%br
%div
=
render
'blob'
%div
#notes
=
render
"notes/notes_with_form"
config/routes.rb
View file @
b49cfbc1
...
@@ -244,9 +244,11 @@ Gitlab::Application.routes.draw do
...
@@ -244,9 +244,11 @@ Gitlab::Application.routes.draw do
end
end
end
end
resources
:snippets
do
scope
module: :projects
do
member
do
resources
:snippets
do
get
"raw"
member
do
get
"raw"
end
end
end
end
end
...
...
spec/routing/project_routing_spec.rb
View file @
b49cfbc1
...
@@ -249,13 +249,37 @@ end
...
@@ -249,13 +249,37 @@ end
# project_snippet GET /:project_id/snippets/:id(.:format) snippets#show
# project_snippet GET /:project_id/snippets/:id(.:format) snippets#show
# PUT /:project_id/snippets/:id(.:format) snippets#update
# PUT /:project_id/snippets/:id(.:format) snippets#update
# DELETE /:project_id/snippets/:id(.:format) snippets#destroy
# DELETE /:project_id/snippets/:id(.:format) snippets#destroy
describe
SnippetsController
,
"routing"
do
describe
Project
::
SnippetsController
,
"routing"
do
it
"to #raw"
do
it
"to #raw"
do
get
(
"/gitlabhq/snippets/1/raw"
).
should
route_to
(
'snippets#raw'
,
project_id:
'gitlabhq'
,
id:
'1'
)
get
(
"/gitlabhq/snippets/1/raw"
).
should
route_to
(
'
projects/
snippets#raw'
,
project_id:
'gitlabhq'
,
id:
'1'
)
end
end
it_behaves_like
"RESTful project resources"
do
it
"to #index"
do
let
(
:controller
)
{
'snippets'
}
get
(
"/gitlabhq/snippets"
).
should
route_to
(
"projects/snippets#index"
,
project_id:
'gitlabhq'
)
end
it
"to #create"
do
post
(
"/gitlabhq/snippets"
).
should
route_to
(
"projects/snippets#create"
,
project_id:
'gitlabhq'
)
end
it
"to #new"
do
get
(
"/gitlabhq/snippets/new"
).
should
route_to
(
"projects/snippets#new"
,
project_id:
'gitlabhq'
)
end
it
"to #edit"
do
get
(
"/gitlabhq/snippets/1/edit"
).
should
route_to
(
"projects/snippets#edit"
,
project_id:
'gitlabhq'
,
id:
'1'
)
end
it
"to #show"
do
get
(
"/gitlabhq/snippets/1"
).
should
route_to
(
"projects/snippets#show"
,
project_id:
'gitlabhq'
,
id:
'1'
)
end
it
"to #update"
do
put
(
"/gitlabhq/snippets/1"
).
should
route_to
(
"projects/snippets#update"
,
project_id:
'gitlabhq'
,
id:
'1'
)
end
it
"to #destroy"
do
delete
(
"/gitlabhq/snippets/1"
).
should
route_to
(
"projects/snippets#destroy"
,
project_id:
'gitlabhq'
,
id:
'1'
)
end
end
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