summaryrefslogtreecommitdiff
path: root/app/helpers/tree_helper.rb
diff options
context:
space:
mode:
authorRobert Schilling <rschilling@student.tugraz.at>2014-08-11 08:50:56 +0200
committerRobert Schilling <rschilling@student.tugraz.at>2014-08-11 08:50:56 +0200
commit99eb283101108f1f95e95ade8c1352f547578b26 (patch)
treeed682bc2303d6862af4f2dbd5dd764d7c1e36f31 /app/helpers/tree_helper.rb
parent0e3f8ea2ef2a7d6cc51ccb5d7ae854c6244b40eb (diff)
downloadgitlab-ce-99eb283101108f1f95e95ade8c1352f547578b26.tar.gz
Use readme we support to render if there are multiple readmes
Diffstat (limited to 'app/helpers/tree_helper.rb')
-rw-r--r--app/helpers/tree_helper.rb27
1 files changed, 12 insertions, 15 deletions
diff --git a/app/helpers/tree_helper.rb b/app/helpers/tree_helper.rb
index 29eb28af879..c36d0cf46e7 100644
--- a/app/helpers/tree_helper.rb
+++ b/app/helpers/tree_helper.rb
@@ -21,6 +21,16 @@ module TreeHelper
tree.html_safe
end
+ def render_readme(readme)
+ if Gitlab::MarkdownHelper.gitlab_markdown?(readme.name)
+ preserve(markdown(readme.data))
+ elsif Gitlab::MarkdownHelper.markup?(readme.name)
+ render_markup(readme.name, readme.data)
+ else
+ simple_format(readme.data)
+ end
+ end
+
# Return an image icon depending on the file type
#
# type - String type of the tree item; either 'folder' or 'file'
@@ -38,20 +48,6 @@ module TreeHelper
"file_#{hexdigest(content.name)}"
end
- # Public: Determines if a given filename is compatible with GitHub::Markup.
- #
- # filename - Filename string to check
- #
- # Returns boolean
- def markup?(filename)
- filename.downcase.end_with?(*%w(.textile .rdoc .org .creole .wiki .mediawiki
- .rst .adoc .asciidoc .asc))
- end
-
- def gitlab_markdown?(filename)
- filename.downcase.end_with?(*%w(.mdown .md .markdown))
- end
-
# Simple shortcut to File.join
def tree_join(*args)
File.join(*args)
@@ -94,7 +90,8 @@ module TreeHelper
end
def editing_preview_title(filename)
- if gitlab_markdown?(filename) || markup?(filename)
+ if Gitlab::MarkdownHelper.gitlab_markdown?(filename) ||
+ Gitlab::MarkdownHelper.markup?(filename)
'Preview'
else
'Diff'