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,37 +0,0 @@
|
|
1
|
-
module Spotlight
|
2
|
-
##
|
3
|
-
# JCrop options helpers
|
4
|
-
module JcropHelper
|
5
|
-
def default_masthead_jcrop_options
|
6
|
-
{
|
7
|
-
croppable: true,
|
8
|
-
selector: 'masthead_image',
|
9
|
-
bg_color: 'black',
|
10
|
-
bg_opacity: '.4',
|
11
|
-
aspect_ratio: 10,
|
12
|
-
box_width: '600',
|
13
|
-
initial_set_select: '[0, 0, 1800, 180]'
|
14
|
-
}
|
15
|
-
end
|
16
|
-
|
17
|
-
def default_thumbnail_jcrop_options
|
18
|
-
w, h = Spotlight::Engine.config.featured_image_thumb_size
|
19
|
-
|
20
|
-
{
|
21
|
-
croppable: true,
|
22
|
-
selector: 'featuredimage_image',
|
23
|
-
bg_color: 'black',
|
24
|
-
bg_opacity: '.4',
|
25
|
-
box_width: '600',
|
26
|
-
aspect_ratio: w.to_f / h.to_f,
|
27
|
-
initial_set_select: '[0, 0, 100000, 100000]'
|
28
|
-
}
|
29
|
-
end
|
30
|
-
|
31
|
-
def default_site_thumbnail_jcrop_options
|
32
|
-
w, h = Spotlight::Engine.config.featured_image_square_size
|
33
|
-
|
34
|
-
default_thumbnail_jcrop_options.merge(aspect_ratio: w.to_f / h.to_f)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
module Spotlight
|
2
|
-
###
|
3
|
-
# Simple concern to mixin to classes that
|
4
|
-
# fetches a default thumbnail after creation
|
5
|
-
# Classes that mixin this module should implement
|
6
|
-
# a set_default_thumbnail method themselves
|
7
|
-
###
|
8
|
-
module DefaultThumbnailable
|
9
|
-
extend ActiveSupport::Concern
|
10
|
-
|
11
|
-
included do
|
12
|
-
after_create(:fetch_default_thumb_later) if respond_to?(:after_create)
|
13
|
-
end
|
14
|
-
|
15
|
-
private
|
16
|
-
|
17
|
-
def fetch_default_thumb_later
|
18
|
-
DefaultThumbnailJob.perform_later(self)
|
19
|
-
end
|
20
|
-
|
21
|
-
def set_default_thumbnail
|
22
|
-
raise NotImplementedError
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,58 +0,0 @@
|
|
1
|
-
module Spotlight
|
2
|
-
###
|
3
|
-
# Include Spotlight::ImageDerivatives in a class or module to get
|
4
|
-
# the derivative configurations in #spotlight_image_derivatives.
|
5
|
-
# A new derivative could theoretically be added by putting the
|
6
|
-
# following in an initializer.
|
7
|
-
# Spotlight::ImageDerivatives.spotlight_image_derivatives << {
|
8
|
-
# version: :my_version,
|
9
|
-
# field: :my_field,
|
10
|
-
# lambda: lambda {|_|
|
11
|
-
# version :my_version do
|
12
|
-
# process :resize_to_fill => [30,30]
|
13
|
-
# end
|
14
|
-
# }
|
15
|
-
# }
|
16
|
-
#
|
17
|
-
# This will then create that new CarrierWave version in any class that extends this module
|
18
|
-
# and calls the apply_spotlight_image_derivative_versions class method described below.
|
19
|
-
module ImageDerivatives
|
20
|
-
mattr_accessor :spotlight_image_derivatives
|
21
|
-
|
22
|
-
# Extend Spotlight::ImageDerivatives in a CarrierWave uploader
|
23
|
-
# then you can call this as a class method and all of the
|
24
|
-
# configured versions will be available
|
25
|
-
def apply_spotlight_image_derivative_versions
|
26
|
-
spotlight_image_derivatives.each do |version_config|
|
27
|
-
if (c = version_config[:lambda]).present?
|
28
|
-
class_eval(&c)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
# Set default derivative configurations
|
34
|
-
self.spotlight_image_derivatives ||= [
|
35
|
-
{
|
36
|
-
field: Spotlight::Engine.config.try(:full_image_field)
|
37
|
-
},
|
38
|
-
{
|
39
|
-
version: :thumb,
|
40
|
-
field: Spotlight::Engine.config.try(:thumbnail_field),
|
41
|
-
lambda: lambda do |_|
|
42
|
-
version :thumb do
|
43
|
-
process resize_to_fit: [400, 400]
|
44
|
-
end
|
45
|
-
end
|
46
|
-
},
|
47
|
-
{
|
48
|
-
version: :square,
|
49
|
-
field: Spotlight::Engine.config.try(:square_image_field),
|
50
|
-
lambda: lambda do |_|
|
51
|
-
version :square do
|
52
|
-
process resize_to_fill: [100, 100]
|
53
|
-
end
|
54
|
-
end
|
55
|
-
}
|
56
|
-
].reject { |v| v[:field].blank? }
|
57
|
-
end
|
58
|
-
end
|
@@ -1,55 +0,0 @@
|
|
1
|
-
###
|
2
|
-
# Simple concern mixed into SolrDocument to create
|
3
|
-
# a mapping of configured Spotlight::ImageDerivatives
|
4
|
-
# to their configured fields in the SolrDocument.
|
5
|
-
# Any derivatives configured (descibed in Spotlight::ImageDerivatives)
|
6
|
-
# will be available under #spotlight_image_versions and an array of available versions
|
7
|
-
# (regardless of their is related data in the document) in the #spotlight_image_versions#versions array.
|
8
|
-
###
|
9
|
-
module Spotlight
|
10
|
-
module SolrDocument
|
11
|
-
##
|
12
|
-
# Spotlight image derivatives helpers
|
13
|
-
module SpotlightImages
|
14
|
-
def spotlight_image_versions
|
15
|
-
@spotlight_image_versions ||= Versions.new(self)
|
16
|
-
end
|
17
|
-
|
18
|
-
##
|
19
|
-
# Spotlight image derivivative class
|
20
|
-
class Versions
|
21
|
-
include Spotlight::ImageDerivatives
|
22
|
-
attr_reader :versions, :document
|
23
|
-
|
24
|
-
def initialize(document)
|
25
|
-
@document = document
|
26
|
-
@versions = spotlight_image_derivatives.map do |derivative|
|
27
|
-
version = version_name(derivative)
|
28
|
-
self.class.send(:define_method, version) do
|
29
|
-
Array.wrap(document.fetch(derivative[:field], []))
|
30
|
-
end
|
31
|
-
version
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def image_versions(*args)
|
36
|
-
send(args.first).each_with_index.map do |_img, i|
|
37
|
-
args.each_with_object({}) do |version, hash|
|
38
|
-
hash[version] = send(version)[i]
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
private
|
44
|
-
|
45
|
-
def version_name(derivative)
|
46
|
-
derivative[:version] || default_version_name
|
47
|
-
end
|
48
|
-
|
49
|
-
def default_version_name
|
50
|
-
:full
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
module Spotlight
|
2
|
-
##
|
3
|
-
# Exhibit contact profile pictures
|
4
|
-
class AvatarUploader < CarrierWave::Uploader::Base
|
5
|
-
include CarrierWave::MiniMagick
|
6
|
-
|
7
|
-
storage Spotlight::Engine.config.uploader_storage
|
8
|
-
|
9
|
-
version :thumb do
|
10
|
-
process crop: :avatar ## Crops this version based on original image
|
11
|
-
resize_to_limit(70, 70)
|
12
|
-
end
|
13
|
-
|
14
|
-
# Override the directory where uploaded files will be stored.
|
15
|
-
# This is a sensible default for uploaders that are meant to be mounted:
|
16
|
-
def store_dir
|
17
|
-
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
|
18
|
-
end
|
19
|
-
|
20
|
-
def default_url
|
21
|
-
ActionController::Base.helpers.image_path('spotlight/fallback/' + [version_name, 'default.png'].compact.join('_'))
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
module Spotlight
|
3
|
-
##
|
4
|
-
# Uploaded resource image attachments, downloaded locally for cropping and
|
5
|
-
# representation. See {Spotlight::Resource::Upload}
|
6
|
-
class ItemUploader < CarrierWave::Uploader::Base
|
7
|
-
include CarrierWave::MiniMagick
|
8
|
-
extend Spotlight::ImageDerivatives
|
9
|
-
storage Spotlight::Engine.config.uploader_storage
|
10
|
-
|
11
|
-
apply_spotlight_image_derivative_versions
|
12
|
-
|
13
|
-
def extension_white_list
|
14
|
-
Spotlight::Engine.config.allowed_upload_extensions
|
15
|
-
end
|
16
|
-
|
17
|
-
def store_dir
|
18
|
-
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
|
19
|
-
end
|
20
|
-
|
21
|
-
def default_url
|
22
|
-
ActionController::Base.helpers.image_path('spotlight/fallback/' + [version_name, 'default.png'].compact.join('_'))
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
module Spotlight
|
3
|
-
##
|
4
|
-
# Exhibit and browse category custom mastheads
|
5
|
-
class MastheadUploader < CarrierWave::Uploader::Base
|
6
|
-
include CarrierWave::MiniMagick
|
7
|
-
storage Spotlight::Engine.config.uploader_storage
|
8
|
-
|
9
|
-
version :cropped do
|
10
|
-
process crop: :image ## Crops this version based on original image
|
11
|
-
process resize_to_fill: [1800, 180]
|
12
|
-
end
|
13
|
-
|
14
|
-
def store_dir
|
15
|
-
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
|
16
|
-
end
|
17
|
-
|
18
|
-
def default_url
|
19
|
-
ActionController::Base.helpers.image_path('spotlight/fallback/' + [version_name, 'default.png'].compact.join('_'))
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
describe Spotlight::JcropHelper do
|
2
|
-
describe '.default_thumbnail_jcrop_options' do
|
3
|
-
it 'produces a 4:3 aspect ratio by default' do
|
4
|
-
expect(helper.default_thumbnail_jcrop_options[:aspect_ratio]).to eq 4.0 / 3.0
|
5
|
-
end
|
6
|
-
|
7
|
-
context 'with a custom thumbnail size' do
|
8
|
-
before do
|
9
|
-
allow(Spotlight::Engine.config).to receive(:featured_image_thumb_size).and_return([7, 5])
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'produces a 7:5 aspect ratio' do
|
13
|
-
expect(helper.default_thumbnail_jcrop_options[:aspect_ratio]).to eq 7.0 / 5.0
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
describe '.default_site_thumbnail_jcrop_options' do
|
19
|
-
it 'produces a 1:1 aspect ratio by default' do
|
20
|
-
expect(helper.default_site_thumbnail_jcrop_options[:aspect_ratio]).to eq 1
|
21
|
-
end
|
22
|
-
|
23
|
-
context 'with a custom square thumbnail size' do
|
24
|
-
before do
|
25
|
-
allow(Spotlight::Engine.config).to receive(:featured_image_square_size).and_return([3, 2])
|
26
|
-
end
|
27
|
-
|
28
|
-
it 'produces a 3:2 aspect ratio' do
|
29
|
-
expect(helper.default_site_thumbnail_jcrop_options[:aspect_ratio]).to eq 3.0 / 2.0
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
describe Spotlight::DefaultThumbnailable do
|
2
|
-
let(:test_class) { Class.new }
|
3
|
-
subject { test_class.new }
|
4
|
-
before { subject.extend(described_class) }
|
5
|
-
|
6
|
-
it 'invokes DefaultThumbnailJob job' do
|
7
|
-
expect(Spotlight::DefaultThumbnailJob).to receive(:perform_later).with(subject)
|
8
|
-
subject.send(:fetch_default_thumb_later)
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'raises a NotImplementedError if the class does not have a set_default_thumbnail method' do
|
12
|
-
expect do
|
13
|
-
subject.send(:set_default_thumbnail)
|
14
|
-
end.to raise_error(NotImplementedError)
|
15
|
-
end
|
16
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
class TestSpotlightImageDerivatives
|
2
|
-
include Spotlight::ImageDerivatives
|
3
|
-
end
|
4
|
-
|
5
|
-
describe Spotlight::ImageDerivatives do
|
6
|
-
let(:subject) { TestSpotlightImageDerivatives.new }
|
7
|
-
describe '#spotlight_image_derivatives' do
|
8
|
-
it 'includes default derivatives' do
|
9
|
-
expect(subject.spotlight_image_derivatives.length).to eq 3
|
10
|
-
expect(subject.spotlight_image_derivatives.map do |d|
|
11
|
-
d[:field]
|
12
|
-
end).to eq [Spotlight::Engine.config.full_image_field, Spotlight::Engine.config.thumbnail_field, Spotlight::Engine.config.square_image_field]
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
|
2
|
-
describe Spotlight::SolrDocument::SpotlightImages do
|
3
|
-
subject do
|
4
|
-
SolrDocument.new(
|
5
|
-
Spotlight::Engine.config.full_image_field => ['http://lorempixel.com/800/500/'],
|
6
|
-
Spotlight::Engine.config.thumbnail_field => ['http://lorempixel.com/400/240/'],
|
7
|
-
Spotlight::Engine.config.square_image_field => ['http://lorempixel.com/200/200/']
|
8
|
-
)
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'is a Versions class' do
|
12
|
-
expect(subject.spotlight_image_versions).to be_a Spotlight::SolrDocument::SpotlightImages::Versions
|
13
|
-
end
|
14
|
-
it 'maps image urls in the document to the appropriate version' do
|
15
|
-
expect(subject.spotlight_image_versions.full).to eq ['http://lorempixel.com/800/500/']
|
16
|
-
expect(subject.spotlight_image_versions.thumb).to eq ['http://lorempixel.com/400/240/']
|
17
|
-
expect(subject.spotlight_image_versions.square).to eq ['http://lorempixel.com/200/200/']
|
18
|
-
end
|
19
|
-
it 'includes the version keys in the versions array' do
|
20
|
-
[:full, :thumb, :square].each do |version|
|
21
|
-
expect(subject.spotlight_image_versions.versions).to include version
|
22
|
-
end
|
23
|
-
end
|
24
|
-
it 'includes newly configured image versions' do
|
25
|
-
Spotlight::ImageDerivatives.spotlight_image_derivatives << {
|
26
|
-
version: :tiny,
|
27
|
-
field: :new_image_field
|
28
|
-
}
|
29
|
-
subject = SolrDocument.new(new_image_field: ['abc'])
|
30
|
-
expect(subject.spotlight_image_versions.tiny).to eq ['abc']
|
31
|
-
Spotlight::ImageDerivatives.spotlight_image_derivatives.delete_if do |d|
|
32
|
-
d[:version] == :tiny
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
it 'gracefully handles missing data' do
|
37
|
-
subject = SolrDocument.new Spotlight::Engine.config.full_image_field => ['http://lorempixel.com/800/500/']
|
38
|
-
expect(subject.spotlight_image_versions.full).to eq ['http://lorempixel.com/800/500/']
|
39
|
-
expect(subject.spotlight_image_versions.thumb).to be_empty
|
40
|
-
expect(subject.spotlight_image_versions.square).to be_empty
|
41
|
-
end
|
42
|
-
end
|
@@ -1,67 +0,0 @@
|
|
1
|
-
require 'carrierwave/test/matchers'
|
2
|
-
|
3
|
-
describe Spotlight::ItemUploader do
|
4
|
-
include CarrierWave::Test::Matchers
|
5
|
-
let(:exhibit) { FactoryGirl.create(:exhibit) }
|
6
|
-
let(:resource) { stub_model(Spotlight::Resources::Upload) }
|
7
|
-
before do
|
8
|
-
allow(resource).to receive(:exhibit).and_return(exhibit)
|
9
|
-
described_class.enable_processing = true
|
10
|
-
end
|
11
|
-
after do
|
12
|
-
described_class.enable_processing = false
|
13
|
-
end
|
14
|
-
describe 'default configuration' do
|
15
|
-
subject do
|
16
|
-
described_class.new(resource, :resource)
|
17
|
-
end
|
18
|
-
|
19
|
-
before do
|
20
|
-
subject.store!(File.open(File.expand_path(File.join('..', 'spec', 'fixtures', '800x600.png'), Rails.root)))
|
21
|
-
end
|
22
|
-
|
23
|
-
after do
|
24
|
-
subject.remove!
|
25
|
-
end
|
26
|
-
|
27
|
-
context 'the thumb version' do
|
28
|
-
it 'scales down an image so that the longest edge is 400px (maintaining aspect ratio)' do
|
29
|
-
expect(subject.thumb).to have_dimensions(400, 300)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
context 'the square version' do
|
34
|
-
it 'scales down a landscape image to fit within 100px by 100px' do
|
35
|
-
expect(subject.square).to be_no_larger_than(100, 100)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
describe 'with added configurations' do
|
40
|
-
subject do
|
41
|
-
described_class.new(resource, :resource)
|
42
|
-
end
|
43
|
-
|
44
|
-
before do
|
45
|
-
Spotlight::ImageDerivatives.spotlight_image_derivatives << {
|
46
|
-
version: :super_tiny,
|
47
|
-
blacklight_config_field: :super_tiny_field,
|
48
|
-
lambda: lambda do
|
49
|
-
version :super_tiny do
|
50
|
-
process resize_to_fill: [25, 25]
|
51
|
-
end
|
52
|
-
end
|
53
|
-
}
|
54
|
-
subject.store!(File.open(File.expand_path(File.join('..', 'spec', 'fixtures', '800x600.png'), Rails.root)))
|
55
|
-
end
|
56
|
-
|
57
|
-
after do
|
58
|
-
subject.remove!
|
59
|
-
end
|
60
|
-
|
61
|
-
context 'the newly configured version' do
|
62
|
-
pending 'should have the newly configured dimensions' do
|
63
|
-
expect(subject.super_tiny).to have_dimensions(25, 25)
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|