Move calls to Gitlab::MarkdownHelper to application_helper

This commit is contained in:
Robert Schilling 2014-08-11 11:59:36 +02:00
parent 99eb283101
commit d7701a263f
6 changed files with 21 additions and 13 deletions

View file

@ -226,6 +226,14 @@ module ApplicationHelper
simple_format(file_content)
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)
css_class = "loading"
css_class << " hide" unless visible

View file

@ -22,9 +22,9 @@ module TreeHelper
end
def render_readme(readme)
if Gitlab::MarkdownHelper.gitlab_markdown?(readme.name)
if gitlab_markdown?(readme.name)
preserve(markdown(readme.data))
elsif Gitlab::MarkdownHelper.markup?(readme.name)
elsif markup?(readme.name)
render_markup(readme.name, readme.data)
else
simple_format(readme.data)
@ -90,8 +90,7 @@ module TreeHelper
end
def editing_preview_title(filename)
if Gitlab::MarkdownHelper.gitlab_markdown?(filename) ||
Gitlab::MarkdownHelper.markup?(filename)
if gitlab_markdown?(filename) || markup?(filename)
'Preview'
else
'Diff'

View file

@ -1,4 +1,6 @@
class Tree
include Gitlab::MarkdownHelper
attr_accessor :entries, :readme, :contribution_guide
def initialize(repository, sha, path = '/')
@ -13,8 +15,7 @@ class Tree
# by markup renderer.
if available_readmes.length > 1
supported_readmes = available_readmes.select do |readme|
Gitlab::MarkdownHelper.gitlab_markdown?(readme.name) ||
Gitlab::MarkdownHelper.markup?(readme.name)
gitlab_markdown?(readme.name) || markup?(readme.name)
end
# Take the first supported readme, or the first available readme, if we

View file

@ -1,8 +1,8 @@
- if Gitlab::MarkdownHelper.gitlab_markdown?(blob.name)
- if gitlab_markdown?(blob.name)
.file-content.wiki
= preserve do
= markdown(blob.data)
- elsif Gitlab::MarkdownHelper.markup?(blob.name)
- elsif markup?(blob.name)
.file-content.wiki
= render_markup(blob.name, blob.data)
- else

View file

@ -1,12 +1,12 @@
.diff-file
.diff-content
- if Gitlab::MarkdownHelper.gitlab_markdown?(@blob.name)
- if gitlab_markdown?(@blob.name)
.file-content.wiki
= preserve do
= markdown(@content)
- elsif Gitlab::MarkdownHelper.markup?(@blob.name)
- elsif markup?(@blob.name)
.file-content.wiki
= raw GitHub::Markup.render(@blob.name, @content)
= raw render_markup(@blob.name, @content)
- else
.file-content.code
- unless @diff.empty?

View file

@ -1,9 +1,9 @@
- unless @snippet.content.empty?
- if Gitlab::MarkdownHelper.gitlab_markdown?(@snippet.file_name)
- if gitlab_markdown?(@snippet.file_name)
.file-content.wiki
= preserve do
= markdown(@snippet.data)
- elsif Gitlab::MarkdownHelper.markup?(@snippet.file_name)
- elsif markup?(@snippet.file_name)
.file-content.wiki
= render_markup(@snippet.file_name, @snippet.data)
- else