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)
|
|
|
|
blob.load_all_data! if blob.respond_to?(:load_all_data!)
|
|
|
|
|
|
|
|
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
|
2018-12-13 13:39:08 +05:30
|
|
|
end
|