Commit f112a03c authored by Douwe Maan's avatar Douwe Maan

Add simple blob viewers

parent 13891a03
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
module BlobViewer
class Download < Base
include Simple
include ServerSide
self.partial_name = 'download'
self.text_based = false
def render_error(*)
nil
end
end
end
module BlobViewer
class Empty < Base
include Simple
include ServerSide
self.partial_name = 'empty'
self.text_based = false
end
end
module BlobViewer
module Simple
extend ActiveSupport::Concern
included do
self.type = :simple
self.switcher_icon = 'code'
self.switcher_title = 'source'
end
end
end
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
- blob.load_all_data!(@repository)
= render 'shared/file_highlight', blob: blob, repository: @repository
.file-content.blob_file.blob-no-preview
.center
= link_to namespace_project_raw_path(@project.namespace, @project, @id) do
= link_to blob_raw_url do
%h1.light
%i.fa.fa-download
= icon('download')
%h4
Download (#{number_to_human_size blob_size(blob)})
Download (#{number_to_human_size(viewer.blob.raw_size)})
.file-content.code
.nothing-here-block
Empty file
= render 'shared/file_highlight', blob: viewer.blob, repository: @repository
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment