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
iv
gitlab-ce
Commits
e7bcbb95
Commit
e7bcbb95
authored
Jun 05, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Restyle snippets
parent
36e832cc
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
138 additions
and
93 deletions
+138
-93
app/controllers/snippets_controller.rb
app/controllers/snippets_controller.rb
+21
-12
app/helpers/snippets_helper.rb
app/helpers/snippets_helper.rb
+8
-0
app/views/layouts/_head_panel.html.haml
app/views/layouts/_head_panel.html.haml
+1
-1
app/views/layouts/snippets.html.haml
app/views/layouts/snippets.html.haml
+2
-5
app/views/projects/snippets/_blob.html.haml
app/views/projects/snippets/_blob.html.haml
+4
-1
app/views/projects/snippets/_snippet.html.haml
app/views/projects/snippets/_snippet.html.haml
+24
-12
app/views/projects/snippets/index.html.haml
app/views/projects/snippets/index.html.haml
+4
-10
app/views/projects/snippets/show.html.haml
app/views/projects/snippets/show.html.haml
+7
-3
app/views/snippets/_blob.html.haml
app/views/snippets/_blob.html.haml
+4
-1
app/views/snippets/_snippet.html.haml
app/views/snippets/_snippet.html.haml
+26
-20
app/views/snippets/_snippets.html.haml
app/views/snippets/_snippets.html.haml
+3
-11
app/views/snippets/current_user_index.html.haml
app/views/snippets/current_user_index.html.haml
+21
-0
app/views/snippets/show.html.haml
app/views/snippets/show.html.haml
+8
-5
app/views/snippets/user_index.html.haml
app/views/snippets/user_index.html.haml
+5
-12
No files found.
app/controllers/snippets_controller.rb
View file @
e7bcbb95
...
@@ -15,19 +15,28 @@ class SnippetsController < ApplicationController
...
@@ -15,19 +15,28 @@ class SnippetsController < ApplicationController
def
user_index
def
user_index
@user
=
User
.
find_by_username
(
params
[
:username
])
@user
=
User
.
find_by_username
(
params
[
:username
])
@snippets
=
@user
.
snippets
.
fresh
.
non_expired
@snippets
=
@current_user
.
snippets
.
fresh
.
non_expired
if
@user
==
current_user
@snippets
=
case
params
[
:scope
]
@snippets
=
case
params
[
:scope
]
when
'public'
then
when
'public'
then
@snippets
.
public
@snippets
.
public
when
'private'
then
when
'private'
then
@snippets
.
private
@snippets
.
private
else
else
@snippets
@snippets
end
end
else
@snippets
=
@snippets
.
public
end
@snippets
=
@snippets
.
page
(
params
[
:page
]).
per
(
20
)
@snippets
=
@snippets
.
page
(
params
[
:page
]).
per
(
20
)
if
@user
==
current_user
render
'current_user_index'
else
render
'user_index'
end
end
end
def
new
def
new
...
@@ -79,7 +88,7 @@ class SnippetsController < ApplicationController
...
@@ -79,7 +88,7 @@ class SnippetsController < ApplicationController
protected
protected
def
snippet
def
snippet
@snippet
||=
PersonalSnippet
.
find
(
params
[
:id
])
@snippet
||=
PersonalSnippet
.
where
(
'author_id = :user_id or private is false'
,
user_id:
current_user
.
id
).
find
(
params
[
:id
])
end
end
def
authorize_modify_snippet!
def
authorize_modify_snippet!
...
...
app/helpers/snippets_helper.rb
View file @
e7bcbb95
...
@@ -8,4 +8,12 @@ module SnippetsHelper
...
@@ -8,4 +8,12 @@ module SnippetsHelper
]
]
options_for_select
(
options
)
options_for_select
(
options
)
end
end
def
reliable_snippet_path
(
snippet
)
if
snippet
.
project_id?
project_snippet_path
(
snippet
.
project
,
snippet
)
else
snippet_path
(
snippet
)
end
end
end
end
app/views/layouts/_head_panel.html.haml
View file @
e7bcbb95
...
@@ -19,7 +19,7 @@
...
@@ -19,7 +19,7 @@
=
link_to
public_root_path
,
title:
"Public area"
,
class:
'has_bottom_tooltip'
,
'data-original-title'
=>
'Public area'
do
=
link_to
public_root_path
,
title:
"Public area"
,
class:
'has_bottom_tooltip'
,
'data-original-title'
=>
'Public area'
do
%i
.icon-globe
%i
.icon-globe
%li
%li
=
link_to
snippets_path
,
title:
"Snippets area
"
,
class:
'has_bottom_tooltip'
,
'data-original-title'
=>
'Public area'
do
=
link_to
user_snippets_path
(
current_user
),
title:
"My snippets
"
,
class:
'has_bottom_tooltip'
,
'data-original-title'
=>
'Public area'
do
%i
.icon-paste
%i
.icon-paste
-
if
current_user
.
is_admin?
-
if
current_user
.
is_admin?
%li
%li
...
...
app/views/layouts/snippets.html.haml
View file @
e7bcbb95
...
@@ -7,15 +7,12 @@
...
@@ -7,15 +7,12 @@
%nav
.main-nav
%nav
.main-nav
.container
.container
%ul
%ul
=
nav_link
(
path:
'
dashboard#show
'
,
html_options:
{
class:
'home'
})
do
=
nav_link
(
path:
'
snippets#user_index
'
,
html_options:
{
class:
'home'
})
do
=
link_to
root_path
,
title:
"Back to dashboard
"
do
=
link_to
user_snippets_path
(
current_user
),
title:
"My Snippets
"
do
%i
.icon-home
%i
.icon-home
=
nav_link
(
path:
'snippets#new'
)
do
=
nav_link
(
path:
'snippets#new'
)
do
=
link_to
new_snippet_path
do
=
link_to
new_snippet_path
do
New snippet
New snippet
=
nav_link
(
path:
'snippets#user_index'
)
do
=
link_to
user_snippets_path
(
@current_user
)
do
My snippets
=
nav_link
(
path:
'snippets#index'
)
do
=
nav_link
(
path:
'snippets#index'
)
do
=
link_to
snippets_path
do
=
link_to
snippets_path
do
Discover snippets
Discover snippets
...
...
app/views/projects/snippets/_blob.html.haml
View file @
e7bcbb95
...
@@ -3,7 +3,10 @@
...
@@ -3,7 +3,10 @@
%i
.icon-file
%i
.icon-file
%strong
=
@snippet
.
file_name
%strong
=
@snippet
.
file_name
%span
.options
%span
.options
=
link_to
"raw"
,
raw_project_snippet_path
(
@project
,
@snippet
),
class:
"btn btn-tiny"
,
target:
"_blank"
.btn-group.tree-btn-group.pull-right
-
if
can?
(
current_user
,
:admin_project_snippet
,
@project
)
||
@snippet
.
author
==
current_user
=
link_to
"Edit"
,
edit_project_snippet_path
(
@project
,
@snippet
),
class:
"btn btn-tiny"
,
title:
'Edit Snippet'
=
link_to
"raw"
,
raw_project_snippet_path
(
@project
,
@snippet
),
class:
"btn btn-tiny"
,
target:
"_blank"
.file_content.code
.file_content.code
-
unless
@snippet
.
content
.
empty?
-
unless
@snippet
.
content
.
empty?
%div
{
class:
user_color_scheme_class
}
%div
{
class:
user_color_scheme_class
}
...
...
app/views/projects/snippets/_snippet.html.haml
View file @
e7bcbb95
%tr
%li
%td
.snippet-title
=
image_tag
gravatar_icon
(
snippet
.
author_email
),
class:
"avatar s24"
-
if
snippet
.
private?
%a
{
href:
project_snippet_path
(
snippet
.
project
,
snippet
)}
%i
.icon-lock.cgreen
%strong
=
truncate
(
snippet
.
title
,
length:
60
)
-
else
%td
%i
.icon-globe.cblue
=
snippet
.
file_name
=
link_to
reliable_snippet_path
(
snippet
)
do
%td
%h5
.inline
=
truncate
(
snippet
.
title
,
length:
60
)
%span
.cgray
%span
.cgray
-
if
snippet
.
expires_at
=
snippet
.
file_name
=
snippet
.
expires_at
.
to_date
.
to_s
(
:short
)
-
else
%small
.pull-right.cgray
Never
Expires:
-
if
snippet
.
expires_at
=
snippet
.
expires_at
.
to_date
.
to_s
(
:short
)
-
else
Never
.snippet-info.prepend-left-20
=
"#
#{
snippet
.
id
}
"
%span
.light
by
=
image_tag
gravatar_icon
(
snippet
.
author_email
),
class:
"avatar avatar-inline s16"
=
snippet
.
author_name
app/views/projects/snippets/index.html.haml
View file @
e7bcbb95
...
@@ -5,15 +5,9 @@
...
@@ -5,15 +5,9 @@
-
if
can?
current_user
,
:write_project_snippet
,
@project
-
if
can?
current_user
,
:write_project_snippet
,
@project
=
link_to
new_project_snippet_path
(
@project
),
class:
"btn btn-small add_new pull-right"
,
title:
"New Snippet"
do
=
link_to
new_project_snippet_path
(
@project
),
class:
"btn btn-small add_new pull-right"
,
title:
"New Snippet"
do
Add new snippet
Add new snippet
%br
%hr
%table
%ul
.bordered-list
%thead
%tr
%th
Title
%th
File Name
%th
Expires At
=
render
partial:
"projects/snippets/snippet"
,
collection:
@snippets
=
render
partial:
"projects/snippets/snippet"
,
collection:
@snippets
-
if
@snippets
.
empty?
-
if
@snippets
.
empty?
%tr
%li
%td
{
colspan:
3
}
%h3
.nothing_here_message
Nothing here.
%h3
.nothing_here_message
Nothing here.
app/views/projects/snippets/show.html.haml
View file @
e7bcbb95
%h3
.page_title
%h3
.page_title
%i
.icon-lock.cgreen
=
@snippet
.
title
=
@snippet
.
title
%small
=
@snippet
.
file_name
-
if
can?
(
current_user
,
:admin_project_snippet
,
@project
)
||
@snippet
.
author
==
current_user
=
link_to
"Edit"
,
edit_project_snippet_path
(
@project
,
@snippet
),
class:
"btn btn-small pull-right"
,
title:
'Edit Snippet'
%small
.pull-right
=
"#
#{
@snippet
.
id
}
"
%span
.light
by
=
image_tag
gravatar_icon
(
@snippet
.
author_email
),
class:
"avatar avatar-inline s16"
=
@snippet
.
author_name
%br
%br
%div
=
render
'projects/snippets/blob'
%div
=
render
'projects/snippets/blob'
%div
#notes
=
render
"notes/notes_with_form"
%div
#notes
=
render
"notes/notes_with_form"
app/views/snippets/_blob.html.haml
View file @
e7bcbb95
...
@@ -3,7 +3,10 @@
...
@@ -3,7 +3,10 @@
%i
.icon-file
%i
.icon-file
%strong
=
@snippet
.
file_name
%strong
=
@snippet
.
file_name
%span
.options
%span
.options
=
link_to
"raw"
,
raw_snippet_path
(
@snippet
),
class:
"btn btn-tiny"
,
target:
"_blank"
.btn-group.tree-btn-group.pull-right
-
if
@snippet
.
author
==
current_user
=
link_to
"Edit"
,
edit_snippet_path
(
@snippet
),
class:
"btn btn-tiny"
,
title:
'Edit Snippet'
=
link_to
"Raw"
,
raw_snippet_path
(
@snippet
),
class:
"btn btn-tiny"
,
target:
"_blank"
.file_content.code
.file_content.code
-
unless
@snippet
.
content
.
empty?
-
unless
@snippet
.
content
.
empty?
%div
{
class:
user_color_scheme_class
}
%div
{
class:
user_color_scheme_class
}
...
...
app/views/snippets/_snippet.html.haml
View file @
e7bcbb95
%
tr
%
li
%td
.snippet-title
-
if
snippet
.
private?
-
if
snippet
.
private?
%i
.icon-lock
%i
.icon-lock
.cgreen
-
else
-
else
%i
.icon-globe
%i
.icon-globe.cblue
=
image_tag
gravatar_icon
(
snippet
.
author_email
),
class:
"avatar s24"
=
link_to
reliable_snippet_path
(
snippet
)
do
-
if
snippet
.
project_id?
%h5
.inline
%a
{
href:
project_snippet_path
(
snippet
.
project
,
snippet
)}
=
truncate
(
snippet
.
title
,
length:
60
)
%strong
=
truncate
(
snippet
.
title
,
length:
60
)
-
else
%a
{
href:
snippet_path
(
snippet
)}
%strong
=
truncate
(
snippet
.
title
,
length:
60
)
%td
=
snippet
.
file_name
%td
%span
.cgray
%span
.cgray
-
if
snippet
.
expires_at
=
snippet
.
file_name
=
snippet
.
expires_at
.
to_date
.
to_s
(
:short
)
-
else
%small
.pull-right.cgray
Never
%td
-
if
snippet
.
project_id?
-
if
snippet
.
project_id?
=
link_to
snippet
.
project
.
name
,
project_path
(
snippet
.
project
)
=
link_to
snippet
.
project
.
name_with_namespace
,
project_path
(
snippet
.
project
)
%span
\|
Expires:
-
if
snippet
.
expires_at
=
snippet
.
expires_at
.
to_date
.
to_s
(
:short
)
-
else
Never
.snippet-info.prepend-left-20
=
"#
#{
snippet
.
id
}
"
%span
.light
by
=
image_tag
gravatar_icon
(
snippet
.
author_email
),
class:
"avatar avatar-inline s16"
=
snippet
.
author_name
app/views/snippets/_snippets.html.haml
View file @
e7bcbb95
%table
%ul
.bordered-list
%thead
%tr
%th
Title
%th
File Name
%th
Expires At
%th
Project
=
render
partial:
'snippet'
,
collection:
@snippets
=
render
partial:
'snippet'
,
collection:
@snippets
-
if
@snippets
.
empty?
-
if
@snippets
.
empty?
%tr
%li
%td
{
colspan:
4
}
%h3
.nothing_here_message
Nothing here.
%h3
.nothing_here_message
Nothing here.
=
paginate
@snippets
=
paginate
@snippets
app/views/snippets/current_user_index.html.haml
0 → 100644
View file @
e7bcbb95
%h3
.page_title
My Snippets
%small
share code pastes with others out of git repository
=
link_to
new_snippet_path
,
class:
"btn btn-small add_new pull-right"
,
title:
"New Snippet"
do
Add new snippet
%hr
.row
.span3
%ul
.nav.nav-pills.nav-stacked
=
nav_tab
:scope
,
nil
do
=
link_to
"All"
,
user_snippets_path
(
@user
)
=
nav_tab
:scope
,
'private'
do
=
link_to
"Private"
,
user_snippets_path
(
@user
,
scope:
'private'
)
=
nav_tab
:scope
,
'public'
do
=
link_to
"Public"
,
user_snippets_path
(
@user
,
scope:
'public'
)
.span9
=
render
'snippets'
app/views/snippets/show.html.haml
View file @
e7bcbb95
%h3
.page_title
%h3
.page_title
-
if
@snippet
.
private?
-
if
@snippet
.
private?
%i
.icon-lock
%i
.icon-lock
.cgreen
-
else
-
else
%i
.icon-globe
%i
.icon-globe
.cblue
=
@snippet
.
title
=
@snippet
.
title
%small
=
@snippet
.
file_name
-
if
@snippet
.
author
==
current_user
=
link_to
"Edit"
,
edit_snippet_path
(
@snippet
),
class:
"btn btn-small pull-right"
,
title:
'Edit Snippet'
%small
.pull-right
=
"#
#{
@snippet
.
id
}
"
%span
.light
by
=
image_tag
gravatar_icon
(
@snippet
.
author_email
),
class:
"avatar avatar-inline s16"
=
@snippet
.
author_name
%br
%br
%div
=
render
'blob'
%div
=
render
'blob'
app/views/snippets/user_index.html.haml
View file @
e7bcbb95
%h3
.page_title
%h3
.page_title
Snippets by
=
image_tag
gravatar_icon
(
@user
.
email
),
class:
"avatar s24"
=
@user
.
name
=
@user
.
name
%span
\/
Snippets
%small
share code pastes with others out of git repository
%small
share code pastes with others out of git repository
=
link_to
new_snippet_path
,
class:
"btn btn-small add_new pull-right"
,
title:
"New Snippet"
do
=
link_to
new_snippet_path
,
class:
"btn btn-small add_new pull-right"
,
title:
"New Snippet"
do
Add new snippet
Add new snippet
%hr
%hr
.row
.span3
%ul
.nav.nav-pills.nav-stacked
=
nav_tab
:scope
,
nil
do
=
link_to
"All"
,
user_snippets_path
(
@user
)
=
nav_tab
:scope
,
'private'
do
=
link_to
"Private"
,
user_snippets_path
(
@user
,
scope:
'private'
)
=
nav_tab
:scope
,
'public'
do
=
link_to
"Public"
,
user_snippets_path
(
@user
,
scope:
'public'
)
.span9
=
render
'snippets'
=
render
'snippets'
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