diff options
author | Douwe Maan <douwe@selenight.nl> | 2017-05-14 14:01:12 -0500 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2017-05-17 13:33:39 -0500 |
commit | 82c2296a1274b6e7c3bb3031a7e903c01bc8a3c4 (patch) | |
tree | 792f348e0561a7c28219a71a409c51eb1d30989b /app/models | |
parent | d4d9b731c41cdb4a8b933edff34bd9c9ddf1403a (diff) | |
download | gitlab-ce-82c2296a1274b6e7c3bb3031a7e903c01bc8a3c4.tar.gz |
Add auxiliary viewer for READMEdm-readme-viewer
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/blob.rb | 1 | ||||
-rw-r--r-- | app/models/blob_viewer/auxiliary.rb | 6 | ||||
-rw-r--r-- | app/models/blob_viewer/readme.rb | 14 |
3 files changed, 21 insertions, 0 deletions
diff --git a/app/models/blob.rb b/app/models/blob.rb index 5ae35d3ab08..8e25ba590c7 100644 --- a/app/models/blob.rb +++ b/app/models/blob.rb @@ -40,6 +40,7 @@ class Blob < SimpleDelegator BlobViewer::GitlabCiYml, BlobViewer::RouteMap, + BlobViewer::Readme, BlobViewer::License, BlobViewer::Contributing, BlobViewer::Changelog diff --git a/app/models/blob_viewer/auxiliary.rb b/app/models/blob_viewer/auxiliary.rb index cd6e596ed60..07a207730cf 100644 --- a/app/models/blob_viewer/auxiliary.rb +++ b/app/models/blob_viewer/auxiliary.rb @@ -2,11 +2,17 @@ module BlobViewer module Auxiliary extend ActiveSupport::Concern + include Gitlab::Allowable + included do self.loading_partial_name = 'loading_auxiliary' self.type = :auxiliary self.overridable_max_size = 100.kilobytes self.max_size = 100.kilobytes end + + def visible_to?(current_user) + true + end end end diff --git a/app/models/blob_viewer/readme.rb b/app/models/blob_viewer/readme.rb new file mode 100644 index 00000000000..75c373a03bb --- /dev/null +++ b/app/models/blob_viewer/readme.rb @@ -0,0 +1,14 @@ +module BlobViewer + class Readme < Base + include Auxiliary + include Static + + self.partial_name = 'readme' + self.file_types = %i(readme) + self.binary = false + + def visible_to?(current_user) + can?(current_user, :read_wiki, project) + end + end +end |