Commit ccb706d3 authored by James Lopez's avatar James Lopez

Refactor MarkupHelper to add INDEX plain filename

parent 75917c51
...@@ -4,10 +4,11 @@ module Gitlab ...@@ -4,10 +4,11 @@ module Gitlab
module MarkupHelper module MarkupHelper
extend self extend self
MARKDOWN_EXTENSIONS = %w(mdown mkd mkdn md markdown).freeze MARKDOWN_EXTENSIONS = %w[mdown mkd mkdn md markdown].freeze
ASCIIDOC_EXTENSIONS = %w(adoc ad asciidoc).freeze ASCIIDOC_EXTENSIONS = %w[adoc ad asciidoc].freeze
OTHER_EXTENSIONS = %w(textile rdoc org creole wiki mediawiki rst).freeze OTHER_EXTENSIONS = %w[textile rdoc org creole wiki mediawiki rst].freeze
EXTENSIONS = MARKDOWN_EXTENSIONS + ASCIIDOC_EXTENSIONS + OTHER_EXTENSIONS EXTENSIONS = MARKDOWN_EXTENSIONS + ASCIIDOC_EXTENSIONS + OTHER_EXTENSIONS
PLAIN_FILENAMES = %w[readme index].freeze
# Public: Determines if a given filename is compatible with GitHub::Markup. # Public: Determines if a given filename is compatible with GitHub::Markup.
# #
...@@ -43,7 +44,7 @@ module Gitlab ...@@ -43,7 +44,7 @@ module Gitlab
# #
# Returns boolean # Returns boolean
def plain?(filename) def plain?(filename)
extension(filename) == 'txt' || filename.casecmp('readme').zero? extension(filename) == 'txt' || plain_filename?(filename)
end end
def previewable?(filename) def previewable?(filename)
...@@ -55,5 +56,9 @@ module Gitlab ...@@ -55,5 +56,9 @@ module Gitlab
def extension(filename) def extension(filename)
File.extname(filename).downcase.delete('.') File.extname(filename).downcase.delete('.')
end end
def plain_filename?(filename)
PLAIN_FILENAMES.include?(filename.downcase)
end
end end
end end
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