blacklight-spotlight 4.7.1 → 5.0.0.pre.alpha1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +30 -12
- data/Rakefile +8 -1
- data/app/assets/javascripts/spotlight/application.js +0 -1
- data/app/assets/javascripts/spotlight/spotlight.esm.js +3620 -3847
- data/app/assets/javascripts/spotlight/spotlight.esm.js.map +1 -1
- data/app/assets/javascripts/spotlight/spotlight.js +3620 -3852
- data/app/assets/javascripts/spotlight/spotlight.js.map +1 -1
- data/app/assets/stylesheets/spotlight/_accessibility.scss +0 -9
- data/app/assets/stylesheets/spotlight/_autocomplete.scss +49 -0
- data/app/assets/stylesheets/spotlight/_blacklight_configuration.scss +0 -1
- data/app/assets/stylesheets/spotlight/_blacklight_overrides.scss +1 -6
- data/app/assets/stylesheets/spotlight/_browse.scss +2 -2
- data/app/assets/stylesheets/spotlight/_catalog.scss +40 -41
- data/app/assets/stylesheets/spotlight/_curation.scss +1 -1
- data/app/assets/stylesheets/spotlight/_exhibit_admin.scss +7 -0
- data/app/assets/stylesheets/spotlight/_exhibits_index.scss +8 -5
- data/app/assets/stylesheets/spotlight/_featured_browse_categories_block.scss +3 -3
- data/app/assets/stylesheets/spotlight/_header.scss +13 -0
- data/app/assets/stylesheets/spotlight/_mixins.scss +3 -4
- data/app/assets/stylesheets/spotlight/_nestable.scss +2 -12
- data/app/assets/stylesheets/spotlight/_pages.scss +11 -9
- data/app/assets/stylesheets/spotlight/_report_a_problem.scss +1 -3
- data/app/assets/stylesheets/spotlight/_sir-trevor_overrides.scss +2 -2
- data/app/assets/stylesheets/spotlight/_spotlight.scss +2 -1
- data/app/assets/stylesheets/spotlight/_tag_selector.scss +34 -0
- data/app/assets/stylesheets/spotlight/_variables.scss +0 -8
- data/app/components/spotlight/analytics/dashboard_component.html.erb +3 -3
- data/app/components/spotlight/breadcrumbs_component.html.erb +13 -19
- data/app/components/spotlight/bulk_action_component.rb +1 -1
- data/app/components/spotlight/document_component.rb +1 -1
- data/app/components/spotlight/save_search_component.rb +1 -1
- data/app/components/spotlight/select_image_component.html.erb +17 -0
- data/app/components/spotlight/select_image_component.rb +24 -0
- data/app/components/spotlight/skip_link_component.rb +16 -0
- data/app/components/spotlight/tag_selector_component.html.erb +40 -0
- data/app/components/spotlight/tag_selector_component.rb +41 -0
- data/app/components/spotlight/tag_selector_component.yml +6 -0
- data/app/components/spotlight/title_component.html.erb +8 -0
- data/app/components/spotlight/title_component.rb +22 -0
- data/app/controllers/spotlight/accessibility_controller.rb +2 -2
- data/app/controllers/spotlight/catalog_controller.rb +7 -2
- data/app/controllers/spotlight/contact_email_controller.rb +8 -2
- data/app/controllers/spotlight/languages_controller.rb +9 -4
- data/app/helpers/spotlight/application_helper.rb +7 -0
- data/app/helpers/spotlight/crop_helper.rb +4 -0
- data/app/helpers/spotlight/meta_helper.rb +59 -36
- data/app/javascript/spotlight/admin/blacklight_configuration.js +1 -1
- data/app/javascript/spotlight/admin/block_mixins/autocompleteable.js +70 -34
- data/app/javascript/spotlight/admin/blocks/block.js +1 -0
- data/app/javascript/spotlight/admin/blocks/browse_block.js +8 -12
- data/app/javascript/spotlight/admin/blocks/browse_group_categories_block.js +14 -18
- data/app/javascript/spotlight/admin/blocks/pages_block.js +6 -10
- data/app/javascript/spotlight/admin/blocks/resources_block.js +33 -15
- data/app/javascript/spotlight/admin/blocks/solr_documents_base_block.js +11 -6
- data/app/javascript/spotlight/admin/blocks/solr_documents_embed_block.js +1 -0
- data/app/javascript/spotlight/admin/blocks/uploaded_items_block.js +4 -3
- data/app/javascript/spotlight/admin/copy_email_addresses.js +2 -0
- data/app/javascript/spotlight/admin/crop.js +45 -17
- data/app/javascript/spotlight/admin/croppable.js +8 -1
- data/app/javascript/spotlight/admin/croppable_modal.js +68 -0
- data/app/javascript/spotlight/admin/exhibits.js +15 -10
- data/app/javascript/spotlight/admin/form_observer.js +1 -1
- data/app/javascript/spotlight/admin/index.js +0 -10
- data/app/javascript/spotlight/admin/locks.js +15 -5
- data/app/javascript/spotlight/admin/pages.js +1 -1
- data/app/javascript/spotlight/admin/search_typeahead.js +62 -55
- data/app/javascript/spotlight/admin/spotlight_nestable.js +173 -50
- data/app/javascript/spotlight/admin/visibility_toggle.js +1 -11
- data/app/javascript/spotlight/controllers/index.js +8 -0
- data/app/javascript/spotlight/controllers/tag_selector_controller.js +203 -0
- data/app/javascript/spotlight/core.js +4 -6
- data/app/javascript/spotlight/index.js +2 -0
- data/app/javascript/spotlight/user/browse_group_categories.js +2 -0
- data/app/javascript/spotlight/user/carousel.js +3 -1
- data/app/javascript/spotlight/user/index.js +0 -2
- data/app/models/sir_trevor_rails/block.rb +5 -4
- data/app/models/sir_trevor_rails/blocks/solr_documents_block.rb +1 -1
- data/app/models/sir_trevor_rails/blocks/solr_documents_embed_block.rb +1 -1
- data/app/models/sir_trevor_rails/blocks/uploaded_items_block.rb +1 -1
- data/app/models/spotlight/page_configurations.rb +1 -1
- data/app/views/catalog/_add_tags.html.erb +2 -2
- data/app/views/catalog/_change_visibility.html.erb +1 -1
- data/app/views/catalog/_remove_tags.html.erb +2 -2
- data/app/views/layouts/spotlight/base.html.erb +24 -13
- data/app/views/layouts/spotlight/spotlight.html.erb +6 -6
- data/app/views/shared/_masthead.html.erb +4 -31
- data/app/views/shared/_site_sidebar.html.erb +1 -1
- data/app/views/shared/_user_util_links.html.erb +3 -1
- data/app/views/spotlight/accessibility/alt_text.html.erb +2 -2
- data/app/views/spotlight/admin_users/index.html.erb +3 -3
- data/app/views/spotlight/appearances/edit.html.erb +1 -1
- data/app/views/spotlight/browse/_search_box.html.erb +8 -8
- data/app/views/spotlight/browse/show.html.erb +1 -1
- data/app/views/spotlight/bulk_updates/_download.html.erb +1 -1
- data/app/views/spotlight/bulk_updates/_upload.html.erb +1 -1
- data/app/views/spotlight/catalog/_admin_header.html.erb +1 -1
- data/app/views/spotlight/catalog/_edit_default.html.erb +2 -1
- data/app/views/spotlight/catalog/select_image.html.erb +1 -0
- data/app/views/spotlight/contacts/_form.html.erb +1 -1
- data/app/views/spotlight/exhibits/_contact.html.erb +5 -6
- data/app/views/spotlight/exhibits/_delete.html.erb +1 -1
- data/app/views/spotlight/exhibits/_languages.html.erb +3 -2
- data/app/views/spotlight/featured_images/_form.html.erb +6 -2
- data/app/views/spotlight/featured_images/_upload_form.html.erb +1 -1
- data/app/views/spotlight/metadata_configurations/_metadata_field.html.erb +1 -1
- data/app/views/spotlight/metadata_configurations/edit.html.erb +6 -6
- data/app/views/spotlight/pages/show.html.erb +1 -1
- data/app/views/spotlight/resources/csv_upload/_form.html.erb +1 -1
- data/app/views/spotlight/resources/upload/_form.html.erb +1 -1
- data/app/views/spotlight/roles/index.html.erb +1 -1
- data/app/views/spotlight/searches/_form.html.erb +1 -1
- data/app/views/spotlight/shared/_dd3_item.html.erb +1 -1
- data/app/views/spotlight/sir_trevor/blocks/_browse_group_categories_block.html.erb +1 -1
- data/app/views/spotlight/sir_trevor/blocks/_solr_documents_block.html.erb +1 -1
- data/app/views/spotlight/sir_trevor/blocks/_solr_documents_carousel_block.html.erb +1 -1
- data/app/views/spotlight/sir_trevor/blocks/_uploaded_items_block.html.erb +1 -1
- data/app/views/spotlight/tags/index.html.erb +2 -3
- data/app/views/spotlight/translations/_import.html.erb +2 -2
- data/config/importmap.rb +5 -0
- data/config/locales/spotlight.en.yml +2 -0
- data/config/routes.rb +5 -3
- data/lib/generators/spotlight/assets/generator_common_utilities.rb +36 -0
- data/lib/generators/spotlight/assets/importmap_generator.rb +87 -0
- data/lib/generators/spotlight/assets/propshaft_generator.rb +96 -0
- data/lib/generators/spotlight/assets_generator.rb +22 -0
- data/lib/generators/spotlight/install_generator.rb +8 -36
- data/lib/generators/spotlight/scaffold_resource_generator.rb +1 -1
- data/lib/generators/spotlight/templates/assets/spotlight.scss +6 -0
- data/lib/generators/spotlight/templates/javascript/jquery-shim.js +1 -0
- data/lib/spotlight/engine.rb +7 -6
- data/lib/spotlight/version.rb +1 -1
- data/spec/support/features/capybara_wait_metadata_helper.rb +13 -0
- data/spec/support/features/test_features_helpers.rb +16 -30
- data/vendor/assets/javascripts/tiny-slider.js +3 -0
- metadata +35 -87
- data/app/assets/stylesheets/spotlight/#_accessibility.scss# +0 -12
- data/app/javascript/spotlight/admin/checkbox_submit.js +0 -75
- data/app/javascript/spotlight/admin/exhibit_tag_autocomplete.js +0 -39
- data/app/javascript/spotlight/user/report_a_problem.js +0 -30
- data/app/views/spotlight/browse/_tophat.html.erb +0 -1
- data/app/views/spotlight/catalog/_tophat_default.html.erb +0 -1
- data/app/views/spotlight/home_pages/_tophat.html.erb +0 -2
- data/app/views/spotlight/pages/_tophat.html.erb +0 -1
- data/lib/generators/spotlight/templates/spotlight.js +0 -1
- data/lib/generators/spotlight/templates/spotlight.scss +0 -5
- data/spec/support/features/capybara_default_max_wait_metadata_helper.rb +0 -20
- data/vendor/assets/javascripts/bootstrap-tagsinput.js +0 -530
- data/vendor/assets/javascripts/jquery.serializejson.js +0 -234
- data/vendor/assets/javascripts/nestable.js +0 -645
- data/vendor/assets/javascripts/sir-trevor.js +0 -23508
- data/vendor/assets/javascripts/typeahead.bundle.min.js +0 -7
- data/vendor/assets/stylesheets/bootstrap-tagsinput.css +0 -46
@@ -3,7 +3,7 @@
|
|
3
3
|
<% html_id = "carousel-#{solr_documents_carousel_block.object_id}" %>
|
4
4
|
<div class="content-block carousel-block carousel-height-<%= solr_documents_carousel_block.max_height %>">
|
5
5
|
<% if solr_documents_carousel_block.documents? %>
|
6
|
-
<div id="<%= html_id %>" class="carousel slide"
|
6
|
+
<div id="<%= html_id %>" class="carousel slide" <%= "data-bs-ride=carousel data-bs-interval=#{solr_documents_carousel_block.interval}" if solr_documents_carousel_block.autoplay? %>>
|
7
7
|
<div class="carousel-inner text-center">
|
8
8
|
<% solr_documents_carousel_block.each_document.each_with_index do |(block_options, document), index| %>
|
9
9
|
<% doc_presenter = document_presenter(document) %>
|
@@ -19,7 +19,7 @@
|
|
19
19
|
<% end %>
|
20
20
|
|
21
21
|
<% if uploaded_items_block.zpr_link? %>
|
22
|
-
<%= button_tag t('.zpr_link_html', title: file[:caption]), class: 'btn btn-
|
22
|
+
<%= button_tag t('.zpr_link_html', title: file[:caption]), class: 'btn btn-primary zpr-link', data: { 'iiif-tilesource' => { type: 'image', url: file[:url] }.to_json } %>
|
23
23
|
<% end %>
|
24
24
|
</div>
|
25
25
|
</div>
|
@@ -13,9 +13,8 @@
|
|
13
13
|
<%= f.fields_for :owned_tags_attributes, tag, index: index do |p| %>
|
14
14
|
<%= render partial: 'tag', locals: { f: p } %>
|
15
15
|
<% end %>
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
<% end %>
|
17
|
+
</ul>
|
19
18
|
<div class="float-right float-end">
|
20
19
|
<%= submit_tag t(:'helpers.action.update_all'), class: "btn btn-primary" %>
|
21
20
|
</div>
|
@@ -27,8 +27,8 @@
|
|
27
27
|
<%= content_tag :span, t(".export_label") %>
|
28
28
|
</div>
|
29
29
|
<div class="col-12 col-md-9">
|
30
|
-
<%= link_to t(:'.export_current_locale', language: t(:"locales.#{@language}")), spotlight.exhibit_translations_path(current_exhibit, format: "yaml", locale: @language), class: 'btn btn-primary mr-3 me-3' %>
|
31
|
-
<%= link_to t(:'.export_default_locale', language: t(:"locales.#{I18n.default_locale}")), spotlight.exhibit_translations_path(current_exhibit, format: "yaml", locale: I18n.default_locale), class: 'btn btn-primary' %>
|
30
|
+
<%= link_to t(:'.export_current_locale', language: t(:"locales.#{@language}")), spotlight.exhibit_translations_path(current_exhibit, format: "yaml", locale: @language), class: 'btn btn-primary mr-3 me-3', data: { turbo: false } %>
|
31
|
+
<%= link_to t(:'.export_default_locale', language: t(:"locales.#{I18n.default_locale}")), spotlight.exhibit_translations_path(current_exhibit, format: "yaml", locale: I18n.default_locale), class: 'btn btn-primary', data: { turbo: false } %>
|
32
32
|
</div>
|
33
33
|
</div>
|
34
34
|
</div>
|
data/config/importmap.rb
CHANGED
@@ -2,3 +2,8 @@
|
|
2
2
|
|
3
3
|
pin_all_from File.expand_path('../app/javascript/spotlight', __dir__), under: 'spotlight'
|
4
4
|
pin_all_from File.expand_path('../vendor/assets/javascripts', __dir__)
|
5
|
+
|
6
|
+
pin 'clipboard', to: 'https://cdn.skypack.dev/clipboard@2.0.10'
|
7
|
+
pin 'sir-trevor', to: 'https://cdn.skypack.dev/sir-trevor@0.8.2'
|
8
|
+
pin 'sortablejs', to: 'https://cdn.skypack.dev/sortablejs@^1.15.3'
|
9
|
+
pin '@github/auto-complete-element', to: 'https://cdn.skypack.dev/@github/auto-complete-element'
|
@@ -734,9 +734,11 @@ en:
|
|
734
734
|
header: Edit page
|
735
735
|
locked: This page is currently being edited by %{user} (%{created_at})
|
736
736
|
form:
|
737
|
+
instructions_html: "Adjust the image so that the rectangle contains the area you want to display to exhibit visitors. \n<ol> \n <li>Click-and-drag to adjust position</li>\n <li> Adjust zoom-level</li>\n</ol> \nSelect Save changes to save the image area.\n"
|
737
738
|
page_content: Content
|
738
739
|
page_options: Options
|
739
740
|
page_thumbnail: Thumbnail
|
741
|
+
select_image: Select image area
|
740
742
|
thumbnail:
|
741
743
|
help: You can select and crop an image to visually represent this page. It will be used as the thumbnail image if you include this page in the Pages widget.
|
742
744
|
title_placeholder: Title
|
data/config/routes.rb
CHANGED
@@ -26,7 +26,7 @@ Spotlight::Engine.routes.draw do
|
|
26
26
|
post 'reindex', to: 'exhibits#reindex'
|
27
27
|
end
|
28
28
|
|
29
|
-
resources :contact_email, only: [:destroy]
|
29
|
+
resources :contact_email, only: [:destroy]
|
30
30
|
resources :attachments, only: :create
|
31
31
|
resource :contact_form, path: 'contact', only: %i[new create]
|
32
32
|
resource :blacklight_configuration, only: [:update]
|
@@ -42,7 +42,7 @@ Spotlight::Engine.routes.draw do
|
|
42
42
|
|
43
43
|
concern :searchable, Blacklight::Routes::Searchable.new
|
44
44
|
|
45
|
-
resource :catalog, only: [
|
45
|
+
resource :catalog, only: [], as: 'catalog', path: '/catalog', controller: 'catalog' do
|
46
46
|
concerns :searchable
|
47
47
|
|
48
48
|
collection do
|
@@ -124,7 +124,7 @@ Spotlight::Engine.routes.draw do
|
|
124
124
|
|
125
125
|
resources :contacts, only: %i[edit update destroy]
|
126
126
|
|
127
|
-
resources :pages
|
127
|
+
resources :pages do
|
128
128
|
collection do
|
129
129
|
patch :update_all
|
130
130
|
end
|
@@ -193,4 +193,6 @@ Spotlight::Engine.routes.draw do
|
|
193
193
|
|
194
194
|
get '/:exhibit_id' => 'home_pages#show', as: :exhibit_root
|
195
195
|
post 'versions/:id/revert' => 'versions#revert', as: :revert_version
|
196
|
+
|
197
|
+
get '/:exhibit_id/select_image' => 'catalog#select_image'
|
196
198
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Spotlight
|
4
|
+
module Assets
|
5
|
+
# Utilities for the Spotlight assets generators
|
6
|
+
module GeneratorCommonUtilities
|
7
|
+
# Some versions of the blacklight/spotlight gem do not have a corresponding package on npm.
|
8
|
+
# Assume we want the most recent version that is compatible with the major version of the gem.
|
9
|
+
def package_yarn_version(package_name, requested_version)
|
10
|
+
versions = JSON.parse(`yarn info #{package_name} versions --json`)['data']
|
11
|
+
exact_match = versions.find { |v| v == requested_version }
|
12
|
+
return exact_match if exact_match
|
13
|
+
|
14
|
+
major_version = Gem::Version.new(requested_version).segments.first
|
15
|
+
"^#{major_version}"
|
16
|
+
end
|
17
|
+
|
18
|
+
def blacklight_yarn_version
|
19
|
+
package_yarn_version('blacklight-frontend', Blacklight::VERSION)
|
20
|
+
end
|
21
|
+
|
22
|
+
def spotlight_yarn_version
|
23
|
+
package_yarn_version('spotlight-frontend', Spotlight::VERSION)
|
24
|
+
end
|
25
|
+
|
26
|
+
def bootstrap_version
|
27
|
+
options[:'bootstrap-version'].presence || '~> 5.3'
|
28
|
+
end
|
29
|
+
|
30
|
+
# Support the gem version format e.g., `~> 5.3` for consistency.
|
31
|
+
def bootstrap_yarn_version
|
32
|
+
bootstrap_version.match(/(\d+(\.\d+)*)/)[0]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'fileutils'
|
4
|
+
require_relative 'generator_common_utilities'
|
5
|
+
|
6
|
+
module Spotlight
|
7
|
+
module Assets
|
8
|
+
# Spotlight Importmap Generator
|
9
|
+
class ImportmapGenerator < Rails::Generators::Base
|
10
|
+
include GeneratorCommonUtilities
|
11
|
+
|
12
|
+
source_root Spotlight::Engine.root.join('lib', 'generators', 'spotlight', 'templates')
|
13
|
+
|
14
|
+
class_option :test, type: :boolean, default: false, aliases: '-t', desc: 'Indicates that app will be installed in a test environment'
|
15
|
+
class_option :'bootstrap-version', type: :string, default: ENV.fetch('BOOTSTRAP_VERSION', '~> 5.3'), desc: "Set the generated app's bootstrap version"
|
16
|
+
|
17
|
+
desc <<-DESCRIPTION
|
18
|
+
This generator configures the Spotlight app to use importmap for
|
19
|
+
javascript and bundling for the styles:
|
20
|
+
|
21
|
+
- Adds the frontend style dependencies, including spotlight-frontend,
|
22
|
+
via yarn
|
23
|
+
- Configures cssbundling-rails to build the styles
|
24
|
+
- Javascript from gems such as Blacklight and Spotlight are delivered
|
25
|
+
via importmap/the asset pipeline without the need for bundling
|
26
|
+
DESCRIPTION
|
27
|
+
|
28
|
+
def add_stylesheet_dependencies
|
29
|
+
run "yarn add blacklight-frontend@#{blacklight_yarn_version}"
|
30
|
+
run "yarn add bootstrap@\"^#{bootstrap_yarn_version}\""
|
31
|
+
run 'yarn add leaflet'
|
32
|
+
end
|
33
|
+
|
34
|
+
# Needed for the stylesheets
|
35
|
+
def add_frontend
|
36
|
+
if ENV['CI']
|
37
|
+
run "yarn add file:#{Spotlight::Engine.root}"
|
38
|
+
elsif options[:test]
|
39
|
+
run 'yarn link spotlight-frontend'
|
40
|
+
|
41
|
+
# If a branch was specified (e.g. you are running a template.rb build
|
42
|
+
# against a test branch), use the latest version available on npm
|
43
|
+
elsif ENV['BRANCH']
|
44
|
+
run 'yarn add spotlight-frontend@latest'
|
45
|
+
|
46
|
+
# Otherwise, pick the version from npm that matches the Spotlight
|
47
|
+
# gem version
|
48
|
+
else
|
49
|
+
run "yarn add spotlight-frontend@#{spotlight_yarn_version}"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def add_javascript
|
54
|
+
# This may have been added from Blacklight, but it is a Spotlight dependency so ensure it is present.
|
55
|
+
insert_into_file 'app/javascript/application.js', "import githubAutoCompleteElement from \"@github/auto-complete-element\"\n"
|
56
|
+
|
57
|
+
append_to_file 'app/javascript/application.js' do
|
58
|
+
<<~CONTENT
|
59
|
+
|
60
|
+
import Spotlight from "spotlight"
|
61
|
+
|
62
|
+
Blacklight.onLoad(function() {
|
63
|
+
Spotlight.activate();
|
64
|
+
});
|
65
|
+
CONTENT
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def add_stylesheets
|
70
|
+
copy_file 'assets/spotlight.scss', 'app/assets/stylesheets/spotlight.scss'
|
71
|
+
append_to_file 'app/assets/stylesheets/application.bootstrap.scss' do
|
72
|
+
<<~CONTENT
|
73
|
+
@import "spotlight";
|
74
|
+
CONTENT
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
private
|
79
|
+
|
80
|
+
def bootstrap_frontend_version
|
81
|
+
yarn_lock = File.read('yarn.lock')
|
82
|
+
bootstrap_entry = yarn_lock.match(/^"?bootstrap@.+:\n version "(.+)"/)
|
83
|
+
bootstrap_entry ? bootstrap_entry[1] : nil
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'fileutils'
|
4
|
+
require_relative 'generator_common_utilities'
|
5
|
+
|
6
|
+
module Spotlight
|
7
|
+
module Assets
|
8
|
+
# Spotlight Propshaft Generator
|
9
|
+
class PropshaftGenerator < Rails::Generators::Base
|
10
|
+
include GeneratorCommonUtilities
|
11
|
+
|
12
|
+
source_root Spotlight::Engine.root.join('lib', 'generators', 'spotlight', 'templates')
|
13
|
+
|
14
|
+
class_option :test, type: :boolean, default: false, aliases: '-t', desc: 'Indicates that app will be installed in a test environment'
|
15
|
+
class_option :'bootstrap-version', type: :string, default: ENV.fetch('BOOTSTRAP_VERSION', '~> 5.3'), desc: "Set the generated app's bootstrap version"
|
16
|
+
|
17
|
+
desc <<-DESCRIPTION
|
18
|
+
This generator configures the Spotlight app to use bundling for both
|
19
|
+
javascript and styles:
|
20
|
+
|
21
|
+
- Adds frontend dependencies, including spotlight-frontend, via yarn
|
22
|
+
- Configures jsbundling-rails (w/ esbuild) to bundle the JS
|
23
|
+
- Configures cssbundling-rails to build the styles
|
24
|
+
DESCRIPTION
|
25
|
+
|
26
|
+
def install_dependencies
|
27
|
+
run 'yarn add @github/auto-complete-element'
|
28
|
+
run 'yarn add @hotwired/turbo-rails'
|
29
|
+
run 'yarn add clipboard'
|
30
|
+
run 'yarn add leaflet'
|
31
|
+
run 'yarn add sir-trevor'
|
32
|
+
run 'yarn add sortablejs'
|
33
|
+
end
|
34
|
+
|
35
|
+
def add_blacklight_frontend
|
36
|
+
run "yarn add blacklight-frontend@#{blacklight_yarn_version}"
|
37
|
+
end
|
38
|
+
|
39
|
+
def add_bootstrap
|
40
|
+
run "yarn add bootstrap@\"^#{bootstrap_yarn_version}\""
|
41
|
+
run 'yarn add @popperjs/core'
|
42
|
+
end
|
43
|
+
|
44
|
+
# Pick a version of the frontend asset package and install it.
|
45
|
+
def add_frontend
|
46
|
+
if ENV['CI']
|
47
|
+
run "yarn add file:#{Spotlight::Engine.root}"
|
48
|
+
elsif options[:test]
|
49
|
+
run 'yarn link spotlight-frontend'
|
50
|
+
|
51
|
+
# If a branch was specified (e.g. you are running a template.rb build
|
52
|
+
# against a test branch), use the latest version available on npm
|
53
|
+
elsif ENV['BRANCH']
|
54
|
+
run 'yarn add spotlight-frontend@latest'
|
55
|
+
|
56
|
+
# Otherwise, pick the version from npm that matches the Spotlight
|
57
|
+
# gem version
|
58
|
+
else
|
59
|
+
run "yarn add spotlight-frontend@#{spotlight_yarn_version}"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def add_javascript
|
64
|
+
copy_file 'javascript/jquery-shim.js', 'app/javascript/jquery-shim.js'
|
65
|
+
gsub_file 'app/javascript/application.js', 'import "controllers"', '// import "controllers"'
|
66
|
+
|
67
|
+
# This may have been added from Blacklight, but it is a Spotlight dependency so ensure it is present.
|
68
|
+
insert_into_file 'app/javascript/application.js', "import githubAutoCompleteElement from \"@github/auto-complete-element\";\n"
|
69
|
+
|
70
|
+
append_to_file 'app/javascript/application.js' do
|
71
|
+
<<~CONTENT
|
72
|
+
import Spotlight from "spotlight-frontend"
|
73
|
+
|
74
|
+
Blacklight.onLoad(function() {
|
75
|
+
Spotlight.activate();
|
76
|
+
});
|
77
|
+
CONTENT
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def add_stylesheets
|
82
|
+
copy_file 'assets/spotlight.scss', 'app/assets/stylesheets/spotlight.scss'
|
83
|
+
append_to_file 'app/assets/stylesheets/application.bootstrap.scss', "\n@import \"spotlight\";\n"
|
84
|
+
end
|
85
|
+
|
86
|
+
def configure_esbuild
|
87
|
+
# The main-fields option resolves a bundling issue with bootstrap/popper on esbuild.
|
88
|
+
custom_options = '--main-fields=main,module --alias:jquery=./app/javascript/jquery-shim.js'
|
89
|
+
custom_options = "#{custom_options} --preserve-symlinks" if options[:test]
|
90
|
+
gsub_file 'package.json',
|
91
|
+
'esbuild app/javascript/*.* --bundle --sourcemap --format=esm --outdir=app/assets/builds --public-path=/assets',
|
92
|
+
"esbuild app/javascript/*.* --bundle --sourcemap --format=esm --outdir=app/assets/builds --public-path=/assets #{custom_options}"
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Spotlight
|
4
|
+
# Run general asset setup and then delegate to the appropriate generator
|
5
|
+
# Based on Blacklight::AssetsGenerator
|
6
|
+
class AssetsGenerator < Rails::Generators::Base
|
7
|
+
class_option :test, type: :boolean, default: ENV.fetch('CI', false) == 'true', aliases: '-t',
|
8
|
+
desc: 'Indicates that app will be installed in a test environment'
|
9
|
+
class_option :'bootstrap-version', type: :string, default: ENV.fetch('BOOTSTRAP_VERSION', '~> 5.3'), desc: "Set the generated app's bootstrap version"
|
10
|
+
|
11
|
+
def run_asset_pipeline_specific_generator
|
12
|
+
generated_options = '--test=true' if options[:test]
|
13
|
+
generator = if defined?(Importmap)
|
14
|
+
'spotlight:assets:importmap'
|
15
|
+
elsif defined?(Propshaft)
|
16
|
+
'spotlight:assets:propshaft'
|
17
|
+
end
|
18
|
+
|
19
|
+
generate generator, generated_options
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -9,13 +9,15 @@ module Spotlight
|
|
9
9
|
source_root File.expand_path('templates', __dir__)
|
10
10
|
class_option :solr_update_class, type: :string, default: 'Spotlight::SolrDocument::AtomicUpdates'
|
11
11
|
class_option :mailer_default_url_host, type: :string, default: '' # e.g. localhost:3000
|
12
|
+
class_option :test, type: :boolean, default: false, aliases: '-t', desc: 'Indicates that app will be installed in a test environment'
|
13
|
+
class_option :'bootstrap-version', type: :string, default: ENV.fetch('BOOTSTRAP_VERSION', '~> 5.3'), desc: "Set the generated app's bootstrap version"
|
12
14
|
|
13
|
-
def
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
def generate_assets
|
16
|
+
if options[:test]
|
17
|
+
generate 'spotlight:assets', '--test=true'
|
18
|
+
else
|
19
|
+
generate 'spotlight:assets'
|
20
|
+
end
|
19
21
|
end
|
20
22
|
|
21
23
|
def inject_spotlight_routes
|
@@ -56,11 +58,6 @@ module Spotlight
|
|
56
58
|
EOS
|
57
59
|
end
|
58
60
|
|
59
|
-
def assets
|
60
|
-
copy_file 'spotlight.scss', 'app/assets/stylesheets/spotlight.scss'
|
61
|
-
copy_file 'spotlight.js', 'app/assets/javascripts/spotlight.js'
|
62
|
-
end
|
63
|
-
|
64
61
|
def add_roles_to_user
|
65
62
|
inject_into_file 'app/models/user.rb', after: 'include Blacklight::User' do
|
66
63
|
"\n include Spotlight::User\n"
|
@@ -122,25 +119,6 @@ module Spotlight
|
|
122
119
|
generate 'blacklight_gallery:install'
|
123
120
|
end
|
124
121
|
|
125
|
-
def configure_osd_for_sprockets
|
126
|
-
return unless defined?(Sprockets)
|
127
|
-
|
128
|
-
append_to_file 'app/assets/javascripts/application.js', "\n//= require openseadragon\n//= require openseadragon-rails/openseadragon-rails\n"
|
129
|
-
|
130
|
-
append_to_file 'config/initializers/assets.rb' do
|
131
|
-
<<~CONTENT
|
132
|
-
Rails.application.config.assets.paths << Rails.root.join('node_modules/openseadragon/build/openseadragon/images')
|
133
|
-
Rails.application.config.assets.paths << Rails.root.join('node_modules/openseadragon/build/openseadragon')
|
134
|
-
CONTENT
|
135
|
-
end
|
136
|
-
|
137
|
-
append_to_file 'app/assets/config/manifest.js', "//= link_tree ../../../node_modules/openseadragon/build/openseadragon/images\n"
|
138
|
-
|
139
|
-
inject_into_file 'app/controllers/application_controller.rb', after: 'class ApplicationController < ActionController::Base' do
|
140
|
-
"\n helper Openseadragon::OpenseadragonHelper\n"
|
141
|
-
end
|
142
|
-
end
|
143
|
-
|
144
122
|
def add_oembed
|
145
123
|
unless Bundler.locked_gems.dependencies.key? 'blacklight-oembed'
|
146
124
|
gem 'blacklight-oembed', '~> 1.0'
|
@@ -148,12 +126,6 @@ module Spotlight
|
|
148
126
|
end
|
149
127
|
generate 'blacklight_oembed:install'
|
150
128
|
copy_file 'config/initializers/oembed.rb'
|
151
|
-
|
152
|
-
return unless defined?(Sprockets)
|
153
|
-
|
154
|
-
# Use the rolled up assets from blacklight-oembed for sprockets
|
155
|
-
gsub_file 'app/assets/javascripts/blacklight_oembed.js', "import oembed from 'blacklight_oembed/oembed'",
|
156
|
-
'//= require blacklight_oembed/oembed'
|
157
129
|
end
|
158
130
|
|
159
131
|
def add_mailer_defaults
|
@@ -38,7 +38,7 @@ module Spotlight
|
|
38
38
|
<%= f.text_field :url %>
|
39
39
|
<div class="form-actions">
|
40
40
|
<div class="primary-actions">
|
41
|
-
<%= cancel_link @resource, :back, class: 'btn btn-
|
41
|
+
<%= cancel_link @resource, :back, class: 'btn btn-primary' %>
|
42
42
|
<%= f.submit t('.add_item'), class: 'btn btn-primary' %>
|
43
43
|
</div>
|
44
44
|
</div>
|
@@ -0,0 +1 @@
|
|
1
|
+
export default window.jQuery;
|
data/lib/spotlight/engine.rb
CHANGED
@@ -7,19 +7,15 @@ require 'devise'
|
|
7
7
|
require 'devise_invitable'
|
8
8
|
|
9
9
|
require 'activejob-status'
|
10
|
-
require 'autoprefixer-rails'
|
11
10
|
require 'blacklight'
|
12
|
-
require 'clipboard/rails'
|
13
11
|
require 'faraday'
|
14
12
|
require 'faraday/follow_redirects'
|
15
13
|
require 'friendly_id'
|
16
14
|
require 'i18n/active_record'
|
17
|
-
require 'leaflet-rails'
|
18
15
|
require 'paper_trail'
|
19
16
|
require 'riiif'
|
20
17
|
require 'spotlight/riiif_service'
|
21
18
|
require 'spotlight/upload_field_config'
|
22
|
-
require 'tophat'
|
23
19
|
|
24
20
|
module Spotlight
|
25
21
|
##
|
@@ -33,7 +29,7 @@ module Spotlight
|
|
33
29
|
require 'github/markup'
|
34
30
|
require 'openseadragon'
|
35
31
|
|
36
|
-
config.assets.precompile += %w[spotlight/fallback/*.png]
|
32
|
+
config.assets.precompile += %w[spotlight/fallback/*.png] if defined?(Sprockets)
|
37
33
|
|
38
34
|
config.autoload_paths += %W[
|
39
35
|
#{config.root}/app/builders
|
@@ -70,7 +66,10 @@ module Spotlight
|
|
70
66
|
end
|
71
67
|
|
72
68
|
initializer 'spotlight.importmap', before: 'importmap' do |app|
|
73
|
-
|
69
|
+
if app.config.respond_to?(:importmap)
|
70
|
+
app.config.importmap.paths << Engine.root.join('config/importmap.rb')
|
71
|
+
app.config.importmap.cache_sweepers << Engine.root.join('app/javascript')
|
72
|
+
end
|
74
73
|
end
|
75
74
|
|
76
75
|
def self.user_class
|
@@ -192,6 +191,7 @@ module Spotlight
|
|
192
191
|
ActiveSupport::Reloader.to_prepare do
|
193
192
|
Spotlight::Engine.config.spotlight = OpenStruct.new
|
194
193
|
Spotlight::Engine.config.spotlight.header_navigation_link_component = Spotlight::HeaderNavigationLinkComponent
|
194
|
+
Spotlight::Engine.config.spotlight.title_component = Spotlight::TitleComponent
|
195
195
|
end
|
196
196
|
end
|
197
197
|
|
@@ -275,6 +275,7 @@ module Spotlight
|
|
275
275
|
|
276
276
|
Blacklight::Configuration.default_values[:search_state_fields] ||= []
|
277
277
|
Blacklight::Configuration.default_values[:search_state_fields] += %i[id exhibit_id browse_category_id]
|
278
|
+
Blacklight::Configuration.default_values[:skip_link_component] = Spotlight::SkipLinkComponent
|
278
279
|
end
|
279
280
|
else
|
280
281
|
config.to_prepare do
|
data/lib/spotlight/version.rb
CHANGED
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CapybaraWaitMetadataHelper
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
around do |example|
|
8
|
+
using_wait_time example.metadata[:max_wait_time] || Capybara.default_max_wait_time do
|
9
|
+
example.run
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -3,38 +3,19 @@
|
|
3
3
|
module Spotlight
|
4
4
|
module TestFeaturesHelpers
|
5
5
|
def fill_in_typeahead_field(opts = {})
|
6
|
-
type = opts[:type] || '
|
7
|
-
# Poltergeist / Capybara doesn't fire the events typeahead.js
|
8
|
-
# is listening for, so we help it out a little:
|
9
|
-
page.execute_script <<-EOF
|
10
|
-
$("[data-#{type}-typeahead]:visible").val("#{opts[:with]}").trigger("input");
|
11
|
-
$("[data-#{type}-typeahead]:visible").typeahead("open");
|
12
|
-
$(".tt-suggestion").click();
|
13
|
-
EOF
|
6
|
+
type = opts[:type] || 'default'
|
14
7
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
# For typeahead "prefetched" fields, we need to wait for a resolved selector
|
20
|
-
# before proceeding.
|
21
|
-
def fill_in_prefetched_typeahead_field(opts)
|
22
|
-
type = opts[:type] || 'twitter'
|
23
|
-
# Poltergeist / Capybara doesn't fire the events typeahead.js
|
24
|
-
# is listening for, so we help it out a little:
|
25
|
-
find(opts[:wait_for]) if opts[:wait_for]
|
26
|
-
page.execute_script <<-EOF
|
27
|
-
$("[data-#{type}-typeahead]:visible").val("#{opts[:with]}").trigger("input");
|
28
|
-
$("[data-#{type}-typeahead]:visible").typeahead("open");
|
29
|
-
$(".tt-suggestion").click();
|
30
|
-
EOF
|
8
|
+
# Role=combobox indicates that the auto-complete is initialized
|
9
|
+
expect(page).to have_css("auto-complete [data-#{type}-typeahead][role='combobox']")
|
10
|
+
find("auto-complete [data-#{type}-typeahead]").fill_in(with: opts[:with])
|
11
|
+
find('auto-complete[open] [role="option"]', text: opts[:with], match: :first).click
|
31
12
|
end
|
32
13
|
|
33
14
|
# just like #fill_in_typeahead_field, but wait for the
|
34
|
-
# form fields to show up on the page too
|
15
|
+
# form fields/thumbnail preview to show up on the page too
|
35
16
|
def fill_in_solr_document_block_typeahead_field(opts)
|
36
17
|
fill_in_typeahead_field(opts)
|
37
|
-
expect(page).to have_css('li[data-resource-id="' + opts[:with] + '"]')
|
18
|
+
expect(page).to have_css('li[data-resource-id="' + opts[:with] + '"] .img-thumbnail[src^="http"]')
|
38
19
|
end
|
39
20
|
|
40
21
|
def add_widget(type)
|
@@ -54,12 +35,17 @@ module Spotlight
|
|
54
35
|
first('.st-block-replacer').click
|
55
36
|
end
|
56
37
|
|
38
|
+
def wait_for_sir_trevor
|
39
|
+
expect(page).to have_selector('.st-blocks.st-ready')
|
40
|
+
sleep 1
|
41
|
+
end
|
42
|
+
|
57
43
|
def save_page_changes
|
58
|
-
|
59
|
-
SirTrevor.getInstance().onFormSubmit();
|
60
|
-
EOF
|
44
|
+
wait_for_sir_trevor
|
61
45
|
click_button('Save changes')
|
62
|
-
#
|
46
|
+
# Load bearing sleep. Remove or reduce at your own risk. Revisit if Sir Trevor is removed.
|
47
|
+
sleep 3 if ENV['CI']
|
48
|
+
# verify that the page was created.
|
63
49
|
expect(page).to have_no_selector('.alert-danger')
|
64
50
|
expect(page).to have_selector('.alert-info', text: 'page was successfully updated')
|
65
51
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
// Includes an unreleased RTL support pull request: https://github.com/ganlanyuan/tiny-slider/pull/658
|
2
|
+
// Includes "export default tns" at the end of the file for spotlight/user/browse_group_categories.js
|
2
3
|
var tns = (function (){
|
3
4
|
var win = window;
|
4
5
|
|
@@ -3216,3 +3217,5 @@ var tns = function(options) {
|
|
3216
3217
|
|
3217
3218
|
return tns;
|
3218
3219
|
})();
|
3220
|
+
|
3221
|
+
export default tns;
|