Skip to content

Commit

Permalink
Restructuring the handling for UV URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
jrgriffiniii committed Mar 21, 2019
1 parent 0054db6 commit 99c4b03
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 3 deletions.
37 changes: 37 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,41 @@ def document_thumbnail(document, image_options = {})
url = values.first
image_tag url, image_options if url.present?
end

# Generate the URL for the Universal Viewer to view the content for the
# document manifest
# @return [String]
def universal_viewer_url
universal_viewer.url
end

private

# Access the base URL for the UV installation
# @return [String]
def universal_viewer_url_base
"https://figgy-staging.princeton.edu"
end

# Generate the URL for the configuration for the UV
# @return [String]
def universal_viewer_config_url
"#{universal_viewer_url_base}/viewer/exhibit/config?manifest=#{@document.manifest}"
end

# Generate the URL for the UV viewer
# @return [String]
def universal_viewer_instance_url
"#{universal_viewer_url_base}/uv/uv"
end

# Construct the object used to handle Universal Viewer installations
# @return [UniversalViewer]
def universal_viewer
UniversalViewer.new(
universal_viewer_instance_url,
manifest: @document.manifest,
config: universal_viewer_config_url
)
end
end
29 changes: 29 additions & 0 deletions app/values/universal_viewer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

# Class modeling URLs for Universal Viewer installations
class UniversalViewer

# Constructor
# @param base_url [String] URL to the installation
# @param uv_params [Hash] GET parameters to pass to the URL
def initialize(base_url, **uv_params)
@base_url = base_url
@params = uv_params
end

# Generate the string representation of the URL
# @return [String]
def url
components = [@base_url.to_s]

components << "#?" unless @params.empty?

params = []
@params.each_pair do |name, value|
params << "#{name.to_s}=#{CGI::escape(value)}"
end
components += [params.join('&')]

components.join
end
end

5 changes: 2 additions & 3 deletions app/views/catalog/_universal_viewer_default.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<div class="uv__overlay">
<iframe allowFullScreen="true" src="https://figgy-staging.princeton.edu/uv/uv#?manifest=<%= document.manifest %>&config=<%= CGI::escape("https://figgy-staging.princeton.edu/viewer/exhibit/config?manifest=#{document.manifest}") %>">
</iframe>
<%= link_to image_tag("iiif.png", class: "logo", alt: "IIIF Drag and Drop"), viewers_page_path(manifest: document.manifest, format: :html) %>
<iframe allowfullscreen="true" src="<%= universal_viewer_url %>"></iframe>
<%= link_to image_tag("iiif.png", class: "logo", alt: "IIIF Drag and Drop"), universal_viewer_url %>
</div>

0 comments on commit 99c4b03

Please sign in to comment.