blacklight-spotlight 4.0.2 → 4.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +17 -9
  3. data/app/assets/stylesheets/spotlight/_catalog.scss +0 -12
  4. data/app/assets/stylesheets/spotlight/_header.scss +9 -0
  5. data/app/assets/stylesheets/spotlight/browse_group_categories_block.scss +4 -4
  6. data/app/components/blacklight/icons/arrow_alt_circle_left_component.rb +15 -0
  7. data/app/components/blacklight/icons/arrow_alt_circle_right_component.rb +15 -0
  8. data/app/components/blacklight/icons/arrow_back_ios_component.rb +15 -0
  9. data/app/components/blacklight/icons/arrow_forward_ios_component.rb +15 -0
  10. data/app/components/blacklight/icons/check_circle_component.rb +15 -0
  11. data/app/components/blacklight/icons/check_component.rb +15 -0
  12. data/app/components/blacklight/icons/chevron_right_component.rb +15 -0
  13. data/app/components/blacklight/icons/close_component.rb +15 -0
  14. data/app/components/blacklight/icons/edit_component.rb +15 -0
  15. data/app/components/blacklight/icons/error_component.rb +14 -0
  16. data/app/components/blacklight/icons/highlight_off_component.rb +15 -0
  17. data/app/components/blacklight/icons/info_component.rb +15 -0
  18. data/app/components/blacklight/icons/warning_component.rb +14 -0
  19. data/app/components/blacklight/icons/zoom_in_component.rb +15 -0
  20. data/app/components/blacklight/icons/zoom_out_component.rb +15 -0
  21. data/app/components/spotlight/analytics/aggregation_component.html.erb +14 -0
  22. data/app/components/spotlight/analytics/aggregation_component.rb +37 -0
  23. data/app/components/spotlight/analytics/dashboard_component.html.erb +50 -0
  24. data/app/components/spotlight/analytics/dashboard_component.rb +32 -0
  25. data/app/components/spotlight/document_admin_table_component.html.erb +36 -0
  26. data/app/components/spotlight/document_admin_table_component.rb +23 -0
  27. data/app/components/spotlight/header_component.html.erb +1 -0
  28. data/app/components/spotlight/header_component.rb +6 -0
  29. data/app/components/spotlight/icon_component.rb +13 -0
  30. data/app/components/spotlight/solr_document_legacy_embed_component.html.erb +11 -0
  31. data/app/components/spotlight/solr_document_legacy_embed_component.rb +7 -0
  32. data/app/controllers/concerns/spotlight/controller.rb +1 -1
  33. data/app/controllers/spotlight/browse_controller.rb +2 -0
  34. data/app/controllers/spotlight/catalog_controller.rb +6 -2
  35. data/app/controllers/spotlight/dashboards_controller.rb +4 -3
  36. data/app/models/concerns/spotlight/exhibit_analytics.rb +6 -4
  37. data/app/models/spotlight/analytics/ga.rb +90 -43
  38. data/app/models/spotlight/blacklight_configuration.rb +8 -1
  39. data/app/views/layouts/spotlight/base.html.erb +2 -2
  40. data/app/views/shared/_header_navbar.html.erb +6 -12
  41. data/app/views/spotlight/catalog/_admin_index_header_default.html.erb +1 -0
  42. data/app/views/spotlight/catalog/_admin_thumbnail_default.html.erb +1 -0
  43. data/app/views/spotlight/catalog/_document_admin_table.html.erb +8 -1
  44. data/app/views/spotlight/catalog/_document_row.html.erb +2 -5
  45. data/app/views/spotlight/catalog/_index_compact_default.html.erb +1 -0
  46. data/app/views/spotlight/catalog/edit.html.erb +15 -2
  47. data/app/views/spotlight/dashboards/analytics.html.erb +2 -2
  48. data/app/views/spotlight/pages/_view_type_group.html.erb +2 -5
  49. data/app/views/spotlight/sir_trevor/blocks/_browse_group_categories_block.html.erb +2 -2
  50. data/app/views/spotlight/sir_trevor/blocks/_embedded_document.html.erb +8 -0
  51. data/app/views/spotlight/sir_trevor/blocks/_solr_documents_embed_block.html.erb +3 -3
  52. data/app/views/spotlight/sir_trevor/blocks/_solr_documents_features_block.html.erb +1 -1
  53. data/config/locales/spotlight.en.yml +16 -4
  54. data/lib/generators/spotlight/templates/catalog_controller.rb +3 -0
  55. data/lib/generators/spotlight/templates/config/initializers/spotlight_initializer.rb +16 -12
  56. data/lib/spotlight/engine.rb +11 -9
  57. data/lib/spotlight/version.rb +1 -1
  58. data/lib/spotlight.rb +3 -0
  59. data/spec/support/features/test_features_helpers.rb +1 -1
  60. metadata +61 -31
  61. data/app/assets/images/blacklight/arrow-alt-circle-left.svg +0 -1
  62. data/app/assets/images/blacklight/arrow-alt-circle-right.svg +0 -1
  63. data/app/assets/images/blacklight/arrow_back_ios.svg +0 -1
  64. data/app/assets/images/blacklight/arrow_forward_ios.svg +0 -1
  65. data/app/assets/images/blacklight/check.svg +0 -1
  66. data/app/assets/images/blacklight/check_circle.svg +0 -1
  67. data/app/assets/images/blacklight/chevron_right.svg +0 -1
  68. data/app/assets/images/blacklight/close.svg +0 -1
  69. data/app/assets/images/blacklight/edit.svg +0 -1
  70. data/app/assets/images/blacklight/error.svg +0 -1
  71. data/app/assets/images/blacklight/highlight_off.svg +0 -1
  72. data/app/assets/images/blacklight/info.svg +0 -1
  73. data/app/assets/images/blacklight/warning.svg +0 -1
  74. data/app/assets/images/blacklight/zoom_in.svg +0 -1
  75. data/app/assets/images/blacklight/zoom_out.svg +0 -1
  76. data/app/models/spotlight/analytics/ga_model.rb +0 -29
  77. data/app/views/spotlight/dashboards/_analytics.html.erb +0 -35
@@ -37,7 +37,11 @@ module Spotlight
37
37
 
38
38
  before_action only: :admin do
39
39
  blacklight_config.view.select! { |k, _v| k == :admin_table }
40
- blacklight_config.view.admin_table(partials: [:index_compact], document_actions: []) unless blacklight_config.view.key? :admin_table
40
+ unless blacklight_config.view.key? :admin_table
41
+ blacklight_config.view.admin_table(document_component: Spotlight::DocumentAdminTableComponent,
42
+ partials: [:index_compact],
43
+ document_actions: [])
44
+ end
41
45
  if Blacklight::VERSION > '8'
42
46
  blacklight_config.track_search_session.storage = false
43
47
  else
@@ -51,7 +55,7 @@ module Spotlight
51
55
  end
52
56
 
53
57
  before_action only: :edit do
54
- blacklight_config.view.edit(partials: blacklight_config.view_config(:show).partials.dup.insert(2, :edit)) unless blacklight_config.view.key? :edit
58
+ blacklight_config.action_mapping.edit.top_level_config = :show
55
59
  end
56
60
 
57
61
  def show
@@ -12,14 +12,15 @@ module Spotlight
12
12
 
13
13
  before_action only: [:show] do
14
14
  blacklight_config.action_mapping&.delete(:show)
15
- blacklight_config.view.clear
16
- blacklight_config.view.admin_table(partials: ['index_compact'], document_actions: [])
15
+ blacklight_config.action_mapping.show.top_level_config = :index if blacklight_config.key?(:action_mapping)
16
+
17
+ blacklight_config.index.document_component = Spotlight::DocumentAdminTableComponent
18
+ blacklight_config.index.document_actions = []
17
19
  if Blacklight::VERSION > '8'
18
20
  blacklight_config.track_search_session.storage = false
19
21
  else
20
22
  blacklight_config.track_search_session = false
21
23
  end
22
- blacklight_config.action_mapping.show.top_level_config = :index if blacklight_config.key?(:action_mapping)
23
24
  end
24
25
 
25
26
  def show
@@ -4,18 +4,20 @@ module Spotlight
4
4
  ##
5
5
  # Exhibit mixin to provide analytics data
6
6
  module ExhibitAnalytics
7
- def analytics(start_date = 1.month, path = nil)
7
+ def analytics(dates = { start_date: '365daysAgo', end_date: 'today' }, path = nil)
8
8
  return OpenStruct.new unless analytics_provider&.enabled?
9
9
 
10
10
  @analytics ||= {}
11
- @analytics[start_date] ||= analytics_provider.exhibit_data(path || self, start_date: start_date.ago)
11
+ start_date = dates['start_date'] || 1.month.ago
12
+ @analytics[start_date] ||= analytics_provider.exhibit_data(path || self, dates)
12
13
  end
13
14
 
14
- def page_analytics(start_date = 1.month, path = nil)
15
+ def page_analytics(dates = { start_date: '365daysAgo', end_date: 'today' }, path = nil)
15
16
  return [] unless analytics_provider&.enabled?
16
17
 
17
18
  @page_analytics ||= {}
18
- @page_analytics[start_date] ||= analytics_provider.page_data(path || self, start_date: start_date.ago)
19
+ start_date = dates['start_date'] || 1.month.ago
20
+ @page_analytics[start_date] ||= analytics_provider.page_data(path || self, dates)
19
21
  end
20
22
 
21
23
  def analytics_provider
@@ -1,80 +1,127 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'signet/oauth_2/client'
4
- require 'legato'
4
+ require 'google/analytics/data'
5
5
 
6
6
  module Spotlight
7
7
  module Analytics
8
8
  ##
9
9
  # Google Analytics data provider for the Exhibit dashboard
10
10
  class Ga
11
- extend Legato::Model
12
-
13
11
  def enabled?
14
- user && site
12
+ Spotlight::Engine.config.ga_json_key_path && client
13
+ end
14
+
15
+ def client
16
+ Google::Analytics::Data.analytics_data do |config|
17
+ config.credentials = Spotlight::Engine.config.ga_json_key_path
18
+ end
19
+ rescue StandardError => e
20
+ Rails.logger.error(e)
21
+ nil
15
22
  end
16
23
 
17
- delegate :metrics, to: :model
24
+ def params(path, dates)
25
+ {
26
+ date_ranges: [{ start_date: dates['start_date'], end_date: dates['end_date'] }],
27
+ metric_aggregations: [
28
+ ::Google::Analytics::Data::V1beta::MetricAggregation::TOTAL
29
+ ],
30
+ property: "properties/#{ga_property_id}",
31
+ dimension_filter: dimension_filter(path)
32
+ }
33
+ end
18
34
 
19
- def exhibit_data(exhibit, options)
20
- model.context(exhibit).results(site, Spotlight::Engine.config.ga_analytics_options.merge(options)).to_a.first || exhibit_data_unavailable
35
+ def dimension_filter(path)
36
+ Google::Analytics::Data::V1beta::FilterExpression.new(
37
+ filter: Google::Analytics::Data::V1beta::Filter.new(
38
+ field_name: 'pagePath',
39
+ string_filter: Google::Analytics::Data::V1beta::Filter::StringFilter.new(
40
+ match_type: :BEGINS_WITH,
41
+ value: path.to_s
42
+ )
43
+ )
44
+ )
21
45
  end
22
46
 
23
- def page_data(exhibit, options)
24
- options[:sort] ||= '-pageviews'
25
- query = model.context(exhibit).results(site, Spotlight::Engine.config.ga_page_analytics_options.merge(options))
26
- query.dimensions << :page_path
27
- query.dimensions << :page_title
47
+ def search_params(path, dates)
48
+ params(path, dates).merge({ dimensions: [{ name: 'searchTerm' }],
49
+ metrics: [{ name: 'eventCount' }, { name: 'sessions' },
50
+ { name: 'screenPageViewsPerSession' }, { name: 'engagementRate' }],
51
+ order_bys: [{ metric: { metric_name: 'eventCount' },
52
+ desc: true }] }).merge(Spotlight::Engine.config.ga_search_analytics_options)
53
+ end
28
54
 
29
- query.to_a
55
+ def page_params(path, dates)
56
+ params(path, dates).merge({
57
+ dimensions: [{ name: 'pagePath' }, { name: 'pageTitle' }],
58
+ order_bys: [{ metric: { metric_name: 'screenPageViews' }, desc: true }],
59
+ metrics: [{ name: 'totalUsers' }, { name: 'activeUsers' },
60
+ { name: 'screenPageViews' }]
61
+ }).merge(Spotlight::Engine.config.ga_page_analytics_options)
30
62
  end
31
63
 
32
- def user(scope = 'https://www.googleapis.com/auth/analytics.readonly')
33
- @user ||= begin
34
- Legato::User.new(oauth_token(scope))
35
- rescue StandardError => e
36
- Rails.logger.info(e)
37
- nil
38
- end
64
+ def report(params)
65
+ request = ::Google::Analytics::Data::V1beta::RunReportRequest.new(params)
66
+ client.run_report request
39
67
  end
40
68
 
41
- def site
42
- @site ||= user.accounts.first.profiles.find { |x| x.web_property_id == Spotlight::Engine.config.ga_web_property_id }
69
+ def page_data(path, dates)
70
+ metric_parsing(report(page_params(path, dates)))
43
71
  end
44
72
 
45
- private
73
+ def parse_data(value)
74
+ if value.to_i.to_s == value
75
+ value.to_i.to_fs(:delimited)
76
+ elsif !!(value =~ /\A[-+]?\d*\.?\d+\z/)
77
+ value.to_f
78
+ else
79
+ value
80
+ end
81
+ end
46
82
 
47
- def model
48
- Spotlight::Analytics::GaModel
83
+ def exhibit_data(path, dates)
84
+ metric_parsing(report(search_params(path, dates)))
49
85
  end
50
86
 
51
- def exhibit_data_unavailable
52
- OpenStruct.new(pageviews: 'n/a', users: 'n/a', sessions: 'n/a')
87
+ def totals
88
+ OpenStruct.new(@report_data.totals[0].metric_values.each_with_index.with_object({}) do |(mv, index), result|
89
+ result[metric_headers[index]] = parse_data(mv.value)
90
+ end)
53
91
  end
54
92
 
55
- def oauth_token(scope)
56
- require 'oauth2'
93
+ # rubocop:disable Metrics/AbcSize
94
+ def rows
95
+ @report_data.rows.map do |row|
96
+ OpenStruct.new(row.dimension_values.each_with_index.with_object({}) do |(dv, index), result|
97
+ result[dimension_headers[index]] = parse_data(dv.value)
98
+ end.merge(row.metric_values.each_with_index.with_object({}) do |(mv, index), result|
99
+ result[metric_headers[index]] = parse_data(mv.value)
100
+ end))
101
+ end
102
+ end
103
+ # rubocop:enable Metrics/AbcSize
57
104
 
58
- access_token = auth_client(scope).fetch_access_token!
59
- OAuth2::AccessToken.new(oauth_client, access_token['access_token'], expires_in: access_token['expires_in'])
105
+ def metric_headers
106
+ @report_data.metric_headers.map(&:name)
60
107
  end
61
108
 
62
- def oauth_client
63
- OAuth2::Client.new('', '', authorize_url: 'https://accounts.google.com/o/oauth2/auth',
64
- token_url: 'https://accounts.google.com/o/oauth2/token')
109
+ def dimension_headers
110
+ @report_data.dimension_headers.map(&:name)
65
111
  end
66
112
 
67
- def signing_key
68
- @signing_key ||= OpenSSL::PKCS12.new(File.read(Spotlight::Engine.config.ga_pkcs12_key_path), 'notasecret').key
113
+ def metric_parsing(report_data)
114
+ return OpenStruct.new({ totals: [], rows: [] }) unless report_data.rows.any?
115
+
116
+ @report_data = report_data
117
+
118
+ OpenStruct.new({ rows: rows, totals: totals })
69
119
  end
70
120
 
71
- def auth_client(scope)
72
- Signet::OAuth2::Client.new token_credential_uri: 'https://accounts.google.com/o/oauth2/token',
73
- audience: 'https://accounts.google.com/o/oauth2/token',
74
- scope: scope,
75
- issuer: Spotlight::Engine.config.ga_email,
76
- signing_key: signing_key,
77
- sub: Spotlight::Engine.config.ga_email
121
+ private
122
+
123
+ def ga_property_id
124
+ Spotlight::Engine.config.ga_property_id
78
125
  end
79
126
  end
80
127
  end
@@ -121,8 +121,15 @@ module Spotlight
121
121
  config.default_per_page = default_per_page if default_per_page
122
122
 
123
123
  config.view.embed!
124
- config.view.embed.partials ||= ['openseadragon']
124
+ # This is blacklight-gallery's openseadragon partial
125
+ unless config.view.embed.document_component
126
+ config.view.embed.partials ||= ['openseadragon']
127
+ config.view.embed.document_component = Spotlight::SolrDocumentLegacyEmbedComponent
128
+ end
125
129
  config.view.embed.if = false
130
+
131
+ # blacklight-gallery requires tile_source_field
132
+ config.view.embed.tile_source_field ||= config.show.tile_source_field
126
133
  config.view.embed.locals ||= { osd_container_class: '' }
127
134
 
128
135
  # Add any custom fields
@@ -26,9 +26,9 @@
26
26
  <%= render partial: 'shared/body_preamble' %>
27
27
  <div id="skip-link">
28
28
  <% if should_render_spotlight_search_bar? %>
29
- <%= link_to t('blacklight.skip_links.search_field'), '#search_field', class: 'element-invisible element-focusable rounded-bottom py-2 px-3' %>
29
+ <%= link_to t('blacklight.skip_links.search_field'), '#search_field', class: 'btn btn-link bg-light sr-only sr-only-focusable visually-hidden-focusable' %>
30
30
  <% end %>
31
- <%= link_to t('blacklight.skip_links.main_content'), '#main-container', class: 'element-invisible element-focusable rounded-bottom py-2 px-3' %>
31
+ <%= link_to t('blacklight.skip_links.main_content'), '#main-container', class: 'btn btn-link bg-light sr-only sr-only-focusable visually-hidden-focusable' %>
32
32
  <%= content_for(:skip_links) %>
33
33
  </div>
34
34
 
@@ -1,12 +1,6 @@
1
- <nav class="navbar navbar-expand-md navbar-dark bg-dark topbar" role="navigation" aria-label="<%= t('spotlight.topbar.label') %>">
2
- <div class="<%= container_classes %>">
3
- <%= link_to application_name, main_app.root_path, class: 'mb-0 navbar-brand navbar-logo' %>
4
- <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-bs-toggle="collapse" data-target="#user-util-collapse" data-bs-target="#user-util-collapse" aria-controls="user-util-collapse" aria-expanded="false" aria-label="<%= t :toggle_nav %>">
5
- <span class="navbar-toggler-icon"></span>
6
- </button>
7
-
8
- <div class="collapse navbar-collapse justify-content-md-end" id="user-util-collapse">
9
- <%= render partial: 'shared/user_util_links' %>
10
- </div>
11
- </div>
12
- </nav>
1
+ <% if blacklight_config.header_component.present? && blacklight_config.header_component != Blacklight::HeaderComponent %>
2
+ <%= render blacklight_config.header_component.new(blacklight_config: blacklight_config) %>
3
+ <% else %>
4
+ <%= render Spotlight::HeaderComponent.new(blacklight_config: blacklight_config) %>
5
+ <% Spotlight.deprecator.warn("_header_navbar.html.erb will be deprecated in future versions. Please use Blacklight configuration to specify your HeaderComponent.") %>
6
+ <% end %>
@@ -1,4 +1,5 @@
1
1
  <%# header bar for doc items in index view -%>
2
+ <%- Spotlight.deprecator.warn 'The partial _spotlight/catalog/admin_index_header_default.html.erb will be removed; customize the admin display using components instead' %>
2
3
  <div class="documentHeader row" data-label-toggle="<%= document.id %>">
3
4
  <%# main title container for doc partial view
4
5
  How many bootstrap columns need to be reserved
@@ -1,3 +1,4 @@
1
+ <%- Spotlight.deprecator.warn 'The partial _spotlight/catalog/_admin_thumbnail.html.erb will be removed; customize the admin display using components instead' %>
1
2
  <% doc_presenter = document_presenter(document) %>
2
3
  <%- if doc_presenter.thumbnail.exists? %>
3
4
  <div class="document-thumbnail spotlight-admin-thumbnail">
@@ -1,4 +1,5 @@
1
1
  <% # container for all documents in index view -%>
2
+ <% view_config = local_assigns[:view_config] || blacklight_config&.view_config(default_document_index_view_type) %>
2
3
  <table id="documents" class="table">
3
4
  <thead>
4
5
  <tr>
@@ -8,5 +9,11 @@
8
9
  <th scope="col" class="checkbox-toggle"><%= t(:'spotlight.catalog.fields.visibility') %></th>
9
10
  </tr>
10
11
  </thead>
11
- <%= render partial: 'document_row', collection: documents, as: :document %>
12
+
13
+ <% if Blacklight.version < '8.0' %>
14
+ <%= render view_config.document_component.with_collection(documents) %>
15
+ <% else %>
16
+ <% document_presenters = documents.map { |doc| document_presenter(doc) } -%>
17
+ <%= render view_config.document_component.with_collection(document_presenters) %>
18
+ <% end %>
12
19
  </table>
@@ -1,5 +1,2 @@
1
- <% # container for a single doc -%>
2
- <tr class="<%= render_document_class document %> doc-row" data-label-toggle="<%= document.id %>" itemscope itemtype="<%= document.itemtype %>">
3
- <%= render_document_partials document, blacklight_config.view_config(document_index_view_type).partials, :document_counter => document_counter %>
4
- </tr>
5
-
1
+ <%- Spotlight.deprecator.warn 'The partial _spotlight/catalog/_document_row.html.erb will be removed; customize the admin display using components instead' %>
2
+ <%= render Spotlight::DocumentAdminTableComponent.new(presenter: document_presenter(document)) %>
@@ -1,3 +1,4 @@
1
+ <%- Spotlight.deprecator.warn 'The partial _spotlight/catalog/_index_compact_default.html.erb will be removed; customize the admin display using components instead' %>
1
2
  <% # header bar for doc items in index view -%>
2
3
  <td>
3
4
  <%= render_document_partial document, 'admin_thumbnail', document_counter: document_counter %>
@@ -1,3 +1,16 @@
1
- <div id="document" class="document <%= render_document_class %>" itemscope itemtype="<%= @document.itemtype %>">
2
- <%= render_document_partials @document, blacklight_config.view_config(:edit).partials %>
1
+ <div class="container">
2
+ <div class="row">
3
+ <%- view_config = blacklight_config.view_config(action_name: :edit) %>
4
+ <%= render (view_config.document_component || Blacklight::DocumentComponent).new(presenter: document_presenter(@document), classes: ['col-md-8'], component: :div, show: true, actions: false, partials: view_config.partials) do |component| %>
5
+ <% component.with_title(as: 'h1', classes: '', link_to_document: false) %>
6
+ <% component.with_body do %>
7
+ <% view_config.partials.each do |view_partial| %>
8
+ <%= render_document_partial @document, view_partial, component: component, document_counter: 1 %>
9
+ <% end %>
10
+ <% end if Blacklight.version < '8.0' && view_config.document_component.blank? %>
11
+ <% end %>
12
+ <div class="col-md-4">
13
+ <%= render 'edit_default', document: @document %>
14
+ </div>
15
+ </div>
3
16
  </div>
@@ -5,9 +5,9 @@
5
5
  <%= curation_page_title %>
6
6
 
7
7
  <% if current_exhibit.analytics_provider&.enabled? %>
8
- <%= render 'analytics' %>
8
+ <%= render Spotlight::Analytics::DashboardComponent.new(current_exhibit: current_exhibit) %>
9
9
  <% else %>
10
10
  <div class="empty-page-block">
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>
11
+ <p>In order to view exhibit analytics, the site administrator must configure an analytics provider.</p>
12
12
  </div>
13
13
  <% end %>
@@ -3,11 +3,8 @@
3
3
  <div class="view-type">
4
4
  <span class="sr-only visually-hidden"><%= t('blacklight.search.view_title') %></span>
5
5
  <div class="view-type-group btn-group">
6
- <% views.each do |view, config| %>
7
- <%= link_to url_for(search_state.to_h.merge(view: view)), :title => t("blacklight.search.view_title.#{view}", default: t("blacklight.search.view.#{view}", default: blacklight_config.view[view].title)), :class => "btn btn-outline-secondary view-type-#{ view.to_s.parameterize } #{"active" if block_document_index_view_type(block) == view}" do %>
8
- <%= blacklight_icon config.icon || view %>
9
- <span class="caption"><%= t("blacklight.search.view.#{view}") %></span>
10
- <% end %>
6
+ <% views.each do |key, config| %>
7
+ <%= render Blacklight::Response::ViewTypeButtonComponent.new(key: key, view: config, selected: block_document_index_view_type(block) == key, search_state: search_state) %>
11
8
  <% end %>
12
9
  </div>
13
10
  </div>
@@ -11,10 +11,10 @@
11
11
  <% if group.searches.count > 1 %>
12
12
  <ul class="browse-group-categories-controls p-0 pt-2 pt-md-0 ml-md-auto ms-md-auto mb-0 d-flex justify-content-center align-items-end">
13
13
  <li class="prev px-1 overflow-hidden">
14
- <%= blacklight_icon 'arrow-alt-circle-left' %>
14
+ <%= blacklight_icon 'arrow_alt_circle_left' %>
15
15
  </li>
16
16
  <li class="next px-1 overflow-hidden">
17
- <%= blacklight_icon 'arrow-alt-circle-right' %>
17
+ <%= blacklight_icon 'arrow_alt_circle_right' %>
18
18
  </li>
19
19
  </ul>
20
20
  <% end %>
@@ -0,0 +1,8 @@
1
+ <div class="box" data-id="<%= document.id %>">
2
+ <% view_config = blacklight_config.view_config(:embed) %>
3
+ <%= render (view_config.document_component || Spotlight::SolrDocumentLegacyEmbedComponent).new((Blacklight.version > '8.0' ? :document : :presenter) => document_presenter(document), counter: nil) do |component| %>
4
+ <% component.with_partial do %>
5
+ <%= render_document_partials document, view_config.partials, component: component, document_counter: nil, view_config: view_config, block: local_assigns[:block], **(view_config.locals) %>
6
+ <% end if view_config&.partials&.any? %>
7
+ <% end %>
8
+ </div>
@@ -11,10 +11,10 @@
11
11
  <% end %>
12
12
  <% end %>
13
13
  <div class="spotlight-flexbox">
14
+ <%# Render the openseadragon viewer from blacklight-gallery.
15
+ # Settings in blacklight_configuration.rb %>
14
16
  <% solr_documents_embed_block.each_document do |block_options, document| %>
15
- <div class="box" data-id="<%= document.id %>">
16
- <%= render_document_partials document, blacklight_config.view.embed.partials, (blacklight_config.view.embed.locals || {}).reverse_merge(block: solr_documents_embed_block) %>
17
- </div>
17
+ <%= render '/spotlight/sir_trevor/blocks/embedded_document', document: document, block: solr_documents_embed_block %>
18
18
  <% end %>
19
19
  </div>
20
20
  </div>
@@ -25,7 +25,7 @@
25
25
  <% caption_text = solr_documents_features_block.document_caption(doc_presenter, solr_documents_features_block.primary_caption_field, default: Spotlight::PageConfigurations::DOCUMENT_TITLE_KEY) %>
26
26
 
27
27
  <a href="#" title="<%= caption_text %>">
28
- <%= truncate(caption_text, length: 95) %>
28
+ <%= truncate(caption_text.to_s, length: 95) %>
29
29
  </a>
30
30
  <% if solr_documents_features_block.secondary_caption? %>
31
31
  <p><%= solr_documents_features_block.document_caption(doc_presenter, solr_documents_features_block.secondary_caption_field) %></p>
@@ -481,14 +481,26 @@ en:
481
481
  header: Add exhibit-specific field
482
482
  dashboards:
483
483
  analytics:
484
+ activeUsers: unique visits
485
+ engagementRate: engagement rate
484
486
  header: Analytics
485
- monthly_header: User activity over the past month
487
+ no_results: There are no analytics for the path "%{pageurl}"
486
488
  pages:
487
489
  header: Most popular pages
488
- pagetitle: page title
489
- pageviews: page views
490
- sessions: visitors
490
+ pagetitle: Page title
491
+ pageviews: Page views
492
+ reporting_period_heading: User activity over the past year
493
+ screenPageViews: page views
494
+ screenPageViewsPerSession: pages per session
495
+ searches:
496
+ header: Most used search terms
497
+ term: Search term
498
+ views: Searches
499
+ session_header: Sessions
500
+ sessions: sessions
501
+ totalUsers: visitors
491
502
  users: unique visits
503
+ visitor_header: Visitors
492
504
  page_activity:
493
505
  field:
494
506
  last_edited_by: User
@@ -13,6 +13,9 @@ class CatalogController < ApplicationController
13
13
  fl: '*'
14
14
  }
15
15
 
16
+ # Blacklight 8 sets a default value to 'advanced'
17
+ config.json_solr_path = nil
18
+ config.header_component = Spotlight::HeaderComponent
16
19
  config.document_solr_path = 'get'
17
20
  config.document_unique_id_param = 'ids'
18
21
 
@@ -42,21 +42,21 @@
42
42
 
43
43
  # ==> Uploaded item configuration
44
44
  # Spotlight::Engine.config.upload_fields = [
45
- # UploadFieldConfig.new(
46
- # field_name: config.upload_description_field,
47
- # label: -> { I18n.t(:"spotlight.search.fields.#{config.upload_description_field}") },
45
+ # Spotlight::UploadFieldConfig.new(
46
+ # field_name: Spotlight::Engine.config.upload_description_field,
47
+ # label: -> { I18n.t(:"spotlight.search.fields.#{Spotlight::Engine.config.upload_description_field}") },
48
48
  # form_field_type: :text_area
49
49
  # ),
50
- # UploadFieldConfig.new(
50
+ # Spotlight::UploadFieldConfig.new(
51
51
  # field_name: :spotlight_upload_attribution_tesim,
52
52
  # label: -> { I18n.t(:'spotlight.search.fields.spotlight_upload_attribution_tesim') }
53
53
  # ),
54
- # UploadFieldConfig.new(
54
+ # Spotlight::UploadFieldConfig.new(
55
55
  # field_name: :spotlight_upload_date_tesim,
56
56
  # label: -> { I18n.t(:'spotlight.search.fields.spotlight_upload_date_tesim') }
57
57
  # )
58
58
  # ]
59
- # Spotlight::Engine.config.upload_title_field = nil # UploadFieldConfig.new(...)
59
+ # Spotlight::Engine.config.upload_title_field = nil # Spotlight::UploadFieldConfig.new(...)
60
60
  # Spotlight::Engine.config.uploader_storage = :file
61
61
  # Spotlight::Engine.config.allowed_upload_extensions = %w(jpg jpeg png)
62
62
 
@@ -65,17 +65,21 @@
65
65
 
66
66
  # ==> Google Analytics integration
67
67
  # After creating a property for your site on Google Analytics, you need to:
68
- # a) register an OAuth service account with access to your analytics property:
69
- # (https://github.com/tpitale/legato/wiki/OAuth2-and-Google#registering-for-api-access)
70
- # b) download the pkcs12 key and make it accessible to your application
71
- # c) set ga_web_property_id below to your site's property id
68
+ # a) Enable Google Analytics API in https://console.cloud.google.com/
69
+ # b) generate and download the JSON key and make it accessible to your application
70
+ # (https://console.cloud.google.com/iam-admin/iam -> Service accounts -> click on service account -> keys)
71
+ # c) set ga_property_id below to your site's property id (located in admin -> Property -> Property details upper right hand corner)
72
+ # d) Set the ga_web_property_id. (located in admin -> Data collection and modification -> Web stream details and begins with G-)
73
+ # ga_property_id is used for fetching analytics data from google's api, ga_web_property_id is used for sending events to GA analtyics
74
+ # ga_web_property_id will probably change in V5 to ga_measurement_id for clarity
72
75
  # Rails.application.config.to_prepare do
73
76
  # Spotlight::Engine.config.analytics_provider = Spotlight::Analytics::Ga
74
- # Spotlight::Engine.config.ga_pkcs12_key_path = nil
77
+ # Spotlight::Engine.config.ga_json_key_path = nil
75
78
  # Spotlight::Engine.config.ga_web_property_id = 'G-XXXXXXXXXX'
76
- # Spotlight::Engine.config.ga_email = 'test@example.com'
79
+ # Spotlight::Engine.config.ga_property_id = '12345678'
77
80
  # Spotlight::Engine.config.ga_analytics_options = {}
78
81
  # Spotlight::Engine.config.ga_page_analytics_options = Spotlight::Engine.config.ga_analytics_options.merge(limit: 5)
82
+ # Spotlight::Engine.config.ga_search_analytics_options = Spotlight::Engine.config.ga_analytics_options.merge(limit: 11)
79
83
  # Spotlight::Engine.config.ga_debug_mode = false
80
84
  # end
81
85
 
@@ -196,14 +196,16 @@ module Spotlight
196
196
  end
197
197
 
198
198
  # After creating a property for your site on Google Analytics, you need to:
199
- # a) register an OAuth service account with access to your analytics property:
200
- # (https://github.com/tpitale/legato/wiki/OAuth2-and-Google#registering-for-api-access)
201
- # b) download the pkcs12 key and make it accessible to your application
202
- # c) in e.g. an initializer, set these configuration values as appropriate
203
- # to your OAuth2 service account and analytics property:
204
- config.ga_pkcs12_key_path = nil
199
+ # a) Enable Google Analytics API in https://console.cloud.google.com/
200
+ # b) generate and download the JSON key and make it accessible to your application
201
+ # (https://console.cloud.google.com/iam-admin/iam -> Service accounts -> click on service account -> keys)
202
+ # c) set ga_property_id below to your site's property id (located in admin -> Property -> Property details upper right hand corner)
203
+ # d) Set the ga_web_property_id. (located in admin -> Data collection and modification -> Web stream details and begins with G-)
204
+ # ga_property_id is used for fetching analytics data from google's api, ga_web_property_id is used for sending events to GA analtyics
205
+ # ga_web_property_id will probably change in V5 to ga_measurement_id for clarity
206
+ config.ga_json_key_path = nil
205
207
  config.ga_web_property_id = nil
206
- config.ga_email = nil
208
+ config.ga_property_id = nil
207
209
  config.ga_analytics_options = {}
208
210
  config.ga_page_analytics_options = config.ga_analytics_options.merge(limit: 5)
209
211
  config.ga_debug_mode = false
@@ -271,7 +273,7 @@ module Spotlight
271
273
  Blacklight::Configuration.property :browse, default: Blacklight::OpenStructWithHashAccess.new(document_actions: [])
272
274
 
273
275
  Blacklight::Configuration.default_values[:search_state_fields] ||= []
274
- Blacklight::Configuration.default_values[:search_state_fields] += %i[id exhibit_id]
276
+ Blacklight::Configuration.default_values[:search_state_fields] += %i[id exhibit_id browse_category_id]
275
277
  end
276
278
  else
277
279
  config.to_prepare do
@@ -284,7 +286,7 @@ module Spotlight
284
286
  Blacklight::Configuration.default_values[:browse] ||= Blacklight::OpenStructWithHashAccess.new(document_actions: [])
285
287
 
286
288
  Blacklight::Configuration.default_values[:search_state_fields] ||= []
287
- Blacklight::Configuration.default_values[:search_state_fields] += %i[id exhibit_id]
289
+ Blacklight::Configuration.default_values[:search_state_fields] += %i[id exhibit_id browse_category_id]
288
290
  end
289
291
  end
290
292
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Spotlight
4
- VERSION = '4.0.2'
4
+ VERSION = '4.1.0'
5
5
  end
data/lib/spotlight.rb CHANGED
@@ -6,4 +6,7 @@ require 'spotlight/engine'
6
6
  ##
7
7
  # Spotlight
8
8
  module Spotlight
9
+ def self.deprecator
10
+ @deprecator ||= ActiveSupport::Deprecation.new('5.0', 'blacklight-spotlight')
11
+ end
9
12
  end
@@ -54,7 +54,7 @@ module Spotlight
54
54
  first('.st-block-replacer').click
55
55
  end
56
56
 
57
- def save_page
57
+ def save_page_changes
58
58
  page.execute_script <<-EOF
59
59
  SirTrevor.getInstance().onFormSubmit();
60
60
  EOF