Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
ca0e3904
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,发现更多精彩内容 >>
未验证
提交
ca0e3904
编写于
9月 21, 2017
作者:
Z
Zeger-Jan van de Weg
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Backend for HTML serving with GitLab Pages
上级
3265ccfc
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
87 addition
and
4 deletion
+87
-4
app/helpers/artifact_helper.rb
app/helpers/artifact_helper.rb
+31
-0
app/views/projects/artifacts/_tree_file.html.haml
app/views/projects/artifacts/_tree_file.html.haml
+3
-4
config/gitlab.yml.example
config/gitlab.yml.example
+1
-0
spec/fixtures/ci_build_artifacts.zip
spec/fixtures/ci_build_artifacts.zip
+0
-0
spec/helpers/artifact_helper_spec.rb
spec/helpers/artifact_helper_spec.rb
+52
-0
未找到文件。
app/helpers/artifact_helper.rb
0 → 100644
浏览文件 @
ca0e3904
module
ArtifactHelper
include
GitlabRoutingHelper
def
link_to_artifact
(
project
,
job
,
file
)
if
external_url?
(
file
.
blob
)
html_artifact_url
(
project
,
job
,
file
.
blob
)
else
file_project_job_artifacts_path
(
project
,
job
,
path:
file
.
path
)
end
end
def
external_url?
(
blob
)
blob
.
name
.
end_with?
(
".html"
)
&&
pages_config
.
enabled
&&
pages_config
.
artifacts_server
end
private
def
html_artifact_url
(
project
,
job
,
blob
)
http
=
pages_config
.
https
?
"https://"
:
"http://"
domain
=
"
#{
project
.
namespace
.
to_param
}
.
#{
pages_config
.
host
}
/"
path
=
"-/jobs/
#{
job
.
id
}
/artifacts/
#{
blob
.
path
}
"
http
+
domain
+
path
end
def
pages_config
Gitlab
.
config
.
pages
end
end
app/views/projects/artifacts/_tree_file.html.haml
浏览文件 @
ca0e3904
-
todo_external_artifacts_path
=
'https://google.com'
-
is_external_link
=
!
todo_external_artifacts_path
.
blank?
-
path_to_file
=
todo_external_artifacts_path
||
file_project_job_artifacts_path
(
@project
,
@build
,
path:
file
.
path
)
-
blob
=
file
.
blob
-
is_external_link
=
external_link?
(
blob
)
-
path_to_file
=
link_to_artifact
(
@project
,
@build
,
file
)
%tr
.tree-item.js-artifact-tree-row
{
data:
{
link:
path_to_file
,
external_link:
"#{is_external_link}"
}
}
-
blob
=
file
.
blob
%td
.tree-item-file-name
=
tree_icon
(
'file'
,
blob
.
mode
,
blob
.
name
)
=
link_to
path_to_file
,
...
...
config/gitlab.yml.example
浏览文件 @
ca0e3904
...
...
@@ -164,6 +164,7 @@ production: &base
host: example.com
port: 80 # Set to 443 if you serve the pages with HTTPS
https: false # Set to true if you serve the pages with HTTPS
artifacts_server: true
# external_http: ["1.1.1.1:80", "[2001::1]:80"] # If defined, enables custom domain support in GitLab Pages
# external_https: ["1.1.1.1:443", "[2001::1]:443"] # If defined, enables custom domain and certificate support in GitLab Pages
...
...
spec/fixtures/ci_build_artifacts.zip
浏览文件 @
ca0e3904
无法预览此类型文件
spec/helpers/artifact_helper_spec.rb
0 → 100644
浏览文件 @
ca0e3904
require
'spec_helper'
describe
ArtifactHelper
do
set
(
:job
)
{
create
(
:ci_build
,
:artifacts
)
}
let
(
:html_entry
)
{
job
.
artifacts_metadata_entry
(
"other_artifacts_0.1.2/index.html"
)
}
let
(
:txt_entry
)
{
job
.
artifacts_metadata_entry
(
"other_artifacts_0.1.2/doc_sample.txt"
)
}
before
do
allow
(
Gitlab
.
config
.
pages
).
to
receive
(
:enabled
).
and_return
(
true
)
allow
(
Gitlab
.
config
.
pages
).
to
receive
(
:artifacts_server
).
and_return
(
true
)
end
describe
'#link_to_artifact'
do
context
'link_to_pages returns true'
do
subject
{
link_to_artifact
(
job
.
project
,
job
,
entry
)
}
before
do
allow
(
Gitlab
.
config
.
pages
).
to
receive
(
:enabled
).
and_return
(
true
)
end
context
'when the entry is HTML'
do
let
(
:entry
)
{
html_entry
}
it
{
is_expected
.
to
match
Gitlab
.
config
.
pages
.
host
}
it
{
is_expected
.
to
match
/-\/jobs\/\d+\/artifacts/
}
end
context
'when the entry is not HTML'
do
let
(
:entry
)
{
txt_entry
}
it
{
is_expected
.
not_to
match
Gitlab
.
config
.
pages
.
host
}
end
end
end
describe
'#external_url?'
do
context
'pages enabled'
do
before
do
allow
(
Gitlab
.
config
.
pages
).
to
receive
(
:artifacts_server
).
and_return
(
true
)
end
it
'returns true for HTML files'
do
expect
(
external_url?
(
txt_entry
.
blob
)).
to
be
(
false
)
end
it
'returns true for HTML files'
do
expect
(
external_url?
(
html_entry
.
blob
)).
to
be
(
true
)
end
end
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录