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
Léo-Paul Géneau
gitlab-ce
Commits
ef4d4446
Commit
ef4d4446
authored
Apr 03, 2017
by
Toon Claes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move some methods from ApplicationHelper to MarkupHelper
parent
d95bffc6
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
34 deletions
+32
-34
app/helpers/application_helper.rb
app/helpers/application_helper.rb
+0
-32
app/helpers/markup_helper.rb
app/helpers/markup_helper.rb
+32
-0
spec/helpers/markup_helper_spec.rb
spec/helpers/markup_helper_spec.rb
+0
-2
No files found.
app/helpers/application_helper.rb
View file @
ef4d4446
...
...
@@ -196,38 +196,6 @@ module ApplicationHelper
end
end
def
render_markup
(
file_name
,
file_content
)
if
gitlab_markdown?
(
file_name
)
Hamlit
::
RailsHelpers
.
preserve
(
markdown
(
file_content
))
elsif
asciidoc?
(
file_name
)
asciidoc
(
file_content
)
elsif
plain?
(
file_name
)
content_tag
:pre
,
class:
'plain-readme'
do
file_content
end
else
other_markup
(
file_name
,
file_content
)
end
rescue
RuntimeError
simple_format
(
file_content
)
end
def
plain?
(
filename
)
Gitlab
::
MarkupHelper
.
plain?
(
filename
)
end
def
markup?
(
filename
)
Gitlab
::
MarkupHelper
.
markup?
(
filename
)
end
def
gitlab_markdown?
(
filename
)
Gitlab
::
MarkupHelper
.
gitlab_markdown?
(
filename
)
end
def
asciidoc?
(
filename
)
Gitlab
::
MarkupHelper
.
asciidoc?
(
filename
)
end
def
promo_host
'about.gitlab.com'
end
...
...
app/helpers/markup_helper.rb
View file @
ef4d4446
require
'nokogiri'
module
MarkupHelper
def
plain?
(
filename
)
Gitlab
::
MarkupHelper
.
plain?
(
filename
)
end
def
markup?
(
filename
)
Gitlab
::
MarkupHelper
.
markup?
(
filename
)
end
def
gitlab_markdown?
(
filename
)
Gitlab
::
MarkupHelper
.
gitlab_markdown?
(
filename
)
end
def
asciidoc?
(
filename
)
Gitlab
::
MarkupHelper
.
asciidoc?
(
filename
)
end
# Use this in places where you would normally use link_to(gfm(...), ...).
#
# It solves a problem occurring with nested links (i.e.
...
...
@@ -110,6 +126,22 @@ module MarkupHelper
end
end
def
render_markup
(
file_name
,
file_content
)
if
gitlab_markdown?
(
file_name
)
Hamlit
::
RailsHelpers
.
preserve
(
markdown
(
file_content
))
elsif
asciidoc?
(
file_name
)
asciidoc
(
file_content
)
elsif
plain?
(
file_name
)
content_tag
:pre
,
class:
'plain-readme'
do
file_content
end
else
other_markup
(
file_name
,
file_content
)
end
rescue
RuntimeError
simple_format
(
file_content
)
end
# Returns the text necessary to reference `entity` across projects
#
# project - Project to reference
...
...
spec/helpers/markup_helper_spec.rb
View file @
ef4d4446
require
'spec_helper'
describe
MarkupHelper
do
include
ApplicationHelper
let!
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:user
)
{
create
(
:user
,
username:
'gfm'
)
}
...
...
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