[Misc] Add optout for april fools

Close #630
This commit is contained in:
Earlopain 2024-04-01 12:24:33 +02:00
parent e2d289baca
commit c1aa5f95b1
No known key found for this signature in database
GPG Key ID: 48860312319ADF61
4 changed files with 17 additions and 2 deletions

View File

@ -49,6 +49,12 @@ class StaticController < ApplicationController
redirect_back fallback_location: posts_path redirect_back fallback_location: posts_path
end end
def dont_fool_me
cookies[:dont_fool_me] = { value: "1", expires: 1.week }
flash[:notice] = "òwō"
redirect_back fallback_location: posts_path
end
def discord def discord
unless CurrentUser.can_discord? unless CurrentUser.can_discord?
raise User::PrivilegeError.new("You must have an account for at least one week in order to join the Discord server.") raise User::PrivilegeError.new("You must have an account for at least one week in order to join the Discord server.")

View File

@ -60,12 +60,13 @@ module ApplicationHelper
end end
def fool? def fool?
return true if params[:fool] return false if Danbooru.config.app_name == "e926"
return false if cookies[:dont_fool_me]
Time.use_zone(Time.find_zone("UTC")) do Time.use_zone(Time.find_zone("UTC")) do
target = Date.new(2024, 4, 1) target = Date.new(2024, 4, 1)
start = target.beginning_of_day - 12.hours start = target.beginning_of_day - 12.hours
stop = target.end_of_day + 12.hours stop = target.end_of_day + 6.hours
Time.now.between?(start, stop) Time.now.between?(start, stop)
end end
end end

View File

@ -7,6 +7,13 @@
<h3 class="redtext" id="no_save_warning">Your device does not allow the site to save theme settings.</h3> <h3 class="redtext" id="no_save_warning">Your device does not allow the site to save theme settings.</h3>
</noscript> </noscript>
<% if fool? %>
<p>
Click <%= link_to "here", dont_fool_me_static_path %> to kill the joke early.
</p>
<% end %>
<div class="simple_form"> <div class="simple_form">
<div class="input"> <div class="input">
<label for="theme_name">Theme</label> <label for="theme_name">Theme</label>

View File

@ -444,6 +444,7 @@ Rails.application.routes.draw do
post "/static/discord" => "static#discord", as: "discord_post" post "/static/discord" => "static#discord", as: "discord_post"
get "/static/toggle_mobile_mode" => "static#disable_mobile_mode", as: "disable_mobile_mode" get "/static/toggle_mobile_mode" => "static#disable_mobile_mode", as: "disable_mobile_mode"
get "/static/theme" => "static#theme", as: "theme" get "/static/theme" => "static#theme", as: "theme"
get "/static/dont_fool_me" => "static#dont_fool_me", as: "dont_fool_me_static"
get "/meta_searches/tags" => "meta_searches#tags", :as => "meta_searches_tags" get "/meta_searches/tags" => "meta_searches#tags", :as => "meta_searches_tags"
root :to => "static#home" root :to => "static#home"