Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
32186b4a
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
32186b4a
编写于
10月 06, 2016
作者:
J
Justin DiPierro
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added 'Download' button to snippet view
上级
0e098495
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
14 addition
and
3 deletion
+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
未找到文件。
CHANGELOG
浏览文件 @
32186b4a
...
...
@@ -38,6 +38,7 @@ v 8.13.0 (unreleased)
- Fix todos page mobile viewport layout (ClemMakesApps)
- Fix inconsistent highlighting of already selected activity nav-links (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)
- 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
...
...
app/controllers/snippets_controller.rb
浏览文件 @
32186b4a
class
SnippetsController
<
ApplicationController
include
ToggleAwardEmoji
before_action
:snippet
,
only:
[
:show
,
:edit
,
:destroy
,
:update
,
:raw
]
before_action
:snippet
,
only:
[
:show
,
:edit
,
:destroy
,
:update
,
:raw
,
:download
]
# Allow read snippet
before_action
:authorize_read_snippet!
,
only:
[
:show
,
:raw
]
before_action
:authorize_read_snippet!
,
only:
[
:show
,
:raw
,
:download
]
# Allow modify snippet
before_action
:authorize_update_snippet!
,
only:
[
:edit
,
:update
]
...
...
@@ -12,7 +12,7 @@ class SnippetsController < ApplicationController
# Allow destroy snippet
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'
respond_to
:html
...
...
@@ -75,6 +75,14 @@ class SnippetsController < ApplicationController
)
end
def
download
send_data
(
@snippet
.
content
,
type:
'text/plain; charset=utf-8'
,
filename:
@snippet
.
sanitized_file_name
)
end
protected
def
snippet
...
...
app/views/snippets/show.html.haml
浏览文件 @
32186b4a
...
...
@@ -9,6 +9,7 @@
.file-actions
=
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
'Download'
,
download_snippet_path
(
@snippet
),
class:
"btn btn-sm"
=
render
'shared/snippets/blob'
=
render
'award_emoji/awards_block'
,
awardable:
@snippet
,
inline:
true
\ No newline at end of file
config/routes/snippets.rb
浏览文件 @
32186b4a
resources
:snippets
,
concerns: :awardable
do
member
do
get
'raw'
get
'download'
end
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录