blacklight-spotlight 0.18.0 → 0.19.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (159) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -9
  3. data/app/assets/javascripts/spotlight/blocks/browse_block.js +1 -0
  4. data/app/assets/stylesheets/spotlight/_bootstrap_overrides.scss +1 -1
  5. data/app/assets/stylesheets/spotlight/_multi_up_item_grid.scss +2 -0
  6. data/app/assets/stylesheets/spotlight/_pages.scss +7 -1
  7. data/app/controllers/spotlight/contact_forms_controller.rb +1 -5
  8. data/app/controllers/spotlight/searches_controller.rb +7 -1
  9. data/app/helpers/spotlight/browse_helper.rb +16 -1
  10. data/app/helpers/spotlight/searches_helper.rb +8 -0
  11. data/app/mailers/spotlight/contact_mailer.rb +9 -0
  12. data/app/models/spotlight/analytics/ga.rb +14 -16
  13. data/app/models/spotlight/blacklight_configuration.rb +6 -6
  14. data/app/models/spotlight/contact_form.rb +12 -10
  15. data/app/services/spotlight/carrierwave_file_resolver.rb +8 -0
  16. data/app/views/spotlight/browse/show.html.erb +5 -1
  17. data/app/views/spotlight/contact_mailer/report_problem.html.erb +14 -0
  18. data/app/views/spotlight/dashboards/analytics.html.erb +1 -3
  19. data/app/views/spotlight/searches/_form.html.erb +5 -0
  20. data/app/views/spotlight/sir_trevor/blocks/_solr_documents_block.html.erb +4 -3
  21. data/app/views/spotlight/sir_trevor/blocks/_solr_documents_carousel_block.html.erb +3 -2
  22. data/app/views/spotlight/sir_trevor/blocks/_solr_documents_features_block.html.erb +3 -2
  23. data/config/locales/spotlight.en.yml +1 -0
  24. data/db/migrate/20160711121314_add_default_view_to_spotlight_searches.rb +5 -0
  25. data/lib/generators/spotlight/install_generator.rb +6 -0
  26. data/lib/generators/spotlight/templates/config/initializers/riiif.rb +7 -0
  27. data/lib/spotlight/version.rb +1 -1
  28. data/spec/controllers/application_controller_spec.rb +0 -2
  29. data/spec/controllers/spotlight/about_pages_controller_spec.rb +0 -2
  30. data/spec/controllers/spotlight/admin_users_controller_spec.rb +0 -2
  31. data/spec/controllers/spotlight/appearances_controller_spec.rb +0 -1
  32. data/spec/controllers/spotlight/application_controller_spec.rb +0 -2
  33. data/spec/controllers/spotlight/attachments_controller_spec.rb +0 -2
  34. data/spec/controllers/spotlight/browse_controller_spec.rb +0 -2
  35. data/spec/controllers/spotlight/catalog_controller_spec.rb +0 -2
  36. data/spec/controllers/spotlight/confirmations_controller_spec.rb +0 -2
  37. data/spec/controllers/spotlight/contact_forms_controller_spec.rb +5 -2
  38. data/spec/controllers/spotlight/contacts_controller_spec.rb +0 -2
  39. data/spec/controllers/spotlight/custom_fields_controller_spec.rb +0 -1
  40. data/spec/controllers/spotlight/dashboards_controller_spec.rb +0 -1
  41. data/spec/controllers/spotlight/exhibits_controller_spec.rb +1 -1
  42. data/spec/controllers/spotlight/feature_pages_controller_spec.rb +0 -1
  43. data/spec/controllers/spotlight/filters_controller_spec.rb +0 -2
  44. data/spec/controllers/spotlight/home_pages_controller_spec.rb +0 -2
  45. data/spec/controllers/spotlight/metadata_configurations_controller_spec.rb +0 -1
  46. data/spec/controllers/spotlight/resources_controller_spec.rb +0 -2
  47. data/spec/controllers/spotlight/roles_controller_spec.rb +0 -2
  48. data/spec/controllers/spotlight/search_configurations_controller_spec.rb +0 -1
  49. data/spec/controllers/spotlight/searches_controller_spec.rb +0 -2
  50. data/spec/controllers/spotlight/sites_controller_spec.rb +0 -2
  51. data/spec/controllers/spotlight/solr_controller_spec.rb +0 -2
  52. data/spec/controllers/spotlight/tags_controller_spec.rb +0 -2
  53. data/spec/controllers/spotlight/versions_controller_spec.rb +0 -2
  54. data/spec/controllers/spotlight/view_configurations_controller_spec.rb +0 -1
  55. data/spec/features/about_page_spec.rb +0 -2
  56. data/spec/features/add_contacts_spec.rb +0 -2
  57. data/spec/features/add_custom_field_metadata_spec.rb +0 -2
  58. data/spec/features/add_items_spec.rb +0 -2
  59. data/spec/features/browse_category_admin_spec.rb +13 -2
  60. data/spec/features/browse_category_spec.rb +27 -2
  61. data/spec/features/catalog_spec.rb +0 -2
  62. data/spec/features/confirm_email_spec.rb +0 -2
  63. data/spec/features/create_exhibit_spec.rb +0 -2
  64. data/spec/features/create_page_spec.rb +0 -2
  65. data/spec/features/curator_items.rb +0 -3
  66. data/spec/features/dashboard_spec.rb +0 -2
  67. data/spec/features/edit_contact_spec.rb +0 -3
  68. data/spec/features/edit_search_fields_spec.rb +0 -2
  69. data/spec/features/exhibit_masthead_spec.rb +0 -2
  70. data/spec/features/exhibits/add_tags_spec.rb +0 -1
  71. data/spec/features/exhibits/administration_spec.rb +0 -1
  72. data/spec/features/exhibits/custom_metadata_fields_spec.rb +0 -1
  73. data/spec/features/exhibits/edit_metadata_fields_spec.rb +0 -1
  74. data/spec/features/exhibits_index_spec.rb +0 -2
  75. data/spec/features/feature_page_spec.rb +0 -2
  76. data/spec/features/home_page_spec.rb +0 -1
  77. data/spec/features/import_exhibit_spec.rb +0 -1
  78. data/spec/features/item_admin_spec.rb +0 -2
  79. data/spec/features/javascript/about_page_admin_spec.rb +0 -2
  80. data/spec/features/javascript/block_controls_spec.rb +0 -2
  81. data/spec/features/javascript/blocks/featured_browse_categories_block_spec.rb +8 -0
  82. data/spec/features/javascript/edit_in_place_spec.rb +0 -2
  83. data/spec/features/javascript/feature_page_admin_spec.rb +0 -2
  84. data/spec/features/javascript/home_page_edit_spec.rb +0 -2
  85. data/spec/features/javascript/metadata_admin_spec.rb +0 -2
  86. data/spec/features/javascript/multi_image_select_spec.rb +0 -2
  87. data/spec/features/javascript/preview_block_spec.rb +0 -2
  88. data/spec/features/javascript/reindex_monitor_spec.rb +0 -2
  89. data/spec/features/javascript/roles_admin_spec.rb +0 -2
  90. data/spec/features/javascript/rule_block_spec.rb +0 -2
  91. data/spec/features/javascript/search_config_admin_spec.rb +0 -2
  92. data/spec/features/javascript/search_context_spec.rb +0 -2
  93. data/spec/features/main_navigation_spec.rb +0 -2
  94. data/spec/features/metadata_admin_spec.rb +0 -2
  95. data/spec/features/report_a_problem_spec.rb +0 -2
  96. data/spec/features/site_admin_management_spec.rb +0 -2
  97. data/spec/features/site_masthead_spec.rb +0 -6
  98. data/spec/features/slideshow_spec.rb +0 -2
  99. data/spec/features/tags_admin_spec.rb +0 -2
  100. data/spec/features/user_admin_spec.rb +0 -2
  101. data/spec/helpers/spotlight/application_helper_spec.rb +0 -1
  102. data/spec/helpers/spotlight/browse_helper_spec.rb +0 -1
  103. data/spec/helpers/spotlight/crud_link_helpers_spec.rb +0 -1
  104. data/spec/helpers/spotlight/jcrop_helper_spec.rb +0 -1
  105. data/spec/helpers/spotlight/main_app_helpers_spec.rb +0 -1
  106. data/spec/helpers/spotlight/navbar_helper_spec.rb +0 -1
  107. data/spec/helpers/spotlight/pages_helper_spec.rb +0 -1
  108. data/spec/helpers/spotlight/roles_helper_spec.rb +0 -1
  109. data/spec/helpers/spotlight/search_configurations_helper_spec.rb +0 -1
  110. data/spec/helpers/spotlight/title_helper_spec.rb +0 -1
  111. data/spec/jobs/spotlight/default_thumbnail_job_spec.rb +0 -1
  112. data/spec/jobs/spotlight/reindex_job_spec.rb +0 -1
  113. data/spec/jobs/spotlight/rename_sidecar_field_job_spec.rb +0 -1
  114. data/spec/lib/spotlight/controller_spec.rb +0 -1
  115. data/spec/mailers/spotlight/indexing_complete_mailer_spec.rb +0 -1
  116. data/spec/models/solr_document_spec.rb +0 -2
  117. data/spec/models/spotlight/ability_spec.rb +0 -1
  118. data/spec/models/spotlight/about_page_spec.rb +0 -2
  119. data/spec/models/spotlight/access_controls_enforcement_search_builder_spec.rb +0 -2
  120. data/spec/models/spotlight/blacklight_configuration_spec.rb +10 -2
  121. data/spec/models/spotlight/contact_email_spec.rb +0 -8
  122. data/spec/models/spotlight/contact_form_spec.rb +0 -2
  123. data/spec/models/spotlight/contact_spec.rb +0 -2
  124. data/spec/models/spotlight/custom_field_spec.rb +0 -1
  125. data/spec/models/spotlight/default_thumbnailable_concern_spec.rb +0 -2
  126. data/spec/models/spotlight/exhibit_spec.rb +0 -2
  127. data/spec/models/spotlight/feature_page_spec.rb +0 -2
  128. data/spec/models/spotlight/featured_image_spec.rb +0 -2
  129. data/spec/models/spotlight/field_metadata_spec.rb +0 -2
  130. data/spec/models/spotlight/filter_spec.rb +0 -2
  131. data/spec/models/spotlight/home_page_spec.rb +0 -2
  132. data/spec/models/spotlight/image_derivatives_spec.rb +0 -2
  133. data/spec/models/spotlight/main_navigation_spec.rb +0 -2
  134. data/spec/models/spotlight/masthead_spec.rb +0 -2
  135. data/spec/models/spotlight/page_spec.rb +0 -2
  136. data/spec/models/spotlight/reindex_progress_spec.rb +0 -2
  137. data/spec/models/spotlight/resource_spec.rb +0 -2
  138. data/spec/models/spotlight/role_spec.rb +0 -2
  139. data/spec/models/spotlight/search_spec.rb +0 -2
  140. data/spec/models/spotlight/site_spec.rb +0 -2
  141. data/spec/models/spotlight/sitemap_spec.rb +0 -1
  142. data/spec/models/spotlight/solr_document_sidecar_spec.rb +0 -2
  143. data/spec/models/spotlight/user_spec.rb +0 -2
  144. data/spec/routing/spotlight/exhibit_catalog_spec.rb +0 -1
  145. data/spec/routing/spotlight/pages_routing_spec.rb +30 -34
  146. data/spec/serializers/spotlight/exhibit_export_serializer_spec.rb +0 -2
  147. data/spec/services/spotlight/carrierwave_file_resolver_spec.rb +14 -0
  148. data/spec/spec_helper.rb +8 -2
  149. data/spec/uploaders/spotlight/item_uploader_spec.rb +0 -1
  150. data/spec/views/_user_util_links.html.erb_spec.rb +70 -74
  151. data/spec/views/shared/_analytics.html.erb_spec.rb +10 -15
  152. data/spec/views/shared/_exhibit_navbar.html.erb_spec.rb +0 -2
  153. data/spec/views/shared/_footer.html.erb_spec.rb +15 -19
  154. data/spec/views/shared/_header_navbar.html.erb_spec.rb +7 -12
  155. data/spec/views/shared/_masthead.html.erb_spec.rb +0 -13
  156. data/spec/views/spotlight/roles/index.html.erb_spec.rb +6 -5
  157. data/spec/views/spotlight/sir_trevor/blocks/_solr_documents_carousel_block.html.erb_spec.rb +1 -1
  158. metadata +37 -30
  159. data/app/views/spotlight/contact_forms/show.html.erb +0 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6bff0876109f9e68d8dcadddb01e465330d67d25
4
- data.tar.gz: 9f7f3daa3104c882c01e8edc24731d8e5fd9401f
3
+ metadata.gz: 797e808c409dd777422ae85313b3730de6bd0cd3
4
+ data.tar.gz: 95908a121831207677ffe422e1b67cb5a451bca1
5
5
  SHA512:
6
- metadata.gz: f27a7aab2b68144eeecd58b51b98fbaf9d78bafb38a780eecdf5a7efe74c3aefe299e4e05f4da8f5fd0251d2422bf8a45e43b6c83b7379768280e6aa0edb72d5
7
- data.tar.gz: 85db41321a6ba7e8baaa8db613bb149d88b6afaf9689bbb27c2c7538dba062e79d66a86902b6b8f9dfe0e2a519c9ad79e67a72ecb4009b454507027b288219c9
6
+ metadata.gz: 2789c3565185605cb60facf97aa1958825d121d4e412d989bb77ba9df20460211236a269812703457624b3d55d152acab312da275a78e601c061cb70aada9d58
7
+ data.tar.gz: ee69b30eb9115c7e96f1cd853cce54949d1f42fe8d9b94cce4eea451308532bbaa2c440570d51fea763e4edb777789bd430bd794058510782f1eaef5a48a9b32
data/README.md CHANGED
@@ -42,16 +42,10 @@ Run the database migrations:
42
42
  $ rake db:migrate
43
43
  ```
44
44
 
45
- Start solr:
45
+ Start Solr and the Rails development server:
46
46
 
47
47
  ```
48
- $ rake jetty:start
49
- ```
50
-
51
- Start the rails development server:
52
-
53
- ```
54
- $ rails s
48
+ $ rake spotlight:server
55
49
  ```
56
50
 
57
51
  Go to http://localhost:3000 in your browser.
@@ -72,7 +66,7 @@ See the [Spotlight wiki](https://github.com/projectblacklight/spotlight/wiki) fo
72
66
  Spotlight:
73
67
 
74
68
  * is a Rails engine and needs to be used in the context of a Rails application. We use [engine_cart](https://github.com/cbeer/engine_cart) to create an internal test application at .internal_test_app/
75
- * uses Solr as part of its integration tests. We use [jettywrapper](https://github.com/projecthydra/jettywrapper) to manage the Solr instance used for development and test.
69
+ * uses Solr as part of its integration tests. We use [solr_wrapper](https://github.com/cbeer/solr_wrapper) to manage the Solr instance used for development and test.
76
70
 
77
71
  Our `$ rake ci` and `$ rake spotlight:server` tasks utilize Solr and the testing rails app automatically.
78
72
 
@@ -12,6 +12,7 @@ SirTrevor.Blocks.Browse = (function(){
12
12
 
13
13
  item_options: function() { return [
14
14
  '<label>',
15
+ '<input type="hidden" name="display-item-counts" value="false" />',
15
16
  '<input type="checkbox" name="display-item-counts" value="true" checked />',
16
17
  '<%= i18n.t("blocks:browse:item_counts") %>',
17
18
  '</label>'
@@ -85,7 +85,7 @@ label.radio {
85
85
  legend {
86
86
  margin-bottom: $padding-large-vertical;
87
87
  }
88
- div.radio + div input, div.radio + input[type="file"] {
88
+ div.radio + input[type="file"] {
89
89
  margin-top: $padding-large-vertical;
90
90
  }
91
91
  }
@@ -43,6 +43,7 @@
43
43
 
44
44
  @media (max-width: $screen-xs-max) {
45
45
  min-width: 200px;
46
+ -webkit-flex: 1 1 200px;
46
47
  }
47
48
 
48
49
  .caption {
@@ -57,5 +58,6 @@
57
58
  -webkit-flex: 1;
58
59
  -ms-flex: 1;
59
60
  flex: 1;
61
+ -webkit-flex: 1 1 125px;
60
62
  }
61
63
  }
@@ -238,12 +238,14 @@
238
238
 
239
239
  .box {
240
240
  min-width: 150px;
241
+ -webkit-flex: 1 1 150px;
241
242
  }
242
243
 
243
244
  /* two items */
244
245
  .box:first-child:nth-last-child(2),
245
246
  .box:first-child:nth-last-child(2) ~ .box {
246
- min-width: 250px;
247
+ min-width: 250px;
248
+ -webkit-flex: 1 1 250px;
247
249
  }
248
250
 
249
251
  /* only images, no text */
@@ -257,6 +259,10 @@
257
259
  height: 175px;
258
260
  }
259
261
  }
262
+
263
+ @media (max-width: $screen-sm-max) {
264
+ -webkit-flex: 1 1 175px;
265
+ }
260
266
  }
261
267
  }
262
268
  }
@@ -11,11 +11,7 @@ module Spotlight
11
11
 
12
12
  def create
13
13
  if @contact_form.valid?
14
- if @contact_form.respond_to? :deliver_now
15
- @contact_form.deliver_now
16
- else
17
- @contact_form.deliver
18
- end
14
+ ContactMailer.report_problem(@contact_form).deliver_now
19
15
 
20
16
  redirect_to :back, notice: t(:'helpers.submit.contact_form.created')
21
17
  else
@@ -94,7 +94,13 @@ module Spotlight
94
94
  end
95
95
 
96
96
  def search_params
97
- params.require(:search).permit(:title, :long_description, masthead_attributes: featured_image_attributes, thumbnail_attributes: featured_image_attributes)
97
+ params.require(:search).permit(
98
+ :title,
99
+ :long_description,
100
+ :default_index_view_type,
101
+ masthead_attributes: featured_image_attributes,
102
+ thumbnail_attributes: featured_image_attributes
103
+ )
98
104
  end
99
105
 
100
106
  def featured_image_attributes
@@ -3,16 +3,31 @@ module Spotlight
3
3
  # Helper for browse views
4
4
  module BrowseHelper
5
5
  include ::BlacklightConfigurationHelper
6
+ def document_index_view_type
7
+ if @search && @search.default_index_view_type.present? && params[:view].blank?
8
+ blacklight_config.view[@search.default_index_view_type].key
9
+ else
10
+ super
11
+ end
12
+ end
6
13
 
7
14
  ##
8
15
  # Override Blacklight's #default_document_index_view_type helper to
9
16
  # use a different default view when presenting browse categories
10
17
  def default_document_index_view_type
11
- (default_browse_index_view_type if blacklight_config.view.key? default_browse_index_view_type) || super
18
+ if view_available? default_browse_index_view_type
19
+ default_browse_index_view_type
20
+ else
21
+ super
22
+ end
12
23
  end
13
24
 
14
25
  private
15
26
 
27
+ def view_available?(view)
28
+ blacklight_config.view.key?(view) && blacklight_configuration_context.evaluate_if_unless_configuration(blacklight_config.view)
29
+ end
30
+
16
31
  def default_browse_index_view_type
17
32
  Spotlight::Engine.config.default_browse_index_view_type
18
33
  end
@@ -0,0 +1,8 @@
1
+ module Spotlight
2
+ # Saved search helpers
3
+ module SearchesHelper
4
+ def available_document_index_views
5
+ blacklight_config.view.select { |_k, v| v.if != false }.keys
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,9 @@
1
+ module Spotlight
2
+ # Mailer for reporting problems to the application contact and/or exhibit administrator
3
+ class ContactMailer < ActionMailer::Base
4
+ def report_problem(contact_form)
5
+ @contact_form = contact_form
6
+ mail(@contact_form.headers)
7
+ end
8
+ end
9
+ end
@@ -1,10 +1,11 @@
1
+ require 'signet/oauth_2/client'
2
+ require 'legato'
3
+
1
4
  module Spotlight
2
5
  module Analytics
3
6
  ##
4
7
  # Google Analytics data provider for the curation dashboard
5
8
  class Ga
6
- require 'legato'
7
-
8
9
  extend Legato::Model
9
10
 
10
11
  cattr_writer :user, :site
@@ -62,7 +63,8 @@ module Spotlight
62
63
  def self.oauth_token(scope)
63
64
  require 'oauth2'
64
65
 
65
- OAuth2::AccessToken.new(oauth_client, api_client(scope).authorization.access_token, expires_in: 1.hour)
66
+ access_token = auth_client(scope).fetch_access_token!
67
+ OAuth2::AccessToken.new(oauth_client, access_token['access_token'], expires_in: access_token['expires_in'])
66
68
  end
67
69
 
68
70
  def self.oauth_client
@@ -70,21 +72,17 @@ module Spotlight
70
72
  token_url: 'https://accounts.google.com/o/oauth2/token')
71
73
  end
72
74
 
73
- def self.service_account(scope)
74
- @service_account ||= begin
75
- oauth_key = Google::APIClient::PKCS12.load_key(Spotlight::Engine.config.ga_pkcs12_key_path, 'notasecret')
76
- Google::APIClient::JWTAsserter.new(Spotlight::Engine.config.ga_email, scope, oauth_key)
77
- end
75
+ def self.signing_key
76
+ @signing_key ||= OpenSSL::PKCS12.new(File.read(Spotlight::Engine.config.ga_pkcs12_key_path), 'notasecret').key
78
77
  end
79
78
 
80
- def self.api_client(scope)
81
- require 'google/api_client'
82
- client = Google::APIClient.new(
83
- application_name: 'spotlight',
84
- application_version: Spotlight::VERSION
85
- )
86
- client.authorization = service_account(scope).authorize
87
- client
79
+ def self.auth_client(scope)
80
+ Signet::OAuth2::Client.new token_credential_uri: 'https://accounts.google.com/o/oauth2/token',
81
+ audience: 'https://accounts.google.com/o/oauth2/token',
82
+ scope: scope,
83
+ issuer: Spotlight::Engine.config.ga_email,
84
+ signing_key: signing_key,
85
+ sub: Spotlight::Engine.config.ga_email
88
86
  end
89
87
  end
90
88
  end
@@ -97,7 +97,7 @@ module Spotlight
97
97
  set_index_field_defaults(v)
98
98
  end
99
99
  v.upstream_if = v.if unless v.if.nil?
100
- v.if = :field_enabled?
100
+ v.if = :field_enabled? unless v.if == false
101
101
 
102
102
  v.normalize! config
103
103
  v.validate!
@@ -115,7 +115,7 @@ module Spotlight
115
115
  end
116
116
 
117
117
  v.upstream_if = v.if unless v.if.nil?
118
- v.if = :field_enabled?
118
+ v.if = :field_enabled? unless v.if == false
119
119
 
120
120
  v.normalize! config
121
121
  v.validate!
@@ -128,7 +128,7 @@ module Spotlight
128
128
 
129
129
  config.search_fields.each do |k, v|
130
130
  v.upstream_if = v.if unless v.if.nil?
131
- v.if = :field_enabled?
131
+ v.if = :field_enabled? unless v.if == false
132
132
  next if search_fields[k].blank?
133
133
 
134
134
  v.merge! search_fields[k].symbolize_keys
@@ -142,7 +142,7 @@ module Spotlight
142
142
 
143
143
  config.sort_fields.each do |k, v|
144
144
  v.upstream_if = v.if unless v.if.nil?
145
- v.if = :field_enabled?
145
+ v.if = :field_enabled? unless v.if == false
146
146
  next if sort_fields[k].blank?
147
147
 
148
148
  v.merge! sort_fields[k].symbolize_keys
@@ -161,7 +161,7 @@ module Spotlight
161
161
  v.merge! facet_fields[k].symbolize_keys
162
162
  v.upstream_if = v.if unless v.if.nil?
163
163
  v.enabled = v.show
164
- v.if = :field_enabled?
164
+ v.if = :field_enabled? unless v.if == false
165
165
  v.normalize! config
166
166
  v.validate!
167
167
  end
@@ -177,7 +177,7 @@ module Spotlight
177
177
  config.view.each do |k, v|
178
178
  v.key = k
179
179
  v.upstream_if = v.if unless v.if.nil?
180
- v.if = :enabled_in_spotlight_view_type_configuration?
180
+ v.if = :enabled_in_spotlight_view_type_configuration? unless v.if == false
181
181
  end unless document_index_view_types.blank?
182
182
 
183
183
  if config.search_fields.blank?
@@ -1,24 +1,26 @@
1
- require 'mail_form'
2
-
3
1
  module Spotlight
4
2
  ##
5
3
  # Exhibit feedback form
6
- class ContactForm < MailForm::Base
7
- attribute :current_exhibit
8
- attribute :name, validate: false
9
- attribute :email, validate: /\A([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})\z/i
10
- attribute :message
11
- attribute :current_url
4
+ class ContactForm
5
+ include ActiveModel::Model
6
+
7
+ attr_accessor :current_exhibit, :name, :email, :message, :current_url, :request
12
8
 
13
- append :remote_ip, :user_agent
9
+ validates :email, format: { with: /\A([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})\z/i }
14
10
 
15
11
  def headers
16
12
  {
13
+ to: to,
17
14
  subject: "#{I18n.t(:'blacklight.application_name')} Contact Form",
18
- to: Spotlight::Engine.config.default_contact_email || current_exhibit.contact_emails.first.to_s,
19
15
  from: %("#{name}" <#{email}>),
20
16
  cc: current_exhibit.contact_emails.join(', ')
21
17
  }
22
18
  end
19
+
20
+ private
21
+
22
+ def to
23
+ Spotlight::Engine.config.default_contact_email || current_exhibit.contact_emails.first.to_s
24
+ end
23
25
  end
24
26
  end
@@ -0,0 +1,8 @@
1
+ module Spotlight
2
+ # Used by RIIIF to find files uploaded by carrierwave
3
+ class CarrierwaveFileResolver < Riiif::AbstractFileSystemResolver
4
+ def pattern(id)
5
+ Spotlight::FeaturedImage.find(id).image.file.file
6
+ end
7
+ end
8
+ end
@@ -15,6 +15,10 @@
15
15
 
16
16
  <div class="col-md-12">
17
17
  <%= render 'sort_and_per_page' %>
18
- <%= render_document_index(@document_list) %>
18
+ <% if @search.default_index_view_type && params[:view].blank? %>
19
+ <%= render_document_index_with_view(@search.default_index_view_type, @document_list) %>
20
+ <% else %>
21
+ <%= render_document_index(@document_list) %>
22
+ <% end %>
19
23
  <%= render 'results_pagination' %>
20
24
  </div>
@@ -0,0 +1,14 @@
1
+ <p><%= @contact_form.name %></p>
2
+ <p>From: <%= %("#{@contact_form.name}" <#{@contact_form.email}>) %></p>
3
+
4
+ <p><%= @contact_form.message %></p>
5
+
6
+ ----
7
+
8
+ <dl>
9
+ <dt>REMOTE_IP</dt><dd><%= @contact_form.request.remote_ip %></dd>
10
+ <dt>USER AGENT</dt><dd><%= @contact_form.request.user_agent %></dd>
11
+ <dt>EXHIBIT</dt><dd><%= @contact_form.current_exhibit.title %></dd>
12
+ <dt>CURRENT_URL</dt><dd><%= @contact_form.current_url %></dd>
13
+ <dt>UUID</dt><dd><%= @contact_form.request.uuid %></dd>
14
+ </dl>
@@ -7,9 +7,7 @@
7
7
  <%= render 'analytics' %>
8
8
  <% else %>
9
9
  <div class="empty-page-block">
10
- <% unless current_user %>
11
- <p>In order to view exhibit analytics, the site administrator must <a href="https://github.com/projectblacklight/spotlight/wiki/Installation">configure an analytics provider.</a></p>
12
- <% end %>
10
+ <p>In order to view exhibit analytics, the site administrator must <a href="https://github.com/projectblacklight/spotlight/wiki/Installation">configure an analytics provider.</a></p>
13
11
  </div>
14
12
  <% end %>
15
13
  </div>
@@ -30,6 +30,11 @@
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 label: { text: t(:".default_index_view_type") } do %>
34
+ <% available_document_index_views.each do |view| %>
35
+ <%= f.radio_button :default_index_view_type, view, label: view_label(view) %>
36
+ <% end %>
37
+ <% end %>
33
38
  <%= f.static_control label: t(:".query_params") do %>
34
39
  <div class="well well-sm">
35
40
  <%= render_constraints(@search.query_params) %>
@@ -5,6 +5,7 @@
5
5
 
6
6
  <div class="items-col spotlight-flexbox pull-<%= solr_documents_block.content_align %> <%= solr_documents_block.text? ? "col-md-6" : "col-md-12" %> ">
7
7
  <% solr_documents_block.each_document do |block_options, document| %>
8
+ <% doc_presenter = index_presenter(document) %>
8
9
  <div class="box" data-id="<%= document.id %>">
9
10
  <div class="contents">
10
11
  <% if block_thumb = block_options[:thumbnail_image_url] %>
@@ -14,12 +15,12 @@
14
15
  <% end %>
15
16
  <% if solr_documents_block.primary_caption? %>
16
17
  <div class="caption primary-caption">
17
- <%= render_index_field_value document, solr_documents_block.primary_caption_field %>
18
+ <%= doc_presenter.field_value solr_documents_block.primary_caption_field %>
18
19
  </div>
19
20
  <% end %>
20
21
  <% if solr_documents_block.secondary_caption? %>
21
22
  <div class="caption secondary-caption">
22
- <%= render_index_field_value document, solr_documents_block.secondary_caption_field %>
23
+ <%= doc_presenter.field_value solr_documents_block.secondary_caption_field %>
23
24
  </div>
24
25
  <% end %>
25
26
  </div>
@@ -36,4 +37,4 @@
36
37
  <%= sir_trevor_markdown solr_documents_block.text %>
37
38
  </div>
38
39
  <% end %>
39
- </div>
40
+ </div>
@@ -6,6 +6,7 @@
6
6
  <div id="<%= html_id %>" class="carousel slide" data-ride="carousel" data-interval="<%= solr_documents_carousel_block.interval %>">
7
7
  <div class="carousel-inner">
8
8
  <% solr_documents_carousel_block.each_document.each_with_index do |(block_options, document), index| %>
9
+ <% doc_presenter = index_presenter(document) %>
9
10
  <div class="item <%= 'active' if index == 0 %>" data-id="<%= document.id %>">
10
11
  <% if block_thumb = block_options[:full_image_url] %>
11
12
  <%= link_to_document(document, image_tag(block_thumb), counter: -1) %>
@@ -15,12 +16,12 @@
15
16
  <div class="carousel-caption">
16
17
  <% if solr_documents_carousel_block.primary_caption? %>
17
18
  <h3 class="primary">
18
- <%= render_index_field_value document, solr_documents_carousel_block.primary_caption_field %>
19
+ <%= doc_presenter.field_value solr_documents_carousel_block.primary_caption_field %>
19
20
  </h3>
20
21
  <% end %>
21
22
  <% if solr_documents_carousel_block.secondary_caption? %>
22
23
  <div class="secondary">
23
- <%= render_index_field_value document, solr_documents_carousel_block.secondary_caption_field %>
24
+ <%= doc_presenter.field_value solr_documents_carousel_block.secondary_caption_field %>
24
25
  </div>
25
26
  <% end %>
26
27
  </div>