blacklight-spotlight 0.32.0 → 0.33.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -0
- data/app/assets/images/spotlight/default_browse_thumbnail.jpg +0 -0
- data/app/assets/javascripts/spotlight/application.js +6 -1
- data/app/assets/javascripts/spotlight/blocks/pages_block.js +1 -1
- data/app/assets/javascripts/spotlight/blocks/resources_block.js +7 -4
- data/app/assets/javascripts/spotlight/blocks/solr_documents_base_block.js +108 -0
- data/app/assets/javascripts/spotlight/blocks/solr_documents_block.js +12 -56
- data/app/assets/javascripts/spotlight/blocks/solr_documents_carousel_block.js +3 -3
- data/app/assets/javascripts/spotlight/blocks/solr_documents_embed_block.js +3 -3
- data/app/assets/javascripts/spotlight/blocks/solr_documents_features_block.js +3 -3
- data/app/assets/javascripts/spotlight/blocks/solr_documents_grid_block.js +3 -3
- data/app/assets/javascripts/spotlight/crop.es6 +205 -0
- data/app/assets/javascripts/spotlight/croppable.js +7 -104
- data/app/assets/javascripts/spotlight/iiif.es6 +54 -0
- data/app/assets/javascripts/spotlight/multi_image_selector.js +34 -16
- data/app/assets/javascripts/spotlight/pages.js.erb +1 -1
- data/app/assets/javascripts/spotlight/reindex_monitor.js +5 -1
- data/app/assets/javascripts/spotlight/search_typeahead.js +33 -47
- data/app/assets/javascripts/spotlight/sir-trevor/locales.js +5 -2
- data/app/assets/javascripts/spotlight/zpr_links.js.erb +30 -0
- data/app/assets/stylesheets/spotlight/_croppable.scss +8 -13
- data/app/assets/stylesheets/spotlight/_multi_image_selector.scss +1 -1
- data/app/assets/stylesheets/spotlight/_pages.scss +5 -0
- data/app/assets/stylesheets/spotlight/typeahead.css +0 -1
- data/app/controllers/concerns/spotlight/base.rb +3 -5
- data/app/controllers/spotlight/appearances_controller.rb +6 -4
- data/app/controllers/spotlight/catalog_controller.rb +10 -0
- data/app/controllers/spotlight/contacts_controller.rb +2 -6
- data/app/controllers/spotlight/featured_images_controller.rb +26 -0
- data/app/controllers/spotlight/pages_controller.rb +3 -2
- data/app/controllers/spotlight/resources/iiif_harvester_controller.rb +10 -0
- data/app/controllers/spotlight/resources/upload_controller.rb +4 -3
- data/app/controllers/spotlight/searches_controller.rb +20 -6
- data/app/controllers/spotlight/sites_controller.rb +2 -5
- data/app/helpers/spotlight/application_helper.rb +14 -1
- data/app/helpers/spotlight/crop_helper.rb +37 -0
- data/app/helpers/spotlight/main_app_helpers.rb +13 -0
- data/app/helpers/spotlight/meta_helper.rb +10 -20
- data/app/models/concerns/spotlight/solr_document.rb +1 -2
- data/app/models/concerns/spotlight/solr_document/uploaded_resource.rb +1 -23
- data/app/models/sir_trevor_rails/blocks/browse_block.rb +10 -0
- data/app/models/sir_trevor_rails/blocks/featured_pages_block.rb +10 -0
- data/app/models/sir_trevor_rails/blocks/solr_documents_block.rb +5 -0
- data/app/models/spotlight/analytics/ga.rb +1 -1
- data/app/models/spotlight/blacklight_configuration.rb +16 -8
- data/app/models/spotlight/contact.rb +2 -13
- data/app/models/spotlight/contact_image.rb +11 -0
- data/app/models/spotlight/exhibit.rb +11 -8
- data/app/models/spotlight/exhibit_thumbnail.rb +12 -0
- data/app/models/spotlight/feature_page.rb +3 -5
- data/app/models/spotlight/featured_image.rb +28 -9
- data/app/models/spotlight/home_page.rb +2 -0
- data/app/models/spotlight/masthead.rb +5 -11
- data/app/models/spotlight/page.rb +5 -0
- data/app/models/spotlight/reindex_progress.rb +10 -18
- data/app/models/spotlight/reindexing_log_entry.rb +1 -0
- data/app/models/spotlight/resources/iiif_harvester.rb +33 -0
- data/app/models/spotlight/resources/iiif_manifest.rb +211 -0
- data/app/models/spotlight/resources/iiif_service.rb +93 -0
- data/app/models/spotlight/resources/upload.rb +1 -2
- data/app/models/spotlight/search.rb +5 -34
- data/app/presenters/spotlight/iiif_manifest_presenter.rb +79 -0
- data/app/serializers/spotlight/exhibit_export_serializer.rb +9 -41
- data/app/services/spotlight/carrierwave_file_resolver.rb +3 -1
- data/app/services/spotlight/iiif_resource_resolver.rb +73 -0
- data/app/services/spotlight/resources/iiif_builder.rb +17 -0
- data/app/services/spotlight/upload_solr_document_builder.rb +23 -23
- data/app/uploaders/spotlight/attachment_uploader.rb +0 -48
- data/app/uploaders/spotlight/featured_image_uploader.rb +2 -16
- data/app/views/_user_util_links.html.erb +8 -5
- data/app/views/catalog/_save_search.html.erb +4 -2
- data/app/views/layouts/spotlight/spotlight.html.erb +5 -1
- data/app/views/shared/_masthead.html.erb +1 -1
- data/app/views/spotlight/about_pages/_contact_properties.html.erb +1 -1
- data/app/views/spotlight/appearances/edit.html.erb +26 -6
- data/app/views/spotlight/browse/_search.html.erb +1 -1
- data/app/views/spotlight/contacts/_form.html.erb +12 -7
- data/app/views/spotlight/dashboards/_reindexing_activity.html.erb +1 -1
- data/app/views/spotlight/exhibits/_exhibit_card_front.html.erb +2 -2
- data/app/views/spotlight/featured_images/_form.html.erb +12 -15
- data/app/views/spotlight/featured_images/_upload_form.html.erb +6 -12
- data/app/views/spotlight/metadata_configurations/_metadata_field.html.erb +3 -3
- data/app/views/spotlight/pages/_form.html.erb +3 -3
- data/app/views/spotlight/pages/edit.html.erb +4 -2
- data/app/views/spotlight/resources/iiif/_form.html.erb +9 -0
- data/app/views/spotlight/searches/_form.html.erb +3 -3
- data/app/views/spotlight/searches/_search.html.erb +4 -2
- data/app/views/spotlight/sir_trevor/blocks/_browse_block.html.erb +2 -2
- data/app/views/spotlight/sir_trevor/blocks/_featured_pages_block.html.erb +1 -1
- data/app/views/spotlight/sir_trevor/blocks/_solr_documents_block.html.erb +7 -2
- data/app/views/spotlight/sir_trevor/blocks/_solr_documents_carousel_block.html.erb +4 -2
- data/app/views/spotlight/sir_trevor/blocks/_solr_documents_features_block.html.erb +4 -2
- data/app/views/spotlight/sir_trevor/blocks/_solr_documents_grid_block.html.erb +4 -2
- data/app/views/spotlight/sites/edit.html.erb +1 -1
- data/config/locales/spotlight.en.yml +31 -6
- data/config/routes.rb +9 -0
- data/db/migrate/20160714144125_add_iiif_urls_to_featured_image.rb +9 -0
- data/db/migrate/20160718194010_add_iiif_url_to_contact.rb +6 -0
- data/db/migrate/20160805143841_add_upload_id_to_resources.rb +6 -0
- data/db/migrate/20170204091234_add_theme_to_spotlight_exhibits.rb +5 -0
- data/lib/generators/spotlight/install_generator.rb +5 -2
- data/lib/generators/spotlight/templates/config/initializers/spotlight_initializer.rb +0 -1
- data/lib/generators/spotlight/templates/spotlight.scss +3 -2
- data/lib/migration/iiif.rb +82 -0
- data/lib/spotlight/engine.rb +22 -10
- data/lib/spotlight/version.rb +1 -1
- data/lib/tasks/spotlight_tasks.rake +10 -0
- data/spec/controllers/spotlight/about_pages_controller_spec.rb +1 -1
- data/spec/controllers/spotlight/appearances_controller_spec.rb +31 -18
- data/spec/controllers/spotlight/catalog_controller_spec.rb +40 -0
- data/spec/controllers/spotlight/contacts_controller_spec.rb +20 -1
- data/spec/controllers/spotlight/feature_pages_controller_spec.rb +2 -6
- data/spec/controllers/spotlight/featured_images_controller_spec.rb +74 -0
- data/spec/controllers/spotlight/home_pages_controller_spec.rb +1 -1
- data/spec/controllers/spotlight/searches_controller_spec.rb +3 -1
- data/spec/controllers/spotlight/sites_controller_spec.rb +6 -1
- data/spec/examples.txt +1118 -1059
- data/spec/factories/contact_images.rb +6 -0
- data/spec/factories/contacts.rb +4 -1
- data/spec/factories/exhibit_thumbnails.rb +6 -0
- data/spec/factories/exhibits.rb +4 -0
- data/spec/factories/featured_images.rb +1 -0
- data/spec/factories/resources.rb +2 -1
- data/spec/features/add_contacts_spec.rb +5 -5
- data/spec/features/add_iiif_manifest_spec.rb +41 -0
- data/spec/features/add_items_spec.rb +2 -2
- data/spec/features/autocomplete_typeahead_spec.rb +86 -0
- data/spec/features/browse_category_admin_spec.rb +27 -6
- data/spec/features/browse_category_spec.rb +2 -2
- data/spec/features/create_exhibit_spec.rb +3 -3
- data/spec/features/exhibit_masthead_spec.rb +20 -9
- data/spec/features/exhibit_themes_spec.rb +25 -0
- data/spec/features/home_page_spec.rb +1 -1
- data/spec/features/javascript/blocks/solr_documents_block_spec.rb +42 -0
- data/spec/features/javascript/blocks/uploaded_items_block_spec.rb +5 -3
- data/spec/features/javascript/feature_page_admin_spec.rb +1 -1
- data/spec/features/javascript/multi_image_select_spec.rb +5 -6
- data/spec/features/javascript/search_config_admin_spec.rb +1 -1
- data/spec/features/site_masthead_spec.rb +14 -4
- data/spec/fixtures/gk446cj2442-manifest.json +58 -0
- data/spec/fixtures/iiif_responses.rb +274 -0
- data/spec/fixtures/sample_solr_documents.yml +106 -0
- data/spec/helpers/spotlight/crop_helper_spec.rb +9 -0
- data/spec/helpers/spotlight/main_app_helpers_spec.rb +45 -0
- data/spec/helpers/spotlight/meta_helper_spec.rb +2 -15
- data/spec/lib/migration/iiif_spec.rb +70 -0
- data/spec/models/spotlight/blacklight_configuration_spec.rb +17 -5
- data/spec/models/spotlight/contact_image_spec.rb +9 -0
- data/spec/models/spotlight/exhibit_spec.rb +17 -20
- data/spec/models/spotlight/exhibit_thumbnail_spec.rb +8 -0
- data/spec/models/spotlight/featured_image_spec.rb +59 -10
- data/spec/models/spotlight/masthead_spec.rb +33 -17
- data/spec/models/spotlight/page_spec.rb +14 -0
- data/spec/models/spotlight/reindex_progress_spec.rb +22 -73
- data/spec/models/spotlight/resources/iiif_harvester_spec.rb +30 -0
- data/spec/models/spotlight/resources/iiif_manifest_spec.rb +107 -0
- data/spec/models/spotlight/resources/iiif_service_spec.rb +52 -0
- data/spec/models/spotlight/resources/upload_spec.rb +7 -3
- data/spec/models/spotlight/search_spec.rb +0 -45
- data/spec/models/spotlight/solr_document/uploaded_resource_spec.rb +11 -29
- data/spec/presenters/spotlight/iiif_manifest_presenter_spec.rb +123 -0
- data/spec/routing/spotlight/exhibit_catalog_spec.rb +4 -0
- data/spec/routing/spotlight/featured_images_spec.rb +21 -0
- data/spec/serializers/spotlight/exhibit_export_serializer_spec.rb +15 -18
- data/spec/services/spotlight/iiif_resource_resolver_spec.rb +90 -0
- data/spec/spec_helper.rb +3 -0
- data/spec/support/features/test_features_helpers.rb +3 -2
- data/spec/support/stub_iiif_response.rb +24 -0
- data/spec/support/views/test_view_helpers.rb +1 -0
- data/spec/test_app_templates/Gemfile.extra +0 -1
- data/spec/uploaders/spotlight/attachment_uploader_spec.rb +24 -0
- data/spec/uploaders/spotlight/featured_image_uploader_spec.rb +30 -0
- data/spec/views/_user_util_links.html.erb_spec.rb +9 -5
- data/spec/views/shared/_masthead.html.erb_spec.rb +5 -2
- data/spec/views/spotlight/browse/_search.html.erb_spec.rb +2 -2
- data/spec/views/spotlight/contacts/edit.html.erb_spec.rb +4 -7
- data/spec/views/spotlight/metadata_configurations/_metadata_field.html.erb_spec.rb +7 -2
- data/spec/views/spotlight/pages/edit.html.erb_spec.rb +3 -1
- data/spec/views/spotlight/pages/new.html.erb_spec.rb +3 -1
- data/spec/views/spotlight/searches/_search.html.erb_spec.rb +3 -2
- data/spec/views/spotlight/searches/edit.html.erb_spec.rb +3 -2
- data/vendor/assets/javascripts/leaflet-areaselect.js +184 -0
- data/vendor/assets/javascripts/leaflet-iiif.js +230 -0
- data/vendor/assets/javascripts/leaflet.js +9 -0
- data/vendor/assets/javascripts/polyfill.min.js +4 -0
- data/vendor/assets/stylesheets/leaflet-areaselect.css +15 -0
- data/vendor/assets/stylesheets/leaflet.css +624 -0
- metadata +136 -62
- data/app/assets/javascripts/spotlight/jcrop.js +0 -1696
- data/app/helpers/spotlight/jcrop_helper.rb +0 -37
- data/app/models/concerns/spotlight/default_thumbnailable.rb +0 -25
- data/app/models/concerns/spotlight/image_derivatives.rb +0 -58
- data/app/models/concerns/spotlight/solr_document/spotlight_images.rb +0 -55
- data/app/uploaders/spotlight/avatar_uploader.rb +0 -24
- data/app/uploaders/spotlight/item_uploader.rb +0 -25
- data/app/uploaders/spotlight/masthead_uploader.rb +0 -22
- data/spec/helpers/spotlight/jcrop_helper_spec.rb +0 -33
- data/spec/models/spotlight/default_thumbnailable_concern_spec.rb +0 -16
- data/spec/models/spotlight/image_derivatives_spec.rb +0 -15
- data/spec/models/spotlight/solr_document/spotlight_images_spec.rb +0 -42
- data/spec/uploaders/spotlight/item_uploader_spec.rb +0 -67
@@ -1,16 +1,11 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
}
|
5
|
-
.form-group.croppable-loading-area {
|
6
|
-
min-height: 100px;
|
7
|
-
margin: ($padding-large-vertical * 2) $padding-large-vertical;
|
1
|
+
.leaflet-container {
|
2
|
+
height: 400px;
|
3
|
+
margin: 0;
|
8
4
|
}
|
9
5
|
|
10
|
-
.
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
6
|
+
.leaflet-areaselect-container {
|
7
|
+
height: 100%;
|
8
|
+
position: absolute;
|
9
|
+
width: 100%;
|
10
|
+
z-index: 800;
|
15
11
|
}
|
16
|
-
|
@@ -108,6 +108,7 @@
|
|
108
108
|
float: left;
|
109
109
|
margin-right: 15px;
|
110
110
|
margin-top: 3px;
|
111
|
+
max-height: 70px;
|
111
112
|
}
|
112
113
|
|
113
114
|
// Indent contact fields so they align evenly, only when there is a contact photo
|
@@ -288,3 +289,7 @@
|
|
288
289
|
padding-left: 2 * $padding-large-horizontal;
|
289
290
|
padding-right: 2 * $padding-large-horizontal;
|
290
291
|
}
|
292
|
+
|
293
|
+
.zpr-link {
|
294
|
+
@extend .btn-sm;
|
295
|
+
}
|
@@ -24,14 +24,12 @@ module Spotlight
|
|
24
24
|
id: doc.id,
|
25
25
|
title: CGI.unescapeHTML(view_context.presenter(doc).heading.to_str),
|
26
26
|
thumbnail: doc.first(blacklight_config.index.thumbnail_field),
|
27
|
-
|
28
|
-
full_image_url: doc.spotlight_image_versions.try(:full).try(:first),
|
29
|
-
full_images: doc.spotlight_image_versions.try(:full),
|
30
|
-
image_versions: doc.spotlight_image_versions.image_versions(:thumb, :full),
|
27
|
+
full_image_url: doc.first(Spotlight::Engine.config.full_image_field),
|
31
28
|
description: doc.id,
|
32
29
|
url: polymorphic_path([current_exhibit, doc]),
|
33
30
|
private: doc.private?(current_exhibit),
|
34
|
-
global_id: doc.to_global_id.to_s
|
31
|
+
global_id: doc.to_global_id.to_s,
|
32
|
+
iiif_manifest: doc[Spotlight::Engine.config.iiif_manifest_field]
|
35
33
|
}
|
36
34
|
end
|
37
35
|
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
|
@@ -23,19 +23,21 @@ module Spotlight
|
|
23
23
|
protected
|
24
24
|
|
25
25
|
def exhibit_params
|
26
|
-
params.require(:exhibit).permit(
|
26
|
+
params.require(:exhibit).permit(:theme,
|
27
|
+
main_navigations_attributes: [:id, :display, :label, :weight],
|
27
28
|
masthead_attributes: featured_image_params,
|
28
29
|
thumbnail_attributes: featured_image_params)
|
29
30
|
end
|
30
31
|
|
31
32
|
def featured_image_params
|
32
33
|
[
|
34
|
+
:iiif_region, :iiif_tilesource,
|
35
|
+
:iiif_manifest_url, :iiif_canvas_id,
|
36
|
+
:iiif_image_id,
|
33
37
|
:display,
|
34
38
|
:source,
|
35
39
|
:image,
|
36
|
-
:
|
37
|
-
:document_global_id,
|
38
|
-
:image_crop_x, :image_crop_y, :image_crop_w, :image_crop_h
|
40
|
+
:document_global_id
|
39
41
|
]
|
40
42
|
end
|
41
43
|
end
|
@@ -109,6 +109,16 @@ module Spotlight
|
|
109
109
|
end
|
110
110
|
end
|
111
111
|
|
112
|
+
def manifest
|
113
|
+
_, document = fetch params[:id]
|
114
|
+
|
115
|
+
if document.uploaded_resource?
|
116
|
+
render json: Spotlight::IiifManifestPresenter.new(document, self).iiif_manifest_json
|
117
|
+
else
|
118
|
+
head :not_found
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
112
122
|
protected
|
113
123
|
|
114
124
|
# TODO: move this out of app/helpers/blacklight/catalog_helper_behavior.rb and into blacklight/catalog.rb
|
@@ -47,12 +47,8 @@ module Spotlight
|
|
47
47
|
|
48
48
|
def contact_params
|
49
49
|
params.require(:contact).permit(:name,
|
50
|
-
:
|
51
|
-
:
|
52
|
-
:avatar_crop_y,
|
53
|
-
:avatar_crop_w,
|
54
|
-
:avatar_crop_h,
|
55
|
-
contact_info: Spotlight::Contact.fields.keys)
|
50
|
+
contact_info: Spotlight::Contact.fields.keys,
|
51
|
+
avatar_attributes: [:iiif_tilesource, :iiif_region])
|
56
52
|
end
|
57
53
|
end
|
58
54
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Spotlight
|
2
|
+
# Handles requests to upload images for exhibit thumbnails
|
3
|
+
class FeaturedImagesController < Spotlight::ApplicationController
|
4
|
+
load_and_authorize_resource instance_name: :featured_image
|
5
|
+
|
6
|
+
def create
|
7
|
+
if @featured_image.save && @featured_image.file_present?
|
8
|
+
render json: { tilesource: tilesource, id: @featured_image.id }
|
9
|
+
else
|
10
|
+
render json: { error: 'unable to create image' }, status: :bad_request
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def tilesource
|
17
|
+
riiif.info_url(@featured_image.id)
|
18
|
+
end
|
19
|
+
|
20
|
+
# The create action can be called from a number of different forms, so
|
21
|
+
# we normalize all the parameters.
|
22
|
+
def create_params
|
23
|
+
params.require(:featured_image).permit(:image)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -4,6 +4,7 @@ module Spotlight
|
|
4
4
|
class PagesController < Spotlight::ApplicationController
|
5
5
|
before_action :authenticate_user!, except: [:show]
|
6
6
|
load_and_authorize_resource :exhibit, class: Spotlight::Exhibit
|
7
|
+
load_and_authorize_resource through: :exhibit, instance_name: 'page', only: [:index]
|
7
8
|
|
8
9
|
helper Openseadragon::OpenseadragonHelper
|
9
10
|
include Spotlight::Base
|
@@ -115,8 +116,8 @@ module Spotlight
|
|
115
116
|
|
116
117
|
def featured_image_attributes
|
117
118
|
[
|
118
|
-
:source, :image, :
|
119
|
-
:
|
119
|
+
:source, :image, :document_global_id, :iiif_region, :iiif_tilesource,
|
120
|
+
:iiif_manifest_url, :iiif_canvas_id, :iiif_image_id
|
120
121
|
]
|
121
122
|
end
|
122
123
|
|
@@ -13,9 +13,10 @@ module Spotlight
|
|
13
13
|
|
14
14
|
load_and_authorize_resource class: 'Spotlight::Resources::Upload', through_association: 'exhibit.resources', instance_name: 'resource'
|
15
15
|
|
16
|
-
# rubocop:disable Metrics/MethodLength
|
16
|
+
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
17
17
|
def create
|
18
18
|
@resource.attributes = resource_params
|
19
|
+
@resource.build_upload(image: params[:resources_upload][:url])
|
19
20
|
|
20
21
|
if @resource.save_and_index
|
21
22
|
flash[:notice] = t('spotlight.resources.upload.success')
|
@@ -29,7 +30,7 @@ module Spotlight
|
|
29
30
|
redirect_to admin_exhibit_catalog_path(@resource.exhibit, sort: :timestamp)
|
30
31
|
end
|
31
32
|
end
|
32
|
-
# rubocop:enable Metrics/MethodLength
|
33
|
+
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
|
33
34
|
|
34
35
|
private
|
35
36
|
|
@@ -38,7 +39,7 @@ module Spotlight
|
|
38
39
|
end
|
39
40
|
|
40
41
|
def resource_params
|
41
|
-
params.require(:resources_upload).permit(
|
42
|
+
params.require(:resources_upload).permit(data: data_param_keys)
|
42
43
|
end
|
43
44
|
|
44
45
|
def data_param_keys
|
@@ -2,17 +2,19 @@ module Spotlight
|
|
2
2
|
##
|
3
3
|
# CRUD actions for curating browse categories (see
|
4
4
|
# {Spotlight::BrowseController} for the end-user read and index actions)
|
5
|
+
# rubocop:disable Metrics/ClassLength
|
5
6
|
class SearchesController < Spotlight::ApplicationController
|
6
7
|
load_resource :exhibit, class: 'Spotlight::Exhibit'
|
7
8
|
before_action :authenticate_user!
|
8
9
|
before_action :only_curators!
|
10
|
+
before_action :create_or_load_resource, only: [:create]
|
9
11
|
load_and_authorize_resource through: :exhibit
|
10
12
|
before_action :attach_breadcrumbs, only: [:index, :edit], unless: -> { request.format.json? }
|
11
13
|
|
12
14
|
include Spotlight::Base
|
13
15
|
|
14
16
|
def create
|
15
|
-
@search.
|
17
|
+
@search.assign_attributes(search_params.except((:title unless @search.new_record?)))
|
16
18
|
@search.query_params = query_params
|
17
19
|
|
18
20
|
if @search.save
|
@@ -99,8 +101,8 @@ module Spotlight
|
|
99
101
|
:title,
|
100
102
|
:long_description,
|
101
103
|
:default_index_view_type,
|
102
|
-
masthead_attributes:
|
103
|
-
thumbnail_attributes:
|
104
|
+
masthead_attributes: featured_image_params,
|
105
|
+
thumbnail_attributes: featured_image_params
|
104
106
|
)
|
105
107
|
end
|
106
108
|
|
@@ -108,8 +110,15 @@ module Spotlight
|
|
108
110
|
params.to_unsafe_h.with_indifferent_access.except(:exhibit_id, :search, *blacklisted_search_session_params).reject { |_k, v| v.blank? }
|
109
111
|
end
|
110
112
|
|
111
|
-
def
|
112
|
-
[
|
113
|
+
def featured_image_params
|
114
|
+
[
|
115
|
+
:iiif_region, :iiif_tilesource,
|
116
|
+
:iiif_manifest_url, :iiif_canvas_id, :iiif_image_id,
|
117
|
+
:display,
|
118
|
+
:source,
|
119
|
+
:image,
|
120
|
+
:document_global_id
|
121
|
+
]
|
113
122
|
end
|
114
123
|
|
115
124
|
def only_curators!
|
@@ -117,11 +126,16 @@ module Spotlight
|
|
117
126
|
end
|
118
127
|
|
119
128
|
def blacklisted_search_session_params
|
120
|
-
[:commit, :counter, :total, :search_id, :page, :per_page, :authenticity_token, :utf8, :action, :controller]
|
129
|
+
[:id, :commit, :counter, :total, :search_id, :page, :per_page, :authenticity_token, :utf8, :action, :controller]
|
121
130
|
end
|
122
131
|
|
123
132
|
def fallback_url
|
124
133
|
spotlight.exhibit_searches_path(current_exhibit)
|
125
134
|
end
|
135
|
+
|
136
|
+
def create_or_load_resource
|
137
|
+
@search = current_exhibit.searches.find(params[:id]) if params[:id].present?
|
138
|
+
end
|
126
139
|
end
|
140
|
+
# rubocop:enable Metrics/ClassLength
|
127
141
|
end
|
@@ -4,8 +4,8 @@ module Spotlight
|
|
4
4
|
module ApplicationHelper
|
5
5
|
include CrudLinkHelpers
|
6
6
|
include TitleHelper
|
7
|
-
include JcropHelper
|
8
7
|
include MetaHelper
|
8
|
+
include CropHelper
|
9
9
|
|
10
10
|
##
|
11
11
|
# Give the application name a chance to include the exhibit title
|
@@ -132,6 +132,19 @@ module Spotlight
|
|
132
132
|
current_exhibit.blacklight_configuration.default_blacklight_config.view.to_h.reject { |_k, v| v.if == false }
|
133
133
|
end
|
134
134
|
|
135
|
+
def exhibit_stylesheet_link_tag(tag)
|
136
|
+
if current_exhibit_theme && current_exhibit.theme != 'default'
|
137
|
+
stylesheet_link_tag "#{tag}_#{current_exhibit_theme}"
|
138
|
+
else
|
139
|
+
Rails.logger.warn "Exhibit theme '#{current_exhibit_theme}' not in white-list of available themes: #{Spotlight::Engine.config.exhibit_themes}"
|
140
|
+
stylesheet_link_tag(tag)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
def current_exhibit_theme
|
145
|
+
current_exhibit.theme if current_exhibit && current_exhibit.theme.present? && Spotlight::Engine.config.exhibit_themes.include?(current_exhibit.theme)
|
146
|
+
end
|
147
|
+
|
135
148
|
private
|
136
149
|
|
137
150
|
def main_app_url_helper?(method)
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Spotlight
|
2
|
+
##
|
3
|
+
# iiif-crop options helpers
|
4
|
+
module CropHelper
|
5
|
+
def iiif_cropper_tags(f, initial_crop_selection:)
|
6
|
+
content_tag(:div) do
|
7
|
+
concat f.hidden_field(:iiif_manifest_url)
|
8
|
+
concat f.hidden_field(:iiif_canvas_id)
|
9
|
+
concat f.hidden_field(:iiif_image_id)
|
10
|
+
concat f.hidden_field(:iiif_region)
|
11
|
+
concat f.hidden_field(:iiif_tilesource)
|
12
|
+
concat iiif_cropper_tag(f, initial_crop_selection: initial_crop_selection)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def iiif_cropper_tag(f, initial_crop_selection:)
|
17
|
+
content_tag :div, '', id: "#{form_prefix(f)}_iiif_cropper", data: {
|
18
|
+
behavior: 'iiif-cropper',
|
19
|
+
cropper_key: f.object.model_name.singular_route_key,
|
20
|
+
'crop-width': initial_crop_selection.first,
|
21
|
+
'crop-height': initial_crop_selection.last
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
def iiif_upload_tag(f)
|
26
|
+
f.file_field_without_bootstrap :file, name: 'featured_image[image]', data: { endpoint: polymorphic_path(f.object.model_name.route_key) }
|
27
|
+
end
|
28
|
+
|
29
|
+
def form_prefix(f)
|
30
|
+
if Rails::VERSION::MAJOR >= 5
|
31
|
+
f.object_name.parameterize(separator: '_')
|
32
|
+
else
|
33
|
+
f.object_name.parameterize('_')
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -34,5 +34,18 @@ module Spotlight
|
|
34
34
|
show_presenter(document)
|
35
35
|
end
|
36
36
|
end
|
37
|
+
|
38
|
+
def exhibit_stylesheet_link_tag(tag)
|
39
|
+
if current_exhibit_theme && current_exhibit.theme != 'default'
|
40
|
+
stylesheet_link_tag "#{tag}_#{current_exhibit_theme}"
|
41
|
+
else
|
42
|
+
Rails.logger.warn "Exhibit theme '#{current_exhibit_theme}' not in white-list of available themes: #{Spotlight::Engine.config.exhibit_themes}"
|
43
|
+
stylesheet_link_tag(tag)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def current_exhibit_theme
|
48
|
+
current_exhibit.theme if current_exhibit && current_exhibit.theme.present? && Spotlight::Engine.config.exhibit_themes.include?(current_exhibit.theme)
|
49
|
+
end
|
37
50
|
end
|
38
51
|
end
|
@@ -11,14 +11,18 @@ module Spotlight
|
|
11
11
|
card.url exhibit_root_url(current_exhibit)
|
12
12
|
card.title current_exhibit.title
|
13
13
|
card.description current_exhibit.subtitle
|
14
|
-
card.image
|
14
|
+
card.image meta_image if current_exhibit.thumbnail
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
+
def meta_image
|
19
|
+
current_exhibit.thumbnail.iiif_url
|
20
|
+
end
|
21
|
+
|
18
22
|
def exhibit_opengraph_content
|
19
23
|
opengraph do |graph|
|
20
24
|
graph.title current_exhibit.title
|
21
|
-
graph.image
|
25
|
+
graph.image meta_image if current_exhibit.thumbnail
|
22
26
|
graph.site_name site_title
|
23
27
|
end
|
24
28
|
end
|
@@ -31,7 +35,7 @@ module Spotlight
|
|
31
35
|
def page_twitter_card_content(page)
|
32
36
|
twitter_card('summary_large_image') do |card|
|
33
37
|
card.title page.title
|
34
|
-
card.image
|
38
|
+
card.image page.thumbnail.iiif_url if page.thumbnail
|
35
39
|
end
|
36
40
|
end
|
37
41
|
|
@@ -40,7 +44,7 @@ module Spotlight
|
|
40
44
|
graph.type 'article'
|
41
45
|
graph.site_name application_name
|
42
46
|
graph.title page.title
|
43
|
-
graph.send('og:image',
|
47
|
+
graph.send('og:image', page.thumbnail.iiif_url) if page.thumbnail
|
44
48
|
graph.send('article:published_time', page.created_at.iso8601)
|
45
49
|
graph.send('article:modified_time', page.updated_at.iso8601)
|
46
50
|
end
|
@@ -54,7 +58,7 @@ module Spotlight
|
|
54
58
|
def browse_twitter_card_content(browse)
|
55
59
|
twitter_card('summary_large_image') do |card|
|
56
60
|
card.title browse.title
|
57
|
-
card.image
|
61
|
+
card.image browse.thumbnail.iiif_url if browse.thumbnail
|
58
62
|
end
|
59
63
|
end
|
60
64
|
|
@@ -63,7 +67,7 @@ module Spotlight
|
|
63
67
|
graph.type 'article'
|
64
68
|
graph.site_name application_name
|
65
69
|
graph.title browse.title
|
66
|
-
graph.send('og:image',
|
70
|
+
graph.send('og:image', browse.thumbnail.iiif_url) if browse.thumbnail
|
67
71
|
graph.send('article:published_time', browse.created_at.iso8601)
|
68
72
|
graph.send('article:modified_time', browse.updated_at.iso8601)
|
69
73
|
end
|
@@ -92,19 +96,5 @@ module Spotlight
|
|
92
96
|
graph.send('og:image', document.first(blacklight_config.index.thumbnail_field))
|
93
97
|
end
|
94
98
|
end
|
95
|
-
|
96
|
-
private
|
97
|
-
|
98
|
-
def carrierwave_url(upload)
|
99
|
-
# Carrierwave's #url returns either a full url (if asset path was configured)
|
100
|
-
# or just the path to the image. We'll try to normalize it to a url.
|
101
|
-
url = upload.url
|
102
|
-
|
103
|
-
if url.nil? || url.starts_with?('http')
|
104
|
-
url
|
105
|
-
else
|
106
|
-
(URI.parse(Rails.application.config.asset_host || root_url) + url).to_s
|
107
|
-
end
|
108
|
-
end
|
109
99
|
end
|
110
100
|
end
|