Sha256: 01954bc8f4153f795acb07277bd8e4a69a8c5e96a06b88d65c104d646684145e

Contents?: true

Size: 1.03 KB

Versions: 25

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true
module Hyrax
  module Breadcrumbs
    extend ActiveSupport::Concern

    def build_breadcrumbs
      if request.referer
        trail_from_referer
      else
        default_trail
        add_breadcrumb_for_controller if user_signed_in?
        add_breadcrumb_for_action
      end
    end

    def default_trail
      add_breadcrumb I18n.t('hyrax.controls.home'), hyrax.root_path
      add_breadcrumb I18n.t('hyrax.dashboard.title'), hyrax.dashboard_path if user_signed_in?
    end

    def trail_from_referer
      case request.referer
      when /catalog/
        add_breadcrumb I18n.t('hyrax.controls.home'), hyrax.root_path
        add_breadcrumb I18n.t('hyrax.bread_crumb.search_results'), request.referer
      else
        default_trail
        add_breadcrumb_for_controller if user_signed_in?
        add_breadcrumb_for_action
      end
    end

    # Override these in your controller
    def add_breadcrumb_for_controller; end

    # Override these in your controller
    def add_breadcrumb_for_action; end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
hyrax-5.0.1 app/controllers/concerns/hyrax/breadcrumbs.rb
hyrax-5.0.0 app/controllers/concerns/hyrax/breadcrumbs.rb
hyrax-5.0.0.rc3 app/controllers/concerns/hyrax/breadcrumbs.rb
hyrax-5.0.0.rc2 app/controllers/concerns/hyrax/breadcrumbs.rb
hyrax-5.0.0.rc1 app/controllers/concerns/hyrax/breadcrumbs.rb
hyrax-3.6.0 app/controllers/concerns/hyrax/breadcrumbs.rb
hyrax-4.0.0 app/controllers/concerns/hyrax/breadcrumbs.rb
hyrax-4.0.0.rc3 app/controllers/concerns/hyrax/breadcrumbs.rb
hyrax-4.0.0.rc2 app/controllers/concerns/hyrax/breadcrumbs.rb
hyrax-4.0.0.rc1 app/controllers/concerns/hyrax/breadcrumbs.rb
hyrax-3.5.0 app/controllers/concerns/hyrax/breadcrumbs.rb
hyrax-4.0.0.beta2 app/controllers/concerns/hyrax/breadcrumbs.rb
hyrax-3.4.2 app/controllers/concerns/hyrax/breadcrumbs.rb
hyrax-4.0.0.beta1 app/controllers/concerns/hyrax/breadcrumbs.rb
hyrax-3.4.1 app/controllers/concerns/hyrax/breadcrumbs.rb
hyrax-3.4.0 app/controllers/concerns/hyrax/breadcrumbs.rb
hyrax-3.3.0 app/controllers/concerns/hyrax/breadcrumbs.rb
hyrax-3.2.0 app/controllers/concerns/hyrax/breadcrumbs.rb
hyrax-3.1.0 app/controllers/concerns/hyrax/breadcrumbs.rb
hyrax-3.0.2 app/controllers/concerns/hyrax/breadcrumbs.rb