blacklight-spotlight 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a374f34b756e77a92a47c12e13ab91bf2a935249
4
- data.tar.gz: 0764167fe263eb2ca0d7e95f804898541695ca94
3
+ metadata.gz: a72c73b4f41f4b18b888922c28acc5dd32d15685
4
+ data.tar.gz: 006e0616e0993818d31f051b61396719513cbaf6
5
5
  SHA512:
6
- metadata.gz: 2e0ca388157dcfd5a7b33f20766098792fb57d9041dc623e973d08fe3ecf89553b24e906fd4fbf99a4982c6ea819538667ac6dfef52a7e843e2b47ba12ec58a6
7
- data.tar.gz: 9774063881b9e5a43eb37829235aa65246ee2760d7250c00c34ded8f2e262a0e43a07cd5fae15e5ba9f9fec8347c41f79e87db9ada603d7231aff76824d13dc2
6
+ metadata.gz: 5eec974abf0bf6fa5b2686dc43f91458e2578e02913405269a9b203ea8f74487003571f1583ed733b89b093559ce39b02ffbf8979fc7db9b832d774ab3dbab1f
7
+ data.tar.gz: dfa692a867b1049e2ff78d11e5a06186d4262b6ace06e0dd27e907c67f291a2fbde9cda7add8d6e03d07aa98cc6455c09fbce595a800453f7ce07acd94fbbd20
data/README.md CHANGED
@@ -25,7 +25,7 @@ $ rails new app-name -m https://raw.githubusercontent.com/projectblacklight/spot
25
25
  or from an existing Rails application:
26
26
 
27
27
  ```
28
- $ rake rails:template LOCATION=https://raw.githubusercontent.com/projectblacklight/spotlight/master/template.rb
28
+ $ rails app:template LOCATION=https://raw.githubusercontent.com/projectblacklight/spotlight/master/template.rb
29
29
  ```
30
30
 
31
31
  *During this process you will be prompted to enter an initial administrator email and password (this is a super-admin that can administer any exhibit in the installation).* If you choose not to create one, the first user will be given administrative privileges.
@@ -0,0 +1,27 @@
1
+ Spotlight.onLoad(function() {
2
+ $('.btn-reset').ClearFormButton();
3
+ });
4
+
5
+ (function($) {
6
+ $.fn.ClearFormButton = function() {
7
+ var $clearBtn = $(this);
8
+ var $input = $clearBtn.parent().prev('input');
9
+ var btnCheck = function(){
10
+ if ($input.val() !== '') {
11
+ $clearBtn.css('display', 'inline-block');
12
+ } else {
13
+ $clearBtn.css('display', 'none');
14
+ }
15
+ };
16
+
17
+ btnCheck();
18
+ $input.on('keyup', function() {
19
+ btnCheck();
20
+ });
21
+
22
+ $clearBtn.on('click', function(event) {
23
+ event.preventDefault();
24
+ $input.val('');
25
+ });
26
+ };
27
+ })(jQuery);
@@ -103,3 +103,27 @@ $image-overlay-bottom-margin: $padding-large-vertical * 3;
103
103
  .image-overlay {max-height: $image-overlay-max-height;}
104
104
  }
105
105
  }
106
+
107
+ .search-box-container {
108
+ margin: 0 auto;
109
+ text-align: center;
110
+ width: 100%;
111
+
112
+ .browse-search-form {
113
+ .browse-search-expand {
114
+ text-align: center;
115
+ }
116
+
117
+ .btn-reset {
118
+ background-color: transparent;
119
+ display: none;
120
+ left: -40px;
121
+ z-index: 20;
122
+ }
123
+
124
+ .search-btn {
125
+ left: -40px;
126
+ z-index: 30;
127
+ }
128
+ }
129
+ }
@@ -39,6 +39,7 @@ module Spotlight
39
39
  end
40
40
 
41
41
  def search_query
42
+ @search.query_params[:q] = [@search.query_params[:q], params[:browse_q]].join(' ')
42
43
  @search.merge_params_for_search(params, blacklight_config)
43
44
  end
44
45
 
@@ -102,6 +102,7 @@ module Spotlight
102
102
  params.require(:search).permit(
103
103
  :title,
104
104
  :long_description,
105
+ :search_box,
105
106
  :default_index_view_type,
106
107
  masthead_attributes: featured_image_params,
107
108
  thumbnail_attributes: featured_image_params
@@ -24,6 +24,12 @@ module Spotlight
24
24
  end
25
25
  end
26
26
 
27
+ ##
28
+ # Get parent results count of a browse category search
29
+ def parent_search_count
30
+ @parent_search_count ||= Spotlight::Search.find(@search.id).count
31
+ end
32
+
27
33
  private
28
34
 
29
35
  def view_available?(view)
@@ -13,7 +13,7 @@ module Spotlight
13
13
  scope :unpublished, -> { where(published: false) }
14
14
  scope :ordered_by_weight, -> { order('weight ASC') }
15
15
 
16
- paginates_per 50
16
+ paginates_per 48
17
17
 
18
18
  extend FriendlyId
19
19
  friendly_id :title, use: [:slugged, :finders]
@@ -0,0 +1,38 @@
1
+ <div class="search-box-container">
2
+ <%= form_tag exhibit_browse_path(current_exhibit, search), method: :get, class: 'browse-search-form form-horizontal', role: 'browse-search' do %>
3
+ <%= render_hash_as_hidden_fields(search_state.params_for_search.except(:q, :search_field, :exhibit_id, :browse_q, :qt, :page, :utf8)) %>
4
+ <div class="form-group">
5
+ <label class="col-sm-4 control-label" for="browse_q"><%= t(:'.label') %></label>
6
+ <div class="col-sm-6">
7
+ <div class="input-group">
8
+ <%= text_field_tag :browse_q, params[:browse_q], placeholder: t(:'.placeholder'), class: "form-control", id: "browse_q" %>
9
+ <span class="input-group-btn">
10
+ <button class="btn btn-reset" type="reset"><span class="sr-only"><%= t(:'.reset') %></span><span class="glyphicon glyphicon-remove-circle"></span></button>
11
+ <button type="submit" class="btn btn-primary search-btn" id="browse-search">
12
+ <span class="submit-search-text"><%= t(:'.submit') %></span>
13
+ <span class="glyphicon glyphicon-search"></span>
14
+ </button>
15
+ </span>
16
+ </div>
17
+ </div>
18
+ </div>
19
+ <% end %>
20
+ <% if params[:browse_q]%>
21
+ <div class="browse-search-expand">
22
+ <% if search.count > 0 %>
23
+ <p><%= t(:'.success.result_number_html', search_size: search.count, parent_search_count: parent_search_count) %></p>
24
+ <p><%= t(:'.success.expand_html',
25
+ expand_search_url: search_exhibit_catalog_path(current_exhibit, q: params[:browse_q]),
26
+ browse_query: params[:browse_q]) %>
27
+ </p>
28
+ <% else %>
29
+ <p><%= t(:'.zero_results.result_number') %></p>
30
+ <p><%= t(:'.zero_results.expand_html',
31
+ clear_search_url: exhibit_browse_path(current_exhibit, search),
32
+ expand_search_url: search_exhibit_catalog_path(current_exhibit, q: params[:browse_q]),
33
+ browse_query: params[:browse_q])%>
34
+ </p>
35
+ <% end %>
36
+ </div>
37
+ <% end %>
38
+ </div>
@@ -1,2 +1,2 @@
1
1
  <%= search.title %>
2
- <small class="item-count"><%= t :'spotlight.browse.search.item_count', count: search.documents.size %></small>
2
+ <small class="item-count"><%= t :'spotlight.browse.search.item_count', count: params[:browse_q] ? parent_search_count: search.documents.size %></small>
@@ -18,6 +18,9 @@
18
18
 
19
19
  <div class="col-md-12">
20
20
  <%= render 'sort_and_per_page' %>
21
+ <% if @search.search_box? %>
22
+ <%= render partial: 'search_box', locals: {search: @search} %>
23
+ <% end %>
21
24
  <% if @search.default_index_view_type && params[:view].blank? %>
22
25
  <%= render_document_index_with_view(@search.default_index_view_type, @document_list) %>
23
26
  <% else %>
@@ -9,17 +9,17 @@
9
9
  <table id="nested-fields" class="table table-striped dd-table">
10
10
  <thead>
11
11
  <tr>
12
- <th><%= t :'.fields.label' %></th>
12
+ <th><%= t :'.field.label' %></th>
13
13
  <th class="text-center">
14
14
  <div>
15
- <%= t :'.view.show', default: t(:'blacklight.search.view.show') %>
15
+ <%= t :'.view.show' %>
16
16
  </div>
17
17
  <%= select_deselect_button %>
18
18
  </th>
19
19
  <% available_view_fields.keys.each do |type| %>
20
20
  <th class="text-center">
21
21
  <div>
22
- <%= t :".view.#{type}", default: t(:".view.#{type}") %>
22
+ <%= t :".view.#{type}", default: t("blacklight.search.view.#{type}", default: type.to_s.humanize.titleize) %>
23
23
  </div>
24
24
  <%= select_deselect_button %>
25
25
  </th>
@@ -30,6 +30,9 @@
30
30
  <div role="tabpanel" class="tab-pane active" id="search-description">
31
31
  <%= f.text_field :title, control_col: "col-sm-5" %>
32
32
  <%= f.text_area :long_description, rows: 5 %>
33
+ <%= f.form_group :search_box, label: { text: t(:'.search_box.label'), class: nil }, help: t(:'.search_box.help_block') do %>
34
+ <%= f.check_box :search_box, label: "" %>
35
+ <% end %>
33
36
  <%= f.form_group label: { text: t(:".default_index_view_type") } do %>
34
37
  <% available_document_index_views.each do |view| %>
35
38
  <%= f.radio_button :default_index_view_type, view, label: view_label(view) %>
@@ -7,8 +7,7 @@
7
7
  <%= f.text_field :name %>
8
8
  <span style="display:none;visibility:hidden;">
9
9
  <% honeypot_field_name = Spotlight::Engine.config.spambot_honeypot_email_field %>
10
- <%= label_tag(honeypot_field_name, t(:'.honeypot_field_explanation')) %><br/>
11
- <%= f.email_field honeypot_field_name %>
10
+ <%= f.email_field honeypot_field_name, label: t(:'.honeypot_field_explanation') %>
12
11
  </span>
13
12
  <%= f.email_field :email %>
14
13
  <%= f.text_area :message, rows: 7 %>
@@ -646,6 +646,9 @@ en:
646
646
  other: "%{count} items"
647
647
  missing_description_html: "%{link} to add a description."
648
648
  form:
649
+ search_box:
650
+ label: Display search box
651
+ help_block: Displays a search box that enables users to search within the browse category results
649
652
  search_description: "Description"
650
653
  search_masthead: "Masthead"
651
654
  search_thumbnail: "Thumbnail"
@@ -668,6 +671,17 @@ en:
668
671
  item_count:
669
672
  one: "%{count} item"
670
673
  other: "%{count} items"
674
+ search_box:
675
+ placeholder: Search…
676
+ label: Search within this browse category
677
+ submit: Search within browse category
678
+ reset: Clear search box
679
+ success:
680
+ result_number_html: Your search matched <strong> %{search_size} of %{parent_search_count} items</strong> in this browse category.
681
+ expand_html: You can also <a href="%{expand_search_url}">search all exhibit items for "%{browse_query}"</a>.
682
+ zero_results:
683
+ result_number: Your search did not match any items in this browse category.
684
+ expand_html: You can <a href="%{clear_search_url}"> clear this search</a> or try <a href="%{expand_search_url}">searching all exhibit items for "%{browse_query}"</a>.
671
685
  tags:
672
686
  index:
673
687
  title: "Curation - Tags"
@@ -0,0 +1,5 @@
1
+ class AddSearchBoxToSpotlightSearches < ActiveRecord::Migration[5.0]
2
+ def change
3
+ add_column :spotlight_searches, :search_box, :boolean, default: false
4
+ end
5
+ end
@@ -1,3 +1,3 @@
1
1
  module Spotlight
2
- VERSION = '1.3.0'.freeze
2
+ VERSION = '1.4.0'.freeze
3
3
  end
@@ -26,10 +26,11 @@ example_id
26
26
  ./spec/controllers/spotlight/attachments_controller_spec.rb[1:2:1:1] | passed | 0.08355 seconds |
27
27
  ./spec/controllers/spotlight/browse_controller_spec.rb[1:1:1:1] | passed | 0.12244 seconds |
28
28
  ./spec/controllers/spotlight/browse_controller_spec.rb[1:2:1:1] | passed | 0.12212 seconds |
29
- ./spec/controllers/spotlight/browse_controller_spec.rb[1:2:2:1] | passed | 0.11488 seconds |
30
- ./spec/controllers/spotlight/browse_controller_spec.rb[1:2:2:2] | passed | 0.11066 seconds |
29
+ ./spec/controllers/spotlight/browse_controller_spec.rb[1:2:2:1] | passed | 0.70312 seconds |
30
+ ./spec/controllers/spotlight/browse_controller_spec.rb[1:2:2:2] | passed | 0.55921 seconds |
31
31
  ./spec/controllers/spotlight/browse_controller_spec.rb[1:2:2:3] | passed | 0.14179 seconds |
32
32
  ./spec/controllers/spotlight/browse_controller_spec.rb[1:2:2:4] | passed | 0.27117 seconds |
33
+ ./spec/controllers/spotlight/browse_controller_spec.rb[1:2:2:5] | unknown | |
33
34
  ./spec/controllers/spotlight/catalog_controller_spec.rb[1:1] | passed | 0.01166 seconds |
34
35
  ./spec/controllers/spotlight/catalog_controller_spec.rb[1:2] | passed | 0.01158 seconds |
35
36
  ./spec/controllers/spotlight/catalog_controller_spec.rb[1:3:1] | passed | 0.01293 seconds |
@@ -260,17 +261,19 @@ example_id
260
261
  ./spec/features/browse_category_admin_spec.rb[1:3:1] | passed | 0.16321 seconds |
261
262
  ./spec/features/browse_category_admin_spec.rb[1:3:2] | passed | 0.27356 seconds |
262
263
  ./spec/features/browse_category_admin_spec.rb[1:3:3] | passed | 0.26013 seconds |
263
- ./spec/features/browse_category_admin_spec.rb[1:3:4] | passed | 0.30772 seconds |
264
+ ./spec/features/browse_category_admin_spec.rb[1:3:4] | passed | 1.72 seconds |
265
+ ./spec/features/browse_category_admin_spec.rb[1:3:5] | unknown | |
264
266
  ./spec/features/browse_category_admin_spec.rb[1:4:1] | pending | 0.07365 seconds |
265
- ./spec/features/browse_category_spec.rb[1:1:1:1] | passed | 0.1567 seconds |
266
- ./spec/features/browse_category_spec.rb[1:1:1:2] | passed | 0.17678 seconds |
267
- ./spec/features/browse_category_spec.rb[1:1:1:3] | passed | 0.15112 seconds |
268
- ./spec/features/browse_category_spec.rb[1:1:2:1] | passed | 0.16314 seconds |
269
- ./spec/features/browse_category_spec.rb[1:1:2:2] | passed | 0.1699 seconds |
270
- ./spec/features/browse_category_spec.rb[1:1:2:3] | passed | 0.15939 seconds |
271
- ./spec/features/browse_category_spec.rb[1:1:3:1] | passed | 0.15127 seconds |
272
- ./spec/features/browse_category_spec.rb[1:1:4:1] | passed | 0.20257 seconds |
273
- ./spec/features/browse_category_spec.rb[1:1:5] | passed | 0.1602 seconds |
267
+ ./spec/features/browse_category_spec.rb[1:1:1:1] | passed | 0.15642 seconds |
268
+ ./spec/features/browse_category_spec.rb[1:1:1:2] | passed | 0.13869 seconds |
269
+ ./spec/features/browse_category_spec.rb[1:1:1:3] | passed | 0.15077 seconds |
270
+ ./spec/features/browse_category_spec.rb[1:1:2:1] | passed | 0.15314 seconds |
271
+ ./spec/features/browse_category_spec.rb[1:1:2:2] | passed | 0.14398 seconds |
272
+ ./spec/features/browse_category_spec.rb[1:1:2:3] | passed | 0.17532 seconds |
273
+ ./spec/features/browse_category_spec.rb[1:1:3:1] | passed | 0.16518 seconds |
274
+ ./spec/features/browse_category_spec.rb[1:1:4:1] | failed | 1.66 seconds |
275
+ ./spec/features/browse_category_spec.rb[1:1:5:1] | passed | 3.6 seconds |
276
+ ./spec/features/browse_category_spec.rb[1:1:6] | passed | 1.7 seconds |
274
277
  ./spec/features/catalog_spec.rb[1:1:1] | passed | 0.52505 seconds |
275
278
  ./spec/features/catalog_spec.rb[1:2] | passed | 0.1486 seconds |
276
279
  ./spec/features/catalog_spec.rb[1:3:1] | failed | 0.0181 seconds |
@@ -427,6 +430,7 @@ example_id
427
430
  ./spec/helpers/spotlight/application_helper_spec.rb[1:8:3] | passed | 0.01286 seconds |
428
431
  ./spec/helpers/spotlight/browse_helper_spec.rb[1:1] | passed | 0.01276 seconds |
429
432
  ./spec/helpers/spotlight/browse_helper_spec.rb[1:2] | passed | 0.01509 seconds |
433
+ ./spec/helpers/spotlight/browse_helper_spec.rb[1:3] | failed | 0.20822 seconds |
430
434
  ./spec/helpers/spotlight/crop_helper_spec.rb[1:1:1] | passed | 0.01104 seconds |
431
435
  ./spec/helpers/spotlight/crud_link_helpers_spec.rb[1:1:1] | passed | 0.01328 seconds |
432
436
  ./spec/helpers/spotlight/crud_link_helpers_spec.rb[1:2:1] | passed | 0.08069 seconds |
@@ -1040,9 +1044,10 @@ example_id
1040
1044
  ./spec/views/spotlight/about_pages/index.html.erb_spec.rb[1:1] | passed | 1.77 seconds |
1041
1045
  ./spec/views/spotlight/about_pages/index.html.erb_spec.rb[1:2:1] | passed | 0.04085 seconds |
1042
1046
  ./spec/views/spotlight/about_pages/index.html.erb_spec.rb[1:2:2] | passed | 0.0429 seconds |
1043
- ./spec/views/spotlight/browse/_search.html.erb_spec.rb[1:1] | passed | 0.14353 seconds |
1044
- ./spec/views/spotlight/browse/_search.html.erb_spec.rb[1:2] | passed | 0.2013 seconds |
1045
- ./spec/views/spotlight/browse/_search.html.erb_spec.rb[1:3] | passed | 0.1344 seconds |
1047
+ ./spec/views/spotlight/browse/_search.html.erb_spec.rb[1:1] | passed | 0.11559 seconds |
1048
+ ./spec/views/spotlight/browse/_search.html.erb_spec.rb[1:2] | passed | 0.15868 seconds |
1049
+ ./spec/views/spotlight/browse/_search.html.erb_spec.rb[1:3] | passed | 0.13951 seconds |
1050
+ ./spec/views/spotlight/browse/_search.html.erb_spec.rb[1:4] | failed | 0.73955 seconds |
1046
1051
  ./spec/views/spotlight/browse/_sort_and_per_page.html.erb_spec.rb[1:1] | passed | 0.0718 seconds |
1047
1052
  ./spec/views/spotlight/browse/index.html.erb_spec.rb[1:1] | passed | 0.01188 seconds |
1048
1053
  ./spec/views/spotlight/browse/index.html.erb_spec.rb[1:2] | passed | 0.15266 seconds |
@@ -83,6 +83,19 @@ describe 'Browse Category Administration', type: :feature do
83
83
  expect(search.thumbnail).not_to be nil
84
84
  end
85
85
 
86
+ it 'can configure a search box' do
87
+ visit spotlight.edit_exhibit_search_path exhibit, search
88
+ expect(search.search_box).to eq false
89
+
90
+ check 'Display search box'
91
+
92
+ click_button 'Save changes'
93
+ expect(page).to have_content('The search was successfully updated.')
94
+ search.reload
95
+
96
+ expect(search.search_box).to eq true
97
+ end
98
+
86
99
  it 'can select a default index view type' do
87
100
  visit spotlight.edit_exhibit_search_path exhibit, search
88
101
  choose 'List'
@@ -87,6 +87,20 @@ feature 'Browse pages' do
87
87
  end
88
88
  end
89
89
 
90
+ context 'with category search box enabled' do
91
+ let(:search) { FactoryBot.create(:default_search, exhibit: exhibit, published: true, search_box: true) }
92
+ it 'renders search box' do
93
+ visit spotlight.exhibit_browse_path(exhibit, search)
94
+ expect(page).to have_selector '.browse-search-form'
95
+ expect(page).not_to have_css '.browse-search-expand'
96
+
97
+ fill_in 'Search within this browse category', with: 'SEPTENTRIONALE'
98
+ click_button 'Search within browse category'
99
+
100
+ expect(page).to have_css '.browse-search-expand'
101
+ end
102
+ end
103
+
90
104
  it 'has <meta> tags' do
91
105
  TopHat.current['twitter_card'] = nil
92
106
  TopHat.current['opengraph'] = nil
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: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Beer
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2018-01-12 00:00:00.000000000 Z
14
+ date: 2018-02-10 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rails
@@ -781,6 +781,7 @@ files:
781
781
  - app/assets/javascripts/spotlight/blocks/solr_documents_grid_block.js
782
782
  - app/assets/javascripts/spotlight/blocks/uploaded_items_block.js
783
783
  - app/assets/javascripts/spotlight/catalog_edit.js
784
+ - app/assets/javascripts/spotlight/clear_form_button.js
784
785
  - app/assets/javascripts/spotlight/compat.js
785
786
  - app/assets/javascripts/spotlight/copy_email_addresses.js
786
787
  - app/assets/javascripts/spotlight/crop.es6
@@ -1006,6 +1007,7 @@ files:
1006
1007
  - app/views/spotlight/admin_users/index.html.erb
1007
1008
  - app/views/spotlight/appearances/edit.html.erb
1008
1009
  - app/views/spotlight/browse/_search.html.erb
1010
+ - app/views/spotlight/browse/_search_box.html.erb
1009
1011
  - app/views/spotlight/browse/_search_title.html.erb
1010
1012
  - app/views/spotlight/browse/_sort_and_per_page.html.erb
1011
1013
  - app/views/spotlight/browse/_tophat.html.erb
@@ -1197,6 +1199,7 @@ files:
1197
1199
  - db/migrate/20170803152134_migrate_tags_to_sidecars.rb
1198
1200
  - db/migrate/20170821165811_change_index_status_to_longblob.rb
1199
1201
  - db/migrate/20171005231502_add_missing_indexes_on_taggings.acts_as_taggable_on_engine.rb
1202
+ - db/migrate/20180119193632_add_search_box_to_spotlight_searches.rb
1200
1203
  - lib/blacklight/spotlight.rb
1201
1204
  - lib/generators/spotlight/install_generator.rb
1202
1205
  - lib/generators/spotlight/scaffold_resource_generator.rb