Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
64bb1906
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,发现更多精彩内容 >>
提交
64bb1906
编写于
10月 11, 2017
作者:
V
Vitaliy @blackst0ne Klachkov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add support for markdown preview to group milestones
上级
2a9147b7
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
57 addition
and
36 deletion
+57
-36
app/controllers/concerns/preview_markdown.rb
app/controllers/concerns/preview_markdown.rb
+22
-0
app/controllers/groups_controller.rb
app/controllers/groups_controller.rb
+1
-0
app/controllers/projects/wikis_controller.rb
app/controllers/projects/wikis_controller.rb
+2
-11
app/controllers/projects_controller.rb
app/controllers/projects_controller.rb
+1
-12
app/controllers/snippets_controller.rb
app/controllers/snippets_controller.rb
+1
-11
app/views/groups/milestones/_form.html.haml
app/views/groups/milestones/_form.html.haml
+1
-1
changelogs/unreleased/move_markdown_preview_to_concern.yml
changelogs/unreleased/move_markdown_preview_to_concern.yml
+5
-0
config/routes/group.rb
config/routes/group.rb
+3
-1
spec/features/groups/milestone_spec.rb
spec/features/groups/milestone_spec.rb
+21
-0
未找到文件。
app/controllers/concerns/preview_markdown.rb
0 → 100644
浏览文件 @
64bb1906
module
PreviewMarkdown
extend
ActiveSupport
::
Concern
def
preview_markdown
result
=
PreviewMarkdownService
.
new
(
@project
,
current_user
,
params
).
execute
markdown_params
=
case
controller_name
when
'wikis'
then
{
pipeline: :wiki
,
project_wiki:
@project_wiki
,
page_slug:
params
[
:id
]
}
when
'snippets'
then
{
skip_project_check:
true
}
else
{}
end
render
json:
{
body:
view_context
.
markdown
(
result
[
:text
],
markdown_params
),
references:
{
users:
result
[
:users
],
commands:
view_context
.
markdown
(
result
[
:commands
])
}
}
end
end
app/controllers/groups_controller.rb
浏览文件 @
64bb1906
...
...
@@ -2,6 +2,7 @@ class GroupsController < Groups::ApplicationController
include
IssuesAction
include
MergeRequestsAction
include
ParamsBackwardCompatibility
include
PreviewMarkdown
respond_to
:html
...
...
app/controllers/projects/wikis_controller.rb
浏览文件 @
64bb1906
class
Projects::WikisController
<
Projects
::
ApplicationController
include
PreviewMarkdown
before_action
:authorize_read_wiki!
before_action
:authorize_create_wiki!
,
only:
[
:edit
,
:create
,
:history
]
before_action
:authorize_admin_wiki!
,
only: :destroy
...
...
@@ -92,17 +94,6 @@ class Projects::WikisController < Projects::ApplicationController
def
git_access
end
def
preview_markdown
result
=
PreviewMarkdownService
.
new
(
@project
,
current_user
,
params
).
execute
render
json:
{
body:
view_context
.
markdown
(
result
[
:text
],
pipeline: :wiki
,
project_wiki:
@project_wiki
,
page_slug:
params
[
:id
]),
references:
{
users:
result
[
:users
]
}
}
end
private
def
load_project_wiki
...
...
app/controllers/projects_controller.rb
浏览文件 @
64bb1906
class
ProjectsController
<
Projects
::
ApplicationController
include
IssuableCollections
include
ExtractsPath
include
PreviewMarkdown
before_action
:authenticate_user!
,
except:
[
:index
,
:show
,
:activity
,
:refs
]
before_action
:project
,
except:
[
:index
,
:new
,
:create
]
...
...
@@ -258,18 +259,6 @@ class ProjectsController < Projects::ApplicationController
render
json:
options
.
to_json
end
def
preview_markdown
result
=
PreviewMarkdownService
.
new
(
@project
,
current_user
,
params
).
execute
render
json:
{
body:
view_context
.
markdown
(
result
[
:text
]),
references:
{
users:
result
[
:users
],
commands:
view_context
.
markdown
(
result
[
:commands
])
}
}
end
private
# Render project landing depending of which features are available
...
...
app/controllers/snippets_controller.rb
浏览文件 @
64bb1906
...
...
@@ -4,6 +4,7 @@ class SnippetsController < ApplicationController
include
SpammableActions
include
SnippetsActions
include
RendersBlob
include
PreviewMarkdown
before_action
:snippet
,
only:
[
:show
,
:edit
,
:destroy
,
:update
,
:raw
]
...
...
@@ -87,17 +88,6 @@ class SnippetsController < ApplicationController
redirect_to
snippets_path
,
status:
302
end
def
preview_markdown
result
=
PreviewMarkdownService
.
new
(
@project
,
current_user
,
params
).
execute
render
json:
{
body:
view_context
.
markdown
(
result
[
:text
],
skip_project_check:
true
),
references:
{
users:
result
[
:users
]
}
}
end
protected
def
snippet
...
...
app/views/groups/milestones/_form.html.haml
浏览文件 @
64bb1906
...
...
@@ -10,7 +10,7 @@
.form-group.milestone-description
=
f
.
label
:description
,
"Description"
,
class:
"control-label"
.col-sm-10
=
render
layout:
'projects/md_preview'
,
locals:
{
url:
''
}
do
=
render
layout:
'projects/md_preview'
,
locals:
{
url:
group_preview_markdown_path
}
do
=
render
'projects/zen'
,
f:
f
,
attr: :description
,
classes:
'note-textarea'
,
placeholder:
'Write milestone description...'
.clearfix
.error-alert
...
...
changelogs/unreleased/move_markdown_preview_to_concern.yml
0 → 100644
浏览文件 @
64bb1906
---
title
:
Add support for markdown preview to group milestones
merge_request
:
14806
author
:
Vitaliy @blackst0ne Klachkov
type
:
fixed
config/routes/group.rb
浏览文件 @
64bb1906
require
'constraints/group_url_constrainer'
resources
:groups
,
only:
[
:index
,
:new
,
:create
]
resources
:groups
,
only:
[
:index
,
:new
,
:create
]
do
post
:preview_markdown
end
scope
(
path:
'groups/*group_id'
,
module: :groups
,
...
...
spec/features/groups/milestone_spec.rb
浏览文件 @
64bb1906
...
...
@@ -18,6 +18,27 @@ feature 'Group milestones', :js do
visit
new_group_milestone_path
(
group
)
end
it
'renders description preview'
do
form
=
find
(
'.gfm-form'
)
form
.
fill_in
(
:milestone_description
,
with:
''
)
click_link
(
'Preview'
)
preview
=
find
(
'.js-md-preview'
)
expect
(
preview
).
to
have_content
(
'Nothing to preview.'
)
click_link
(
'Write'
)
form
.
fill_in
(
:milestone_description
,
with:
':+1: Nice'
)
click_link
(
'Preview'
)
expect
(
preview
).
to
have_css
(
'gl-emoji'
)
expect
(
find
(
'#milestone_description'
,
visible:
false
)).
not_to
be_visible
end
it
'creates milestone with start date'
do
fill_in
'Title'
,
with:
'testing'
find
(
'#milestone_start_date'
).
click
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录