Class: Decidim::Blogs::PostPresenter

Inherits:
ResourcePresenter
  • Object
show all
Includes:
ActionView::Helpers::UrlHelper, ResourceHelper
Defined in:
app/presenters/decidim/blogs/post_presenter.rb

Overview

Decorator for posts

Instance Method Summary collapse

Instance Method Details

#authorObject



12
13
14
15
16
17
18
# File 'app/presenters/decidim/blogs/post_presenter.rb', line 12

def author
  @author ||= if official?
                Decidim::Blogs::OfficialAuthorPresenter.new
              else
                Decidim::UserPresenter.new(super)
              end
end

#body(links: false, strip_tags: false, all_locales: false) ⇒ Object



34
35
36
37
38
# File 'app/presenters/decidim/blogs/post_presenter.rb', line 34

def body(links: false, strip_tags: false, all_locales: false)
  return unless post

  content_handle_locale(post.body, all_locales, links, strip_tags)
end

#postObject



20
21
22
# File 'app/presenters/decidim/blogs/post_presenter.rb', line 20

def post
  __getobj__
end

#post_pathObject



24
25
26
# File 'app/presenters/decidim/blogs/post_presenter.rb', line 24

def post_path
  Decidim::ResourceLocatorPresenter.new(post).path
end

#taxonomy_names(html_escape: false, all_locales: false) ⇒ Object



40
41
42
43
44
# File 'app/presenters/decidim/blogs/post_presenter.rb', line 40

def taxonomy_names(html_escape: false, all_locales: false)
  post.taxonomies.map do |taxonomy|
    taxonomy.presenter.title(html_escape:, all_locales:)
  end
end

#title(html_escape: false, all_locales: false) ⇒ Object



28
29
30
31
32
# File 'app/presenters/decidim/blogs/post_presenter.rb', line 28

def title(html_escape: false, all_locales: false)
  return unless post

  super(post.title, html_escape, all_locales)
end