diff --git a/app/controllers/skins_controller.rb b/app/controllers/skins_controller.rb index 7473b12160..76df0ba337 100644 --- a/app/controllers/skins_controller.rb +++ b/app/controllers/skins_controller.rb @@ -134,13 +134,13 @@ def preview redirect_to user_skins_path(current_user) and return end - flash[:notice] = [] - flash[:notice] << ts("You are previewing the skin %{title}. This is a randomly chosen page.", title: @skin.title) - flash[:notice] << ts("Go back or click any link to remove the skin.") - flash[:notice] << ts("Tip: You can preview any archive page you want by tacking on '?site_skin=[skin_id]' like you can see in the url above.") - flash[:notice] << "".html_safe + ts("Return To Skin To Use") + "".html_safe - tag = FilterCount.where("public_works_count BETWEEN 10 AND 20").random_order.first.filter - redirect_to tag_works_path(tag, site_skin: @skin.id) + flash[:notice] = [ + t(".skin_title", title: @skin.title), + t(".remove_skin"), + t(".tip", site_skin_id: @skin.id), + helpers.link_to(t(".return_to_skin"), skin_path(@skin), class: "action") + ].join('
') + redirect_to "#{ArchiveConfig.SKIN_PREVIEW_URL}?site_skin=#{@skin.id}" end def set diff --git a/config/config.yml b/config/config.yml index dba41f3485..cd3db39c2d 100644 --- a/config/config.yml +++ b/config/config.yml @@ -810,3 +810,9 @@ WORKS_SHARDS: 5 ACTIVE_RECORD_ENCRYPTION_PRIMARY_KEY: bEZjYLY9tCYGh6WlcMtEJpIi7GO2plZC ACTIVE_RECORD_ENCRYPTION_DETERMINISTIC_KEY: PpLWizzsQHIWnIihtECw8nDHZQd0amzf ACTIVE_RECORD_ENCRYPTION_KEY_DERIVATION_SALT: 3S99KdpdEWLnCYudBgUfdCFDBWePWCud + +# The relative URL to redirect to when previewing a skin +# e.g. /users/OTW_Translation/works -> +# http://test.archiveofourown.org/users/OTW_Translation/works?site_skin=[skin_id] +# This will not work in dev unless you manually create the OTW_Translation user +SKIN_PREVIEW_URL: '/users/OTW_Translation/works' diff --git a/config/locales/controllers/en.yml b/config/locales/controllers/en.yml index 880ebc1268..7da508e4b4 100644 --- a/config/locales/controllers/en.yml +++ b/config/locales/controllers/en.yml @@ -316,6 +316,10 @@ en: public_work_page_title: Public Work Skins preview: cannot_preview: Sorry, you can't preview that skin. + remove_skin: Go back or follow any link to remove the skin. + return_to_skin: Return to Skin to Use + skin_title: You are previewing the skin %{title}. + tip: 'Tip: You can preview any archive page you want by adding "?site_skin=%{site_skin_id}" to the end of the URL.' set: failure: Sorry, but only certain skins can be used this way (for performance reasons). Please drop a support request if you'd like %{skin_title} to be added! skin_page: "%{skin_title} skin page" diff --git a/features/other_b/skin_public.feature b/features/other_b/skin_public.feature index 8033bd9cf9..3c4f4faba5 100644 --- a/features/other_b/skin_public.feature +++ b/features/other_b/skin_public.feature @@ -103,20 +103,19 @@ Feature: Public skins And I should not see "Uncached skin" Scenario: A user can preview a cached public site skin, and it will take the - user to the works page for a canonical tag with between 10 and 20 works + user to the configured page for skin previews Given the approved public skin "Usable Skin" + And the user "OTW_Translation" exists and is activated And the skin "Usable Skin" is cached - And the canonical fandom "Dallas" with 2 works - And the canonical fandom "Major Crimes" with 11 works - And the canonical fandom "Rizzoli and Isles" with 21 works And I am logged in as "skinner" When I go to the public skins page And I follow "Preview" - Then I should be on the works tagged "Major Crimes" - And I should see "You are previewing the skin Usable Skin. This is a randomly chosen page." - And I should see "Go back or click any link to remove the skin" - And I should see "Tip: You can preview any archive page you want by tacking on '?site_skin=[skin_id]' like you can see in the url above." - When I follow "Return To Skin To Use" + Then I should be on OTW_Translation's works page + And I should see "You are previewing the skin Usable Skin." + And I should see "Go back or follow any link to remove the skin" + And I should see 'Tip: You can preview any archive page you want by adding "?site_skin=' + And I should see '" to the end of the URL' + When I follow "Return to Skin to Use" Then I should be on "Usable Skin" skin page Scenario: Setting a skin from the footer maintains the same page diff --git a/spec/controllers/skins_controller_spec.rb b/spec/controllers/skins_controller_spec.rb index 9fa98ff605..9a1a64f3fd 100644 --- a/spec/controllers/skins_controller_spec.rb +++ b/spec/controllers/skins_controller_spec.rb @@ -750,16 +750,8 @@ end context "with accessible site skin" do - let(:success) { it_redirects_to_simple(tag_works_path(tag, site_skin: skin.id)) } - let(:tag) { create(:canonical_fandom) } - - before do - FilterCount.create!( - filter: tag, - public_works_count: 10, - unhidden_works_count: 10 - ) - end + let(:success) { it_redirects_to_simple(user_works_path(otw_translation_user, site_skin: skin.id)) } + let(:otw_translation_user) { create(:user, login: "OTW_Translation") } context "when site skin is public" do let(:skin) { create(:skin, :public, title: "Accessible Site Skin", author: skin_creator) }