Class: Decidim::Blogs::PostPresenter

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

Overview

Decorator for posts

Instance Method Summary collapse

Methods included from SanitizeHelper

#decidim_escape_translated, #decidim_html_escape, #decidim_rich_text, #decidim_sanitize, #decidim_sanitize_admin, #decidim_sanitize_editor, #decidim_sanitize_editor_admin, #decidim_sanitize_newsletter, #decidim_sanitize_translated, #decidim_url_escape, included

Methods included from ResourceHelper

#linked_classes_filter_values_for, #linked_classes_for, #resource_locator

Methods inherited from ResourcePresenter

#editor_locales, #handle_locales

Methods included from TranslatableAttributes

#attachment?, #default_locale?

Instance Method Details

#authorObject



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

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

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



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

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

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

#postObject



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

def post
  __getobj__
end

#post_pathObject



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

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

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



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

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

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



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

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

  super(post.title, links, html_escape, all_locales)
end