BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
6e1069d5
Commit
6e1069d5
authored
Apr 20, 2017
by
Robert Speicher
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dm-markup-helper-constants' into 'master'
Use constants in Gitlab::MarkupHelper See merge request !10741
parents
ceb1ebc9
3509534a
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
9 deletions
+16
-9
markup_helper.rb
lib/gitlab/markup_helper.rb
+16
-9
No files found.
lib/gitlab/markup_helper.rb
View file @
6e1069d5
module
Gitlab
module
Gitlab
module
MarkupHelper
module
MarkupHelper
module_function
extend
self
MARKDOWN_EXTENSIONS
=
%w(mdown mkd mkdn md markdown)
.
freeze
ASCIIDOC_EXTENSIONS
=
%w(adoc ad asciidoc)
.
freeze
OTHER_EXTENSIONS
=
%w(textile rdoc org creole wiki mediawiki rst)
.
freeze
EXTENSIONS
=
MARKDOWN_EXTENSIONS
+
ASCIIDOC_EXTENSIONS
+
OTHER_EXTENSIONS
# Public: Determines if a given filename is compatible with GitHub::Markup.
# Public: Determines if a given filename is compatible with GitHub::Markup.
#
#
...
@@ -8,10 +13,7 @@ module Gitlab
...
@@ -8,10 +13,7 @@ module Gitlab
#
#
# Returns boolean
# Returns boolean
def
markup?
(
filename
)
def
markup?
(
filename
)
gitlab_markdown?
(
filename
)
||
EXTENSIONS
.
include?
(
extension
(
filename
))
asciidoc?
(
filename
)
||
filename
.
downcase
.
end_with?
(
*
%w(.textile .rdoc .org .creole .wiki
.mediawiki .rst)
)
end
end
# Public: Determines if a given filename is compatible with
# Public: Determines if a given filename is compatible with
...
@@ -21,7 +23,7 @@ module Gitlab
...
@@ -21,7 +23,7 @@ module Gitlab
#
#
# Returns boolean
# Returns boolean
def
gitlab_markdown?
(
filename
)
def
gitlab_markdown?
(
filename
)
filename
.
downcase
.
end_with?
(
*
%w(.mdown .mkd .mkdn .md .markdown
)
)
MARKDOWN_EXTENSIONS
.
include?
(
extension
(
filename
))
end
end
# Public: Determines if the given filename has AsciiDoc extension.
# Public: Determines if the given filename has AsciiDoc extension.
...
@@ -30,7 +32,7 @@ module Gitlab
...
@@ -30,7 +32,7 @@ module Gitlab
#
#
# Returns boolean
# Returns boolean
def
asciidoc?
(
filename
)
def
asciidoc?
(
filename
)
filename
.
downcase
.
end_with?
(
*
%w(.adoc .ad .asciidoc
)
)
ASCIIDOC_EXTENSIONS
.
include?
(
extension
(
filename
))
end
end
# Public: Determines if the given filename is plain text.
# Public: Determines if the given filename is plain text.
...
@@ -39,12 +41,17 @@ module Gitlab
...
@@ -39,12 +41,17 @@ module Gitlab
#
#
# Returns boolean
# Returns boolean
def
plain?
(
filename
)
def
plain?
(
filename
)
filename
.
downcase
.
end_with?
(
'.txt'
)
||
extension
(
filename
)
==
'txt'
||
filename
.
casecmp
(
'readme'
).
zero?
filename
.
casecmp
(
'readme'
).
zero?
end
end
def
previewable?
(
filename
)
def
previewable?
(
filename
)
markup?
(
filename
)
markup?
(
filename
)
end
end
private
def
extension
(
filename
)
File
.
extname
(
filename
).
downcase
.
delete
(
'.'
)
end
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment