refactor novelty logo bgs to method

Previously I've manually applied Christmas styling on Christmas by hacking the
prod CSS, nice to bring that into the codebase properly.
This commit is contained in:
Peter Bhat Harkins 2022-06-01 22:16:16 -05:00
parent 047a017474
commit 10d2557afd
2 changed files with 17 additions and 4 deletions

View File

@ -92,10 +92,9 @@ class ApplicationController < ActionController::Base
return true if Rails.application.read_only? ||
agent_is_spider? ||
%w{json rss}.include?(params[:format])
if Time.current.month == 6 && Time.current.day == 28 # Anniversary of the Stonewall riots
@traffic_style = "background: linear-gradient(180deg, #FE0000 16.66%, #FD8C00 16.66%, 33.32%, #FFE500 33.32%, 49.98%, #119F0B 49.98%, 66.64%, #0644B3 66.64%, 83.3%, #C22EDC 83.3%);" # rubocop:disable Layout/LineLength
return true
if (skip = TrafficHelper.novelty_logo)
@traffic_style = skip
return
end
@traffic_intensity = TrafficHelper.cached_current_intensity

View File

@ -56,4 +56,18 @@ module TrafficHelper
def self.cached_current_intensity
Keystore.value_for('traffic:intensity') || 0.5
end
# rubocop:disable Layout/LineLength
def self.novelty_logo
time = Time.current
if time.month == 6 && time.day == 28 # Stonewall riots
return "background: linear-gradient(180deg, #FE0000 16.66%, #FD8C00 16.66%, 33.32%, #FFE500 33.32%, 49.98%, #119F0B 49.98%, 66.64%, #0644B3 66.64%, 83.3%, #C22EDC 83.3%);"
elsif time.month == 12 && time.day == 25 # Christmas
return "background: conic-gradient(at 50% 0, #9f3631 157.5deg, #01c94f 0, #01c94f 202.5deg, #9f3631 0);"
end
nil
end
# rubocop:enable Layout/LineLength
end