Update Winter Sale banner for last day.
This commit is contained in:
@@ -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")}"
|
||||
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
|
||||
|
||||
@@ -70,21 +70,14 @@
|
||||
<div id="page">
|
||||
<%= 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? %>
|
||||
<div class="notice notice-info notice-large" id="promotion-notice">
|
||||
<% 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" %>)
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
@@ -19,7 +19,11 @@
|
||||
<h1>Upgrade Account</h1>
|
||||
|
||||
<% if Danbooru.config.is_promotion? %>
|
||||
<p><b>Danbooru Winter Sale! Gold and Platinum upgrades are 25% off from now until January 1st.</b></p>
|
||||
<p>
|
||||
<%= tag.img src: "/images/padoru.gif", width: 24, height: 24 %>
|
||||
<b>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) } %>.</b>
|
||||
<%= tag.img src: "/images/padoru.gif", width: 24, height: 24 %>
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
<p>Upgrading your account gives you exclusive benefits and helps support
|
||||
|
||||
Reference in New Issue
Block a user