mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-06-02 23:59:52 -04:00
fix check-for-update fetching code
This commit is contained in:
parent
73993d26c0
commit
8ee2981957
2 changed files with 37 additions and 36 deletions
|
@ -141,42 +141,43 @@
|
|||
{% block footer %}<div id="footer"></div>{% endblock %}
|
||||
</div>
|
||||
|
||||
<script>
|
||||
{% if user.is_authenticated and user.is_superuser and CAN_UPGRADE %}
|
||||
if (!localStorage.getItem("bannerDismissed")) {
|
||||
const upgradeVersionTag = "{{VERSIONS_AVAILABLE.recommended_version.tag_name}}"
|
||||
const upgradeVersionURL = "{{VERSIONS_AVAILABLE.recommended_version.html_url}}"
|
||||
const currentVersionTag = "{{VERSION}}"
|
||||
const currentVersionURL = "{{VERSIONS_AVAILABLE.recommended_version.html_url}}"
|
||||
{% if user.is_authenticated and user.is_superuser and CAN_UPGRADE %}
|
||||
<script>
|
||||
if (!localStorage.getItem("bannerDismissed")) {
|
||||
const upgradeVersionTag = "{{VERSIONS_AVAILABLE.recommended_version.tag_name}}"
|
||||
const upgradeVersionURL = "{{VERSIONS_AVAILABLE.recommended_version.html_url}}"
|
||||
const currentVersionTag = "{{VERSION}}"
|
||||
const currentVersionURL = "{{VERSIONS_AVAILABLE.recommended_version.html_url}}"
|
||||
|
||||
createBanner(currentVersionTag, currentVersionURL, upgradeVersionTag, upgradeVersionURL)
|
||||
}
|
||||
|
||||
function createBanner(currentVersionTag, currentVersionURL, upgradeVersionTag, upgradeVersionURL) {
|
||||
const banner = document.createElement('div')
|
||||
banner.setAttribute('id', 'upgrade-banner');
|
||||
banner.innerHTML = `
|
||||
<p>There's a new version of ArchiveBox available!</p>
|
||||
Your version: <a href=${currentVersionURL}>${currentVersionTag}</a> | New version: <a href=${upgradeVersionURL}>${upgradeVersionTag}</a>
|
||||
<p>
|
||||
<a href=https://github.com/ArchiveBox/ArchiveBox/wiki/Upgrading-or-Merging-Archives>Upgrade Instructions</a> | <a href=https://github.com/ArchiveBox/ArchiveBox/releases>Changelog</a> | <a href=https://github.com/ArchiveBox/ArchiveBox/wiki/Roadmap>Roadmap</a>
|
||||
</p>
|
||||
<button id="dismiss-btn">Dismiss</button>
|
||||
`
|
||||
document.body.appendChild(banner);
|
||||
const dismissButton = document.querySelector("#dismiss-btn")
|
||||
if (dismissButton) {
|
||||
dismissButton.addEventListener("click", dismissBanner)
|
||||
createBanner(currentVersionTag, currentVersionURL, upgradeVersionTag, upgradeVersionURL)
|
||||
}
|
||||
}
|
||||
|
||||
function dismissBanner() {
|
||||
const banner = document.getElementById("upgrade-banner")
|
||||
banner.style.display = "none"
|
||||
localStorage.setItem("bannerDismissed", "true")
|
||||
}
|
||||
{% endif %}
|
||||
function createBanner(currentVersionTag, currentVersionURL, upgradeVersionTag, upgradeVersionURL) {
|
||||
const banner = document.createElement('div')
|
||||
banner.setAttribute('id', 'upgrade-banner');
|
||||
banner.innerHTML = `
|
||||
<p>There's a new version of ArchiveBox available!</p>
|
||||
Your version: <a href=${currentVersionURL}>${currentVersionTag}</a> | New version: <a href=${upgradeVersionURL}>${upgradeVersionTag}</a>
|
||||
<p>
|
||||
<a href=https://github.com/ArchiveBox/ArchiveBox/wiki/Upgrading-or-Merging-Archives>Upgrade Instructions</a> | <a href=https://github.com/ArchiveBox/ArchiveBox/releases>Changelog</a> | <a href=https://github.com/ArchiveBox/ArchiveBox/wiki/Roadmap>Roadmap</a>
|
||||
</p>
|
||||
<button id="dismiss-btn">Dismiss</button>
|
||||
`
|
||||
document.body.appendChild(banner);
|
||||
const dismissButton = document.querySelector("#dismiss-btn")
|
||||
if (dismissButton) {
|
||||
dismissButton.addEventListener("click", dismissBanner)
|
||||
}
|
||||
}
|
||||
|
||||
function dismissBanner() {
|
||||
const banner = document.getElementById("upgrade-banner")
|
||||
banner.style.display = "none"
|
||||
localStorage.setItem("bannerDismissed", "true")
|
||||
}
|
||||
</script>
|
||||
{% endif %}
|
||||
<script>
|
||||
$ = django.jQuery;
|
||||
$.fn.reverse = [].reverse;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue