diff --git a/app/javascript/src/javascripts/news_updates.js b/app/javascript/src/javascripts/news_updates.js index b7eafa88d..9cc303c77 100644 --- a/app/javascript/src/javascripts/news_updates.js +++ b/app/javascript/src/javascripts/news_updates.js @@ -2,28 +2,25 @@ import LS from './local_storage' let NewsUpdate = {}; -NewsUpdate.initialize = function() { - if (!$("#news-updates").length) { +NewsUpdate.initialize = function () { + if (!$("#news").length) { return; } + const key = parseInt($("#news").data("id"), 10); - var key = $("#news-updates").data("id").toString(); - - if (LS.get("news-ticker") === key) { - $("#news-updates").hide(); - } else { - $("#news-updates").show(); - - $("#close-news-ticker-link").on("click.danbooru", function(e) { - $("#news-updates").hide(); - LS.put("news-ticker", key); - - return false; - }); + $('#news').on('click', function () { + $('#news').toggleClass('open'); + }); + $('#news-closebutton').on('click', function () { + $('#news').hide(); + LS.put('hide_news_notice', key.toString()); + }); + if (parseInt(LS.get("hide_news_notice") || 0, 10) !== key) { + $("#news").show(); } -} +}; -$(function() { +$(function () { NewsUpdate.initialize(); }); diff --git a/app/javascript/src/styles/common/news.scss b/app/javascript/src/styles/common/news.scss index 2abaa7b5a..7dcc59f09 100644 --- a/app/javascript/src/styles/common/news.scss +++ b/app/javascript/src/styles/common/news.scss @@ -1,5 +1,34 @@ @import "../base/005_vars.scss"; +div#news { + max-height: 1rem; + overflow-y: hidden; + user-select: none; + + &:hover { + cursor: pointer; + } + + &.open { + max-height: none; + } + + .newsbody { + margin-top: 5px; + } + + .closebutton { + float: right; + cursor: pointer; + margin-right: 10px; + font-size: 14pt; + font-weight: bold; + color: white; + vertical-align: center; + margin-top: -3px; + } +} + div#news-updates { padding: 5px; background: $news-background; diff --git a/app/models/news_update.rb b/app/models/news_update.rb index b2263485c..6912b7eba 100644 --- a/app/models/news_update.rb +++ b/app/models/news_update.rb @@ -7,7 +7,7 @@ class NewsUpdate < ApplicationRecord def self.recent @recent_news ||= Cache.get('recent_news', 1.day) do - self.order('created_at desc').first(5) + self.order('id desc').first(1) end end diff --git a/app/views/layouts/default.html.erb b/app/views/layouts/default.html.erb index 775ebc303..f49fcc10a 100644 --- a/app/views/layouts/default.html.erb +++ b/app/views/layouts/default.html.erb @@ -108,7 +108,16 @@ <%= tag.body **body_attributes(CurrentUser.user) do %> - <%= render "news_updates/listing" %> + <% if Danbooru.config.beta_notice %> +
+ +
+ <% end %>

<%= link_to Danbooru.config.app_name, "/" %>

@@ -125,6 +134,8 @@
+ <%= render "news_updates/listing" %> + <% if CurrentUser.user.is_banned? %> <%= render "users/ban_notice" %> <% end %> diff --git a/app/views/news_updates/_listing.html.erb b/app/views/news_updates/_listing.html.erb index 8a3b3955f..c1c08a01d 100644 --- a/app/views/news_updates/_listing.html.erb +++ b/app/views/news_updates/_listing.html.erb @@ -1,13 +1,10 @@ -<% cache("news-updates", :expires_in => 1.hour) do %> - <% if NewsUpdate.recent.any? %> - - <% end %> +<% if NewsUpdate.recent.present? %> + <% end %> diff --git a/app/views/news_updates/edit.html.erb b/app/views/news_updates/edit.html.erb index e19d6a131..d667f5a95 100644 --- a/app/views/news_updates/edit.html.erb +++ b/app/views/news_updates/edit.html.erb @@ -3,7 +3,7 @@

Edit Update

<%= simple_form_for(@news_update) do |f| %> - <%= f.input :message, :hint => "Use HTML for formatting", :input_html => {:size => "30x5"} %> + <%= f.input :message, :hint => "Use DText for formatting", :input_html => {:size => "30x5"} %> <%= f.button :submit, "Submit" %> <% end %>
diff --git a/app/views/news_updates/new.html.erb b/app/views/news_updates/new.html.erb index 9b2c9a309..97de830a2 100644 --- a/app/views/news_updates/new.html.erb +++ b/app/views/news_updates/new.html.erb @@ -3,7 +3,7 @@

New Update

<%= simple_form_for(@news_update) do |f| %> - <%= f.input :message, :hint => "Use HTML for formatting", :input_html => {:size => "30x5"} %> + <%= f.input :message, :hint => "Use DText for formatting", :input_html => {:size => "30x5"} %> <%= f.button :submit, "Submit" %> <% end %> diff --git a/config/danbooru_default_config.rb b/config/danbooru_default_config.rb index e9e430cd9..f668398ca 100644 --- a/config/danbooru_default_config.rb +++ b/config/danbooru_default_config.rb @@ -289,6 +289,10 @@ fart' 1_000 end + def beta_notice + false + end + # Maximum size of an upload. If you change this, you must also change # `client_max_body_size` in your nginx.conf. def max_file_size