diff options
author | Douwe Maan <douwe@gitlab.com> | 2017-05-17 18:00:13 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2017-05-17 18:00:13 +0000 |
commit | d1bce8ea75df00970f3d4a67587ceb64bf4ec905 (patch) | |
tree | bc6c9af3d218b0f32f75b19744e4314f05141be6 /app | |
parent | 17e799980f6aaa6b378469f3e237c713f293e079 (diff) | |
download | gitlab-ce-d1bce8ea75df00970f3d4a67587ceb64bf4ec905.tar.gz |
Add auxiliary blob viewer for CHANGELOG
Diffstat (limited to 'app')
-rw-r--r-- | app/models/blob.rb | 3 | ||||
-rw-r--r-- | app/models/blob_viewer/base.rb | 2 | ||||
-rw-r--r-- | app/models/blob_viewer/changelog.rb | 16 | ||||
-rw-r--r-- | app/models/blob_viewer/license.rb | 2 | ||||
-rw-r--r-- | app/views/projects/blob/viewers/_changelog.html.haml | 4 |
5 files changed, 25 insertions, 2 deletions
diff --git a/app/models/blob.rb b/app/models/blob.rb index e0c539a17cf..5ae35d3ab08 100644 --- a/app/models/blob.rb +++ b/app/models/blob.rb @@ -41,7 +41,8 @@ class Blob < SimpleDelegator BlobViewer::RouteMap, BlobViewer::License, - BlobViewer::Contributing + BlobViewer::Contributing, + BlobViewer::Changelog ].freeze attr_reader :project diff --git a/app/models/blob_viewer/base.rb b/app/models/blob_viewer/base.rb index c7b8fbfc56a..26a3778c2a3 100644 --- a/app/models/blob_viewer/base.rb +++ b/app/models/blob_viewer/base.rb @@ -11,6 +11,8 @@ module BlobViewer attr_reader :blob attr_accessor :override_max_size + delegate :project, to: :blob + def initialize(blob) @blob = blob end diff --git a/app/models/blob_viewer/changelog.rb b/app/models/blob_viewer/changelog.rb new file mode 100644 index 00000000000..0464ae27f71 --- /dev/null +++ b/app/models/blob_viewer/changelog.rb @@ -0,0 +1,16 @@ +module BlobViewer + class Changelog < Base + include Auxiliary + include Static + + self.partial_name = 'changelog' + self.file_types = %i(changelog) + self.binary = false + + def render_error + return if project.repository.tag_count > 0 + + :no_tags + end + end +end diff --git a/app/models/blob_viewer/license.rb b/app/models/blob_viewer/license.rb index 6751ea15a5d..57355f2c3aa 100644 --- a/app/models/blob_viewer/license.rb +++ b/app/models/blob_viewer/license.rb @@ -8,7 +8,7 @@ module BlobViewer self.binary = false def license - blob.project.repository.license + project.repository.license end def render_error diff --git a/app/views/projects/blob/viewers/_changelog.html.haml b/app/views/projects/blob/viewers/_changelog.html.haml new file mode 100644 index 00000000000..53921e63b5f --- /dev/null +++ b/app/views/projects/blob/viewers/_changelog.html.haml @@ -0,0 +1,4 @@ += icon('history fw') += succeed '.' do + To find the state of this project's repository at the time of any of these versions, check out + = link_to "the tags", namespace_project_tags_path(viewer.project.namespace, viewer.project) |