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.
32 33 34 |
# File 'lib/cocina_display/concerns/url_helpers.rb', line 32 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.
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.
19 20 21 22 23 24 |
# File 'lib/cocina_display/concerns/url_helpers.rb', line 19 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 |
#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.
53 54 55 56 |
# File 'lib/cocina_display/concerns/url_helpers.rb', line 53 def searchworks_url return "#{searchworks_base_url}/view/#{folio_hrid}" if folio_hrid.present? "#{searchworks_base_url}/view/#{}" if .present? end |