From 07e9cb6b77b35ed92d0d9a8e5bcdf92884024dbf Mon Sep 17 00:00:00 2001 From: Ciro Santilli Date: Sat, 4 Oct 2014 17:56:12 +0200 Subject: [PATCH] Factor markup? || gitlab_markdown? into new method --- app/helpers/tree_helper.rb | 2 +- app/models/tree.rb | 2 +- lib/gitlab/markdown_helper.rb | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/helpers/tree_helper.rb b/app/helpers/tree_helper.rb index c3b537eac47..9c611a1c147 100644 --- a/app/helpers/tree_helper.rb +++ b/app/helpers/tree_helper.rb @@ -90,7 +90,7 @@ module TreeHelper end def editing_preview_title(filename) - if gitlab_markdown?(filename) || markup?(filename) + if Gitlab::MarkdownHelper.previewable?(filename) 'Preview' else 'Diff' diff --git a/app/models/tree.rb b/app/models/tree.rb index 07c9a825e24..4f5d81f0a5e 100644 --- a/app/models/tree.rb +++ b/app/models/tree.rb @@ -15,7 +15,7 @@ class Tree # by markup renderer. if available_readmes.length > 1 supported_readmes = available_readmes.select do |readme| - gitlab_markdown?(readme.name) || markup?(readme.name) + previewable?(readme.name) end # Take the first supported readme, or the first available readme, if we diff --git a/lib/gitlab/markdown_helper.rb b/lib/gitlab/markdown_helper.rb index abed12fe570..5e3cfc0585b 100644 --- a/lib/gitlab/markdown_helper.rb +++ b/lib/gitlab/markdown_helper.rb @@ -21,5 +21,9 @@ module Gitlab def gitlab_markdown?(filename) filename.downcase.end_with?(*%w(.mdown .md .markdown)) end + + def previewable?(filename) + gitlab_markdown?(filename) || markup?(filename) + end end end