blacklight-spotlight 0.8.0 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/spotlight/application.js +1 -0
- data/app/assets/javascripts/spotlight/exhibits.js +15 -1
- data/app/assets/stylesheets/spotlight/_browse.scss +8 -4
- data/app/controllers/spotlight/exhibits_controller.rb +1 -1
- data/app/jobs/spotlight/default_thumbnail_job.rb +14 -0
- data/app/models/concerns/spotlight/default_thumbnailable.rb +25 -0
- data/app/models/spotlight/exhibit.rb +6 -0
- data/app/models/spotlight/featured_image.rb +14 -5
- data/app/models/spotlight/search.rb +14 -11
- data/app/serializers/spotlight/featured_image_representer.rb +2 -0
- data/app/views/spotlight/exhibits/_exhibit_card.html.erb +1 -1
- data/app/views/spotlight/exhibits/_exhibit_list.html.erb +3 -0
- data/app/views/spotlight/exhibits/index.html.erb +9 -0
- data/config/locales/spotlight.en.yml +2 -0
- data/lib/spotlight/version.rb +1 -1
- data/spec/features/create_exhibit_spec.rb +16 -0
- data/spec/features/exhibits_index_spec.rb +1 -1
- data/spec/features/import_exhibit_spec.rb +0 -1
- data/spec/jobs/spotlight/default_thumbnail_job_spec.rb +13 -0
- data/spec/models/spotlight/default_thumbnailable_concern_spec.rb +18 -0
- data/spec/models/spotlight/exhibit_spec.rb +17 -0
- data/spec/models/spotlight/search_spec.rb +20 -11
- data/spec/serializers/spotlight/exhibit_export_serializer_spec.rb +26 -0
- data/spec/views/spotlight/exhibits/index.html.erb_spec.rb +16 -1
- data/vendor/assets/javascripts/parameterize.js +137 -0
- metadata +9 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79f3c55215f17eb642d2939afb0a526090b929ae
|
4
|
+
data.tar.gz: 73621327bd47b37ef54c0a083cfd3efdbe170223
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30ec54bcc766d93a529f47cfdec4ccef3dd0fc5fe1f361dea825c4020fab77c9b5de4268801c850e4706bf7167312f870517a09191bdc6492d9ef14b275bc966
|
7
|
+
data.tar.gz: 8e01d90acd6a9c838d8cfe59d18caa50dbe02a39f5838af87b4764c798911b82da81b97bb3cdaee2c5e8bb917567fc3e7b718ad54d724bdfa831b5cfddf80a42
|
@@ -1,4 +1,18 @@
|
|
1
1
|
Spotlight.onLoad(function() {
|
2
|
+
|
3
|
+
// auto-fill the exhibit slug on the new exhibit form
|
4
|
+
$('#new_exhibit').each(function() {
|
5
|
+
$('#exhibit_title').on('change keyup', function() {
|
6
|
+
$('#exhibit_slug').attr('placeholder', URLify($(this).val(), $(this).val().length));
|
7
|
+
});
|
8
|
+
|
9
|
+
$('#exhibit_slug').on('focus', function() {
|
10
|
+
if ($(this).val() === '') {
|
11
|
+
$(this).val($(this).attr('placeholder'));
|
12
|
+
}
|
13
|
+
});
|
14
|
+
});
|
15
|
+
|
2
16
|
$("#another-email").on("click", function() {
|
3
17
|
var container = $(this).closest('.form-group');
|
4
18
|
var contacts = container.find('.contact');
|
@@ -24,5 +38,5 @@ Spotlight.onLoad(function() {
|
|
24
38
|
// Put focus in saved search title input when Save this search modal is shown
|
25
39
|
$('#save-modal').on('shown.bs.modal', function () {
|
26
40
|
$('#search_title').focus();
|
27
|
-
})
|
41
|
+
});
|
28
42
|
});
|
@@ -25,13 +25,17 @@ $image-overlay-bottom-margin: $padding-large-vertical * 3;
|
|
25
25
|
}
|
26
26
|
|
27
27
|
.image-overlay {
|
28
|
-
|
29
|
-
|
28
|
+
border: 2px solid $gray-light;
|
29
|
+
border-radius: $border-radius-large;
|
30
30
|
margin-bottom: $image-overlay-bottom-margin;
|
31
31
|
max-height: 240px;
|
32
|
-
|
33
|
-
border: 2px solid $gray-light;
|
32
|
+
min-height: 140px;
|
34
33
|
overflow: hidden;
|
34
|
+
position: relative;
|
35
|
+
|
36
|
+
img {
|
37
|
+
width: 100%;
|
38
|
+
}
|
35
39
|
}
|
36
40
|
|
37
41
|
.text-overlay {
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Spotlight
|
2
|
+
###
|
3
|
+
# Calls the #set_default_thumbnail method
|
4
|
+
# on the object passed in and calls save
|
5
|
+
###
|
6
|
+
class DefaultThumbnailJob < ActiveJob::Base
|
7
|
+
queue_as :default
|
8
|
+
|
9
|
+
def perform(thumbnailable)
|
10
|
+
thumbnailable.set_default_thumbnail
|
11
|
+
thumbnailable.save
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,25 @@
|
|
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
|
+
fail NotImplementedError
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -7,6 +7,7 @@ module Spotlight
|
|
7
7
|
include Spotlight::ExhibitDocuments
|
8
8
|
|
9
9
|
scope :published, -> { where(published: true) }
|
10
|
+
scope :unpublished, -> { where(published: false) }
|
10
11
|
|
11
12
|
extend FriendlyId
|
12
13
|
friendly_id :title, use: [:slugged, :finders]
|
@@ -49,6 +50,7 @@ module Spotlight
|
|
49
50
|
after_create :initialize_config
|
50
51
|
after_create :initialize_browse
|
51
52
|
after_create :initialize_main_navigation
|
53
|
+
include Spotlight::DefaultThumbnailable
|
52
54
|
|
53
55
|
scope :published, -> { where(published: true) }
|
54
56
|
|
@@ -85,6 +87,10 @@ module Spotlight
|
|
85
87
|
blacklight_config.search_fields.any? { |_k, v| v.enabled && v.include_in_simple_select != false }
|
86
88
|
end
|
87
89
|
|
90
|
+
def set_default_thumbnail
|
91
|
+
self.thumbnail ||= searches.first.try(:thumbnail)
|
92
|
+
end
|
93
|
+
|
88
94
|
protected
|
89
95
|
|
90
96
|
def initialize_config
|
@@ -4,11 +4,7 @@ module Spotlight
|
|
4
4
|
class FeaturedImage < ActiveRecord::Base
|
5
5
|
mount_uploader :image, Spotlight::FeaturedImageUploader
|
6
6
|
|
7
|
-
before_validation
|
8
|
-
if document && document.uploaded_resource?
|
9
|
-
self.image = document.uploaded_resource.url.file
|
10
|
-
end
|
11
|
-
end
|
7
|
+
before_validation :set_image_from_uploaded_resource
|
12
8
|
|
13
9
|
after_save do
|
14
10
|
if image.present?
|
@@ -33,6 +29,19 @@ module Spotlight
|
|
33
29
|
end
|
34
30
|
|
35
31
|
@document ||= GlobalID::Locator.locate document_global_id
|
32
|
+
|
33
|
+
rescue Blacklight::Exceptions::RecordNotFound => e
|
34
|
+
Rails.logger.info("Exception fetching record by id: #{document_global_id}")
|
35
|
+
Rails.logger.info(e)
|
36
|
+
|
37
|
+
nil
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def set_image_from_uploaded_resource
|
43
|
+
return unless document && document.uploaded_resource?
|
44
|
+
self.image = document.uploaded_resource.url.file
|
36
45
|
end
|
37
46
|
end
|
38
47
|
end
|
@@ -2,6 +2,7 @@ module Spotlight
|
|
2
2
|
##
|
3
3
|
# Exhibit saved searches
|
4
4
|
class Search < ActiveRecord::Base
|
5
|
+
include DefaultThumbnailable
|
5
6
|
extend FriendlyId
|
6
7
|
friendly_id :title, use: [:slugged, :scoped, :finders, :history], scope: :exhibit
|
7
8
|
|
@@ -18,8 +19,6 @@ module Spotlight
|
|
18
19
|
accepts_nested_attributes_for :thumbnail, update_only: true
|
19
20
|
accepts_nested_attributes_for :masthead, update_only: true
|
20
21
|
|
21
|
-
before_create :set_default_featured_image
|
22
|
-
|
23
22
|
include Blacklight::SearchHelper
|
24
23
|
include Spotlight::Catalog::AccessControlsEnforcement
|
25
24
|
|
@@ -55,6 +54,19 @@ module Spotlight
|
|
55
54
|
masthead && masthead.display?
|
56
55
|
end
|
57
56
|
|
57
|
+
def set_default_thumbnail
|
58
|
+
self.thumbnail ||= begin
|
59
|
+
doc = documents.detect { |x| x.first(Spotlight::Engine.config.full_image_field) }
|
60
|
+
if doc
|
61
|
+
create_thumbnail(
|
62
|
+
source: 'exhibit',
|
63
|
+
document_global_id: doc.to_global_id.to_s,
|
64
|
+
remote_image_url: doc.first(Spotlight::Engine.config.full_image_field)
|
65
|
+
)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
58
70
|
private
|
59
71
|
|
60
72
|
def solr_response
|
@@ -79,15 +91,6 @@ module Spotlight
|
|
79
91
|
title_changed?
|
80
92
|
end
|
81
93
|
|
82
|
-
def set_default_featured_image
|
83
|
-
self.thumbnail ||= begin
|
84
|
-
doc = documents.detect { |x| x.first(Spotlight::Engine.config.full_image_field) }
|
85
|
-
if doc
|
86
|
-
create_thumbnail source: 'exhibit', document_global_id: doc.to_global_id.to_s, remote_image_url: doc.first(Spotlight::Engine.config.full_image_field)
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
94
|
alias_method :current_exhibit, :exhibit
|
92
95
|
end
|
93
96
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<div class="col-xs-12 col-sm-4 exhibit-card">
|
2
2
|
<div class="flipper">
|
3
3
|
<div class="card-front card-face">
|
4
|
-
<%= image_tag(exhibit.thumbnail.image.url) if exhibit.thumbnail.present? %>
|
4
|
+
<%= image_tag(exhibit.thumbnail.image.cropped.url) if exhibit.thumbnail.present? %>
|
5
5
|
<h2 class="card-title"><%= exhibit.title %></h2>
|
6
6
|
</div>
|
7
7
|
<div class="card-back card-face">
|
@@ -10,6 +10,15 @@
|
|
10
10
|
</div>
|
11
11
|
<% end %>
|
12
12
|
<% end %>
|
13
|
+
|
14
|
+
<% private_exhibits = @exhibits.unpublished.accessible_by(current_ability) %>
|
15
|
+
|
16
|
+
<% if private_exhibits.any? %>
|
17
|
+
<h2><%= t(:'.private') %></h2>
|
18
|
+
<ul>
|
19
|
+
<%= render collection: private_exhibits, partial: 'exhibit_list', as: 'exhibit' %>
|
20
|
+
</ul>
|
21
|
+
<% end %>
|
13
22
|
</div>
|
14
23
|
|
15
24
|
<aside class="col-md-3">
|
data/lib/spotlight/version.rb
CHANGED
@@ -27,5 +27,21 @@ describe 'Create a new exhibit', type: :feature do
|
|
27
27
|
click_button 'Save'
|
28
28
|
|
29
29
|
expect(page).to have_content 'The exhibit was created.'
|
30
|
+
expect(Spotlight::Exhibit.last.slug).to eq 'my-exhibit-title'
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'allows admins to create a new exhibit with a slug' do
|
34
|
+
visit '/'
|
35
|
+
within '.dropdown-menu' do
|
36
|
+
click_link 'Create Exhibit'
|
37
|
+
end
|
38
|
+
|
39
|
+
fill_in 'Title', with: 'My exhibit title'
|
40
|
+
fill_in 'URL slug', with: 'custom-slug'
|
41
|
+
|
42
|
+
click_button 'Save'
|
43
|
+
|
44
|
+
expect(page).to have_content 'The exhibit was created.'
|
45
|
+
expect(Spotlight::Exhibit.last.slug).to eq 'custom-slug'
|
30
46
|
end
|
31
47
|
end
|
@@ -8,7 +8,7 @@ describe 'Exhibits index page', type: :feature do
|
|
8
8
|
it 'shows some cards for each published exhibit' do
|
9
9
|
visit spotlight.exhibits_path
|
10
10
|
|
11
|
-
within '.exhibit-card:first' do
|
11
|
+
within '.exhibit-card:first-child' do
|
12
12
|
expect(page).to have_selector 'h2', text: 'Some Exhibit Title'
|
13
13
|
end
|
14
14
|
end
|
@@ -31,7 +31,6 @@ the export option behind a bootstrap tab)))
|
|
31
31
|
end
|
32
32
|
|
33
33
|
it 'allows admins to import content into an exhibit' do
|
34
|
-
pending 'PhantomJS 2.0.0 is unable to upload files; see https://github.com/ariya/phantomjs/issues/12506'
|
35
34
|
visit spotlight.exhibit_home_page_path(exhibit, exhibit.home_page)
|
36
35
|
|
37
36
|
click_link user.email
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Spotlight::DefaultThumbnailJob do
|
4
|
+
let(:thumbnailable) { double('Thumbnailable') }
|
5
|
+
subject { described_class.new(thumbnailable) }
|
6
|
+
|
7
|
+
it 'calls #set_default_thumbnail on the object passed in and saves' do
|
8
|
+
expect(thumbnailable).to receive(:set_default_thumbnail)
|
9
|
+
expect(thumbnailable).to receive(:save)
|
10
|
+
|
11
|
+
subject.perform_now
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Spotlight::DefaultThumbnailable do
|
4
|
+
let(:test_class) { Class.new }
|
5
|
+
subject { test_class.new }
|
6
|
+
before { subject.extend(described_class) }
|
7
|
+
|
8
|
+
it 'invokes DefaultThumbnailJob job' do
|
9
|
+
expect(Spotlight::DefaultThumbnailJob).to receive(:perform_later).with(subject)
|
10
|
+
subject.send(:fetch_default_thumb_later)
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'raises a NotImplementedError if the class does not have a set_default_thumbnail method' do
|
14
|
+
expect do
|
15
|
+
subject.send(:set_default_thumbnail)
|
16
|
+
end.to raise_error(NotImplementedError)
|
17
|
+
end
|
18
|
+
end
|
@@ -47,6 +47,23 @@ describe Spotlight::Exhibit, type: :model do
|
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
|
+
context 'thumbnail' do
|
51
|
+
it 'calls DefaultThumbnailJob to fetch a default feature image' do
|
52
|
+
expect(Spotlight::DefaultThumbnailJob).to receive(:perform_later).with(subject.searches.first)
|
53
|
+
expect(Spotlight::DefaultThumbnailJob).to receive(:perform_later).with(subject)
|
54
|
+
subject.save!
|
55
|
+
end
|
56
|
+
|
57
|
+
context '#set_default_thumbnail' do
|
58
|
+
before { subject.save! }
|
59
|
+
it 'uses the thubmnail from the first search' do
|
60
|
+
subject.set_default_thumbnail
|
61
|
+
expect(subject.thumbnail).not_to be_nil
|
62
|
+
expect(subject.thumbnail).to eq subject.searches.first.thumbnail
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
50
67
|
describe '#main_navigations' do
|
51
68
|
subject { FactoryGirl.create(:exhibit, title: 'Sample') }
|
52
69
|
it 'has main navigations' do
|
@@ -17,18 +17,27 @@ describe Spotlight::Search, type: :model do
|
|
17
17
|
|
18
18
|
it { is_expected.to be_a Spotlight::Catalog::AccessControlsEnforcement }
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
end
|
20
|
+
context 'thumbnail' do
|
21
|
+
it 'calls DefaultThumbnailJob to fetch a default feature image' do
|
22
|
+
expect(Spotlight::DefaultThumbnailJob).to receive(:perform_later).with(subject)
|
23
|
+
subject.save!
|
24
|
+
end
|
26
25
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
26
|
+
context '#set_default_thumbnail' do
|
27
|
+
it 'has a default feature image' do
|
28
|
+
allow(subject).to receive_messages(documents: [document])
|
29
|
+
subject.set_default_thumbnail
|
30
|
+
expect(subject.thumbnail).not_to be_nil
|
31
|
+
expect(subject.thumbnail.image.path).to end_with 'default.jpg'
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'uses a document with an image for the default feature image' do
|
35
|
+
allow(subject).to receive_messages(documents: [document_without_an_image, document])
|
36
|
+
subject.set_default_thumbnail
|
37
|
+
expect(subject.thumbnail).not_to be_nil
|
38
|
+
expect(subject.thumbnail.image.path).to end_with 'default.jpg'
|
39
|
+
end
|
40
|
+
end
|
32
41
|
end
|
33
42
|
|
34
43
|
it 'has items' do
|
@@ -195,6 +195,32 @@ describe Spotlight::ExhibitExportSerializer do
|
|
195
195
|
expect(subject.searches.first.thumbnail).not_to be_blank
|
196
196
|
expect(subject.searches.first.thumbnail.image.file.path).not_to eq search.thumbnail.image.file.path
|
197
197
|
end
|
198
|
+
|
199
|
+
context 'without an attached image' do
|
200
|
+
before do
|
201
|
+
search.masthead.remove_image!
|
202
|
+
search.masthead.save
|
203
|
+
end
|
204
|
+
|
205
|
+
it 'copies the masthead without an image' do
|
206
|
+
expect(subject.searches.last.masthead).not_to be_blank
|
207
|
+
expect(subject.searches.last.masthead.image).to be_blank
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
context 'with a thumbnail from an uploaded resource' do
|
212
|
+
before do
|
213
|
+
search.masthead.document_global_id = SolrDocument.new(id: 'xyz').to_global_id
|
214
|
+
search.masthead.source = 'exhibit'
|
215
|
+
search.masthead.save
|
216
|
+
|
217
|
+
source_exhibit.reload
|
218
|
+
end
|
219
|
+
|
220
|
+
it 'copies the resource' do
|
221
|
+
expect(subject.searches.last.masthead).not_to be_blank
|
222
|
+
end
|
223
|
+
end
|
198
224
|
end
|
199
225
|
|
200
226
|
context 'with a masthead' do
|
@@ -3,10 +3,12 @@ require 'spec_helper'
|
|
3
3
|
module Spotlight
|
4
4
|
describe 'spotlight/exhibits/index', type: :view do
|
5
5
|
let(:exhibits) { Spotlight::Exhibit.none }
|
6
|
+
let(:ability) { ::Ability.new(user) }
|
7
|
+
let(:user) { ::User.new }
|
6
8
|
|
7
9
|
before do
|
8
10
|
assign(:exhibits, exhibits)
|
9
|
-
allow(view).to receive_messages(exhibit_path: '/')
|
11
|
+
allow(view).to receive_messages(exhibit_path: '/', current_ability: ability)
|
10
12
|
end
|
11
13
|
|
12
14
|
context 'with published exhibits' do
|
@@ -23,6 +25,19 @@ module Spotlight
|
|
23
25
|
expect(rendered).to have_text exhibit_a.title
|
24
26
|
expect(rendered).to have_text exhibit_b.title
|
25
27
|
expect(rendered).not_to have_text exhibit_c.title
|
28
|
+
|
29
|
+
expect(rendered).not_to include 'Private exhibits'
|
30
|
+
end
|
31
|
+
|
32
|
+
context 'with an authorized user' do
|
33
|
+
let(:user) { FactoryGirl.create(:site_admin) }
|
34
|
+
|
35
|
+
it 'includes a list of unpublished exhibits' do
|
36
|
+
render
|
37
|
+
|
38
|
+
expect(rendered).to include 'Private exhibits'
|
39
|
+
expect(rendered).to have_text exhibit_c.title
|
40
|
+
end
|
26
41
|
end
|
27
42
|
end
|
28
43
|
|
@@ -0,0 +1,137 @@
|
|
1
|
+
/*
|
2
|
+
https://gist.github.com/pjambet/3710461
|
3
|
+
*/
|
4
|
+
var LATIN_MAP = {
|
5
|
+
'À': 'A', 'Á': 'A', 'Â': 'A', 'Ã': 'A', 'Ä': 'A', 'Å': 'A', 'Æ': 'AE', 'Ç':
|
6
|
+
'C', 'È': 'E', 'É': 'E', 'Ê': 'E', 'Ë': 'E', 'Ì': 'I', 'Í': 'I', 'Î': 'I',
|
7
|
+
'Ï': 'I', 'Ð': 'D', 'Ñ': 'N', 'Ò': 'O', 'Ó': 'O', 'Ô': 'O', 'Õ': 'O', 'Ö':
|
8
|
+
'O', 'Ő': 'O', 'Ø': 'O', 'Ù': 'U', 'Ú': 'U', 'Û': 'U', 'Ü': 'U', 'Ű': 'U',
|
9
|
+
'Ý': 'Y', 'Þ': 'TH', 'ß': 'ss', 'à':'a', 'á':'a', 'â': 'a', 'ã': 'a', 'ä':
|
10
|
+
'a', 'å': 'a', 'æ': 'ae', 'ç': 'c', 'è': 'e', 'é': 'e', 'ê': 'e', 'ë': 'e',
|
11
|
+
'ì': 'i', 'í': 'i', 'î': 'i', 'ï': 'i', 'ð': 'd', 'ñ': 'n', 'ò': 'o', 'ó':
|
12
|
+
'o', 'ô': 'o', 'õ': 'o', 'ö': 'o', 'ő': 'o', 'ø': 'o', 'ù': 'u', 'ú': 'u',
|
13
|
+
'û': 'u', 'ü': 'u', 'ű': 'u', 'ý': 'y', 'þ': 'th', 'ÿ': 'y'
|
14
|
+
}
|
15
|
+
var LATIN_SYMBOLS_MAP = {
|
16
|
+
'©':'(c)'
|
17
|
+
}
|
18
|
+
var GREEK_MAP = {
|
19
|
+
'α':'a', 'β':'b', 'γ':'g', 'δ':'d', 'ε':'e', 'ζ':'z', 'η':'h', 'θ':'8',
|
20
|
+
'ι':'i', 'κ':'k', 'λ':'l', 'μ':'m', 'ν':'n', 'ξ':'3', 'ο':'o', 'π':'p',
|
21
|
+
'ρ':'r', 'σ':'s', 'τ':'t', 'υ':'y', 'φ':'f', 'χ':'x', 'ψ':'ps', 'ω':'w',
|
22
|
+
'ά':'a', 'έ':'e', 'ί':'i', 'ό':'o', 'ύ':'y', 'ή':'h', 'ώ':'w', 'ς':'s',
|
23
|
+
'ϊ':'i', 'ΰ':'y', 'ϋ':'y', 'ΐ':'i',
|
24
|
+
'Α':'A', 'Β':'B', 'Γ':'G', 'Δ':'D', 'Ε':'E', 'Ζ':'Z', 'Η':'H', 'Θ':'8',
|
25
|
+
'Ι':'I', 'Κ':'K', 'Λ':'L', 'Μ':'M', 'Ν':'N', 'Ξ':'3', 'Ο':'O', 'Π':'P',
|
26
|
+
'Ρ':'R', 'Σ':'S', 'Τ':'T', 'Υ':'Y', 'Φ':'F', 'Χ':'X', 'Ψ':'PS', 'Ω':'W',
|
27
|
+
'Ά':'A', 'Έ':'E', 'Ί':'I', 'Ό':'O', 'Ύ':'Y', 'Ή':'H', 'Ώ':'W', 'Ϊ':'I',
|
28
|
+
'Ϋ':'Y'
|
29
|
+
}
|
30
|
+
var TURKISH_MAP = {
|
31
|
+
'ş':'s', 'Ş':'S', 'ı':'i', 'İ':'I', 'ç':'c', 'Ç':'C', 'ü':'u', 'Ü':'U',
|
32
|
+
'ö':'o', 'Ö':'O', 'ğ':'g', 'Ğ':'G'
|
33
|
+
}
|
34
|
+
var RUSSIAN_MAP = {
|
35
|
+
'а':'a', 'б':'b', 'в':'v', 'г':'g', 'д':'d', 'е':'e', 'ё':'yo', 'ж':'zh',
|
36
|
+
'з':'z', 'и':'i', 'й':'j', 'к':'k', 'л':'l', 'м':'m', 'н':'n', 'о':'o',
|
37
|
+
'п':'p', 'р':'r', 'с':'s', 'т':'t', 'у':'u', 'ф':'f', 'х':'h', 'ц':'c',
|
38
|
+
'ч':'ch', 'ш':'sh', 'щ':'sh', 'ъ':'', 'ы':'y', 'ь':'', 'э':'e', 'ю':'yu',
|
39
|
+
'я':'ya',
|
40
|
+
'А':'A', 'Б':'B', 'В':'V', 'Г':'G', 'Д':'D', 'Е':'E', 'Ё':'Yo', 'Ж':'Zh',
|
41
|
+
'З':'Z', 'И':'I', 'Й':'J', 'К':'K', 'Л':'L', 'М':'M', 'Н':'N', 'О':'O',
|
42
|
+
'П':'P', 'Р':'R', 'С':'S', 'Т':'T', 'У':'U', 'Ф':'F', 'Х':'H', 'Ц':'C',
|
43
|
+
'Ч':'Ch', 'Ш':'Sh', 'Щ':'Sh', 'Ъ':'', 'Ы':'Y', 'Ь':'', 'Э':'E', 'Ю':'Yu',
|
44
|
+
'Я':'Ya'
|
45
|
+
}
|
46
|
+
var UKRAINIAN_MAP = {
|
47
|
+
'Є':'Ye', 'І':'I', 'Ї':'Yi', 'Ґ':'G', 'є':'ye', 'і':'i', 'ї':'yi', 'ґ':'g'
|
48
|
+
}
|
49
|
+
var CZECH_MAP = {
|
50
|
+
'č':'c', 'ď':'d', 'ě':'e', 'ň': 'n', 'ř':'r', 'š':'s', 'ť':'t', 'ů':'u',
|
51
|
+
'ž':'z', 'Č':'C', 'Ď':'D', 'Ě':'E', 'Ň': 'N', 'Ř':'R', 'Š':'S', 'Ť':'T',
|
52
|
+
'Ů':'U', 'Ž':'Z'
|
53
|
+
}
|
54
|
+
|
55
|
+
var POLISH_MAP = {
|
56
|
+
'ą':'a', 'ć':'c', 'ę':'e', 'ł':'l', 'ń':'n', 'ó':'o', 'ś':'s', 'ź':'z',
|
57
|
+
'ż':'z', 'Ą':'A', 'Ć':'C', 'Ę':'e', 'Ł':'L', 'Ń':'N', 'Ó':'o', 'Ś':'S',
|
58
|
+
'Ź':'Z', 'Ż':'Z'
|
59
|
+
}
|
60
|
+
|
61
|
+
var LATVIAN_MAP = {
|
62
|
+
'ā':'a', 'č':'c', 'ē':'e', 'ģ':'g', 'ī':'i', 'ķ':'k', 'ļ':'l', 'ņ':'n',
|
63
|
+
'š':'s', 'ū':'u', 'ž':'z', 'Ā':'A', 'Č':'C', 'Ē':'E', 'Ģ':'G', 'Ī':'i',
|
64
|
+
'Ķ':'k', 'Ļ':'L', 'Ņ':'N', 'Š':'S', 'Ū':'u', 'Ž':'Z'
|
65
|
+
}
|
66
|
+
|
67
|
+
var ALL_DOWNCODE_MAPS=new Array()
|
68
|
+
ALL_DOWNCODE_MAPS[0]=LATIN_MAP
|
69
|
+
ALL_DOWNCODE_MAPS[1]=LATIN_SYMBOLS_MAP
|
70
|
+
ALL_DOWNCODE_MAPS[2]=GREEK_MAP
|
71
|
+
ALL_DOWNCODE_MAPS[3]=TURKISH_MAP
|
72
|
+
ALL_DOWNCODE_MAPS[4]=RUSSIAN_MAP
|
73
|
+
ALL_DOWNCODE_MAPS[5]=UKRAINIAN_MAP
|
74
|
+
ALL_DOWNCODE_MAPS[6]=CZECH_MAP
|
75
|
+
ALL_DOWNCODE_MAPS[7]=POLISH_MAP
|
76
|
+
ALL_DOWNCODE_MAPS[8]=LATVIAN_MAP
|
77
|
+
|
78
|
+
var Downcoder = new Object();
|
79
|
+
Downcoder.Initialize = function()
|
80
|
+
{
|
81
|
+
if (Downcoder.map) // already made
|
82
|
+
return ;
|
83
|
+
Downcoder.map ={}
|
84
|
+
Downcoder.chars = '' ;
|
85
|
+
for(var i in ALL_DOWNCODE_MAPS)
|
86
|
+
{
|
87
|
+
var lookup = ALL_DOWNCODE_MAPS[i]
|
88
|
+
for (var c in lookup)
|
89
|
+
{
|
90
|
+
Downcoder.map[c] = lookup[c] ;
|
91
|
+
Downcoder.chars += c ;
|
92
|
+
}
|
93
|
+
}
|
94
|
+
Downcoder.regex = new RegExp('[' + Downcoder.chars + ']|[^' + Downcoder.chars + ']+','g') ;
|
95
|
+
}
|
96
|
+
|
97
|
+
downcode= function( slug )
|
98
|
+
{
|
99
|
+
Downcoder.Initialize() ;
|
100
|
+
var downcoded =""
|
101
|
+
var pieces = slug.match(Downcoder.regex);
|
102
|
+
if(pieces)
|
103
|
+
{
|
104
|
+
for (var i = 0 ; i < pieces.length ; i++)
|
105
|
+
{
|
106
|
+
if (pieces[i].length == 1)
|
107
|
+
{
|
108
|
+
var mapped = Downcoder.map[pieces[i]] ;
|
109
|
+
if (mapped != null)
|
110
|
+
{
|
111
|
+
downcoded+=mapped;
|
112
|
+
continue ;
|
113
|
+
}
|
114
|
+
}
|
115
|
+
downcoded+=pieces[i];
|
116
|
+
}
|
117
|
+
}
|
118
|
+
else
|
119
|
+
{
|
120
|
+
downcoded = slug;
|
121
|
+
}
|
122
|
+
return downcoded;
|
123
|
+
}
|
124
|
+
|
125
|
+
|
126
|
+
function URLify(s, num_chars) {
|
127
|
+
// changes, e.g., "Petty theft" to "petty_theft"
|
128
|
+
// remove all these words from the string before urlifying
|
129
|
+
s = downcode(s);
|
130
|
+
//
|
131
|
+
// if downcode doesn't hit, the char will be stripped here
|
132
|
+
s = s.replace(/[^-\w\s]/g, ' '); // remove unneeded chars
|
133
|
+
s = s.replace(/^\s+|\s+$/g, ''); // trim leading/trailing spaces
|
134
|
+
s = s.replace(/[-\s]+/g, '-'); // convert spaces to hyphens
|
135
|
+
s = s.toLowerCase(); // convert to lowercase
|
136
|
+
return s.substring(0, num_chars);// trim to first num_chars chars
|
137
|
+
}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blacklight-spotlight
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Beer
|
@@ -814,6 +814,7 @@ files:
|
|
814
814
|
- app/helpers/spotlight/search_configurations_helper.rb
|
815
815
|
- app/helpers/spotlight/title_helper.rb
|
816
816
|
- app/jobs/spotlight/add_uploads_from_csv.rb
|
817
|
+
- app/jobs/spotlight/default_thumbnail_job.rb
|
817
818
|
- app/jobs/spotlight/reindex_job.rb
|
818
819
|
- app/jobs/spotlight/rename_sidecar_field_job.rb
|
819
820
|
- app/mailers/spotlight/confirmation_mailer.rb
|
@@ -821,6 +822,7 @@ files:
|
|
821
822
|
- app/models/ability.rb
|
822
823
|
- app/models/concerns/spotlight/ar_light.rb
|
823
824
|
- app/models/concerns/spotlight/blacklight_configuration_defaults.rb
|
825
|
+
- app/models/concerns/spotlight/default_thumbnailable.rb
|
824
826
|
- app/models/concerns/spotlight/exhibit_analytics.rb
|
825
827
|
- app/models/concerns/spotlight/exhibit_documents.rb
|
826
828
|
- app/models/concerns/spotlight/image_derivatives.rb
|
@@ -953,6 +955,7 @@ files:
|
|
953
955
|
- app/views/spotlight/exhibits/_contact.html.erb
|
954
956
|
- app/views/spotlight/exhibits/_delete.html.erb
|
955
957
|
- app/views/spotlight/exhibits/_exhibit_card.html.erb
|
958
|
+
- app/views/spotlight/exhibits/_exhibit_list.html.erb
|
956
959
|
- app/views/spotlight/exhibits/_export.html.erb
|
957
960
|
- app/views/spotlight/exhibits/_form.html.erb
|
958
961
|
- app/views/spotlight/exhibits/_import.html.erb
|
@@ -1185,6 +1188,7 @@ files:
|
|
1185
1188
|
- spec/helpers/spotlight/roles_helper_spec.rb
|
1186
1189
|
- spec/helpers/spotlight/search_configurations_helper_spec.rb
|
1187
1190
|
- spec/helpers/spotlight/title_helper_spec.rb
|
1191
|
+
- spec/jobs/spotlight/default_thumbnail_job_spec.rb
|
1188
1192
|
- spec/jobs/spotlight/reindex_job_spec.rb
|
1189
1193
|
- spec/jobs/spotlight/rename_sidecar_field_job_spec.rb
|
1190
1194
|
- spec/lib/spotlight/catalog/access_controls_enforcement_spec.rb
|
@@ -1201,6 +1205,7 @@ files:
|
|
1201
1205
|
- spec/models/spotlight/contact_email_spec.rb
|
1202
1206
|
- spec/models/spotlight/contact_spec.rb
|
1203
1207
|
- spec/models/spotlight/custom_field_spec.rb
|
1208
|
+
- spec/models/spotlight/default_thumbnailable_concern_spec.rb
|
1204
1209
|
- spec/models/spotlight/exhibit_spec.rb
|
1205
1210
|
- spec/models/spotlight/feature_page_spec.rb
|
1206
1211
|
- spec/models/spotlight/featured_image_spec.rb
|
@@ -1286,6 +1291,7 @@ files:
|
|
1286
1291
|
- vendor/assets/javascripts/jquery.serializejson.js
|
1287
1292
|
- vendor/assets/javascripts/jquery.waitforimages.min.js
|
1288
1293
|
- vendor/assets/javascripts/nestable.js
|
1294
|
+
- vendor/assets/javascripts/parameterize.js
|
1289
1295
|
- vendor/assets/javascripts/sir-trevor.js
|
1290
1296
|
- vendor/assets/javascripts/typeahead.bundle.min.js
|
1291
1297
|
- vendor/assets/stylesheets/bootstrap-tagsinput.css
|
@@ -1411,6 +1417,7 @@ test_files:
|
|
1411
1417
|
- spec/helpers/spotlight/roles_helper_spec.rb
|
1412
1418
|
- spec/helpers/spotlight/search_configurations_helper_spec.rb
|
1413
1419
|
- spec/helpers/spotlight/title_helper_spec.rb
|
1420
|
+
- spec/jobs/spotlight/default_thumbnail_job_spec.rb
|
1414
1421
|
- spec/jobs/spotlight/reindex_job_spec.rb
|
1415
1422
|
- spec/jobs/spotlight/rename_sidecar_field_job_spec.rb
|
1416
1423
|
- spec/lib/spotlight/catalog/access_controls_enforcement_spec.rb
|
@@ -1427,6 +1434,7 @@ test_files:
|
|
1427
1434
|
- spec/models/spotlight/contact_email_spec.rb
|
1428
1435
|
- spec/models/spotlight/contact_spec.rb
|
1429
1436
|
- spec/models/spotlight/custom_field_spec.rb
|
1437
|
+
- spec/models/spotlight/default_thumbnailable_concern_spec.rb
|
1430
1438
|
- spec/models/spotlight/exhibit_spec.rb
|
1431
1439
|
- spec/models/spotlight/feature_page_spec.rb
|
1432
1440
|
- spec/models/spotlight/featured_image_spec.rb
|