Refine cache purgring

This commit is contained in:
2026-02-18 20:42:48 +01:00
parent b2600485c4
commit 1e52f75627
5 changed files with 182 additions and 12 deletions

View File

@@ -115,6 +115,62 @@
}
}
// ============================================================
// Purge Cache Dialog
// ============================================================
function initPurgeCacheDialog() {
var $link = jQuery('a.luxtools-invalidate-cache');
if ($link.length === 0) return;
$link.on('click.luxtools', function (e) {
e.preventDefault();
var href = $link.attr('href') || '';
var lang = (window.LANG && window.LANG.plugins && window.LANG.plugins.luxtools)
? window.LANG.plugins.luxtools
: {};
var $dialog = jQuery(
'<div>' +
'<p>' + (lang.cache_purge_dialog_intro || 'The DokuWiki cache will always be purged. Optionally also purge the luxtools-specific caches:') + '</p>' +
'<p><label><input type="checkbox" id="luxtools-purge-pagelinks"> <strong>' + (lang.cache_purge_pagelinks_label || 'Pagelinks') + '</strong>' +
' &ndash; ' + (lang.cache_purge_pagelinks_desc || 'Purges the pagelink mapping cache') + '</label></p>' +
'<p><label><input type="checkbox" id="luxtools-purge-thumbs"> <strong>' + (lang.cache_purge_thumbs_label || 'Thumbnails') + '</strong>' +
' &ndash; ' + (lang.cache_purge_thumbs_desc || 'Purges all cached image thumbnails') + '</label></p>' +
'</div>'
);
$dialog.dialog({
title: lang.cache_purge_dialog_title || 'Purge Cache',
modal: true,
width: 420,
buttons: [
{
text: lang.cache_purge_cancel || 'Cancel',
click: function () { $dialog.dialog('close'); }
},
{
text: lang.cache_purge_confirm || 'Purge Cache',
click: function () {
var url = href;
if ($dialog.find('#luxtools-purge-pagelinks').prop('checked')) {
url += '&luxtools_purge_pagelinks=1';
}
if ($dialog.find('#luxtools-purge-thumbs').prop('checked')) {
url += '&luxtools_purge_thumbs=1';
}
$dialog.dialog('close');
window.location.href = url;
}
}
],
close: function () {
jQuery(this).dialog('destroy').remove();
}
});
});
}
// ============================================================
// Initialize
// ============================================================
@@ -123,6 +179,7 @@
if (GalleryThumbnails && GalleryThumbnails.init) GalleryThumbnails.init();
initChronologicalEventTimes();
if (CalendarWidget && CalendarWidget.init) CalendarWidget.init();
initPurgeCacheDialog();
}, false);
document.addEventListener('DOMContentLoaded', function () {
if (Scratchpads && Scratchpads.init) Scratchpads.init();