Class: BlobPresenter

Inherits:
Gitlab::View::Presenter::Delegated show all
Defined in:
app/presenters/blob_presenter.rb

Direct Known Subclasses

Blobs::UnfoldPresenter, SnippetBlobPresenter

Instance Attribute Summary

Attributes included from Gitlab::View::Presenter::Base

#subject

Instance Method Summary collapse

Methods inherited from Gitlab::View::Presenter::Delegated

#initialize

Methods included from Gitlab::View::Presenter::Base

#can?, #declarative_policy_delegate, #is_a?, #present, #url_builder

Methods included from Gitlab::Allowable

#can?

Methods included from Gitlab::Routing

add_helpers, includes_helpers, redirect_legacy_paths, url_helpers

Constructor Details

This class inherits a constructor from Gitlab::View::Presenter::Delegated

Instance Method Details

#highlight(to: nil, plain: nil) ⇒ Object


6
7
8
9
10
11
12
13
14
15
# File 'app/presenters/blob_presenter.rb', line 6

def highlight(to: nil, plain: nil)
  load_all_blob_data

  Gitlab::Highlight.highlight(
    blob.path,
    limited_blob_data(to: to),
    language: language,
    plain: plain
  )
end

#web_pathObject


21
22
23
# File 'app/presenters/blob_presenter.rb', line 21

def web_path
  Gitlab::Routing.url_helpers.project_blob_path(blob.repository.project, File.join(blob.commit_id, blob.path))
end

#web_urlObject


17
18
19
# File 'app/presenters/blob_presenter.rb', line 17

def web_url
  Gitlab::Routing.url_helpers.project_blob_url(blob.repository.project, File.join(blob.commit_id, blob.path))
end