Skip to content

Commit dcccc06

Browse files
committed
AO3-7397 Make skin preview page configurable
1 parent 6053018 commit dcccc06

4 files changed

Lines changed: 20 additions & 3 deletions

File tree

app/controllers/skins_controller.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,7 @@ def preview
134134
flash[:notice] << t(".preview.remove_skin")
135135
flash[:notice] << t(".preview.tip")
136136
flash[:notice] << ("<a href='#{skin_path(@skin)}' class='action' role='button'>".html_safe + t(".preview.return_to_skin") + "</a>".html_safe)
137-
tag = FilterCount.where("public_works_count BETWEEN 10 AND 20").random_order.first.filter
138-
redirect_to tag_works_path(tag, site_skin: @skin.id)
137+
redirect_to "#{ArchiveConfig.SKIN_PREVIEW_URL}?site_skin=#{@skin.id}"
139138
end
140139

141140
def set

config/config.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -802,3 +802,9 @@ PSEUD_SHARDS: 5
802802
TAG_SHARDS: 5
803803
USER_SHARDS: 5
804804
WORKS_SHARDS: 5
805+
806+
# The relative URL to redirect to when previewing a skin
807+
# e.g. /works -> http://test.archiveofourown.org/works?site_skin=[skin_id]
808+
# Production should pick something more suitable with roughly 1-20 works and
809+
# predictable content such as /users/OTW_Translation/works
810+
SKIN_PREVIEW_URL: '/works'

config/locales/controllers/en.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ en:
310310
public_site_page_title: Public Site Skins
311311
public_work_page_title: Public Work Skins
312312
preview:
313-
skin_title: "You are previewing the skin %{title}. This is a randomly chosen page."
313+
skin_title: "You are previewing the skin %{title}."
314314
remove_skin: "Go back or click any link to remove the skin."
315315
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."
316316
return_to_skin: "Return To Skin To Use"

spec/controllers/skins_controller_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,18 @@
133133
end
134134
end
135135

136+
describe "GET #preview" do
137+
context "with a public site skin" do
138+
let(:skin) { create(:skin, :public) }
139+
140+
it "redirects to the configured preview page" do
141+
get :preview, params: { id: skin.id }
142+
it_redirects_to_simple("#{ArchiveConfig.SKIN_PREVIEW_URL}?site_skin=#{skin.id}")
143+
expect(flash[:notice]).to include("You are previewing the skin #{skin.title}.")
144+
end
145+
end
146+
end
147+
136148
describe "PUT #update" do
137149
shared_examples "an action guests and random logged-in users can't access" do |attribute:, value:|
138150
context "when logged in as a user who is not the skin author" do

0 commit comments

Comments
 (0)