Sha256: 7a4f71dd6eb97771799c9c735c0c3d2bbd87d4c8c01129841c4c3b3ea15a6da3

Contents?: true

Size: 1.47 KB

Versions: 10

Compression:

Stored size: 1.47 KB

Contents

module Hyrax::HomepageControllerBehavior
  extend ActiveSupport::Concern

  included do
    # Adds Hydra behaviors into the application controller
    include Blacklight::SearchContext
    include Blacklight::SearchHelper
    include Blacklight::AccessControls::Catalog

    def search_builder_class
      Hyrax::HomepageSearchBuilder
    end

    class_attribute :presenter_class
    self.presenter_class = Hyrax::HomepagePresenter
    layout 'homepage'
    helper Hyrax::ContentBlockHelper
  end

  def index
    @presenter = presenter_class.new(current_ability)
    @featured_researcher = ContentBlock.featured_researcher
    @marketing_text = ContentBlock.marketing_text
    @featured_work_list = FeaturedWorkList.new
    @announcement_text = ContentBlock.announcement_text
    @admin_sets = fetch_admin_sets
    recent
  end

  protected

    def fetch_admin_sets
      return [] unless Flipflop.assign_admin_set?
      builder = Hyrax::AdminSetSearchBuilder.new(self, current_ability)
                                            .rows(5)
      response = repository.search(builder)
      response.documents
    rescue Blacklight::Exceptions::ECONNREFUSED
      []
    end

    def recent
      # grab any recent documents
      (_, @recent_documents) = search_results(q: '', sort: sort_field, rows: 4)
    rescue Blacklight::Exceptions::ECONNREFUSED
      @recent_documents = []
    end

    def sort_field
      "#{Solrizer.solr_name('system_create', :stored_sortable, type: :date)} desc"
    end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
hyrax-1.1.1 app/controllers/concerns/hyrax/homepage_controller_behavior.rb
hyrax-1.1.0 app/controllers/concerns/hyrax/homepage_controller_behavior.rb
hyrax-1.0.5 app/controllers/concerns/hyrax/homepage_controller_behavior.rb
hyrax-1.0.4 app/controllers/concerns/hyrax/homepage_controller_behavior.rb
hyrax-1.0.3 app/controllers/concerns/hyrax/homepage_controller_behavior.rb
hyrax-1.0.2 app/controllers/concerns/hyrax/homepage_controller_behavior.rb
hyrax-1.0.1 app/controllers/concerns/hyrax/homepage_controller_behavior.rb
hyrax-1.0.0.rc2 app/controllers/concerns/hyrax/homepage_controller_behavior.rb
hyrax-1.0.0.rc1 app/controllers/concerns/hyrax/homepage_controller_behavior.rb
test_hyrax-0.0.1.alpha app/controllers/concerns/hyrax/homepage_controller_behavior.rb