diff options
author | Douwe Maan <douwe@selenight.nl> | 2017-04-13 20:04:29 +0300 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2017-04-27 20:23:26 +0300 |
commit | f112a03cba884aa67d5d601520d4c05ce517f28a (patch) | |
tree | 4410ef7ffa96d2aed75329326a4656bfc278086b | |
parent | 13891a03c7388315bb66b30cd0b8e87fa21958b0 (diff) |
Add simple blob viewers
-rw-r--r-- | app/models/blob_viewer/client_side.rb | 11 | ||||
-rw-r--r-- | app/models/blob_viewer/download.rb | 13 | ||||
-rw-r--r-- | app/models/blob_viewer/empty.rb | 9 | ||||
-rw-r--r-- | app/models/blob_viewer/simple.rb | 11 | ||||
-rw-r--r-- | app/models/blob_viewer/text.rb | 11 | ||||
-rw-r--r-- | app/views/projects/blob/_download.html.haml | 7 | ||||
-rw-r--r-- | app/views/projects/blob/_text.html.haml | 2 | ||||
-rw-r--r-- | app/views/projects/blob/viewers/_download.html.haml | 7 | ||||
-rw-r--r-- | app/views/projects/blob/viewers/_empty.html.haml | 3 | ||||
-rw-r--r-- | app/views/projects/blob/viewers/_text.html.haml | 1 |
10 files changed, 66 insertions, 9 deletions
diff --git a/app/models/blob_viewer/client_side.rb b/app/models/blob_viewer/client_side.rb new file mode 100644 index 00000000000..42ec68f864b --- /dev/null +++ b/app/models/blob_viewer/client_side.rb @@ -0,0 +1,11 @@ +module BlobViewer + module ClientSide + extend ActiveSupport::Concern + + included do + self.client_side = true + self.max_size = 10.megabytes + self.absolute_max_size = 50.megabytes + end + end +end diff --git a/app/models/blob_viewer/download.rb b/app/models/blob_viewer/download.rb new file mode 100644 index 00000000000..45cb38a3268 --- /dev/null +++ b/app/models/blob_viewer/download.rb @@ -0,0 +1,13 @@ +module BlobViewer + class Download < Base + include Simple + include ServerSide + + self.partial_name = 'download' + self.text_based = false + + def render_error(*) + nil + end + end +end diff --git a/app/models/blob_viewer/empty.rb b/app/models/blob_viewer/empty.rb new file mode 100644 index 00000000000..60003a7c12a --- /dev/null +++ b/app/models/blob_viewer/empty.rb @@ -0,0 +1,9 @@ +module BlobViewer + class Empty < Base + include Simple + include ServerSide + + self.partial_name = 'empty' + self.text_based = false + end +end diff --git a/app/models/blob_viewer/simple.rb b/app/models/blob_viewer/simple.rb new file mode 100644 index 00000000000..454a20495fc --- /dev/null +++ b/app/models/blob_viewer/simple.rb @@ -0,0 +1,11 @@ +module BlobViewer + module Simple + extend ActiveSupport::Concern + + included do + self.type = :simple + self.switcher_icon = 'code' + self.switcher_title = 'source' + end + end +end diff --git a/app/models/blob_viewer/text.rb b/app/models/blob_viewer/text.rb new file mode 100644 index 00000000000..5f442dadf0f --- /dev/null +++ b/app/models/blob_viewer/text.rb @@ -0,0 +1,11 @@ +module BlobViewer + class Text < Base + include Simple + include ServerSide + + self.partial_name = 'text' + self.text_based = true + self.max_size = 1.megabyte + self.absolute_max_size = 10.megabytes + end +end diff --git a/app/views/projects/blob/_download.html.haml b/app/views/projects/blob/_download.html.haml deleted file mode 100644 index 7908fcae3de..00000000000 --- a/app/views/projects/blob/_download.html.haml +++ /dev/null @@ -1,7 +0,0 @@ -.file-content.blob_file.blob-no-preview - .center - = link_to namespace_project_raw_path(@project.namespace, @project, @id) do - %h1.light - %i.fa.fa-download - %h4 - Download (#{number_to_human_size blob_size(blob)}) diff --git a/app/views/projects/blob/_text.html.haml b/app/views/projects/blob/_text.html.haml deleted file mode 100644 index 20638f6961d..00000000000 --- a/app/views/projects/blob/_text.html.haml +++ /dev/null @@ -1,2 +0,0 @@ -- blob.load_all_data!(@repository) -= render 'shared/file_highlight', blob: blob, repository: @repository diff --git a/app/views/projects/blob/viewers/_download.html.haml b/app/views/projects/blob/viewers/_download.html.haml new file mode 100644 index 00000000000..684240d02c7 --- /dev/null +++ b/app/views/projects/blob/viewers/_download.html.haml @@ -0,0 +1,7 @@ +.file-content.blob_file.blob-no-preview + .center + = link_to blob_raw_url do + %h1.light + = icon('download') + %h4 + Download (#{number_to_human_size(viewer.blob.raw_size)}) diff --git a/app/views/projects/blob/viewers/_empty.html.haml b/app/views/projects/blob/viewers/_empty.html.haml new file mode 100644 index 00000000000..a293a8de231 --- /dev/null +++ b/app/views/projects/blob/viewers/_empty.html.haml @@ -0,0 +1,3 @@ +.file-content.code + .nothing-here-block + Empty file diff --git a/app/views/projects/blob/viewers/_text.html.haml b/app/views/projects/blob/viewers/_text.html.haml new file mode 100644 index 00000000000..a91df321ca0 --- /dev/null +++ b/app/views/projects/blob/viewers/_text.html.haml @@ -0,0 +1 @@ += render 'shared/file_highlight', blob: viewer.blob, repository: @repository |