diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index dc2a83536..6d67494d4 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -20,25 +20,24 @@ jobs: include: - rails_version: "~> 7.2" ruby: "3.3" - blacklight_version: "~> 7.34" - bootstrap_version: ~> 5.0 + blacklight_version: "~> 7.38" + bootstrap_version: "~> 5.0" additional_name: Bootstrap 5 - rails_version: "7.1.4" ruby: "3.2" - blacklight_version: "~> 7.34" - bootstrap_version: ~> 4.0 + blacklight_version: "~> 7.38" + bootstrap_version: "~> 4.0" additional_name: Rails 7.1 - rails_version: "~> 7.2" ruby: "3.3" blacklight_version: "~> 8.0" - bootstrap_version: ~> 4.0 + bootstrap_version: "~> 4.0" additional_name: Blacklight 8 - additional_engine_cart_rails_options: "-j rollup -a sprockets" env: RAILS_VERSION: ${{ matrix.rails_version }} BLACKLIGHT_VERSION: ${{ matrix.blacklight_version }} BOOTSTRAP_VERSION: ${{ matrix.bootstrap_version }} - ENGINE_CART_RAILS_OPTIONS: "--skip-git --skip-listen --skip-spring --skip-keeps --skip-coffee --skip-test ${{ matrix.additional_engine_cart_rails_options }}" + ENGINE_CART_RAILS_OPTIONS: "--skip-git --skip-listen --skip-spring --skip-keeps --skip-coffee --skip-test -a propshaft ${{ matrix.additional_engine_cart_rails_options }}" steps: - uses: actions/checkout@v4 # Remove these Chrome steps after https://issues.chromium.org/issues/351858989 is fixed diff --git a/Dockerfile b/Dockerfile index ba000ec3e..b2655ab25 100644 --- a/Dockerfile +++ b/Dockerfile @@ -45,7 +45,7 @@ RUN bundle install --jobs "$(nproc)" RUN mkdir -p /spotlight/app WORKDIR /spotlight/app -RUN SKIP_TRANSLATION=yes rails _${RAILS_VERSION}_ new . -j webpack --force --template=../engine/template.rb +RUN SKIP_TRANSLATION=yes rails _${RAILS_VERSION}_ new . -a propshaft --force --template=../engine/template.rb RUN bundle add pg RUN yarn add @babel/plugin-proposal-private-methods --dev RUN yarn add @babel/plugin-proposal-private-property-in-object diff --git a/Gemfile b/Gemfile index 0983cccd3..71cd5d263 100644 --- a/Gemfile +++ b/Gemfile @@ -23,7 +23,7 @@ else if ENV['RAILS_VERSION'] if ENV['RAILS_VERSION'] == 'edge' gem 'rails', github: 'rails/rails' - ENV['ENGINE_CART_RAILS_OPTIONS'] = '--edge --skip-turbolinks' + ENV['ENGINE_CART_RAILS_OPTIONS'] = '--edge --skip-turbolinks -a propshaft' else gem 'rails', ENV['RAILS_VERSION'] end diff --git a/README.md b/README.md index 3daa9d0c9..c3f5d3143 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Read more about what Spotlight is, our motivations for creating it, and how to i To bootstrap a new Rails application: ``` -$ SKIP_TRANSLATION=1 rails new app-name -m https://raw.githubusercontent.com/projectblacklight/spotlight/main/template.rb +$ SKIP_TRANSLATION=1 rails new app-name -m https://raw.githubusercontent.com/projectblacklight/spotlight/main/template.rb -a propshaft ``` or from an existing Rails application: diff --git a/Rakefile b/Rakefile index d21efc97a..c46ba6faf 100644 --- a/Rakefile +++ b/Rakefile @@ -30,6 +30,9 @@ require 'engine_cart/rake_task' require 'spotlight/version' +# Ensure the app generates with Propshaft; sprockets is no longer supported +ENV['ENGINE_CART_RAILS_OPTIONS'] = "#{ENV.fetch('ENGINE_CART_RAILS_OPTIONS', nil)} -a propshaft" + task ci: ['engine_cart:generate'] do ENV['environment'] = 'test' @@ -63,7 +66,7 @@ namespace :spotlight do system 'bin/rails spotlight:initialize spotlight_test:solr:seed' File.open('.initialized', 'w') {} end - system 'bin/rails s' + system 'bin/dev' end end end diff --git a/app/assets/javascripts/spotlight/spotlight.esm.js b/app/assets/javascripts/spotlight/spotlight.esm.js index 0d4c22a76..43e07039f 100644 --- a/app/assets/javascripts/spotlight/spotlight.esm.js +++ b/app/assets/javascripts/spotlight/spotlight.esm.js @@ -1,3815 +1,6813 @@ -class BrowseGroupCateogries { - connect() { - var $container, slider; - - function init() { - var data = $container.data(); - var sidebar = $container.data().sidebar; - var items = data.browseGroupCategoriesCount; - var dir = $('html').attr('dir'); - var controls = $container.parent().find('.browse-group-categories-controls')[0]; - - slider = tns({ - container: $container[0], - controlsContainer: controls, - loop: false, - nav: false, - items: 1, - slideBy: 'page', - textDirection: dir, - responsive: { - 576: { - items: itemCount(items, sidebar) - } +import require$$0 from 'leaflet'; +import Clipboard from 'clipboard'; +import Blacklight from 'blacklight-frontend'; +import SirTrevor from 'sir-trevor'; + +// Includes an unreleased RTL support pull request: https://github.com/ganlanyuan/tiny-slider/pull/658 +// Includes "export default tns" at the end of the file for spotlight/user/browse_group_categories.js +var tns = (function (){ +var win = window; + +var raf = win.requestAnimationFrame + || win.webkitRequestAnimationFrame + || win.mozRequestAnimationFrame + || win.msRequestAnimationFrame + || function(cb) { return setTimeout(cb, 16); }; + +var win$1 = window; + +var caf = win$1.cancelAnimationFrame + || win$1.mozCancelAnimationFrame + || function(id){ clearTimeout(id); }; + +function extend() { + var obj, name, copy, + target = arguments[0] || {}, + i = 1, + length = arguments.length; + + for (; i < length; i++) { + if ((obj = arguments[i]) !== null) { + for (name in obj) { + copy = obj[name]; + + if (target === copy) { + continue; + } else if (copy !== undefined) { + target[name] = copy; } - }); + } } + } + return target; +} - // Destroy the slider instance, as tns will change the dom elements, causing some issues with turbolinks - function setupDestroy() { - document.addEventListener('turbolinks:before-cache', function() { - if (slider && slider.destroy) { - slider.destroy(); - } - }); - } +function checkStorageValue (value) { + return ['true', 'false'].indexOf(value) >= 0 ? JSON.parse(value) : value; +} - function itemCount(items, sidebar) { - if (items < 3) { - return items; - } - return sidebar ? 3 : 4; - } +function setLocalStorage(storage, key, value, access) { + if (access) { + try { storage.setItem(key, value); } catch (e) {} + } + return value; +} - return $('[data-browse-group-categories-carousel]').each(function() { - $container = $(this); - init(); - setupDestroy(); - }); +function getSlideId() { + var id = window.tnsId; + window.tnsId = !id ? 1 : id + 1; + + return 'tns' + window.tnsId; +} + +function getBody () { + var doc = document, + body = doc.body; + + if (!body) { + body = doc.createElement('body'); + body.fake = true; } + + return body; } -class Carousel { - connect() { - $('.carousel').carousel(); +var docElement = document.documentElement; + +function setFakeBody (body) { + var docOverflow = ''; + if (body.fake) { + docOverflow = docElement.style.overflow; + //avoid crashing IE8, if background image is used + body.style.background = ''; + //Safari 5.13/5.1.4 OSX stops loading if ::-webkit-scrollbar is used and scrollbars are visible + body.style.overflow = docElement.style.overflow = 'hidden'; + docElement.appendChild(body); } + + return docOverflow; } -class ClearFormButton { - connect() { - var $clearBtn = $('.btn-reset'); - var $input = $clearBtn.parent().prev('input'); - var btnCheck = function(){ - if ($input.val() !== '') { - $clearBtn.css('display', 'inline-block'); - } else { - $clearBtn.css('display', 'none'); +function resetFakeBody (body, docOverflow) { + if (body.fake) { + body.remove(); + docElement.style.overflow = docOverflow; + // Trigger layout so kinetic scrolling isn't disabled in iOS6+ + // eslint-disable-next-line + docElement.offsetHeight; + } +} + +// get css-calc + +function calc() { + var doc = document, + body = getBody(), + docOverflow = setFakeBody(body), + div = doc.createElement('div'), + result = false; + + body.appendChild(div); + try { + var str = '(10px * 10)', + vals = ['calc' + str, '-moz-calc' + str, '-webkit-calc' + str], + val; + for (var i = 0; i < 3; i++) { + val = vals[i]; + div.style.width = val; + if (div.offsetWidth === 100) { + result = val.replace(str, ''); + break; } - }; + } + } catch (e) {} + + body.fake ? resetFakeBody(body, docOverflow) : div.remove(); - btnCheck(); - $input.on('keyup', function() { - btnCheck(); - }); + return result; +} - $clearBtn.on('click', function(event) { - event.preventDefault(); - $input.val(''); - }); +// get subpixel support value + +function percentageLayout() { + // check subpixel layout supporting + var doc = document, + body = getBody(), + docOverflow = setFakeBody(body), + wrapper = doc.createElement('div'), + outer = doc.createElement('div'), + str = '', + count = 70, + perPage = 3, + supported = false; + + wrapper.className = "tns-t-subp2"; + outer.className = "tns-t-ct"; + + for (var i = 0; i < count; i++) { + str += '
'; } + + outer.innerHTML = str; + wrapper.appendChild(outer); + body.appendChild(wrapper); + + supported = Math.abs(wrapper.getBoundingClientRect().left - outer.children[count - perPage].getBoundingClientRect().left) < 2; + + body.fake ? resetFakeBody(body, docOverflow) : wrapper.remove(); + + return supported; } -class ReportProblem { - connect(){ - var container, target; +function mediaquerySupport () { + if (window.matchMedia || window.msMatchMedia) { + return true; + } + + var doc = document, + body = getBody(), + docOverflow = setFakeBody(body), + div = doc.createElement('div'), + style = doc.createElement('style'), + rule = '@media all and (min-width:1px){.tns-mq-test{position:absolute}}', + position; + + style.type = 'text/css'; + div.className = 'tns-mq-test'; + + body.appendChild(style); + body.appendChild(div); + + if (style.styleSheet) { + style.styleSheet.cssText = rule; + } else { + style.appendChild(doc.createTextNode(rule)); + } - function init() { - const target_val = container.attr('data-target') || container.attr('data-bs-target'); - if (!target_val) - return + position = window.getComputedStyle ? window.getComputedStyle(div).position : div.currentStyle['position']; - target = $("#" + target_val); - container.on('click', open); - target.find('[data-behavior="cancel-link"]').on('click', close); - } + body.fake ? resetFakeBody(body, docOverflow) : div.remove(); - function open(event) { - event.preventDefault(); - target.slideToggle('slow'); - } + return position === "absolute"; +} - function close(event) { - event.preventDefault(); - target.slideUp('fast'); - } +// create and append style sheet +function createStyleSheet (media, nonce) { + // Create the