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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
64bb1906
Commit
64bb1906
authored
Oct 11, 2017
by
Vitaliy @blackst0ne Klachkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for markdown preview to group milestones
parent
2a9147b7
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
57 additions
and
36 deletions
+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
No files found.
app/controllers/concerns/preview_markdown.rb
0 → 100644
View file @
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
View file @
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
View file @
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
View file @
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
View file @
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
View file @
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
View file @
64bb1906
---
title
:
Add support for markdown preview to group milestones
merge_request
:
14806
author
:
Vitaliy @blackst0ne Klachkov
type
:
fixed
config/routes/group.rb
View file @
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
View file @
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
...
...
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