diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 57f4819c0..a288ee64f 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -108,13 +108,17 @@ module ApplicationHelper tag.time content || datetime, datetime: datetime, title: time.to_formatted_s, **options end - def humanized_duration(from, to) + def humanized_duration(from, to, compact: false) if to - from > 10.years duration = "forever" else duration = distance_of_time_in_words(from, to) end + if compact + duration = duration.gsub(/almost|about|over/, "").gsub(/less than a/, "<1").strip + end + datetime = from.iso8601 + "/" + to.iso8601 title = "#{from.strftime("%Y-%m-%d %H:%M")} to #{to.strftime("%Y-%m-%d %H:%M")}" diff --git a/app/javascript/src/javascripts/common.js b/app/javascript/src/javascripts/common.js index e0fc4d0c0..cc04ab125 100644 --- a/app/javascript/src/javascripts/common.js +++ b/app/javascript/src/javascripts/common.js @@ -9,8 +9,8 @@ $(function() { $("#hide-promotion-notice").on("click.danbooru", function(e) { $("#promotion-notice").hide(); - Cookie.put("hide_promotion_notice", "1", 1 * 24 * 60 * 60); - Cookie.put("hide_upgrade_account_notice", "1", 1 * 24 * 60 * 60); + Cookie.put("hide_final_promotion_notice", "1", 3 * 60 * 60); + Cookie.put("hide_upgrade_account_notice", "1", 7 * 24 * 60 * 60); e.preventDefault(); }); diff --git a/app/views/layouts/default.html.erb b/app/views/layouts/default.html.erb index 778a3c143..7c6606f56 100644 --- a/app/views/layouts/default.html.erb +++ b/app/views/layouts/default.html.erb @@ -70,21 +70,14 @@
<%= render "users/verification_notice" %> - <% if Danbooru.config.is_promotion? && cookies[:hide_promotion_notice].blank? %> + <% if Danbooru.config.is_promotion? && cookies[:hide_final_promotion_notice].blank? %>
- <% if rand <= 0.0025 %> - <%= tag.img src: "/images/provgift.png", width: 24, height: 24 %> - <% elsif rand <= 0.0025 %> - <%= tag.img src: "/images/kemogift.png", width: 24, height: 24 %> - <% elsif rand <= 0.0025 %> - <%= tag.img src: "/images/padoru.gif", width: 24, height: 24 %> - <% elsif rand <= 0.0025 %> - <%= tag.img src: "/images/ablobgift.gif", width: 24, height: 24 %> - <% else %> - <%= tag.img src: "/images/blobgift.png", width: 24, height: 24 %> - <% end %> + <% file = %w[provgift.png kemogift.png padoru.gif ablobgift.gif].sample %> + <%= tag.img src: "/images/#{file}", width: 24, height: 24 %> - <%= link_to "Danbooru Winter Sale!", forum_topic_path(17832) %> 25% off Gold and unlimited searches for Members! + <%= link_to "Danbooru Winter Sale", forum_topic_path(17832) %> ends in + <%= Time.use_zone("UTC") { humanized_duration(Time.zone.parse("2021-01-01"), Time.zone.now, compact: true) } %>! + Get 25% off Gold & Platinum (<%= link_to "hide", "#", id: "hide-promotion-notice" %>)
<% end %> diff --git a/app/views/user_upgrades/new.html.erb b/app/views/user_upgrades/new.html.erb index 31a85d34d..ed3647fe1 100644 --- a/app/views/user_upgrades/new.html.erb +++ b/app/views/user_upgrades/new.html.erb @@ -19,7 +19,11 @@

Upgrade Account

<% if Danbooru.config.is_promotion? %> -

Danbooru Winter Sale! Gold and Platinum upgrades are 25% off from now until January 1st.

+

+ <%= tag.img src: "/images/padoru.gif", width: 24, height: 24 %> + Danbooru Winter Sale! Gold and Platinum upgrades are 25% off. Sale ends in <%= Time.use_zone("UTC") { humanized_duration(Time.zone.parse("2021-01-01"), Time.zone.now, compact: true) } %>. + <%= tag.img src: "/images/padoru.gif", width: 24, height: 24 %> +

<% end %>

Upgrading your account gives you exclusive benefits and helps support