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
093159a8
Commit
093159a8
authored
Jun 12, 2012
by
randx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Styled snippets. Raw button for snippet
parent
b96af79b
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
39 additions
and
7 deletions
+39
-7
app/controllers/snippets_controller.rb
app/controllers/snippets_controller.rb
+11
-1
app/views/snippets/_snippet.html.haml
app/views/snippets/_snippet.html.haml
+9
-3
app/views/snippets/index.html.haml
app/views/snippets/index.html.haml
+11
-2
app/views/snippets/show.html.haml
app/views/snippets/show.html.haml
+2
-0
config/routes.rb
config/routes.rb
+6
-1
No files found.
app/controllers/snippets_controller.rb
View file @
093159a8
class
SnippetsController
<
ApplicationController
class
SnippetsController
<
ApplicationController
before_filter
:authenticate_user!
before_filter
:authenticate_user!
before_filter
:project
before_filter
:project
before_filter
:snippet
,
:only
=>
[
:show
,
:edit
,
:destroy
,
:update
]
before_filter
:snippet
,
:only
=>
[
:show
,
:edit
,
:destroy
,
:update
,
:raw
]
layout
"project"
layout
"project"
# Authorize
# Authorize
...
@@ -67,7 +67,17 @@ class SnippetsController < ApplicationController
...
@@ -67,7 +67,17 @@ class SnippetsController < ApplicationController
redirect_to
project_snippets_path
(
@project
)
redirect_to
project_snippets_path
(
@project
)
end
end
def
raw
send_data
(
@snippet
.
content
,
:type
=>
"text/plain"
,
:disposition
=>
'inline'
,
:filename
=>
@snippet
.
file_name
)
end
protected
protected
def
snippet
def
snippet
@snippet
||=
@project
.
snippets
.
find
(
params
[
:id
])
@snippet
||=
@project
.
snippets
.
find
(
params
[
:id
])
end
end
...
...
app/views/snippets/_snippet.html.haml
View file @
093159a8
%tr
%tr
%td
%td
%a
{
:href
=>
project_snippet_path
(
snippet
.
project
,
snippet
)}
%a
{
:href
=>
project_snippet_path
(
snippet
.
project
,
snippet
)}
=
truncate
(
snippet
.
title
,
:length
=>
60
)
%strong
=
truncate
(
snippet
.
title
,
:length
=>
60
)
%span
.right.cgray
%td
=
snippet
.
file_name
=
snippet
.
file_name
%td
%span
.cgray
-
if
snippet
.
expires_at
=
snippet
.
expires_at
.
to_date
.
to_s
(
:short
)
-
else
Never
app/views/snippets/index.html.haml
View file @
093159a8
...
@@ -8,5 +8,14 @@
...
@@ -8,5 +8,14 @@
%br
%br
To add new snippet - click on button.
To add new snippet - click on button.
-
unless
@snippets
.
fresh
.
empty?
%table
.admin-table
%table
.zebra-striped.borders
=
render
@snippets
.
fresh
%thead
%tr
%th
Title
%th
File Name
%th
Expires At
=
render
@snippets
.
fresh
-
if
@snippets
.
fresh
.
empty?
%tr
%td
{
:colspan
=>
3
}
%h3
.nothing_here_message
Nothing here.
app/views/snippets/show.html.haml
View file @
093159a8
...
@@ -13,6 +13,8 @@
...
@@ -13,6 +13,8 @@
.view_file_header
.view_file_header
%i
.icon-file
%i
.icon-file
%strong
=
@snippet
.
file_name
%strong
=
@snippet
.
file_name
%span
.options
=
link_to
"raw"
,
raw_project_snippet_path
(
@project
,
@snippet
),
:class
=>
"btn very_small"
,
:target
=>
"_blank"
.view_file_content
.view_file_content
%div
{
:class
=>
current_user
.
dark_scheme
?
"black"
:
""
}
%div
{
:class
=>
current_user
.
dark_scheme
?
"black"
:
""
}
=
raw
@snippet
.
colorize
(
options:
{
linenos:
'True'
})
=
raw
@snippet
.
colorize
(
options:
{
linenos:
'True'
})
...
...
config/routes.rb
View file @
093159a8
...
@@ -119,7 +119,12 @@ Gitlab::Application.routes.draw do
...
@@ -119,7 +119,12 @@ Gitlab::Application.routes.draw do
end
end
end
end
resources
:snippets
resources
:snippets
do
member
do
get
"raw"
end
end
resources
:hooks
,
:only
=>
[
:index
,
:create
,
:destroy
]
do
resources
:hooks
,
:only
=>
[
:index
,
:create
,
:destroy
]
do
member
do
member
do
get
:test
get
:test
...
...
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