diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 0d69840df..471c8a320 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -151,8 +151,14 @@ module ApplicationHelper end time_tag(text, time, class: klass) - else - time_tag("in " + distance_of_time_in_words(Time.now, time), time) + elsif time.future? + if compact + text = distance_of_time_in_words(Time.now, time) + text = text.gsub(/almost|about|over/, "").gsub(/less than a/, "<1").strip + time_tag(text, time) + else + time_tag("in " + distance_of_time_in_words(Time.now, time), time) + end end end diff --git a/app/javascript/src/javascripts/common.js b/app/javascript/src/javascripts/common.js index 90fc89347..6d8eb9776 100644 --- a/app/javascript/src/javascripts/common.js +++ b/app/javascript/src/javascripts/common.js @@ -7,6 +7,13 @@ $(function() { e.preventDefault(); }); + $("#hide-promotion-notice").on("click.danbooru", function(e) { + $("#promotion-notice").hide(); + Cookie.put("hide_promotion_notice", "1", 1 * 18 * 60 * 60); + Cookie.put("hide_upgrade_account_notice", "1", 7 * 24 * 60 * 60); + e.preventDefault(); + }); + $("#hide-dmail-notice").on("click.danbooru", function(e) { var $dmail_notice = $("#dmail-notice"); $dmail_notice.hide(); diff --git a/app/models/user.rb b/app/models/user.rb index 27f80d6c6..5e54b50c0 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -437,7 +437,9 @@ class User < ApplicationRecord end def tag_query_limit(level) - if level >= User::Levels::BUILDER + if level >= User::Levels::MEMBER && Danbooru.config.is_promotion? + Float::INFINITY + elsif level >= User::Levels::BUILDER Float::INFINITY elsif level == User::Levels::PLATINUM 12 diff --git a/app/models/user_upgrade.rb b/app/models/user_upgrade.rb index 46dee3845..8551c7951 100644 --- a/app/models/user_upgrade.rb +++ b/app/models/user_upgrade.rb @@ -37,7 +37,11 @@ class UserUpgrade < ApplicationRecord end def self.gold_price - 2000 + if Danbooru.config.is_promotion? + 1500 + else + 2000 + end end def self.platinum_price @@ -161,6 +165,9 @@ class UserUpgrade < ApplicationRecord price: price_id, quantity: 1, }], + discounts: [{ + coupon: promotion_discount_id, + }], metadata: { user_upgrade_id: id, purchaser_id: purchaser.id, @@ -218,6 +225,12 @@ class UserUpgrade < ApplicationRecord !pending? end + def promotion_discount_id + if Danbooru.config.is_promotion? + Danbooru.config.stripe_promotion_discount_id + end + end + def upgrade_price_id(currency) case [upgrade_type, currency] when ["gold", "usd"] diff --git a/app/views/layouts/default.html.erb b/app/views/layouts/default.html.erb index b94ba203f..a12cb7945 100644 --- a/app/views/layouts/default.html.erb +++ b/app/views/layouts/default.html.erb @@ -80,7 +80,20 @@
<%= render "users/verification_notice" %> - <% if !CurrentUser.is_anonymous? && !CurrentUser.is_gold? && !CurrentUser.user.is_banned? && cookies[:hide_upgrade_account_notice].blank? && params[:action] != "upgrade_information" %> + <% if Danbooru.config.is_promotion? && cookies[:hide_promotion_notice].blank? %> +
+ <% file = %w[provgift.png kemogift.png padoru.gif ablobgift.gif].sample %> + <%= tag.img src: "/images/#{file}", width: 32, height: 32 %> + + + <%= link_to "Danbooru Winter Sale", forum_topic_path(Danbooru.config.winter_sale_forum_topic_id) %> ends <%= time_ago_in_words_tagged(Danbooru.config.winter_sale_end_date) %>! +
+ <%= link_to "Get 25% off Gold & Platinum", new_user_upgrade_path %> +
+ + (<%= link_to "hide", "#", id: "hide-promotion-notice" %>) +
+ <% elsif !CurrentUser.is_anonymous? && !CurrentUser.is_gold? && !CurrentUser.user.is_banned? && cookies[:hide_upgrade_account_notice].blank? && params[:action] != "upgrade_information" %> <%= render "users/upgrade_notice" %> <% end %> diff --git a/app/views/user_upgrades/new.html.erb b/app/views/user_upgrades/new.html.erb index 7e88565bb..85566f6b4 100644 --- a/app/views/user_upgrades/new.html.erb +++ b/app/views/user_upgrades/new.html.erb @@ -26,6 +26,14 @@ their profile page and look for a "Gift Upgrade" link.

<% end %> + <% if Danbooru.config.is_promotion? %> +

+ <%= tag.img src: "/images/padoru.gif", width: 24, height: 24 %> + Danbooru Winter Sale! Gold and Platinum upgrades are 25% off. Sale ends <%= time_ago_in_words_tagged(Time.utc("2022-01-01")) %>. + <%= tag.img src: "/images/padoru.gif", width: 24, height: 24 %> +

+ <% end %> + @@ -44,19 +52,25 @@ - - - + + + diff --git a/config/danbooru_default_config.rb b/config/danbooru_default_config.rb index bc5b4c840..225a296e4 100644 --- a/config/danbooru_default_config.rb +++ b/config/danbooru_default_config.rb @@ -516,6 +516,19 @@ module Danbooru # https://docs.newrelic.com/docs/accounts/accounts-billing/account-setup/new-relic-license-key/ def new_relic_license_key end + + # True if the Winter Sale is active. + def is_promotion? + false + end + + # The end date of the Winter Sale. + def winter_sale_end_date + end + + # The forum topic linked to in the Winter Sale notice. + def winter_sale_forum_topic_id + end end EnvironmentConfiguration = Struct.new(:config) do diff --git a/public/images/blobgift.png b/public/images/blobgift.png new file mode 100644 index 000000000..bfcb3aa64 Binary files /dev/null and b/public/images/blobgift.png differ diff --git a/public/images/kemogift.png b/public/images/kemogift.png new file mode 100644 index 000000000..300da66fb Binary files /dev/null and b/public/images/kemogift.png differ diff --git a/public/images/padoru.gif b/public/images/padoru.gif new file mode 100644 index 000000000..454968b16 Binary files /dev/null and b/public/images/padoru.gif differ diff --git a/public/images/provgift.png b/public/images/provgift.png new file mode 100644 index 000000000..2dac5a97f Binary files /dev/null and b/public/images/provgift.png differ
Free + <% if Danbooru.config.is_promotion? %> + $20 + <% end %> <%= cents_to_usd(UserUpgrade.gold_price) %>
One time fee
+ <% if Danbooru.config.is_promotion? %> + $40 + <% end %> <%= cents_to_usd(UserUpgrade.platinum_price) %>
One time fee
Tag Limit<%= User.tag_query_limit(User::Levels::MEMBER) %><%= User.tag_query_limit(User::Levels::GOLD) %><%= User.tag_query_limit(User::Levels::PLATINUM) %>2612
See Hidden Tags