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
Jérome Perrin
gitlab-ce
Commits
32186b4a
Commit
32186b4a
authored
Oct 06, 2016
by
Justin DiPierro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added 'Download' button to snippet view
parent
0e098495
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
3 deletions
+14
-3
CHANGELOG
CHANGELOG
+1
-0
app/controllers/snippets_controller.rb
app/controllers/snippets_controller.rb
+11
-3
app/views/snippets/show.html.haml
app/views/snippets/show.html.haml
+1
-0
config/routes/snippets.rb
config/routes/snippets.rb
+1
-0
No files found.
CHANGELOG
View file @
32186b4a
...
@@ -38,6 +38,7 @@ v 8.13.0 (unreleased)
...
@@ -38,6 +38,7 @@ v 8.13.0 (unreleased)
- Fix todos page mobile viewport layout (ClemMakesApps)
- Fix todos page mobile viewport layout (ClemMakesApps)
- Fix inconsistent highlighting of already selected activity nav-links (ClemMakesApps)
- Fix inconsistent highlighting of already selected activity nav-links (ClemMakesApps)
- Remove redundant mixins (ClemMakesApps)
- Remove redundant mixins (ClemMakesApps)
- Added 'Download' button to the Snippets page (Justin DiPierro)
- Fix robots.txt disallowing access to groups starting with "s" (Matt Harrison)
- Fix robots.txt disallowing access to groups starting with "s" (Matt Harrison)
- Close open merge request without source project (Katarzyna Kobierska Ula Budziszewska)
- Close open merge request without source project (Katarzyna Kobierska Ula Budziszewska)
- Fix that manual jobs would no longer block jobs in the next stage. !6604
- Fix that manual jobs would no longer block jobs in the next stage. !6604
...
...
app/controllers/snippets_controller.rb
View file @
32186b4a
class
SnippetsController
<
ApplicationController
class
SnippetsController
<
ApplicationController
include
ToggleAwardEmoji
include
ToggleAwardEmoji
before_action
:snippet
,
only:
[
:show
,
:edit
,
:destroy
,
:update
,
:raw
]
before_action
:snippet
,
only:
[
:show
,
:edit
,
:destroy
,
:update
,
:raw
,
:download
]
# Allow read snippet
# Allow read snippet
before_action
:authorize_read_snippet!
,
only:
[
:show
,
:raw
]
before_action
:authorize_read_snippet!
,
only:
[
:show
,
:raw
,
:download
]
# Allow modify snippet
# Allow modify snippet
before_action
:authorize_update_snippet!
,
only:
[
:edit
,
:update
]
before_action
:authorize_update_snippet!
,
only:
[
:edit
,
:update
]
...
@@ -12,7 +12,7 @@ class SnippetsController < ApplicationController
...
@@ -12,7 +12,7 @@ class SnippetsController < ApplicationController
# Allow destroy snippet
# Allow destroy snippet
before_action
:authorize_admin_snippet!
,
only:
[
:destroy
]
before_action
:authorize_admin_snippet!
,
only:
[
:destroy
]
skip_before_action
:authenticate_user!
,
only:
[
:index
,
:show
,
:raw
]
skip_before_action
:authenticate_user!
,
only:
[
:index
,
:show
,
:raw
,
:download
]
layout
'snippets'
layout
'snippets'
respond_to
:html
respond_to
:html
...
@@ -75,6 +75,14 @@ class SnippetsController < ApplicationController
...
@@ -75,6 +75,14 @@ class SnippetsController < ApplicationController
)
)
end
end
def
download
send_data
(
@snippet
.
content
,
type:
'text/plain; charset=utf-8'
,
filename:
@snippet
.
sanitized_file_name
)
end
protected
protected
def
snippet
def
snippet
...
...
app/views/snippets/show.html.haml
View file @
32186b4a
...
@@ -9,6 +9,7 @@
...
@@ -9,6 +9,7 @@
.file-actions
.file-actions
=
clipboard_button
(
clipboard_target:
".blob-content[data-blob-id='
#{
@snippet
.
id
}
']"
)
=
clipboard_button
(
clipboard_target:
".blob-content[data-blob-id='
#{
@snippet
.
id
}
']"
)
=
link_to
'Raw'
,
raw_snippet_path
(
@snippet
),
class:
"btn btn-sm"
,
target:
"_blank"
=
link_to
'Raw'
,
raw_snippet_path
(
@snippet
),
class:
"btn btn-sm"
,
target:
"_blank"
=
link_to
'Download'
,
download_snippet_path
(
@snippet
),
class:
"btn btn-sm"
=
render
'shared/snippets/blob'
=
render
'shared/snippets/blob'
=
render
'award_emoji/awards_block'
,
awardable:
@snippet
,
inline:
true
=
render
'award_emoji/awards_block'
,
awardable:
@snippet
,
inline:
true
\ No newline at end of file
config/routes/snippets.rb
View file @
32186b4a
resources
:snippets
,
concerns: :awardable
do
resources
:snippets
,
concerns: :awardable
do
member
do
member
do
get
'raw'
get
'raw'
get
'download'
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