Skip to content
Open
14 changes: 7 additions & 7 deletions app/controllers/skins_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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] << "<a href='#{skin_path(@skin)}' class='action' role='button'>".html_safe + ts("Return To Skin To Use") + "</a>".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('<br />')
Comment on lines +138 to +142
Copy link
Copy Markdown
Contributor Author

@nicolacleary nicolacleary May 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes in flash message:

Details

Flash before:
Image

Flash using <br /> rather than <ul>:
Image

Flash using <br /> rather than <ul> and wrapping it in <p>:
Image

AO3-6765 says:

The “Return To Skin To Use” link ... should ideally be in a <p>, not a <li>. The role="button" can also be removed, because it is not acting like a button, just a link.

AFAIK I could just do view_context.content_tag(:p, <rest of the line>) and it would work (see screenshots above), but it's a little unclear for me what the desired look of this flash is, given that there are quite a few changes here now. I decided to leave it is as now since it's no longer part of a list.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I can tell, a .html_safe doesn't impact what is rendered in this case, so I omitted it.

redirect_to "#{ArchiveConfig.SKIN_PREVIEW_URL}?site_skin=#{@skin.id}"
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This provides no guarantees that the url is correct (formatting or exists) - e.g. if you configure "/idonotexist" then you would get an error only when you tried to preview a skin.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fine, but thanks for noting it!

end

def set
Expand Down
6 changes: 6 additions & 0 deletions config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
4 changes: 4 additions & 0 deletions config/locales/controllers/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
17 changes: 8 additions & 9 deletions features/other_b/skin_public.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 2 additions & 10 deletions spec/controllers/skins_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Expand Down