From 38f88809668a97717aeb01167d32e405ea7f794c Mon Sep 17 00:00:00 2001 From: Nicolas F Date: Tue, 9 Apr 2019 04:50:30 +0200 Subject: [PATCH] Make blue info bubble dismissible, configurable (#526) Infobubble text is now in a separate file, along with a timestamp in the main file, 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. A timestamp of 0 disables the infobubble altogether. --- nyaa/static/js/main.js | 10 ++++++++++ nyaa/templates/home.html | 5 +---- nyaa/templates/infobubble.html | 16 ++++++++++++++++ nyaa/templates/infobubble_content.html | 1 + 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..68bda06 --- /dev/null +++ b/nyaa/templates/infobubble.html @@ -0,0 +1,16 @@ +{# Update this to a larger timestamp if you change your announcement #} +{# A value of 0 disables the announcements altogether #} +{% set info_ts = 0 %} +{% if info_ts > 0 %} + + +{% endif %} diff --git a/nyaa/templates/infobubble_content.html b/nyaa/templates/infobubble_content.html new file mode 100644 index 0000000..735e86a --- /dev/null +++ b/nyaa/templates/infobubble_content.html @@ -0,0 +1 @@ +Put your announcements into infobubble_content.html!