Repository: internetarchive/openlibrary

Issue:
Add a way to ignore/dismiss OL banner-bar by name
<!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -->

### Describe the problem that you'd like solved
<!-- A clear and concise description of what you want to happen. -->

We've received a few complaints about the prominence of our banner bar, from @tfmorris and others.

<!-- Add any other context or screenshots about the feature request here. -->
![ol-dev1 us archive org_1337_people_mekBot_books (1)](https://user-images.githubusercontent.com/978325/210018820-4edbb6a5-5b24-4855-88cc-8d619e483e23.png)

It's an important discovery mechanism for us and it's unlikely we'll sunset it, however, it would be advantageous to enable patrons to dismiss a banner after they've seen it.

This could be achieved by assigning a unique name attribute to each banner we deploy and adding a `x` to dismiss the banner (i.e. mark it as read) by adding the banner name to e.g. LocalStorage and hiding banners or elements with that name.

### Proposal & Constraints
<!-- What is the proposed solution / implementation? Is there a precedent of this approach succeeding elsewhere? -->

<!-- Which suggestions or requirements should be considered for how feature needs to appear or be implemented? -->

### Additional context

### Stakeholders
<!-- @ tag stakeholders of this bug -->





Discussion:
To avoid accidentally reusing a banner name, a date could be included in the banner name.
For example, the banner pictured above could have a name like `2022-12-28_My_Books_announcement`.
Thanks for creating the issue for me, @mekarpeles!  The banner rendered differently on my screen. It looked like this:

![OpenLibraryGarishBanner](https://user-images.githubusercontent.com/82178/210104077-c30d8489-e524-4f63-a5d6-bd45e51b2319.png)

Being able to dismiss the banner would be useful, but I think it's worth taking a step back to look at this holistically. Here are some other things that I noted:
- The message is not served in the language to which my browser is set
- The styling doesn't match the content. When I see a red & black element which is the most prominent element on the page, I expect the message to be along the lines of "Emergency shutdown in 15 minutes!!!," not "Please take this survey"
- A message asking for feedback on a section of the web site, belongs on that section where it'll be seen by the users who actually use it, not as a global thing which appears on every single page impression.
- If the message is more about a blog post than a feature, I'd expect to be prompted to subscribe to an RSS feed or an email list or some other announcement mechanism for new blog posts.
- Lastly, as long as I'm picking nits, the blog post isn't even about the feature, it's about the UX design process. I'd expect a feature announcement to lead with, above the fold, a brief description, or bulleted list, of things that were changed/added and why I, as a user, should care. I enjoy UX design odyssey descriptions, but most users are going to be interested much more in the feature.

Perhaps this could be the next UX design experiment - How do users want to receive notice about new features and provide feedback on same?

p.s. I don't remember the details of how that bar used to be styled, but I'm pretty sure it wasn't as jarring before. Different color? Thinner bar?
I believe it used to be a blue background, white text.
Hi I will be taking on this issue. Will make a PR by the end of the week!

Resolving patch:
diff --git a/openlibrary/plugins/openlibrary/api.py b/openlibrary/plugins/openlibrary/api.py
--- a/openlibrary/plugins/openlibrary/api.py
+++ b/openlibrary/plugins/openlibrary/api.py
@@ -634,3 +634,20 @@ def POST(self, work_id: str):
             ),
             content_type="application/json",
         )
+
+
+class hide_banner(delegate.page):
+    path = '/hide_banner'
+
+    def POST(self):
+        data = json.loads(web.data())
+        user = accounts.get_current_user()
+
+        user.save_preferences({'hidden-banner': data['storage-key']})
+
+        def response(msg, status="success"):
+            return delegate.RawText(
+                json.dumps({status: msg}), content_type="application/json"
+            )
+
+        return response('Preference saved')


Test patch: