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.
-
#searchworks_url ⇒ String?
The Searchworks URL for this object.
Instance Method Details
#download_url ⇒ String?
Collections and related resources do not have a download URL.
The download URL to get the entire object as a .zip file. Stacks generates the .zip for the object on request.
35 36 37 |
# File 'lib/cocina_display/concerns/url_helpers.rb', line 35 def download_url "#{stacks_base_url}/object/#{}" if is_a?(CocinaDisplay::CocinaRecord) && .present? && !collection? end |
#iiif_manifest_url(version: 3) ⇒ String?
The IIIF manifest URL for the object. PURL generates the IIIF manifest.
45 46 47 48 |
# File 'lib/cocina_display/concerns/url_helpers.rb', line 45 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.
19 20 21 22 23 24 25 26 27 |
# File 'lib/cocina_display/concerns/url_helpers.rb', line 19 def (params: {}) return if (!is_a?(CocinaDisplay::RelatedResource) && collection?) || purl_url.blank? ### Note that searchworks_traject_indexer sends in a single instance of params for all oembed_url calls. ### We dup the params to avoid modifying the original hash. = params.dup [:url] ||= purl_url "#{purl_base_url}/embed.json?#{.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 |
#searchworks_url ⇒ String?
This does not guarantee that the object is actually in Searchworks.
The Searchworks URL for this object. Uses the catkey (FOLIO HRID) if present, otherwise uses the druid.
56 57 58 59 |
# File 'lib/cocina_display/concerns/url_helpers.rb', line 56 def searchworks_url return "#{searchworks_base_url}/view/#{folio_hrid}" if folio_hrid.present? "#{searchworks_base_url}/view/#{}" if .present? end |