From 62ec8a523601a43be6ffae48889e6ef0ee4eccdf Mon Sep 17 00:00:00 2001 From: Nicolas F Date: Fri, 3 Aug 2018 04:16:28 +0200 Subject: [PATCH] Make blue info bubble dismissible, configurable (#508) Infobubble text is now in a separate file, along with a timestamp, so that changes to it don't result in merge conflicts too often. We also add some JS to make the bubble dismissible, keeping track of the last timestamp that was dismissed in localstorage. --- nyaa/static/js/main.js | 10 ++++++++++ nyaa/templates/home.html | 5 +---- nyaa/templates/infobubble.html | 14 ++++++++++++++ nyaa/templates/infobubble_content.html | 3 +++ 4 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 nyaa/templates/infobubble.html create mode 100644 nyaa/templates/infobubble_content.html diff --git a/nyaa/static/js/main.js b/nyaa/static/js/main.js index 4cb58df..8eb3624 100644 --- a/nyaa/static/js/main.js +++ b/nyaa/static/js/main.js @@ -260,6 +260,16 @@ document.addEventListener("DOMContentLoaded", function() { } }); +// Info bubble stuff +document.addEventListener("DOMContentLoaded", function() { + var bubble = document.getElementById('infobubble'); + if (Number(localStorage.getItem('infobubble_dismiss_ts')) < Number(bubble.dataset.ts)) { + bubble.removeAttribute('hidden'); + } + $('#infobubble').on('close.bs.alert', function () { + localStorage.setItem('infobubble_dismiss_ts', bubble.dataset.ts); + }) +}); // Decode HTML entities (> etc), used for decoding comment markdown from escaped text function htmlDecode(input){ diff --git a/nyaa/templates/home.html b/nyaa/templates/home.html index ae44076..a80641e 100644 --- a/nyaa/templates/home.html +++ b/nyaa/templates/home.html @@ -12,10 +12,7 @@ {% block body %} {% if not search.term %} -
-

We welcome you to provide feedback on IRC at #nyaa-dev@irc.rizon.net

-

Our GitHub: https://github.com/nyaadevs - creating issues for features and faults is recommended!

-
+{% include "infobubble.html" %} {% endif %} {% include "search_results.html" %} diff --git a/nyaa/templates/infobubble.html b/nyaa/templates/infobubble.html new file mode 100644 index 0000000..4926837 --- /dev/null +++ b/nyaa/templates/infobubble.html @@ -0,0 +1,14 @@ +{% import "infobubble_content.html" as info %} +{% if info.info_text %} + + +{% endif %} diff --git a/nyaa/templates/infobubble_content.html b/nyaa/templates/infobubble_content.html new file mode 100644 index 0000000..e6289f0 --- /dev/null +++ b/nyaa/templates/infobubble_content.html @@ -0,0 +1,3 @@ +{% set info_text = "Put your announcements here!" %} +{# Update this to a larger timestamp if you change your announcement #} +{% set info_ts = 1531215917 %}