blacklight-spotlight 1.5.1 → 2.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +11 -3
  3. data/app/assets/javascripts/spotlight/translation_progress.js +23 -0
  4. data/app/assets/stylesheets/spotlight/_spotlight.scss +2 -0
  5. data/app/assets/stylesheets/spotlight/_translations.scss +47 -0
  6. data/app/assets/stylesheets/spotlight/_utilities.scss +3 -0
  7. data/app/assets/stylesheets/spotlight/_variables.scss +5 -0
  8. data/app/controllers/concerns/spotlight/controller.rb +12 -1
  9. data/app/controllers/spotlight/about_pages_controller.rb +6 -0
  10. data/app/controllers/spotlight/browse_controller.rb +1 -1
  11. data/app/controllers/spotlight/catalog_controller.rb +6 -1
  12. data/app/controllers/spotlight/exhibits_controller.rb +10 -2
  13. data/app/controllers/spotlight/feature_pages_controller.rb +6 -0
  14. data/app/controllers/spotlight/filters_controller.rb +2 -2
  15. data/app/controllers/spotlight/home_pages_controller.rb +10 -0
  16. data/app/controllers/spotlight/languages_controller.rb +46 -0
  17. data/app/controllers/spotlight/pages_controller.rb +57 -3
  18. data/app/controllers/spotlight/solr_controller.rb +3 -3
  19. data/app/controllers/spotlight/translations_controller.rb +34 -0
  20. data/app/helpers/spotlight/application_helper.rb +1 -0
  21. data/app/helpers/spotlight/languages_helper.rb +33 -0
  22. data/app/helpers/spotlight/translations_helper.rb +13 -0
  23. data/app/models/concerns/spotlight/custom_translation_extension.rb +4 -0
  24. data/app/models/concerns/spotlight/translatables.rb +30 -0
  25. data/app/models/spotlight/ability.rb +5 -2
  26. data/app/models/spotlight/about_page.rb +1 -1
  27. data/app/models/spotlight/exhibit.rb +14 -6
  28. data/app/models/spotlight/feature_page.rb +1 -2
  29. data/app/models/spotlight/home_page.rb +1 -3
  30. data/app/models/spotlight/language.rb +24 -0
  31. data/app/models/spotlight/main_navigation.rb +12 -0
  32. data/app/models/spotlight/page.rb +53 -1
  33. data/app/models/spotlight/resources/upload.rb +6 -1
  34. data/app/models/spotlight/search.rb +4 -0
  35. data/app/services/spotlight/clone_translated_page_from_locale.rb +32 -0
  36. data/app/views/_user_util_links.html.erb +1 -0
  37. data/app/views/devise/mailer/invitation_instructions.html.erb +2 -2
  38. data/app/views/layouts/spotlight/spotlight.html.erb +2 -2
  39. data/app/views/shared/_curated_features_navbar.html.erb +2 -2
  40. data/app/views/spotlight/about_pages/_sidebar.html.erb +1 -1
  41. data/app/views/spotlight/admin_users/index.html.erb +1 -1
  42. data/app/views/spotlight/catalog/_edit_default.html.erb +1 -1
  43. data/app/views/spotlight/exhibits/_export.html.erb +1 -1
  44. data/app/views/spotlight/exhibits/_form.html.erb +1 -1
  45. data/app/views/spotlight/exhibits/_import.html.erb +2 -1
  46. data/app/views/spotlight/exhibits/_languages.html.erb +56 -0
  47. data/app/views/spotlight/exhibits/edit.html.erb +11 -5
  48. data/app/views/spotlight/feature_pages/_sidebar.html.erb +1 -1
  49. data/app/views/spotlight/filters/_form.html.erb +2 -1
  50. data/app/views/spotlight/resources/upload/_form.html.erb +1 -1
  51. data/app/views/spotlight/shared/_curation_sidebar.html.erb +5 -0
  52. data/app/views/spotlight/shared/_locale_picker.html.erb +14 -0
  53. data/app/views/spotlight/translations/_browse_categories.html.erb +67 -0
  54. data/app/views/spotlight/translations/_general.html.erb +176 -0
  55. data/app/views/spotlight/translations/_metadata.html.erb +67 -0
  56. data/app/views/spotlight/translations/_page.html.erb +45 -0
  57. data/app/views/spotlight/translations/_pages.html.erb +37 -0
  58. data/app/views/spotlight/translations/_pages_table.html.erb +15 -0
  59. data/app/views/spotlight/translations/_search_fields.html.erb +97 -0
  60. data/app/views/spotlight/translations/edit.html.erb +55 -0
  61. data/config/i18n-tasks.yml +81 -0
  62. data/config/locales/devise.en.yml +2 -1
  63. data/config/locales/spotlight.en.yml +657 -614
  64. data/config/routes.rb +19 -1
  65. data/db/migrate/20180308203409_create_spotlight_languages.rb +12 -0
  66. data/db/migrate/20180403130857_translation_uniqueness.rb +5 -0
  67. data/db/migrate/20180405044000_add_locale_to_pages.rb +6 -0
  68. data/db/migrate/20180406212516_add_default_locale_reference_to_spotlight_pages.rb +7 -0
  69. data/lib/generators/spotlight/templates/catalog_controller.rb +2 -2
  70. data/lib/generators/spotlight/templates/config/initializers/spotlight_initializer.rb +14 -4
  71. data/lib/generators/spotlight/templates/config/initializers/translation.rb +4 -2
  72. data/lib/migration/page_language.rb +27 -0
  73. data/lib/spotlight/engine.rb +32 -4
  74. data/lib/spotlight/upload_field_config.rb +27 -0
  75. data/lib/spotlight/version.rb +1 -1
  76. data/lib/tasks/spotlight_tasks.rake +6 -0
  77. data/spec/controllers/spotlight/about_pages_controller_spec.rb +67 -1
  78. data/spec/controllers/spotlight/feature_pages_controller_spec.rb +50 -0
  79. data/spec/controllers/spotlight/filters_controller_spec.rb +4 -4
  80. data/spec/controllers/spotlight/home_pages_controller_spec.rb +25 -0
  81. data/spec/controllers/spotlight/languages_controller_spec.rb +66 -0
  82. data/spec/controllers/spotlight/pages_controller_spec.rb +45 -0
  83. data/spec/controllers/spotlight/solr_controller_spec.rb +1 -1
  84. data/spec/controllers/spotlight/translations_controller_spec.rb +67 -0
  85. data/spec/examples.txt +1171 -1281
  86. data/spec/factories/exhibits.rb +1 -1
  87. data/spec/factories/language.rb +6 -0
  88. data/spec/factories/main_navigation.rb +7 -0
  89. data/spec/factories/searches.rb +1 -0
  90. data/spec/factories/tags.rb +1 -0
  91. data/spec/features/exhibits/language_create_edit_spec.rb +53 -0
  92. data/spec/features/exhibits/translation_editing_spec.rb +397 -0
  93. data/spec/features/javascript/locale_selector_spec.rb +61 -0
  94. data/spec/helpers/spotlight/languages_helper_spec.rb +73 -0
  95. data/spec/helpers/spotlight/translations_helper_spec.rb +16 -0
  96. data/spec/i18n_spec.rb +29 -0
  97. data/spec/lib/migration/page_language_spec.rb +21 -0
  98. data/spec/lib/spotlight/upload_field_config_spec.rb +24 -0
  99. data/spec/models/spotlight/ability_spec.rb +17 -4
  100. data/spec/models/spotlight/exhibit_spec.rb +49 -0
  101. data/spec/models/spotlight/language_spec.rb +41 -0
  102. data/spec/models/spotlight/page_spec.rb +109 -0
  103. data/spec/models/translation_spec.rb +11 -0
  104. data/spec/services/spotlight/clone_translated_page_from_locale_spec.rb +29 -0
  105. data/spec/spec_helper.rb +1 -13
  106. data/spec/support/disable_friendly_id_deprecation_warnings.rb +7 -6
  107. data/spec/test_app_templates/Gemfile.extra +3 -0
  108. data/spec/test_app_templates/catalog_controller.rb +31 -31
  109. data/spec/test_app_templates/lib/generators/test_app_generator.rb +9 -6
  110. data/spec/views/spotlight/contacts/edit.html.erb_spec.rb +13 -0
  111. data/spec/views/spotlight/exhibits/_form.html.erb_spec.rb +33 -0
  112. data/spec/views/spotlight/exhibits/edit.html.erb_spec.rb +4 -1
  113. data/spec/views/spotlight/resources/_external_resources_form.html.erb_spec.rb +13 -0
  114. data/spec/views/spotlight/resources/new.html.erb_spec.rb +10 -4
  115. data/spec/views/spotlight/translations/_page.html.erb_spec.rb +75 -0
  116. metadata +88 -28
  117. data/app/assets/javascripts/spotlight/sir-trevor.js +0 -0
  118. data/app/views/shared/_share_follow.html.erb +0 -5
  119. data/config/locales/social_share_button.en.yml +0 -18
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6283454c62ce693d7859d54abf0f6b8f231872a2
4
- data.tar.gz: b3614482d805ac181bdd85908786897a83998413
3
+ metadata.gz: 43aa7318e230cbd7070a23b77fc8f2758251955d
4
+ data.tar.gz: 5746230c90332de03ca53665ce41ded0779a41b9
5
5
  SHA512:
6
- metadata.gz: bc6add80eb86ad87548c3c4b40c9f73dd15de59b8b0443b9fcbdec2860ea1ef5c820190f8c288e471f8e7c021f4fd611be103ac66a39640c9d5d80600aa7194f
7
- data.tar.gz: ac68408582986b2115ea46832b6ee2271501ecf99311bb56c2a37bb7dfee7337679850264217e76948e1afd03956732c9a3d643a09f940569d41491dcc4752cc
6
+ metadata.gz: e974e1406d141557044df899294a30804b8a05b47b2ae833619236d530fa7dbf6b794ae057996e3ab9a2c099705ce6386d444870f34b435d73cdb16b68786e65
7
+ data.tar.gz: 802dcd0807263030ff2ae9371d552e6330826b4fce26a516dafdacef728aea2e5a7784c914c35c0adab99021a04120afd8e8fb6a84007c33409223a274f39a44
data/README.md CHANGED
@@ -9,8 +9,8 @@ Read more about what Spotlight is, our motivations for creating it, and how to i
9
9
 
10
10
  ## Requirements
11
11
 
12
- 1. Ruby (2.2.0 or greater)
13
- 2. Rails (5.0 or greater)
12
+ 1. Ruby (2.3.0 or greater)
13
+ 2. Rails (5.1 or greater)
14
14
  3. Java (7 or greater) *for Solr*
15
15
  4. ImageMagick (http://www.imagemagick.org/script/index.php) due to [carrierwave](https://github.com/carrierwaveuploader/carrierwave#adding-versions)
16
16
 
@@ -45,7 +45,7 @@ $ rake db:migrate
45
45
  Start Solr (possibly using `solr_wrapper` in development or testing):
46
46
 
47
47
  ```
48
- $ solr_wrapper
48
+ $ solr_wrapper
49
49
  ```
50
50
 
51
51
  and the Rails development server:
@@ -88,3 +88,11 @@ $ rake
88
88
  ```
89
89
 
90
90
  This utilizes Solr and the testing rails app automatically.
91
+
92
+ ## Translations
93
+
94
+ Spotlight ships with [`i18n-tasks`](https://github.com/glebm/i18n-tasks) to help manage translations. To run a translation health check:
95
+
96
+ ```sh
97
+ $ bundle exec i18n-tasks health
98
+ ```
@@ -0,0 +1,23 @@
1
+ Spotlight.onLoad(function() {
2
+ $('[data-behavior="translation-progress"]').translationProgress();
3
+ });
4
+
5
+ // translationProgress is a plugin that updates the "3/14" progress
6
+ // counters in the tabs of the translation adminstration dashboard.
7
+ // This works by counting the number of progress items and translations
8
+ // present (indicated by data attributes) in each tab's content
9
+ (function($) {
10
+ $.fn.translationProgress = function() {
11
+ var translationTabs = this;
12
+ $(translationTabs).each(function(){
13
+ var currentTab = $(this);
14
+ var tabName = $(this).attr('aria-controls');
15
+ var translationFields = $('#' + tabName).find('[data-translation-progress-item="true"]');
16
+ var completedTranslations = $('#' + tabName).find('[data-translation-present="true"]');
17
+
18
+ currentTab.find('span').text(completedTranslations.length + '/' + translationFields.length);
19
+ });
20
+
21
+ return this;
22
+ };
23
+ })(jQuery);
@@ -30,6 +30,8 @@
30
30
  @import "spotlight/report_a_problem";
31
31
  @import "spotlight/exhibits_index";
32
32
  @import "spotlight/collapse_toggle";
33
+ @import "spotlight/translations";
34
+ @import "spotlight/utilities";
33
35
 
34
36
 
35
37
 
@@ -0,0 +1,47 @@
1
+ .translation-edit-form {
2
+ .glyphicon-ok {
3
+ color: $translation-available-color;
4
+ }
5
+ }
6
+
7
+ .translation-subheading {
8
+ border-bottom: 1px solid $navbar-default-border;
9
+ margin-bottom: 20px;
10
+ }
11
+
12
+ .form-group.translation-form {
13
+ .control-label {
14
+ padding-top: $panel-body-padding + $padding-base-vertical;
15
+ }
16
+
17
+ .glyphicon-ok {
18
+ padding-top: $panel-body-padding + $padding-base-vertical;
19
+ }
20
+ }
21
+
22
+ .tanslation-description-toggle {
23
+ margin: 0;
24
+ padding: 0;
25
+
26
+ &.collapsed {
27
+ .caret {
28
+ transform: rotate(-90deg);
29
+ }
30
+ }
31
+
32
+ label { cursor: pointer; }
33
+ }
34
+
35
+ .panel-translation {
36
+ background-color: $translation-panel-bg;
37
+ padding-bottom: 0;
38
+
39
+ .help-block {
40
+ color: $translation-help-color;
41
+ padding-left: 12px;
42
+ }
43
+ }
44
+
45
+ .default-page-outdated {
46
+ font-weight: 700;
47
+ }
@@ -0,0 +1,3 @@
1
+ .inline-block {
2
+ display: inline-block;
3
+ }
@@ -36,3 +36,8 @@ $navbar-transparent-brand-hover-bg: transparent !default;
36
36
  $navbar-transparent-toggle-hover-bg: $navbar-default-toggle-hover-bg !default;
37
37
  $navbar-transparent-toggle-icon-bar-bg: $navbar-default-toggle-icon-bar-bg !default;
38
38
  $navbar-transparent-toggle-border-color: $navbar-default-toggle-border-color !default;
39
+
40
+ // Translations
41
+ $translation-available-color: #80bf77;
42
+ $translation-panel-bg: #f5f5f5;
43
+ $translation-help-color: #555;
@@ -8,7 +8,7 @@ module Spotlight
8
8
 
9
9
  included do
10
10
  helper_method :current_site, :current_exhibit, :current_masthead, :exhibit_masthead?, :resource_masthead?
11
- before_action :set_exhibit_locale_scope
11
+ before_action :set_exhibit_locale_scope, :set_locale
12
12
  end
13
13
 
14
14
  def set_exhibit_locale_scope
@@ -48,6 +48,17 @@ module Spotlight
48
48
  current_exhibit && current_exhibit.masthead && current_exhibit.masthead.display?
49
49
  end
50
50
 
51
+ def set_locale
52
+ I18n.locale = params[:locale] || I18n.default_locale
53
+ end
54
+
55
+ def default_url_options
56
+ return super unless current_exhibit
57
+ return super if current_exhibit.languages.accessible_by(current_ability).none? || I18n.locale == I18n.default_locale
58
+
59
+ super.merge(locale: I18n.locale)
60
+ end
61
+
51
62
  # overwrites Blacklight::Controller#blacklight_config
52
63
  def blacklight_config
53
64
  if current_exhibit
@@ -5,6 +5,12 @@ module Spotlight
5
5
  load_and_authorize_resource through: :exhibit, instance_name: 'page'
6
6
  before_action :attach_breadcrumbs, except: [:update_contacts]
7
7
 
8
+ # We're oddly getting an unknown action
9
+ # error w/o explicitly defining this here
10
+ def clone
11
+ super
12
+ end
13
+
8
14
  def update_contacts
9
15
  if @exhibit.update(contact_params)
10
16
  redirect_to exhibit_about_pages_path(@exhibit), notice: t(:'helpers.submit.contact.batch_updated')
@@ -56,7 +56,7 @@ module Spotlight
56
56
  end
57
57
 
58
58
  def attach_breadcrumbs
59
- add_breadcrumb t(:'spotlight.exhibits.breadcrumb', title: @exhibit.title), @exhibit
59
+ add_breadcrumb t(:'spotlight.curation.nav.home', title: @exhibit.title), @exhibit
60
60
  add_breadcrumb(@exhibit.main_navigations.browse.label_or_default, exhibit_browse_index_path(@exhibit))
61
61
  end
62
62
 
@@ -133,7 +133,12 @@ module Spotlight
133
133
  # /exhibits/1?f%5Bgenre_sim%5D%5B%5D=map&q= is not the same as /exhibits/1
134
134
  # Otherwise the exhibit breadcrumb won't be a link.
135
135
  # see http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-current_page-3F
136
- add_breadcrumb t(:'spotlight.exhibits.breadcrumb', title: @exhibit.title), exhibit_root_path(@exhibit, q: '')
136
+ if view_context.current_page?(action: :admin)
137
+ add_breadcrumb t(:'spotlight.exhibits.breadcrumb', title: @exhibit.title), exhibit_root_path(@exhibit, q: '')
138
+ else
139
+ # When not on the admin page, get the translated value for the "Home" breadcrumb
140
+ add_breadcrumb t(:'spotlight.curation.nav.home', title: @exhibit.title), exhibit_root_path(@exhibit, q: '')
141
+ end
137
142
  end
138
143
 
139
144
  ##
@@ -3,6 +3,7 @@ module Spotlight
3
3
  # Administrative CRUD actions for an exhibit
4
4
  class ExhibitsController < Spotlight::ApplicationController
5
5
  before_action :authenticate_user!, except: [:index]
6
+ before_action :set_tab, only: [:edit, :update]
6
7
  include Blacklight::SearchHelper
7
8
 
8
9
  load_and_authorize_resource
@@ -63,7 +64,9 @@ module Spotlight
63
64
 
64
65
  def update
65
66
  if @exhibit.update(exhibit_params)
66
- redirect_to edit_exhibit_path(@exhibit), notice: t(:'helpers.submit.exhibit.updated', model: @exhibit.class.model_name.human.downcase)
67
+ redirect_to edit_exhibit_path(@exhibit, tab: @tab),
68
+ notice: t(:'helpers.submit.exhibit.updated',
69
+ model: @exhibit.class.model_name.human.downcase)
67
70
  else
68
71
  flash[:alert] = @exhibit.errors.full_messages.join('<br>'.html_safe)
69
72
  render action: :edit
@@ -89,10 +92,15 @@ module Spotlight
89
92
  :description,
90
93
  :published,
91
94
  :tag_list,
92
- contact_emails_attributes: [:id, :email]
95
+ contact_emails_attributes: [:id, :email],
96
+ languages_attributes: [:id, :public]
93
97
  )
94
98
  end
95
99
 
100
+ def set_tab
101
+ @tab = params[:tab]
102
+ end
103
+
96
104
  def create_params
97
105
  params.require(:exhibit).permit(
98
106
  :title,
@@ -5,6 +5,12 @@ module Spotlight
5
5
  load_and_authorize_resource through: :exhibit, instance_name: 'page'
6
6
  before_action :attach_breadcrumbs
7
7
 
8
+ # We're oddly getting an unknown action
9
+ # error w/o explicitly defining this here
10
+ def clone
11
+ super
12
+ end
13
+
8
14
  protected
9
15
 
10
16
  def attach_breadcrumbs
@@ -11,14 +11,14 @@ module Spotlight
11
11
  else
12
12
  flash[:alert] = @filter.errors.full_messages.join('<br/>'.html_safe)
13
13
  end
14
- redirect_to spotlight.edit_exhibit_path @exhibit, anchor: 'filter'
14
+ redirect_to spotlight.edit_exhibit_path @exhibit, tab: 'filter'
15
15
  end
16
16
 
17
17
  def update
18
18
  unless @filter.update(filter_params)
19
19
  flash[:alert] = @filter.errors.full_messages.join('<br/>'.html_safe)
20
20
  end
21
- redirect_to spotlight.edit_exhibit_path @exhibit, anchor: 'filter'
21
+ redirect_to spotlight.edit_exhibit_path @exhibit, tab: 'filter'
22
22
  end
23
23
 
24
24
  def filter_params
@@ -29,11 +29,21 @@ module Spotlight
29
29
  end
30
30
  end
31
31
 
32
+ # We're oddly getting an unknown action
33
+ # error w/o explicitly defining this here
34
+ def clone
35
+ super
36
+ end
37
+
32
38
  private
33
39
 
34
40
  alias search_action_url exhibit_search_action_url
35
41
  alias search_facet_url exhibit_search_facet_url
36
42
 
43
+ def load_locale_specific_page
44
+ @page = Spotlight::HomePage.for_locale.find_by(exhibit: current_exhibit)
45
+ end
46
+
37
47
  def allowed_page_params
38
48
  super.concat [:display_title, :display_sidebar]
39
49
  end
@@ -0,0 +1,46 @@
1
+ module Spotlight
2
+ # Create and update languages for an exhibit
3
+ class LanguagesController < ApplicationController
4
+ before_action :authenticate_user!
5
+ load_and_authorize_resource :exhibit, class: 'Spotlight::Exhibit'
6
+ load_and_authorize_resource through: :exhibit
7
+
8
+ # This is being done in a before action to de-couple the Page creation from Language creation.
9
+ # A language can be created in tests, console, etc. w/o necessarily requiring an associated page is created.
10
+ # This ties the home page creation explicitly to the action in the dashboard.
11
+ before_action only: :create do
12
+ @cloned_home_page = CloneTranslatedPageFromLocale.call(
13
+ locale: @language.locale,
14
+ page: @language.exhibit.home_page
15
+ )
16
+ @cloned_home_page.published = true
17
+ end
18
+
19
+ def create
20
+ if @language.save && @cloned_home_page.save
21
+ flash[:notice] = t('helpers.submit.language.created', model: @language.model_name.human.downcase)
22
+ else
23
+ flash[:alert] = [
24
+ @language.errors.full_messages,
25
+ @cloned_home_page.errors.full_messages
26
+ ].join('<br/>'.html_safe)
27
+ end
28
+ redirect_to spotlight.edit_exhibit_path @exhibit, tab: 'language'
29
+ end
30
+
31
+ def destroy
32
+ @language.destroy
33
+
34
+ redirect_to(
35
+ spotlight.edit_exhibit_path(@exhibit, tab: 'language'),
36
+ notice: t(:'helpers.submit.language.destroyed', model: @language.model_name.human.downcase)
37
+ )
38
+ end
39
+
40
+ private
41
+
42
+ def create_params
43
+ params.require(:language).permit(:locale)
44
+ end
45
+ end
46
+ end
@@ -1,8 +1,12 @@
1
1
  module Spotlight
2
2
  ##
3
3
  # Base CRUD controller for pages
4
+ # rubocop:disable Metrics/ClassLength
5
+ # Disableing class length because this is a base
6
+ # controller that gives other controllers their behavior
4
7
  class PagesController < Spotlight::ApplicationController
5
8
  before_action :authenticate_user!, except: [:show]
9
+ before_action :load_locale_specific_page, only: [:destroy, :edit, :show, :update]
6
10
  load_and_authorize_resource :exhibit, class: Spotlight::Exhibit
7
11
  load_and_authorize_resource through: :exhibit, instance_name: 'page', only: [:index]
8
12
 
@@ -19,7 +23,7 @@ module Spotlight
19
23
 
20
24
  respond_to do |format|
21
25
  format.html
22
- format.json { render json: @pages.published.to_json(methods: [:thumbnail_image_url]) }
26
+ format.json { render json: @pages.for_locale.published.to_json(methods: [:thumbnail_image_url]) }
23
27
  end
24
28
  end
25
29
 
@@ -85,6 +89,20 @@ module Spotlight
85
89
  redirect_back fallback_location: spotlight.exhibit_dashboard_path(@exhibit), notice: notice
86
90
  end
87
91
 
92
+ def clone
93
+ new_page = CloneTranslatedPageFromLocale.call(locale: clone_params, page: @page)
94
+
95
+ model_name = @page.class.model_name.human.downcase
96
+ if new_page.save
97
+ redirect_to(
98
+ edit_exhibit_translations_path(current_exhibit, new_page, language: clone_params, tab: 'pages'),
99
+ notice: t(:'helpers.submit.page.created', model: model_name)
100
+ )
101
+ else
102
+ redirect_to :back, error: t(:'helpers.submit.page.clone_error', model: model_name)
103
+ end
104
+ end
105
+
88
106
  protected
89
107
 
90
108
  def _prefixes
@@ -100,6 +118,10 @@ module Spotlight
100
118
  view_context.safe_join([t(:"helpers.submit.page.#{key}", model: @page.class.model_name.human.downcase), undo_link], ' ')
101
119
  end
102
120
 
121
+ def clone_params
122
+ params.require(:language)
123
+ end
124
+
103
125
  ##
104
126
  # Browsing an exhibit should start a new search session
105
127
  def start_new_search_session?
@@ -129,17 +151,49 @@ module Spotlight
129
151
 
130
152
  def attach_breadcrumbs
131
153
  if view_context.current_page? '/'
132
- add_breadcrumb t(:'spotlight.exhibits.breadcrumb', title: current_exhibit.title), main_app.root_path
154
+ add_breadcrumb t(:'spotlight.curation.nav.home', title: current_exhibit.title), main_app.root_path
155
+ elsif @page
156
+ # Use curator-accessible i18n key for user-facing breadcrumb
157
+ breadcrumb_to_exhibit_root(:'spotlight.curation.nav.home')
133
158
  else
134
- add_breadcrumb t(:'spotlight.exhibits.breadcrumb', title: current_exhibit.title), spotlight.exhibit_root_path(current_exhibit)
159
+ # Use admin interface language for dashboard breadcrumb
160
+ breadcrumb_to_exhibit_root(:'spotlight.exhibits.breadcrumb')
135
161
  end
136
162
  end
137
163
 
164
+ def load_locale_specific_page
165
+ @page = current_exhibit.pages.for_locale.find(params[:id])
166
+ rescue ActiveRecord::RecordNotFound
167
+ redirect_page_to_related_locale_version
168
+ end
169
+
138
170
  private
139
171
 
172
+ def update_all_page_params
173
+ params.require(:exhibit).permit(
174
+ pages_attributes: [:id, :published]
175
+ )
176
+ end
177
+
178
+ def breadcrumb_to_exhibit_root(key)
179
+ add_breadcrumb t(key, title: current_exhibit.title), spotlight.exhibit_root_path(current_exhibit)
180
+ end
181
+
140
182
  # Only allow a trusted parameter "white list" through.
141
183
  def page_params
142
184
  params.require(controller_name.singularize).permit(allowed_page_params)
143
185
  end
186
+
187
+ def redirect_page_to_related_locale_version
188
+ pages_for_id = current_exhibit.pages.find(params[:id])
189
+ if pages_for_id.default_locale_page
190
+ redirect_to polymorphic_path([current_exhibit, pages_for_id.default_locale_page])
191
+ elsif pages_for_id.translated_page_for(I18n.locale)
192
+ redirect_to polymorphic_path([current_exhibit, pages_for_id.translated_page_for(I18n.locale)])
193
+ else
194
+ raise ActiveRecord::RecordNotFound
195
+ end
196
+ end
144
197
  end
198
+ # rubocop:enable Metrics/ClassLength
145
199
  end