Sha256: 1afbe4fcac96112c356337acfff6e9af424033232fb1a45700bc9691fceaee61

Contents?: true

Size: 787 Bytes

Versions: 7

Compression:

Stored size: 787 Bytes

Contents

# frozen_string_literal: true

module Decidim
  #
  # Decorator for users
  #
  class HashtagPresenter < SimpleDelegator
    include Rails.application.routes.mounted_helpers
    include ActionView::Helpers::UrlHelper

    def initialize(hashtag, cased_name: nil)
      super(hashtag)
      @cased_name = cased_name if cased_name&.downcase == hashtag.name
    end

    #
    # hashtag presented in a twitter-like style
    #
    def name
      "##{@cased_name || super}"
    end

    delegate :url, to: :hashtag, prefix: true

    def hashtag_path
      decidim.hashtag_path(__getobj__.name)
    end

    def display_hashtag
      link_to name, decidim.search_path(term: name), target: "_blank", class: "hashtag-mention"
    end

    def display_hashtag_name
      name
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
decidim-core-0.18.1 app/presenters/decidim/hashtag_presenter.rb
decidim-core-0.17.2 app/presenters/decidim/hashtag_presenter.rb
decidim-core-0.18.0 app/presenters/decidim/hashtag_presenter.rb
decidim-core-0.17.1 app/presenters/decidim/hashtag_presenter.rb
decidim-core-0.16.1 app/presenters/decidim/hashtag_presenter.rb
decidim-core-0.17.0 app/presenters/decidim/hashtag_presenter.rb
decidim-core-0.16.0 app/presenters/decidim/hashtag_presenter.rb