Class: SirTrevorRails::Blocks::SolrDocumentsBlock
- Inherits:
-
SirTrevorRails::Block
- Object
- SirTrevorRails::Block
- SirTrevorRails::Blocks::SolrDocumentsBlock
show all
- Includes:
- Displayable, Textable
- Defined in:
- app/models/sir_trevor_rails/blocks/solr_documents_block.rb
Overview
Multi-up document viewer with text block
Instance Attribute Summary collapse
Instance Method Summary
collapse
#item_ids, #items, #ordered_items
Methods included from Textable
#content_align, #text, #text?, #text_align
Instance Attribute Details
#solr_helper ⇒ Object
Returns the value of attribute solr_helper.
8
9
10
|
# File 'app/models/sir_trevor_rails/blocks/solr_documents_block.rb', line 8
def solr_helper
@solr_helper
end
|
Instance Method Details
#documents ⇒ Object
24
25
26
27
28
29
30
|
# File 'app/models/sir_trevor_rails/blocks/solr_documents_block.rb', line 24
def documents
@documents ||= begin
doc_ids = items.map { |v| v[:id] }
_, documents = solr_helper.fetch(doc_ids)
documents
end
end
|
#documents? ⇒ Boolean
32
33
34
|
# File 'app/models/sir_trevor_rails/blocks/solr_documents_block.rb', line 32
def documents?
each_document.any?
end
|
#each_document ⇒ Object
14
15
16
17
18
19
20
21
22
|
# File 'app/models/sir_trevor_rails/blocks/solr_documents_block.rb', line 14
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
36
37
38
|
# File 'app/models/sir_trevor_rails/blocks/solr_documents_block.rb', line 36
def primary_caption?
primary_caption_field.present? && send(:'show-primary-caption')
end
|
#primary_caption_field ⇒ Object
48
49
50
51
|
# File 'app/models/sir_trevor_rails/blocks/solr_documents_block.rb', line 48
def primary_caption_field
val = send(:'primary-caption-field')
val unless val.blank?
end
|
#secondary_caption? ⇒ Boolean
40
41
42
|
# File 'app/models/sir_trevor_rails/blocks/solr_documents_block.rb', line 40
def secondary_caption?
secondary_caption_field.present? && send(:'show-secondary-caption')
end
|
#secondary_caption_field ⇒ Object
53
54
55
56
|
# File 'app/models/sir_trevor_rails/blocks/solr_documents_block.rb', line 53
def secondary_caption_field
val = send(:'secondary-caption-field')
val unless val.blank?
end
|
#with_solr_helper(solr_helper) ⇒ Object
10
11
12
|
# File 'app/models/sir_trevor_rails/blocks/solr_documents_block.rb', line 10
def with_solr_helper(solr_helper)
@solr_helper = solr_helper
end
|
#zpr_link? ⇒ Boolean
44
45
46
|
# File 'app/models/sir_trevor_rails/blocks/solr_documents_block.rb', line 44
def zpr_link?
zpr_link == 'true'
end
|