Openseadragon support for Rails apps
npm install openseadragon-railsOpenSeadragon is a javascript library for displaying tiling images. This gem packages those assets and some Rails helpers for using them.
http://openseadragon.github.io/
Add the gem to your Gemfile:
``ruby`
gem 'openseadragon'
Run bundle install:
``
$ bundle install
And run the openseadragon-rails install generator:
``
$ bundle exec rails g openseadragon:install
The generator will install the Rails helpers and openseadragon assets.
You must provide the openseadragon npm package as an external dependency.
See https://openseadragon.github.io for further details
and #openseadragon_picture_tag.
#### picture_tag
The
#picture_tag helper creates HTML5 tags .In the simple case, a view like:
`ruby
picture_tag 'page1.jpg', 'page2.jpg', 'page3.jpg'
`Creates the HTML like:
`html
`You can control the attributes on
and elements:`ruby
picture_tag ['page1.jpg' => { id: 'first-picture'}], 'page2.jpg', 'page3.jpg', { class: "picture-image" }, { id: 'my-picture'}
``html
`#### openseadragon_picture_tag
If you have an OpenSeaDragon tilesource, you can use this helper to construct a HTML5
that will render as an OpenSeaDragon tile viewer.`ruby
openseadragon_picture_tag 'page1.jpg'
``html
`This gem includes some javascript that translates that markup to the OSD viewer.
As with
#picture_tag, you can provide additional options.`ruby
openseadragon_picture_tag 'page1.jpg', 'path/to/info.json', ['some-custom-tilesource' => { Image: { xmlns: "...", Url: '...', Format: 'jpg', Overlap: 2}}], { class: 'osd-image'}, { data: { openseadragon: { preserveViewport: true, visibilityRatio: 1}}}
``html
`The
src attribute (or the JSON-encoded options given in the data-openseadragon) are translated into an OpenSeaDragon tilesource` configuration.