From c1aa5f95b1585e6e731cc49fcec402ef94360e00 Mon Sep 17 00:00:00 2001 From: Earlopain <14981592+Earlopain@users.noreply.github.com> Date: Mon, 1 Apr 2024 12:24:33 +0200 Subject: [PATCH] [Misc] Add optout for april fools Close #630 --- app/controllers/static_controller.rb | 6 ++++++ app/helpers/application_helper.rb | 5 +++-- app/views/static/theme.html.erb | 7 +++++++ config/routes.rb | 1 + 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/app/controllers/static_controller.rb b/app/controllers/static_controller.rb index 64161eb14..eb76bb990 100644 --- a/app/controllers/static_controller.rb +++ b/app/controllers/static_controller.rb @@ -49,6 +49,12 @@ class StaticController < ApplicationController redirect_back fallback_location: posts_path 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 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.") diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 15b8bbb5c..43342b58b 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -60,12 +60,13 @@ module ApplicationHelper end 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 target = Date.new(2024, 4, 1) 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) end end diff --git a/app/views/static/theme.html.erb b/app/views/static/theme.html.erb index f252c29fc..503b65b7a 100644 --- a/app/views/static/theme.html.erb +++ b/app/views/static/theme.html.erb @@ -7,6 +7,13 @@
+ Click <%= link_to "here", dont_fool_me_static_path %> to kill the joke early. +
+<% end %> + +