Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
e3402769
Commit
e3402769
authored
Dec 05, 2011
by
Saito
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refator handle_file_type. add velocity jade c header and others syntax detect
parent
da424d94
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
9 deletions
+18
-9
lib/utils.rb
lib/utils.rb
+18
-9
No files found.
lib/utils.rb
View file @
e3402769
...
@@ -40,21 +40,30 @@ module Utils
...
@@ -40,21 +40,30 @@ module Utils
end
end
def
handle_file_type
(
file_name
,
mime_type
=
nil
)
def
handle_file_type
(
file_name
,
mime_type
=
nil
)
if
file_name
=~
/(\.rb|\.ru|\.rake|Rakefile|\.gemspec|\.rbx|Gemfile)$/
case
file_name
when
/(\.pl|\.scala|\.java|\.haml|\.jade|\.scaml|\.html|\.sass|\.scss|\.php|\.erb)$/
$1
[
1
..-
1
].
to_sym
when
/(\.c|\.h|\.idc)$/
:c
when
/(\.cpp|\.hpp|\.c++|\.h++|\.cc|\.hh|\.cxx|\.hxx)$/
:cpp
when
/(\.rb|\.ru|\.rake|Rakefile|\.gemspec|\.rbx|Gemfile)$/
:ruby
:ruby
elsif
file_name
=~
/\.py
$/
when
/(\.py|\.pyw|\.sc|SConstruct|SConscript|\.tac)
$/
:python
:python
elsif
file_name
=~
/(\.pl|\.scala|\.c|\.cpp|\.java|\.haml|\.html|\.sass|\.scss|\.xml|\.php|\.erb)$/
when
/(\.js|\.json)$/
$1
[
1
..-
1
].
to_sym
elsif
file_name
=~
/\.js$/
:javascript
:javascript
elsif
file_name
=~
/\.sh$/
when
/(\.xml|\.xsl|\.rss|\.xslt|\.xsd|\.wsdl)$/
:xml
when
/(\.vm|\.fhtml)$/
:velocity
when
/\.sh$/
:bash
:bash
elsif
file_name
=~
/\.coffee$/
when
/\.coffee$/
:coffeescript
:coffeescript
elsif
file_name
=~
/\.yml
$/
when
/(\.yml|\.yaml)
$/
:yaml
:yaml
elsif
file_name
=~
/\.md$/
when
/\.md$/
:minid
:minid
else
else
:text
:text
...
...
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