Class: SirTrevorRails::Blocks::SolrDocumentsBlock
Overview
Multi-up document viewer with text block
Constant Summary
SirTrevorRails::Block::DEFAULT_FORMAT
Instance Attribute Summary collapse
#parent, #type
Instance Method Summary
collapse
#item_ids, #items, #ordered_items
Methods included from Textable
#content_align, #text, #text?, #text_align
#as_json, block_class, block_class!, custom_block_types, #format, from_hash, #initialize, #to_partial_path, type_klass
Instance Attribute Details
#solr_helper ⇒ Object
Returns the value of attribute solr_helper.
10
11
12
|
# File 'app/models/sir_trevor_rails/blocks/solr_documents_block.rb', line 10
def solr_helper
@solr_helper
end
|
Instance Method Details
#document_caption(presenter, caption_field, default: nil) ⇒ Object
46
47
48
49
50
51
52
53
|
# File 'app/models/sir_trevor_rails/blocks/solr_documents_block.rb', line 46
def document_caption(presenter, caption_field, default: nil)
caption_field ||= default
return unless caption_field
return presenter.heading if caption_field == Spotlight::PageConfigurations::DOCUMENT_TITLE_KEY
presenter.field_value(solr_helper.blacklight_config.index_fields[caption_field] || Blacklight::Configuration::NullField.new(caption_field))
end
|
#documents ⇒ Object
26
27
28
29
30
31
32
|
# File 'app/models/sir_trevor_rails/blocks/solr_documents_block.rb', line 26
def documents
@documents ||= begin
doc_ids = items.map { |v| v[:id] }
_, documents = solr_helper.controller.send(:search_service).fetch(doc_ids)
documents
end
end
|
#documents? ⇒ Boolean
34
35
36
|
# File 'app/models/sir_trevor_rails/blocks/solr_documents_block.rb', line 34
def documents?
each_document.any?
end
|
#each_document ⇒ Object
16
17
18
19
20
21
22
23
24
|
# File 'app/models/sir_trevor_rails/blocks/solr_documents_block.rb', line 16
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
|
#primary_caption? ⇒ Boolean
38
39
40
|
# File 'app/models/sir_trevor_rails/blocks/solr_documents_block.rb', line 38
def primary_caption?
primary_caption_field.present? && show_primary_caption?
end
|
#primary_caption_field ⇒ Object
67
68
69
70
|
# File 'app/models/sir_trevor_rails/blocks/solr_documents_block.rb', line 67
def primary_caption_field
val = send(:'primary-caption-field')
val unless val.blank?
end
|
#secondary_caption? ⇒ Boolean
55
56
57
|
# File 'app/models/sir_trevor_rails/blocks/solr_documents_block.rb', line 55
def secondary_caption?
secondary_caption_field.present? && show_secondary_caption?
end
|
#secondary_caption_field ⇒ Object
72
73
74
75
|
# File 'app/models/sir_trevor_rails/blocks/solr_documents_block.rb', line 72
def secondary_caption_field
val = send(:'secondary-caption-field')
val unless val.blank?
end
|
#show_primary_caption? ⇒ Boolean
42
43
44
|
# File 'app/models/sir_trevor_rails/blocks/solr_documents_block.rb', line 42
def show_primary_caption?
ActiveModel::Type::Boolean.new.cast(send(:'show-primary-caption'))
end
|
#show_secondary_caption? ⇒ Boolean
59
60
61
|
# File 'app/models/sir_trevor_rails/blocks/solr_documents_block.rb', line 59
def show_secondary_caption?
ActiveModel::Type::Boolean.new.cast(send(:'show-secondary-caption'))
end
|
#with_solr_helper(solr_helper) ⇒ Object
12
13
14
|
# File 'app/models/sir_trevor_rails/blocks/solr_documents_block.rb', line 12
def with_solr_helper(solr_helper)
@solr_helper = solr_helper
end
|
#zpr_link? ⇒ Boolean
63
64
65
|
# File 'app/models/sir_trevor_rails/blocks/solr_documents_block.rb', line 63
def zpr_link?
zpr_link == 'true'
end
|