Module: CocinaDisplay::Concerns::UrlHelpers
- Included in:
- CocinaDisplay::CocinaRecord, RelatedResource
- Defined in:
- lib/cocina_display/concerns/url_helpers.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_url ⇒ String
The PURL URL for this object.
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.
32 33 34 |
# File 'lib/cocina_display/concerns/url_helpers.rb', line 32 def download_url "#{stacks_base_url}/object/#{}" if .present? end |
#iiif_manifest_url(version: 3) ⇒ String
The IIIF manifest URL for the object. PURL generates the IIIF manifest.
42 43 44 45 |
# File 'lib/cocina_display/concerns/url_helpers.rb', line 42 def iiif_manifest_url(version: 3) iiif_path = (version == 3) ? "iiif3" : "iiif" "#{purl_url}/#{iiif_path}/manifest" if purl_url.present? end |
#oembed_url(params: {}) ⇒ String?
The oEmbed URL for the object, optionally with additional parameters. Corresponds to the PURL environment.
20 21 22 23 24 25 |
# File 'lib/cocina_display/concerns/url_helpers.rb', line 20 def (params: {}) return if (!is_a?(CocinaDisplay::RelatedResource) && collection?) || purl_url.blank? params[:url] ||= purl_url "#{purl_base_url}/embed.json?#{params.to_query}" end |
#purl_url ⇒ String
The PURL URL for this object.
9 10 11 |
# File 'lib/cocina_display/concerns/url_helpers.rb', line 9 def purl_url cocina_doc.dig("description", "purl") end |