Sha256: d019323234b32a8844152fe94e9252ecc767e2a4db2a4c204dffe934c06ed020

Contents?: true

Size: 1.43 KB

Versions: 1

Compression:

Stored size: 1.43 KB

Contents

module Riiif
  module OpenseadragonHelper
    def openseadragon_viewer(id_or_image, options={})
      image = case id_or_image
      when String
        Image.new(id_or_image)
      when Image
        id_or_image
      end
      options[:tile_width] ||= '1024'
      options[:tile_height] ||= '1024'
      options[:html_id] ||= 'openseadragon1'
      options[:html] ||= {}
      options[:html][:id] = options[:html_id]
      options[:image_host] ||= '/image-service'
      options[:prefix_url] ||= '/assets/openseadragon/'
      js =<<-EOF
        var viewer = OpenSeadragon({
            id: "#{options[:html_id]}",
            prefixUrl: "#{options[:prefix_url]}",
            tileSources:   [{
            "image_host":     "#{options[:image_host]}",
            "identifier":   "#{image.id}",   
            "width":        #{image.info[:width]},   
            "height":       #{image.info[:height]},   
            "scale_factors": [1, 2, 3, 4, 5],   
            "tile_width":   #{options[:tile_width]},   
            "tile_height":  #{options[:tile_height]},   
            "formats":      [ "jpg", "png" ],   
            "qualities":    ["native", "bitonal", "grey", "color"],   
            "profile":      "http://library.stanford.edu/iiif/image-api/compliance.html#level3"
          }]
        });
      EOF

      #<%=javascript_include_tag "openseadragon.js" %>
      content_tag(:div, '', options[:html]) + javascript_tag(js) 
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
riiif-0.0.4 app/helpers/riiif/openseadragon_helper.rb