Class: IiifManifestController

Inherits:
CatalogController
  • Object
show all
Includes:
CommonwealthVlrEngine::CatalogHelper, CommonwealthVlrEngine::IiifManifest
Defined in:
app/controllers/iiif_manifest_controller.rb

Overview

use to render new image in multi image viewer in catalog#show

Instance Method Summary collapse

Methods included from CommonwealthVlrEngine::IiifManifest

#canvas_from_id, #collection_for_manifests, #create_iiif_manifest, #image_annotation_from_image_id, #image_resource_from_image_id, #label_for_canvas, #manifest_attribution, #manifest_metadata

Methods included from CommonwealthVlrEngine::CatalogHelper

#cc_terms_code, #cc_url, #collection_gallery_url, #collection_icon_path, #create_download_links, #create_thumb_img_element, #extra_body_classes, #has_downloadable_files?, #has_image_files?, #ia_download_title, #index_collection_link, #index_date_value, #index_institution_link, #index_relation_base_icon, #index_slideshow_img_url, #index_title_length, #institution_icon_path, #link_to_az_value, #normalize_date, #render_cc_license, #render_full_title, #render_hiergo_subject, #render_item_breadcrumb, #render_main_title, #render_mlt_search_link, #render_mods_date, #render_mods_dates, #render_mods_xml_record, #render_volume_title, #return_oai_inst_name, #setup_collection_links, #setup_names_roles, #should_autofocus_on_search_box?, #thumbnail_url

Instance Method Details

#annotationObject



39
40
41
42
43
44
45
46
47
# File 'app/controllers/iiif_manifest_controller.rb', line 39

def annotation
  response, document = fetch(params[:id])
  if has_image_files?(get_files(params[:id])).include?(params[:annotation_object_id])
    annotation = image_annotation_from_image_id(params[:annotation_object_id], document)
    render :json => annotation.to_json
  else
    not_found
  end
end

#canvasObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/controllers/iiif_manifest_controller.rb', line 20

def canvas
  canvas_response, canvas_document = fetch(params[:canvas_object_id])
  if canvas_document[:is_file_of_ssim]
    response, document = fetch(params[:id])
    image_files = has_image_files?(get_files(params[:id]))
    if image_files
      image_index = Hash[image_files.map.with_index.to_a][params[:canvas_object_id]]
      iiif_canvas = canvas_from_id(params[:canvas_object_id],
                                   label_for_canvas(canvas_document, image_index),
                                   document)
      render :json => iiif_canvas.to_json
    else
      not_found
    end
  else
    not_found
  end
end

#collectionObject



49
50
51
52
53
54
55
56
57
58
# File 'app/controllers/iiif_manifest_controller.rb', line 49

def collection
  response, document = fetch(params[:id])
  volumes = get_volume_objects(params[:id])
  if volumes.length > 0
    iiif_collection = collection_for_manifests(document, volumes)
    render :json => iiif_collection.to_json
  else
    not_found
  end
end

#manifestObject



7
8
9
10
11
12
13
14
15
16
17
18
# File 'app/controllers/iiif_manifest_controller.rb', line 7

def manifest
  response, document = fetch(params[:id])
  image_files = get_image_files(params[:id])
  if image_files.length > 0
    iiif_manifest = create_iiif_manifest(document, image_files)
    render :json => iiif_manifest.to_json
  elsif get_volume_objects(params[:id]).length > 0
    redirect_to iiif_collection_path(params[:id])
  else
    not_found
  end
end