Module: CocinaDisplay::Concerns::Access
- Included in:
- CocinaDisplay::CocinaRecord
- Defined in:
- lib/cocina_display/concerns/access.rb
Overview
Methods that generate URLs to access an object.
Instance Method Summary collapse
-
#download_url ⇒ String
The download URL to get the entire object as a .zip file.
-
#iiif_manifest_url(version: 3) ⇒ String
The IIIF manifest URL for the object.
-
#oembed_url(params: {}) ⇒ String?
The oEmbed URL for the object, optionally with additional parameters.
-
#purl_base_url ⇒ String
The URL to the PURL environment this object is from.
-
#purl_url ⇒ String
The PURL URL for this object.
-
#stacks_base_url ⇒ String
The URL to the stacks environment this object is shelved in.
Instance Method Details
#download_url ⇒ String
The download URL to get the entire object as a .zip file. Stacks generates the .zip for the object on request.
55 56 57 |
# File 'lib/cocina_display/concerns/access.rb', line 55 def download_url "#{stacks_base_url}/object/#{}" end |
#iiif_manifest_url(version: 3) ⇒ String
The IIIF manifest URL for the object. PURL generates the IIIF manifest.
65 66 67 68 |
# File 'lib/cocina_display/concerns/access.rb', line 65 def iiif_manifest_url(version: 3) iiif_path = (version == 3) ? "iiif3" : "iiif" "#{purl_url}/#{iiif_path}/manifest" end |
#oembed_url(params: {}) ⇒ String?
The oEmbed URL for the object, optionally with additional parameters. Corresponds to the PURL environment.
43 44 45 46 47 48 |
# File 'lib/cocina_display/concerns/access.rb', line 43 def (params: {}) return if collection? params[:url] ||= purl_url "#{purl_base_url}/embed.json?#{params.to_query}" end |
#purl_base_url ⇒ String
Objects accessed via UAT will still have a production PURL base URL.
The URL to the PURL environment this object is from.
18 19 20 |
# File 'lib/cocina_display/concerns/access.rb', line 18 def purl_base_url URI(purl_url).origin end |
#purl_url ⇒ String
The PURL URL for this object.
9 10 11 |
# File 'lib/cocina_display/concerns/access.rb', line 9 def purl_url cocina_doc.dig("description", "purl") || "https://purl.stanford.edu/#{}" end |
#stacks_base_url ⇒ String
The URL to the stacks environment this object is shelved in. Corresponds to the PURL environment.
28 29 30 31 32 33 34 |
# File 'lib/cocina_display/concerns/access.rb', line 28 def stacks_base_url if purl_base_url == "https://sul-purl-stage.stanford.edu" "https://sul-stacks-stage.stanford.edu" else "https://stacks.stanford.edu" end end |