Sha256: ed42f8e2a8a43f4d38524da8c1a57881d514d7a34a81e8baf76086a61add9e65
Contents?: true
Size: 1.44 KB
Versions: 11
Compression:
Stored size: 1.44 KB
Contents
# frozen_string_literal: true class Hyrax::HomepageController < ApplicationController # Adds Hydra behaviors into the application controller include Blacklight::SearchContext include Blacklight::AccessControls::Catalog class_attribute :presenter_class self.presenter_class = Hyrax::HomepagePresenter layout 'homepage' helper Hyrax::ContentBlockHelper def index @presenter = presenter_class.new(current_ability, collections) @featured_researcher = ContentBlock.for(:researcher) @marketing_text = ContentBlock.for(:marketing) @featured_work_list = FeaturedWorkList.new @announcement_text = ContentBlock.for(:announcement) recent end private # Return 5 collections def collections(rows: 5) Hyrax::CollectionsService.new(self).search_results do |builder| builder.rows(rows) end rescue Blacklight::Exceptions::ECONNREFUSED, Blacklight::Exceptions::InvalidRequest [] end def recent # grab any recent documents (_, @recent_documents) = search_service.search_results do |builder| builder.rows(4) builder.merge(sort: sort_field) end rescue Blacklight::Exceptions::ECONNREFUSED, Blacklight::Exceptions::InvalidRequest @recent_documents = [] end def search_service Hyrax::SearchService.new(config: blacklight_config, user_params: { q: '' }, scope: self, search_builder_class: Hyrax::HomepageSearchBuilder) end def sort_field "date_uploaded_dtsi desc" end end
Version data entries
11 entries across 11 versions & 1 rubygems