Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-06-07 16:46:58 +0400
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-06-07 16:46:58 +0400
commit0d13abb1c8d527f2a6e6b97e34899e9b35f264bc (patch)
tree2b9d8be7f4464f2cc1f05523400fcdcb9be65756 /app
parentab094e67eed54f5c29a33d2114cc91908e543972 (diff)
Specify language detection for highlight.js
Because I am tired of CHANGELOG highlighted as sql file :) Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app')
-rw-r--r--app/helpers/blob_helper.rb18
-rw-r--r--app/views/shared/_file_hljs.html.haml2
2 files changed, 19 insertions, 1 deletions
diff --git a/app/helpers/blob_helper.rb b/app/helpers/blob_helper.rb
new file mode 100644
index 00000000000..11fbf1baae7
--- /dev/null
+++ b/app/helpers/blob_helper.rb
@@ -0,0 +1,18 @@
+module BlobHelper
+ def highlightjs_class(blob_name)
+ if blob_name.include?('.')
+ ext = blob_name.split('.').last
+ return 'language-' + ext
+ else
+ if no_highlight_files.include?(blob_name.downcase)
+ 'no-highlight'
+ else
+ blob_name.downcase
+ end
+ end
+ end
+
+ def no_highlight_files
+ %w(credits changelog copying copyright license authors)
+ end
+end
diff --git a/app/views/shared/_file_hljs.html.haml b/app/views/shared/_file_hljs.html.haml
index 338236c0752..ceee2c7527d 100644
--- a/app/views/shared/_file_hljs.html.haml
+++ b/app/views/shared/_file_hljs.html.haml
@@ -8,5 +8,5 @@
= i
.highlight
%pre
- %code
+ %code{ class: highlightjs_class(blob.name) }
= blob.data