Class: Decidim::Challenges::ChallengePresenter
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Decidim::Challenges::ChallengePresenter
- Includes:
- ActionView::Helpers::UrlHelper, SanitizeHelper, TranslatableAttributes
- Defined in:
- app/presenters/decidim/challenges/challenge_presenter.rb
Overview
Decorator for challenge
Instance Method Summary collapse
- #card_image_url ⇒ Object
- #challenge ⇒ Object
- #challenge_path ⇒ Object
- #display_mention ⇒ Object
-
#global_description(links: false, extras: true, strip_tags: false) ⇒ Object
Render the challenge global_description.
- #id_and_title(links: false, extras: true, html_escape: false) ⇒ Object
-
#local_description(links: false, extras: true, strip_tags: false) ⇒ Object
Render the challenge local_description.
- #resource_manifest ⇒ Object
-
#title(links: false, extras: true, html_escape: false) ⇒ Object
Render the challenge title.
Instance Method Details
#card_image_url ⇒ Object
82 83 84 85 86 |
# File 'app/presenters/decidim/challenges/challenge_presenter.rb', line 82 def card_image_url return if challenge.card_image.blank? challenge.attached_uploader(:card_image).url(host: challenge.organization.host) end |
#challenge ⇒ Object
16 17 18 |
# File 'app/presenters/decidim/challenges/challenge_presenter.rb', line 16 def challenge __getobj__ end |
#challenge_path ⇒ Object
20 21 22 |
# File 'app/presenters/decidim/challenges/challenge_presenter.rb', line 20 def challenge_path Decidim::ResourceLocatorPresenter.new(challenge).path end |
#display_mention ⇒ Object
24 25 26 |
# File 'app/presenters/decidim/challenges/challenge_presenter.rb', line 24 def display_mention link_to title, challenge_path end |
#global_description(links: false, extras: true, strip_tags: false) ⇒ Object
Render the challenge global_description
links - should render hashtags as links? extras - should include extra hashtags?
Returns a String.
70 71 72 73 74 75 76 77 78 79 80 |
# File 'app/presenters/decidim/challenges/challenge_presenter.rb', line 70 def global_description(links: false, extras: true, strip_tags: false) text = translated_attribute(challenge.global_description) text = (sanitize_text(text)) if renderer = Decidim::ContentRenderers::HashtagRenderer.new(text) text = renderer.render(links:, extras:).html_safe text = Decidim::ContentRenderers::LinkRenderer.new(text).render if links text end |
#id_and_title(links: false, extras: true, html_escape: false) ⇒ Object
42 43 44 |
# File 'app/presenters/decidim/challenges/challenge_presenter.rb', line 42 def id_and_title(links: false, extras: true, html_escape: false) "##{challenge.id} - #{title(links:, extras:, html_escape:)}" end |
#local_description(links: false, extras: true, strip_tags: false) ⇒ Object
Render the challenge local_description
links - should render hashtags as links? extras - should include extra hashtags?
Returns a String.
52 53 54 55 56 57 58 59 60 61 62 |
# File 'app/presenters/decidim/challenges/challenge_presenter.rb', line 52 def local_description(links: false, extras: true, strip_tags: false) text = translated_attribute(challenge.local_description) text = (sanitize_text(text)) if renderer = Decidim::ContentRenderers::HashtagRenderer.new(text) text = renderer.render(links:, extras:).html_safe text = Decidim::ContentRenderers::LinkRenderer.new(text).render if links text end |
#resource_manifest ⇒ Object
90 91 92 |
# File 'app/presenters/decidim/challenges/challenge_presenter.rb', line 90 def resource_manifest challenge.class.resource_manifest end |
#title(links: false, extras: true, html_escape: false) ⇒ Object
Render the challenge title
links - should render hashtags as links? extras - should include extra hashtags?
Returns a String.
34 35 36 37 38 39 40 |
# File 'app/presenters/decidim/challenges/challenge_presenter.rb', line 34 def title(links: false, extras: true, html_escape: false) text = translated_attribute(challenge.title) text = decidim_html_escape(text) if html_escape renderer = Decidim::ContentRenderers::HashtagRenderer.new(text) renderer.render(links:, extras:).html_safe end |