Sha256: 56ccf1c3553364a4fd577506c182056de5910fdf04dd8e3cbbf0e4794ec00a1f

Contents?: true

Size: 794 Bytes

Versions: 50

Compression:

Stored size: 794 Bytes

Contents

class PageDecorator < ApplicationDecorator
  delegate_all

  def options_for_parents
    Page.flat_tree.map do |p|
      ["#{'-' * p.depth} #{p.description}".strip, p.id]
    end
  end

  def path(locale: I18n.locale, options: {})
    return h.send(route, options) if route.present?

    slugs = []

    parents.each do |p|
      if p.route.present?
        slugs << h.send(p.route, options)
        return slugs.reverse.join('/')
      else
        slugs << p.seo(locale).slug
      end
    end

    "/#{locale}/#{slugs.reverse.join('/')}"
  end

  def url(locale: I18n.locale, options: {})
    prefix = Rails.configuration.force_ssl ? 'https://' : 'http://'
    host = Udongo.config.base.host
    params = { locale: locale, options: options }

    "#{prefix}#{host}#{path(params)}"
  end
end

Version data entries

50 entries across 50 versions & 1 rubygems

Version Path
udongo-7.9.0 app/decorators/page_decorator.rb
udongo-7.8.1 app/decorators/page_decorator.rb
udongo-7.8.0 app/decorators/page_decorator.rb
udongo-7.7.2 app/decorators/page_decorator.rb
udongo-7.7.1 app/decorators/page_decorator.rb
udongo-7.7.0 app/decorators/page_decorator.rb
udongo-7.6.2 app/decorators/page_decorator.rb
udongo-7.6.1 app/decorators/page_decorator.rb
udongo-7.6.0 app/decorators/page_decorator.rb
udongo-7.5.1 app/decorators/page_decorator.rb
udongo-7.5.0 app/decorators/page_decorator.rb
udongo-7.4.2 app/decorators/page_decorator.rb
udongo-7.4.1 app/decorators/page_decorator.rb
udongo-7.4.0 app/decorators/page_decorator.rb
udongo-7.3.5 app/decorators/page_decorator.rb
udongo-7.3.4 app/decorators/page_decorator.rb
udongo-7.3.3 app/decorators/page_decorator.rb
udongo-7.3.2 app/decorators/page_decorator.rb
udongo-7.3.1 app/decorators/page_decorator.rb
udongo-7.2.1 app/decorators/page_decorator.rb