Skip to content

Commit

Permalink
Added the ability to specify the number of pixels to shift in the URL…
Browse files Browse the repository at this point in the history
… for /shifting_content and /shifting_content/random
  • Loading branch information
Dave Haeffner committed Dec 12, 2014
1 parent ab73a36 commit f89d14f
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -376,12 +376,34 @@ def authorized?
erb :shifting_content
end

get '/shifting_content/:pixel_shift' do |pixel_shift|
pixel_count = [0, pixel_shift]
cookies[:page_visit_count] ||= '0'
page_visit_count = cookies[:page_visit_count].to_i

if page_visit_count.even?
@pixel_shift = pixel_count[0]
else
@pixel_shift = pixel_count[1]
end

page_visit_count += 1
cookies[:page_visit_count] = page_visit_count.to_s
erb :shifting_content
end

get '/shifting_content/random' do
pixel_count = [0, 25]
@pixel_shift = pixel_count[rand(2)]
erb :shifting_content
end

get '/shifting_content/random/:pixel_shift' do |pixel_shift|
pixel_count = [0, pixel_shift]
@pixel_shift = pixel_count[rand(2)]
erb :shifting_content
end

get '/challenging_dom' do
require 'uuid'
@text = %w(foo bar baz qux)
Expand Down

0 comments on commit f89d14f

Please sign in to comment.