Commit d7701a26 authored by Robert Schilling's avatar Robert Schilling

Move calls to Gitlab::MarkdownHelper to application_helper

parent 99eb2831
...@@ -226,6 +226,14 @@ module ApplicationHelper ...@@ -226,6 +226,14 @@ module ApplicationHelper
simple_format(file_content) simple_format(file_content)
end end
def markup?(filename)
Gitlab::MarkdownHelper.markup?(filename)
end
def gitlab_markdown?(filename)
Gitlab::MarkdownHelper.gitlab_markdown?(filename)
end
def spinner(text = nil, visible = false) def spinner(text = nil, visible = false)
css_class = "loading" css_class = "loading"
css_class << " hide" unless visible css_class << " hide" unless visible
......
...@@ -22,9 +22,9 @@ module TreeHelper ...@@ -22,9 +22,9 @@ module TreeHelper
end end
def render_readme(readme) def render_readme(readme)
if Gitlab::MarkdownHelper.gitlab_markdown?(readme.name) if gitlab_markdown?(readme.name)
preserve(markdown(readme.data)) preserve(markdown(readme.data))
elsif Gitlab::MarkdownHelper.markup?(readme.name) elsif markup?(readme.name)
render_markup(readme.name, readme.data) render_markup(readme.name, readme.data)
else else
simple_format(readme.data) simple_format(readme.data)
...@@ -90,8 +90,7 @@ module TreeHelper ...@@ -90,8 +90,7 @@ module TreeHelper
end end
def editing_preview_title(filename) def editing_preview_title(filename)
if Gitlab::MarkdownHelper.gitlab_markdown?(filename) || if gitlab_markdown?(filename) || markup?(filename)
Gitlab::MarkdownHelper.markup?(filename)
'Preview' 'Preview'
else else
'Diff' 'Diff'
......
class Tree class Tree
include Gitlab::MarkdownHelper
attr_accessor :entries, :readme, :contribution_guide attr_accessor :entries, :readme, :contribution_guide
def initialize(repository, sha, path = '/') def initialize(repository, sha, path = '/')
...@@ -13,8 +15,7 @@ class Tree ...@@ -13,8 +15,7 @@ class Tree
# by markup renderer. # by markup renderer.
if available_readmes.length > 1 if available_readmes.length > 1
supported_readmes = available_readmes.select do |readme| supported_readmes = available_readmes.select do |readme|
Gitlab::MarkdownHelper.gitlab_markdown?(readme.name) || gitlab_markdown?(readme.name) || markup?(readme.name)
Gitlab::MarkdownHelper.markup?(readme.name)
end end
# Take the first supported readme, or the first available readme, if we # Take the first supported readme, or the first available readme, if we
......
- if Gitlab::MarkdownHelper.gitlab_markdown?(blob.name) - if gitlab_markdown?(blob.name)
.file-content.wiki .file-content.wiki
= preserve do = preserve do
= markdown(blob.data) = markdown(blob.data)
- elsif Gitlab::MarkdownHelper.markup?(blob.name) - elsif markup?(blob.name)
.file-content.wiki .file-content.wiki
= render_markup(blob.name, blob.data) = render_markup(blob.name, blob.data)
- else - else
......
.diff-file .diff-file
.diff-content .diff-content
- if Gitlab::MarkdownHelper.gitlab_markdown?(@blob.name) - if gitlab_markdown?(@blob.name)
.file-content.wiki .file-content.wiki
= preserve do = preserve do
= markdown(@content) = markdown(@content)
- elsif Gitlab::MarkdownHelper.markup?(@blob.name) - elsif markup?(@blob.name)
.file-content.wiki .file-content.wiki
= raw GitHub::Markup.render(@blob.name, @content) = raw render_markup(@blob.name, @content)
- else - else
.file-content.code .file-content.code
- unless @diff.empty? - unless @diff.empty?
......
- unless @snippet.content.empty? - unless @snippet.content.empty?
- if Gitlab::MarkdownHelper.gitlab_markdown?(@snippet.file_name) - if gitlab_markdown?(@snippet.file_name)
.file-content.wiki .file-content.wiki
= preserve do = preserve do
= markdown(@snippet.data) = markdown(@snippet.data)
- elsif Gitlab::MarkdownHelper.markup?(@snippet.file_name) - elsif markup?(@snippet.file_name)
.file-content.wiki .file-content.wiki
= render_markup(@snippet.file_name, @snippet.data) = render_markup(@snippet.file_name, @snippet.data)
- else - else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment