Sha256: 995e3dbff4d4bac089b8cca87aab85b86fb8edc42de5fe63677ef4ab3a4c05c0

Contents?: true

Size: 976 Bytes

Versions: 6

Compression:

Stored size: 976 Bytes

Contents

  module Sufia
  module Breadcrumbs
    extend ActiveSupport::Concern

    def build_breadcrumbs
      if request.referer 
        trail_from_referer
      else
        default_trail
      end
    end

    def default_trail
      if user_signed_in?
        add_breadcrumb I18n.t('sufia.dashboard.title'), sufia.dashboard_index_path
      end
    end

    def trail_from_referer
      case request.referer
      when /catalog/
        add_breadcrumb I18n.t('sufia.bread_crumb.search_results'), request.referer
      when /dashboard/
        default_trail
        add_breadcrumb_for_controller    
      else
        default_trail
      end
    end

    def add_breadcrumb_for_controller
      case controller_name
      when /files|batch/
        add_breadcrumb I18n.t('sufia.dashboard.my.files'), sufia.dashboard_files_path
      when /collections/
        add_breadcrumb I18n.t('sufia.dashboard.my.collections'), sufia.dashboard_collections_path
      end
    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
sufia-4.3.1 app/controllers/concerns/sufia/breadcrumbs.rb
sufia-6.0.0.beta1 app/controllers/concerns/sufia/breadcrumbs.rb
sufia-4.2.0 app/controllers/concerns/sufia/breadcrumbs.rb
sufia-4.1.0 app/controllers/concerns/sufia/breadcrumbs.rb
sufia-4.0.1 app/controllers/concerns/sufia/breadcrumbs.rb
sufia-4.0.0 app/controllers/concerns/sufia/breadcrumbs.rb