diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/namespaces_controller.rb | 18 | ||||
-rw-r--r-- | app/helpers/blob_helper.rb | 18 | ||||
-rw-r--r-- | app/views/shared/_file_hljs.html.haml | 2 |
3 files changed, 37 insertions, 1 deletions
diff --git a/app/controllers/namespaces_controller.rb b/app/controllers/namespaces_controller.rb new file mode 100644 index 00000000000..c59a2401cef --- /dev/null +++ b/app/controllers/namespaces_controller.rb @@ -0,0 +1,18 @@ +class NamespacesController < ApplicationController + skip_before_filter :authenticate_user! + + def show + namespace = Namespace.find_by(path: params[:id]) + + unless namespace + return render_404 + end + + if namespace.type == "Group" + redirect_to group_path(namespace) + else + redirect_to user_path(namespace.owner) + end + end +end + 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 |