blacklight-spotlight 0.13.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/spotlight/reindex_monitor.js +109 -0
  3. data/app/assets/stylesheets/spotlight/_blacklight_configuration.scss +9 -8
  4. data/app/assets/stylesheets/spotlight/_bootstrap_overrides.scss +15 -7
  5. data/app/assets/stylesheets/spotlight/_header.scss +67 -90
  6. data/app/assets/stylesheets/spotlight/_variables.scss +4 -0
  7. data/app/controllers/spotlight/attachments_controller.rb +2 -5
  8. data/app/controllers/spotlight/browse_controller.rb +15 -3
  9. data/app/controllers/spotlight/resources_controller.rb +4 -0
  10. data/app/controllers/spotlight/roles_controller.rb +1 -1
  11. data/app/controllers/spotlight/sites_controller.rb +50 -0
  12. data/app/helpers/spotlight/application_helper.rb +2 -1
  13. data/app/helpers/spotlight/navbar_helper.rb +1 -1
  14. data/app/jobs/spotlight/reindex_job.rb +17 -8
  15. data/app/models/concerns/spotlight/user.rb +8 -4
  16. data/app/models/spotlight/ability.rb +5 -4
  17. data/app/models/spotlight/exhibit.rb +15 -1
  18. data/app/models/spotlight/reindex_progress.rb +107 -0
  19. data/app/models/spotlight/resource.rb +4 -0
  20. data/app/models/spotlight/role.rb +2 -2
  21. data/app/models/spotlight/site.rb +16 -0
  22. data/app/views/devise/mailer/invitation_instructions.html.erb +1 -1
  23. data/app/views/layouts/spotlight/spotlight.html.erb +1 -1
  24. data/app/views/shared/_breadcrumbs.html.erb +1 -1
  25. data/app/views/shared/_exhibit_navbar.html.erb +6 -7
  26. data/app/views/shared/_masthead.html.erb +32 -0
  27. data/app/views/shared/_site_sidebar.html.erb +16 -0
  28. data/app/views/spotlight/about_pages/_sidebar.html.erb +4 -2
  29. data/app/views/spotlight/browse/_search_title.html.erb +1 -1
  30. data/app/views/spotlight/browse/index.html.erb +6 -4
  31. data/app/views/spotlight/browse/show.html.erb +6 -8
  32. data/app/views/spotlight/catalog/_admin_header.html.erb +15 -12
  33. data/app/views/spotlight/catalog/_reindex_progress_panel.html.erb +21 -0
  34. data/app/views/spotlight/exhibits/index.html.erb +4 -2
  35. data/app/views/spotlight/featured_images/_upload_form.html.erb +17 -0
  36. data/app/views/spotlight/home_pages/_empty.html.erb +1 -1
  37. data/app/views/spotlight/metadata_configurations/_metadata_field.html.erb +2 -2
  38. data/app/views/spotlight/metadata_configurations/edit.html.erb +3 -3
  39. data/app/views/spotlight/shared/_configuration_sidebar.html.erb +2 -2
  40. data/app/views/spotlight/shared/_curation_sidebar.html.erb +1 -1
  41. data/app/views/spotlight/sites/_exhibit.html.erb +18 -0
  42. data/app/views/spotlight/sites/edit.html.erb +40 -0
  43. data/app/views/spotlight/sites/edit_exhibits.html.erb +32 -0
  44. data/config/locales/spotlight.en.yml +30 -2
  45. data/config/routes.rb +5 -0
  46. data/db/migrate/20151210073829_create_spotlight_site.rb +9 -0
  47. data/db/migrate/20151211131415_add_site_to_spotlight_exhibits.rb +23 -0
  48. data/db/migrate/20151215141516_change_roles_to_support_polymorphic_associations.rb +40 -0
  49. data/db/migrate/20151215192845_add_index_status_to_resources.rb +6 -0
  50. data/lib/spotlight/controller.rb +18 -7
  51. data/lib/spotlight/engine.rb +37 -35
  52. data/lib/spotlight/version.rb +1 -1
  53. data/spec/controllers/spotlight/contacts_controller_spec.rb +2 -2
  54. data/spec/controllers/spotlight/home_pages_controller_spec.rb +2 -4
  55. data/spec/controllers/spotlight/resources_controller_spec.rb +14 -0
  56. data/spec/controllers/spotlight/roles_controller_spec.rb +1 -1
  57. data/spec/controllers/spotlight/sites_controller_spec.rb +48 -0
  58. data/spec/controllers/spotlight/versions_controller_spec.rb +1 -2
  59. data/spec/factories/roles.rb +1 -1
  60. data/spec/factories/users.rb +3 -3
  61. data/spec/features/add_contacts_spec.rb +2 -2
  62. data/spec/features/browse_category_spec.rb +65 -0
  63. data/spec/features/edit_contact_spec.rb +2 -2
  64. data/spec/features/exhibit_masthead_spec.rb +100 -0
  65. data/spec/features/javascript/reindex_monitor_spec.rb +22 -0
  66. data/spec/features/site_masthead_spec.rb +17 -52
  67. data/spec/helpers/spotlight/application_helper_spec.rb +16 -0
  68. data/spec/lib/spotlight/controller_spec.rb +34 -8
  69. data/spec/models/spotlight/ability_spec.rb +3 -4
  70. data/spec/models/spotlight/exhibit_spec.rb +23 -0
  71. data/spec/models/spotlight/reindex_progress_spec.rb +104 -0
  72. data/spec/models/spotlight/site_spec.rb +9 -0
  73. data/spec/views/shared/_exhibit_navbar.html.erb_spec.rb +3 -9
  74. data/spec/views/shared/_masthead.html.erb_spec.rb +83 -0
  75. data/spec/views/spotlight/browse/show.html.erb_spec.rb +2 -2
  76. data/spec/views/spotlight/catalog/admin.html.erb_spec.rb +1 -0
  77. data/spec/views/spotlight/roles/index.html.erb_spec.rb +1 -1
  78. data/spec/views/spotlight/sites/edit_exhibits.html.erb_spec.rb +29 -0
  79. metadata +33 -14
  80. data/app/views/shared/_exhibit_masthead.html.erb +0 -20
  81. data/app/views/shared/_exhibit_masthead_and_navbar.html.erb +0 -9
  82. data/app/views/shared/_home_sidebar.html.erb +0 -1
  83. data/app/views/spotlight/attachments/_form.html.erb +0 -29
  84. data/app/views/spotlight/attachments/edit.html.erb +0 -6
  85. data/app/views/spotlight/attachments/index.html.erb +0 -31
  86. data/app/views/spotlight/attachments/new.html.erb +0 -5
  87. data/app/views/spotlight/attachments/show.html.erb +0 -19
  88. data/spec/views/shared/_exhibit_masthead.html.erb_spec.rb +0 -70
  89. data/spec/views/shared/_exhibit_masthead_and_navbar.html.erb_spec.rb +0 -36
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1e1e38c99f14e8cbfe3482e6d4adb02adc7dd6cd
4
- data.tar.gz: e7c12eb9e49ecf927dd98f9331d363d796bc4825
3
+ metadata.gz: d5a848d17a782a172979d2f5f1474be224e5aa50
4
+ data.tar.gz: aaf3bb7c7c594a324f31bacc68a854576bcadfa3
5
5
  SHA512:
6
- metadata.gz: 3bea84a5474d94a0fe33b0d041675c2dd1647dfb4ab2968638bb70563eaad164a2e46dd1655893a99e30bbee06a59cd2eca5ceec758aca930b1dcf765906663d
7
- data.tar.gz: f94dbfd2a1507db4e4938144c1c65a1f13995aea9113792eabe15589affd017433dfbbca4b5b1424c5988daf34f4bf7f7dcf9308a65071344ec0c5f261976c3c
6
+ metadata.gz: fa6893ca19f7e9607d5398f2920af9954b9edee98a4e0cd59e120057ed1aed8c0b901bbe2933efdd9aef2140a6c04708b442472b8a55133055db960be35e9190
7
+ data.tar.gz: 41d04adaad2035a0ee4693b41ed794fe5b8d4d627f1b638cc6d07967385919424c4789e0ef4e1ff13a14b3a57cb950bd333f02120fe522a5fd1cd102b9e5b468
@@ -0,0 +1,109 @@
1
+ Spotlight.onLoad(function() {
2
+ $('[data-behavior="reindex-monitor"]').reindexMonitor();
3
+ });
4
+
5
+ (function($) {
6
+ $.fn.reindexMonitor = function() {
7
+ var monitorElements = this;
8
+ var defaultRefreshRate = 3000;
9
+ var panelContainer;
10
+
11
+ $(monitorElements).each(function() {
12
+ panelContainer = $(this);
13
+ var monitorUrl = panelContainer.data('monitorUrl');
14
+ var refreshRate = panelContainer.data('refreshRate') || defaultRefreshRate;
15
+ setInterval(function() {
16
+ checkMonitorUrl(monitorUrl);
17
+ }, refreshRate);
18
+ });
19
+
20
+ function checkMonitorUrl(url) {
21
+ $.ajax(url).success(success).fail(fail);
22
+ }
23
+
24
+ function success(data) {
25
+ if (data.in_progress) {
26
+ monitorPanel().show();
27
+ updateMonitorPanel(data);
28
+ } else {
29
+ monitorPanel().hide();
30
+ }
31
+ }
32
+
33
+ function fail() { monitorPanel().hide(); }
34
+
35
+ function updateMonitorPanel(data) {
36
+ panelStartDate().text(data.started);
37
+ panelCurrentDate().text(data.updated_at);
38
+ panelCompleted().text(data.completed);
39
+ updatePanelTotals(data);
40
+ updatePanelErrorMessage(data);
41
+ updateProgressBar(data);
42
+ }
43
+
44
+ function updateProgressBar(data) {
45
+ var percentage = calculatePercentage(data);
46
+ progressBar()
47
+ .attr('aria-valuemax', data.total)
48
+ .attr('aria-valuenow', percentage)
49
+ .css('width', percentage + '%')
50
+ .text(percentage + '%');
51
+ }
52
+
53
+ function updatePanelErrorMessage(data) {
54
+ // We currently do not store this state,
55
+ // but with this code we can in the future.
56
+ if ( data.errored ) {
57
+ panelErrorMessage().show();
58
+ } else {
59
+ panelErrorMessage().hide();
60
+ }
61
+ }
62
+
63
+ function updatePanelTotals(data) {
64
+ panelTotals().each(function() {
65
+ $(this).text(data.total);
66
+ });
67
+ }
68
+
69
+ function calculatePercentage(data) {
70
+ return Math.floor((data.completed / data.total) * 100);
71
+ }
72
+
73
+ function monitorPanel() {
74
+ return panelContainer.find('.index-status');
75
+ }
76
+
77
+ function panelStartDate() {
78
+ return monitorPanel()
79
+ .find('[data-behavior="monitor-start"]')
80
+ .find('[data-behavior="date"]');
81
+ }
82
+
83
+ function panelCurrentDate() {
84
+ return monitorPanel()
85
+ .find('[data-behavior="monitor-current"]')
86
+ .find('[data-behavior="date"]');
87
+ }
88
+
89
+ function panelTotals() {
90
+ return monitorPanel().find('[data-behavior="total"]');
91
+ }
92
+
93
+ function panelCompleted() {
94
+ return monitorPanel()
95
+ .find('[data-behavior="monitor-current"]')
96
+ .find('[data-behavior="completed"]');
97
+ }
98
+
99
+ function progressBar() {
100
+ return monitorPanel().find('.progress-bar');
101
+ }
102
+
103
+ function panelErrorMessage() {
104
+ return monitorPanel().find('[data-behavior="monitor-error"]');
105
+ }
106
+
107
+ return this;
108
+ };
109
+ })(jQuery);
@@ -1,10 +1,8 @@
1
1
  .dd-item td {
2
- text-align:center;
3
-
4
2
  &:first-child {
5
3
  padding: 0;
6
4
 
7
- a {
5
+ .edit-in-place {
8
6
  cursor: text;
9
7
  color: inherit;
10
8
  text-decoration: none;
@@ -23,7 +21,6 @@
23
21
 
24
22
  }
25
23
 
26
- text-align: left;
27
24
  .dd3-handle:before {
28
25
  top: 3px;
29
26
  }
@@ -49,15 +46,19 @@
49
46
  }
50
47
  }
51
48
 
52
- #nested-fields {
53
- margin-bottom: 1em;
49
+ .dd-table {
50
+ margin-top: 2 * $padding-large-vertical;
51
+
54
52
  th {
55
53
  &:first-child {
56
54
  padding-left: 40px;
57
- text-align: left;
58
55
  }
59
- text-align:center;
60
56
  }
57
+ }
58
+
59
+ #nested-fields {
60
+ margin-bottom: 1em;
61
+
61
62
  .metadata-select {
62
63
  display: inline-block;
63
64
  min-width: 72px;
@@ -21,20 +21,28 @@
21
21
  }
22
22
 
23
23
  .sidenav {
24
-
25
24
  margin-bottom: 24px;
26
25
 
27
- li > a {
28
- padding: 0 15px 0 0;
29
- }
26
+ .active {
27
+ a {
28
+ color: $black;
30
29
 
31
- &.top-level {
32
- li > a {
33
- padding-left: 0;
30
+ &:hover {
31
+ background-color: inherit;
32
+ }
34
33
  }
35
34
  }
36
35
  }
37
36
 
37
+ .nav-heading {
38
+ margin: 0;
39
+ padding: $nav-link-padding;
40
+ }
41
+
42
+ .btn-nav {
43
+ margin: $nav-link-padding;
44
+ }
45
+
38
46
  h1,h2,h3,h4,h5,h6 {
39
47
  .label {
40
48
  font-size: $font-size-base;
@@ -1,6 +1,3 @@
1
- $masthead-height: 180px;
2
- $masthead-image-blur: 1px;
3
-
4
1
  @mixin masthead-background-containers() {
5
2
  position: absolute;
6
3
  left: 0;
@@ -31,23 +28,39 @@ $masthead-image-blur: 1px;
31
28
  }
32
29
  }
33
30
 
34
- #exhibit-masthead,
35
- #exhibit-navbar {
36
- z-index: 1;
31
+ .navbar-static-top {
32
+ margin-bottom: 0;
37
33
  }
38
34
 
39
- #exhibit-navbar {
40
- z-index: 100;
35
+ .masthead {
36
+ background-color: $masthead-bg;
37
+ border-bottom: 1px solid $navbar-default-border;
38
+ margin-bottom: $padding-large-vertical * 2.5;
39
+ overflow: hidden;
40
+ padding: 0;
41
+ position: relative;
42
+ // allow dropdowns in the top nav to stack above the masthead
43
+ z-index: $zindex-navbar - 1;
41
44
 
42
- &.page-masthead {
43
- @include transparent-masthead-navigation-menu();
44
- background-color: $navbar-transparent-page-bg;
45
- border-bottom: 1px solid $navbar-transparent-border;
46
- margin-bottom: 0;
47
- margin-top: 0;
48
45
 
49
- .navbar-nav {
50
- float: right;
46
+ .site-title {
47
+ padding-bottom: $padding-base-vertical;
48
+ position: relative;
49
+ white-space: nowrap;
50
+ }
51
+
52
+ small {
53
+ @extend .hidden-xs;
54
+
55
+ display: block;
56
+ margin-top: $padding-base-vertical;
57
+ padding-bottom: $padding-base-vertical;
58
+ padding-top: $padding-base-vertical;
59
+ }
60
+
61
+ .navbar {
62
+ &:last-child {
63
+ margin-bottom: 0;
51
64
  }
52
65
  }
53
66
 
@@ -56,81 +69,46 @@ $masthead-image-blur: 1px;
56
69
  }
57
70
  }
58
71
 
59
- #exhibit-masthead.with-image + #exhibit-navbar.navbar-default {
60
- @include transparent-masthead-navigation-menu();
61
- background-color: $navbar-transparent-bg;
62
- border-top: 1px solid $navbar-transparent-border;
63
- }
64
-
65
- .navbar + .navbar {
66
- margin-top: 0;
67
- }
68
-
69
- #header-navbar {
70
- margin-bottom: 0;
71
- }
72
-
73
- #exhibit-masthead {
74
- height: $masthead-height;
75
- margin-bottom: -50px;
76
- padding: 0;
77
- position: static;
78
-
79
- & > .container {
80
- position: relative;
81
- top: 33%;
82
- -webkit-transform: translateY(-50%);
83
- transform: translateY(-50%);
72
+ .resource-masthead {
73
+ .site-title {
74
+ @extend .text-center;
84
75
  }
85
76
 
86
- &.with-page-masthead {
87
- margin-bottom: $padding-base-vertical;
88
- margin-top: -51px;
89
-
90
- > .container {
91
- top: 60%;
92
- }
93
-
94
- .navbar-brand {
95
- font-size: $font-size-large;
96
- text-shadow: 1px 1px 0 $black;
97
- }
98
-
99
- .search-title {
100
- text-align: center;
101
-
102
- small {
103
- text-transform: uppercase;
104
- }
105
- }
77
+ .navbar {
78
+ border-bottom: 1px solid $navbar-transparent-border;
79
+ border-top: 0;
80
+ margin-bottom: 0;
106
81
  }
107
82
 
108
- .site-title {
109
- font-size: 30px;
83
+ .navbar-nav {
84
+ float: right;
110
85
  }
111
86
 
112
- small {
113
- display: block;
114
- padding-top: $padding-base-vertical;
115
- @extend .hidden-xs;
87
+ .search-query-form {
88
+ display: none;
116
89
  }
90
+ }
117
91
 
118
- &.with-image {
119
- .site-title,
120
- .search-title {
121
- color: $white;
122
- text-shadow: 1px 1px 0 $black;
123
- }
92
+ .site-title-container {
93
+ max-height: $masthead-height - $navbar-height;
94
+
95
+ padding-bottom: $padding-large-vertical;
96
+ padding-top: $padding-large-vertical;
97
+ }
124
98
 
125
- small {
126
- color: $white;
127
- }
99
+ .image-masthead {
100
+ .navbar {
101
+ @include transparent-masthead-navigation-menu();
102
+ background-color: $navbar-transparent-page-bg;
128
103
  }
129
104
 
130
- &.with-page-masthead {
131
- .site-title {
132
- margin-top: $padding-large-vertical * 3;
133
- }
105
+ .h1 {
106
+ color: $white;
107
+ text-shadow: 1px 1px 0 $black;
108
+ }
109
+
110
+ small {
111
+ color: $white;
134
112
  }
135
113
 
136
114
  // This is to add a background image to the masthead, in a way that
@@ -139,16 +117,21 @@ $masthead-image-blur: 1px;
139
117
  @include masthead-background-containers();
140
118
  background-repeat: no-repeat;
141
119
  background-size: cover;
120
+
121
+ // Add right border to image to hide lighter blurred edge
122
+ border-right: 1px solid $black;
123
+
142
124
  // Add small amount of blur to help text stand out
143
125
  //filter: url(masthead/blur.svg#blur); // for older versions of FF
144
126
  -webkit-filter: blur($masthead-image-blur);
145
127
  filter: blur($masthead-image-blur);
128
+
129
+ height: $masthead-height;
130
+
146
131
  // Shift image slightly to hide blurred edge of image
147
132
  margin-left: -$masthead-image-blur;
148
133
  margin-top: -$masthead-image-blur;
149
134
  overflow: hidden;
150
- // Add right border to image to hide lighter blurred edge
151
- border-right: 1px solid $black;
152
135
  }
153
136
 
154
137
  // Include gradient to improve text legibility,
@@ -161,15 +144,9 @@ $masthead-image-blur: 1px;
161
144
  rgba(0, 0, 0, 0.4),
162
145
  rgba(0, 0, 0, 0.5)
163
146
  );
164
- }
165
- }
166
147
 
167
- // Margin between bottom of masthead and start of page content.
168
- // Need to apply bottom margin to different element, depending on
169
- // whether it is a regular masthead or a browse category masthead
170
- #exhibit-masthead + #exhibit-navbar,
171
- #exhibit-navbar + #exhibit-masthead {
172
- margin-bottom: $padding-large-vertical * 2.5;
148
+ height: $masthead-height;
149
+ }
173
150
  }
174
151
 
175
152
  .col-md-4 {
@@ -3,6 +3,10 @@ $footer-height: 118px !default;
3
3
  $white: #ffffff !default;
4
4
  $black: #000000 !default;
5
5
 
6
+ $masthead-bg: $well-bg !default;
7
+ $masthead-height: 180px !default;
8
+ $masthead-image-blur: 1px !default;
9
+
6
10
  $exhibit-card-height: 350px !default;
7
11
  $exhibit-card-bg: $well-bg !default;
8
12
  $exhibit-card-border: $well-border !default;
@@ -9,11 +9,8 @@ module Spotlight
9
9
  # POST /attachments
10
10
  def create
11
11
  @attachment.attributes = attachment_params
12
- if @attachment.save
13
- render json: @attachment
14
- else
15
- render action: 'new'
16
- end
12
+ @attachment.save!
13
+ render json: @attachment
17
14
  end
18
15
 
19
16
  private
@@ -11,7 +11,7 @@ module Spotlight
11
11
  before_action :attach_breadcrumbs
12
12
  record_search_parameters only: :show
13
13
 
14
- before_action :set_masthead, only: :show
14
+ helper_method :should_render_spotlight_search_bar?
15
15
 
16
16
  def index
17
17
  @searches = @exhibit.searches.published
@@ -47,8 +47,20 @@ module Spotlight
47
47
  @_prefixes ||= super + ['catalog']
48
48
  end
49
49
 
50
- def set_masthead
51
- self.current_masthead = @search.masthead if @search.masthead && @search.masthead.display?
50
+ def current_masthead
51
+ if resource_masthead?
52
+ @search.masthead
53
+ else
54
+ super
55
+ end
56
+ end
57
+
58
+ def resource_masthead?
59
+ @search && @search.masthead && @search.masthead.display?
60
+ end
61
+
62
+ def should_render_spotlight_search_bar?
63
+ !resource_masthead?
52
64
  end
53
65
  end
54
66
  end