Sha256: 27f850ecedfe10d310d6647c5db1a8b3cf4a4517c593c3bae30b5d75a5678b7f
Contents?: true
Size: 1.68 KB
Versions: 15
Compression:
Stored size: 1.68 KB
Contents
# frozen_string_literal: true module SirTrevorRails module Blocks ## # Multi-up document viewer with text block class SolrDocumentsBlock < SirTrevorRails::Block include Textable include Displayable attr_reader :solr_helper def with_solr_helper(solr_helper) @solr_helper = solr_helper end def each_document return to_enum(:each_document) unless block_given? items.each do |i| document = documents.detect { |doc| doc.id == i[:id] } i[:iiif_tilesource_base] = i.fetch(:iiif_tilesource, '').sub('/info.json', '') yield i, document if document end end def documents @documents ||= begin doc_ids = items.map { |v| v[:id] } _, documents = solr_helper.controller.send(:search_service).fetch(doc_ids) documents end end def documents? each_document.any? end def primary_caption? primary_caption_field.present? && show_primary_caption? end def show_primary_caption? ActiveModel::Type::Boolean.new.cast(send(:'show-primary-caption')) end def secondary_caption? secondary_caption_field.present? && show_secondary_caption? end def show_secondary_caption? ActiveModel::Type::Boolean.new.cast(send(:'show-secondary-caption')) end def zpr_link? zpr_link == 'true' end def primary_caption_field val = send(:'primary-caption-field') val unless val.blank? end def secondary_caption_field val = send(:'secondary-caption-field') val unless val.blank? end end end end
Version data entries
15 entries across 15 versions & 1 rubygems