debian-mirror-gitlab/app/presenters/blob_presenter.rb

27 lines
547 B
Ruby
Raw Normal View History

2018-12-13 13:39:08 +05:30
# frozen_string_literal: true
2019-09-04 21:01:54 +05:30
class BlobPresenter < Gitlab::View::Presenter::Delegated
2018-12-13 13:39:08 +05:30
presents :blob
def highlight(plain: nil)
2019-10-12 21:52:04 +05:30
load_all_blob_data
2018-12-13 13:39:08 +05:30
Gitlab::Highlight.highlight(
blob.path,
blob.data,
language: blob.language_from_gitattributes,
plain: plain
)
end
2019-09-04 21:01:54 +05:30
def web_url
Gitlab::Routing.url_helpers.project_blob_url(blob.repository.project, File.join(blob.commit_id, blob.path))
end
2019-10-12 21:52:04 +05:30
private
def load_all_blob_data
blob.load_all_data! if blob.respond_to?(:load_all_data!)
end
2018-12-13 13:39:08 +05:30
end