diff options
author | Douwe Maan <douwe@selenight.nl> | 2017-04-13 12:21:07 -0500 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2017-04-27 12:23:26 -0500 |
commit | 5cb27e9fa74c7234195e10ade933e8a475cff403 (patch) | |
tree | 954cbdb45d3d0bea3b4dea33805dff4ab0d83646 /app/models | |
parent | f112a03cba884aa67d5d601520d4c05ce517f28a (diff) | |
download | gitlab-ce-5cb27e9fa74c7234195e10ade933e8a475cff403.tar.gz |
Add rich blob viewers
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/blob.rb | 8 | ||||
-rw-r--r-- | app/models/blob_viewer/binary_stl.rb | 10 | ||||
-rw-r--r-- | app/models/blob_viewer/image.rb | 12 | ||||
-rw-r--r-- | app/models/blob_viewer/markup.rb | 10 | ||||
-rw-r--r-- | app/models/blob_viewer/notebook.rb | 12 | ||||
-rw-r--r-- | app/models/blob_viewer/pdf.rb | 12 | ||||
-rw-r--r-- | app/models/blob_viewer/rich.rb | 11 | ||||
-rw-r--r-- | app/models/blob_viewer/server_side.rb | 11 | ||||
-rw-r--r-- | app/models/blob_viewer/sketch.rb | 12 | ||||
-rw-r--r-- | app/models/blob_viewer/svg.rb | 12 | ||||
-rw-r--r-- | app/models/blob_viewer/text_stl.rb | 10 |
11 files changed, 120 insertions, 0 deletions
diff --git a/app/models/blob.rb b/app/models/blob.rb index 2b2425a926e..26ee2c883a0 100644 --- a/app/models/blob.rb +++ b/app/models/blob.rb @@ -6,6 +6,14 @@ class Blob < SimpleDelegator MAXIMUM_TEXT_HIGHLIGHT_SIZE = 1.megabyte RICH_VIEWERS = [ + BlobViewer::Image, + BlobViewer::PDF, + BlobViewer::Sketch, + BlobViewer::BinarySTL, + BlobViewer::TextSTL, + BlobViewer::Notebook, + BlobViewer::SVG, + BlobViewer::Markup, ].freeze attr_reader :project diff --git a/app/models/blob_viewer/binary_stl.rb b/app/models/blob_viewer/binary_stl.rb new file mode 100644 index 00000000000..6cb54d49d86 --- /dev/null +++ b/app/models/blob_viewer/binary_stl.rb @@ -0,0 +1,10 @@ +module BlobViewer + class BinarySTL < Base + include Rich + include ClientSide + + self.partial_name = 'stl' + self.extensions = %w(stl) + self.text_based = false + end +end diff --git a/app/models/blob_viewer/image.rb b/app/models/blob_viewer/image.rb new file mode 100644 index 00000000000..b78f82df38f --- /dev/null +++ b/app/models/blob_viewer/image.rb @@ -0,0 +1,12 @@ +module BlobViewer + class Image < Base + include Rich + include ClientSide + + self.partial_name = 'image' + self.extensions = UploaderHelper::IMAGE_EXT + self.text_based = false + self.switcher_icon = 'picture-o' + self.switcher_title = 'image' + end +end diff --git a/app/models/blob_viewer/markup.rb b/app/models/blob_viewer/markup.rb new file mode 100644 index 00000000000..34740661320 --- /dev/null +++ b/app/models/blob_viewer/markup.rb @@ -0,0 +1,10 @@ +module BlobViewer + class Markup < Base + include Rich + include ServerSide + + self.partial_name = 'markup' + self.extensions = Gitlab::MarkupHelper::EXTENSIONS + self.text_based = true + end +end diff --git a/app/models/blob_viewer/notebook.rb b/app/models/blob_viewer/notebook.rb new file mode 100644 index 00000000000..c5231f1e691 --- /dev/null +++ b/app/models/blob_viewer/notebook.rb @@ -0,0 +1,12 @@ +module BlobViewer + class Notebook < Base + include Rich + include ClientSide + + self.partial_name = 'notebook' + self.extensions = %w(ipynb) + self.text_based = true + self.switcher_icon = 'file-text-o' + self.switcher_title = 'notebook' + end +end diff --git a/app/models/blob_viewer/pdf.rb b/app/models/blob_viewer/pdf.rb new file mode 100644 index 00000000000..1067388c72a --- /dev/null +++ b/app/models/blob_viewer/pdf.rb @@ -0,0 +1,12 @@ +module BlobViewer + class PDF < Base + include Rich + include ClientSide + + self.partial_name = 'pdf' + self.extensions = %w(pdf) + self.text_based = false + self.switcher_icon = 'file-pdf-o' + self.switcher_title = 'PDF' + end +end diff --git a/app/models/blob_viewer/rich.rb b/app/models/blob_viewer/rich.rb new file mode 100644 index 00000000000..be373dbc948 --- /dev/null +++ b/app/models/blob_viewer/rich.rb @@ -0,0 +1,11 @@ +module BlobViewer + module Rich + extend ActiveSupport::Concern + + included do + self.type = :rich + self.switcher_icon = 'file-text-o' + self.switcher_title = 'rendered file' + end + end +end diff --git a/app/models/blob_viewer/server_side.rb b/app/models/blob_viewer/server_side.rb new file mode 100644 index 00000000000..899107d02ea --- /dev/null +++ b/app/models/blob_viewer/server_side.rb @@ -0,0 +1,11 @@ +module BlobViewer + module ServerSide + extend ActiveSupport::Concern + + included do + self.client_side = false + self.max_size = 2.megabytes + self.absolute_max_size = 5.megabytes + end + end +end diff --git a/app/models/blob_viewer/sketch.rb b/app/models/blob_viewer/sketch.rb new file mode 100644 index 00000000000..3de94efe67d --- /dev/null +++ b/app/models/blob_viewer/sketch.rb @@ -0,0 +1,12 @@ +module BlobViewer + class Sketch < Base + include Rich + include ClientSide + + self.partial_name = 'sketch' + self.extensions = %w(sketch) + self.text_based = false + self.switcher_icon = 'file-image-o' + self.switcher_title = 'preview' + end +end diff --git a/app/models/blob_viewer/svg.rb b/app/models/blob_viewer/svg.rb new file mode 100644 index 00000000000..5fd11a98462 --- /dev/null +++ b/app/models/blob_viewer/svg.rb @@ -0,0 +1,12 @@ +module BlobViewer + class SVG < Base + include Rich + include ServerSide + + self.partial_name = 'svg' + self.extensions = %w(svg) + self.text_based = true + self.switcher_icon = 'picture-o' + self.switcher_title = 'image' + end +end diff --git a/app/models/blob_viewer/text_stl.rb b/app/models/blob_viewer/text_stl.rb new file mode 100644 index 00000000000..1b238777c32 --- /dev/null +++ b/app/models/blob_viewer/text_stl.rb @@ -0,0 +1,10 @@ +module BlobViewer + class TextSTL < Base + include Rich + include ClientSide + + self.partial_name = 'stl' + self.extensions = %w(stl) + self.text_based = true + end +end |