-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ca277da
commit 7979d39
Showing
4 changed files
with
26 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,4 @@ | ||
document.addEventListener('DOMContentLoaded', function() { | ||
if (document.getElementsByClassName('custom-banner-dismiss')[0].style.display != 'none') { | ||
if (document.cookie.split('; ').find(row => row.startsWith('custom-banner-dismiss'))) { | ||
document.getElementsByClassName('custom-banner-container')[0].style.display = 'none'; | ||
} | ||
} else { | ||
document.cookie = "custom-banner-dismiss=false; max-age=0"; | ||
} | ||
}); | ||
|
||
function custom_button_dismiss() { | ||
document.cookie = 'custom-banner-dismiss=true; max-age=1800'; | ||
document.cookie = 'custom-banner-dismiss=true; max-age=1800;'; | ||
document.getElementsByClassName('custom-banner-container')[0].style.display = 'none'; | ||
} |
7979d39
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you mind sharing what your thinking is behind the
onAdminSave
? I'm afraid I fail to see the benefits of it. I think the goal is to revive the banner when, for example, the text has changed. However, I suspect that that goal will not be achieved...onAdminSaved()
will only be called once when the Admin page has been saved.false
for the user logged in as Admin and it will expire immediately.7979d39
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, as the cookie expiry time is only 30 mins I didn't think it was all that important for end-users to get the new banner straight away, but for the admin user making the changes it's useful to be able to see those changes straight away without having to either wait 30 mins or manually clear that cookie (which they won't necessarily know about).
So it doesn't solve the problem of displaying new banners to end users, but it solves a problem I'd run into as a developer trying to see changes I'd made to a banner that I'd dismissed!
7979d39
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK fair enough that the end-user doesn't get to see a changed banner right away.
What changes should the Admin be able to see straight away? The Admin doesn't get to see the banner anyway, isn't it?
7979d39
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well when I add a banner to the site the first thing I do is go to the site and see if I like the look of it and test that it works. If I make some changes I'll go back to the site and see if I like them.
However, you're right that there is an issue with visitors not seeing banner updates. How about:
onAdminSave
and checks it against the value in the visitors cookieonPluginInitialized
rather than just checking that the cookie exists7979d39
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Admin:
Hm... If I login as user and dismiss the banner and I login in to Admin in a new tab. I never get to see the changes in my 'user' tab... The cookie remains set. Probably because the paths in the cookie are different.
Visitor:
May I presume the server will save the hash calculated during
onAdminSave
?onPageContentProcessed
, which is fired when the cache is invalidated, which happens when any config file has changed, or when executing$ bin/grav cache
.