Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions app/controllers/skins_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,11 @@ def update
# Get /skins/1/preview
def preview
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)
flash[:notice] << t(".remove_skin")
flash[:notice] << t(".tip")
flash[:notice] << ("<a href='#{skin_path(@skin)}' class='action' role='button'>".html_safe + t(".return_to_skin") + "</a>".html_safe)
Comment on lines +133 to +136
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.

Rubocop would complain on the usage of ts when I removed "This is a randomly chosen page" from the notice.
I decided it made sense to convert all of the lines rather than just one

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.

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 @@ -802,3 +802,9 @@ PSEUD_SHARDS: 5
TAG_SHARDS: 5
USER_SHARDS: 5
WORKS_SHARDS: 5

# 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'
5 changes: 5 additions & 0 deletions config/locales/controllers/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,11 @@ en:
index:
public_site_page_title: Public Site Skins
public_work_page_title: Public Work Skins
preview:
remove_skin: Go back or click 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 tacking on ''?site_skin=[skin_id]'' like you can see in the url above.'
stats:
index:
page_title: "%{username} - Stats"
Expand Down
10 changes: 4 additions & 6 deletions features/other_b/skin_public.feature
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,15 @@ 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."
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 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"
Expand Down
Loading