Class: Triannon::IIIFAnnoList
- Inherits:
-
Object
- Object
- Triannon::IIIFAnnoList
- Defined in:
- lib/triannon/iiif_anno_list.rb
Constant Summary collapse
- ANNO_LIST_FRAME =
JSON.parse(' { "@context" : "http://iiif.io/api/presentation/2/context.json", "@type": "sc:AnnotationList", "resources": [{ "@type": "oa:Annotation", "on" : [{ "@embed" : false }] }] }')
- ANNO_FRAME =
JSON.parse(' { "@context" : "http://iiif.io/api/presentation/2/context.json", "@type": "oa:Annotation", "on" : [{ "@embed" : false }] }')
Class Method Summary collapse
-
.anno_list(tgraph_array) ⇒ Hash
take an Array of annos as OA::Graph objects and return a Hash representation of IIIF Annotation List.
Class Method Details
.anno_list(tgraph_array) ⇒ Hash
take an Array of annos as OA::Graph objects and return a Hash representation
of IIIF Annotation List
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/triannon/iiif_anno_list.rb', line 34 def self.anno_list(tgraph_array) if tgraph_array result = { "@context" => OA::Graph::IIIF_CONTEXT_URL, "@type" => "sc:AnnotationList", "within" => {"@type" => "sc:Layer", "total" => tgraph_array.size }, "resources" => tgraph_array.map { |g| = JSON::LD::API.frame(JSON.parse(g.jsonld_iiif), ANNO_FRAME) resource = ["@graph"] if resource.is_a?(Array) && resource.size == 1 resource = resource.first end resource } } # remove context from each anno as it is redundant result["resources"].each { |anno_hash| anno_hash.delete("@context") } result end end |