diff --git a/.env.template b/.env.template index 38261e9e66185d86fd2b757e91eb1a4f0d041f10..9b11e0c9631bad9777a4405e46e4446e5dcffa31 100644 --- a/.env.template +++ b/.env.template @@ -65,6 +65,7 @@ HYRAX_ANALYTICS_PROVIDER=matomo ANALYTICS_START_DATE=2022-02-18 MATOMO_SITE_ID= MATOMO_BASE_URL= +MATOMO_BASE_URL_SUFFIX="index.php" MATOMO_AUTH_TOKEN= # Hyrax application setting diff --git a/.env.template.development b/.env.template.development index 840bd3713661d92ccdc68b7f54ebcb2888068999..3aa9000af0707ce669214994b8a7bb5444b7ae6a 100644 --- a/.env.template.development +++ b/.env.template.development @@ -68,6 +68,7 @@ HYRAX_ANALYTICS_PROVIDER= ANALYTICS_START_DATE= MATOMO_SITE_ID= MATOMO_BASE_URL= +MATOMO_BASE_URL_SUFFIX="index.php" MATOMO_AUTH_TOKEN= # Hyrax application setting diff --git a/hyrax/config/initializers/hyrax.rb b/hyrax/config/initializers/hyrax.rb index deff604dc86a760a2fbfd8dd69def57f289d8333..086eb2eb0e9196e22a7135e9bab3167edf59ac48 100644 --- a/hyrax/config/initializers/hyrax.rb +++ b/hyrax/config/initializers/hyrax.rb @@ -131,21 +131,10 @@ Hyrax.config do |config| # # Default is false config.iiif_image_server = true - if ENV.fetch('IIIF_TO_SERVE_SSL_URLS', 'false') == 'true' - protocol = 'https' - else - protocol = 'http' - end - - if Rails.env.development? - port = ENV.fetch('PORT', 3000) - else - port = nil - end # Returns a URL that resolves to an image provided by a IIIF image server config.iiif_image_url_builder = lambda do |file_id, base_url, size, format| - Riiif::Engine.routes.url_helpers.image_url(file_id, host: base_url, size: size, protocol: protocol, port: port) + Riiif::Engine.routes.url_helpers.image_url(file_id, size: size, only_path: true) end # config.iiif_image_url_builder = lambda do |file_id, base_url, size, format| # "#{base_url}/downloads/#{file_id.split('/').first}" @@ -153,7 +142,8 @@ Hyrax.config do |config| # Returns a URL that resolves to an info.json file provided by a IIIF image server config.iiif_info_url_builder = lambda do |file_id, base_url| - uri = Riiif::Engine.routes.url_helpers.info_url(file_id, host: base_url, protocol: protocol, port: port) + uri = Riiif::Engine.routes.url_helpers.info_url(file_id, only_path: true) + uri.sub(/\Ahttp:/, 'https:') uri.sub(%r{/info\.json\Z}, '') end diff --git a/hyrax/config/initializers/hyrax_matomo.rb b/hyrax/config/initializers/hyrax_matomo.rb new file mode 100644 index 0000000000000000000000000000000000000000..dadb28242b05f8a36e6b78a01b19f3a80948b982 --- /dev/null +++ b/hyrax/config/initializers/hyrax_matomo.rb @@ -0,0 +1,14 @@ +# Make the base URL suffix of the external matomo instance configurable. +# This is required because +# a) by default, Faraday does not follow HTTP redirects, and +# b) the code in the Hyrax 3.5.0 code doesn't work if the Matomo instance's webserver redirects / to /index.php +# See also https://github.com/samvera/hyrax/issues/5593 and https://github.com/samvera/hyrax/issues/5846 +Rails.configuration.to_prepare do + Hyrax::Analytics::Matomo::Config.class_eval do + def get(params) + response = Faraday.get(config.base_url+ENV.fetch("MATOMO_BASE_URL_SUFFIX","index.php"), params) + return [] if response.status != 200 + JSON.parse(response.body) + end + end +end diff --git a/hyrax/config/uv/uv.html b/hyrax/config/uv/uv.html index c8e8eced524e450fcd69e837c72cce8696a949ea..e01b72dd758aa9fa2214999cd2f9eb80b7e575a2 100644 --- a/hyrax/config/uv/uv.html +++ b/hyrax/config/uv/uv.html @@ -8,7 +8,7 @@ <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" /> <link rel="icon" href="favicon.ico"> <link rel="stylesheet" type="text/css" href="uv.css"> - <script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script> + <script src="lib/hls.min.js"></script> <script type="text/javascript" src="lib/offline.js"></script> <script type="text/javascript" src="helpers.js"></script> <style>