Allow downloading the pagelink file directly

This commit is contained in:
2026-02-04 09:53:43 +01:00
parent 70a9f30336
commit a5c44e106e
3 changed files with 78 additions and 4 deletions

View File

@@ -127,6 +127,45 @@
});
}
function attachDocInfoLink() {
var container = document.querySelector('.docInfo');
if (!container || !container.getAttribute) return;
if (container.getAttribute('data-luxtools-pagelink-docinfo') === '1') return;
container.setAttribute('data-luxtools-pagelink-docinfo', '1');
var pageId = getPageId();
if (!pageId) return;
var endpoint = getBaseUrl() + 'lib/plugins/luxtools/pagelink.php';
var query = endpoint + '?cmd=info&id=' + encodeURIComponent(pageId);
window.fetch(query, {
method: 'GET',
credentials: 'same-origin'
}).then(function (res) {
return res.json().catch(function () { return null; }).then(function (body) {
if (!res.ok || !body || body.ok !== true) {
throw new Error('request failed');
}
return body;
});
}).then(function (info) {
if (!info || !info.uuid) return;
var link = document.createElement('a');
link.href = endpoint + '?cmd=download&id=' + encodeURIComponent(pageId);
link.textContent = 'Page ID: ' + String(info.uuid);
var first = container.firstChild;
container.insertBefore(link, first);
if (first) {
container.insertBefore(document.createTextNode(' · '), first);
}
}).catch(function () {
// ignore failures
});
}
window.addBtnActionLuxtoolsPageLink = function ($btn, props, edid) {
$btn.on('click', function () {
var pageId = getPageId();
@@ -165,5 +204,8 @@
return 'luxtools-pagelink';
};
document.addEventListener('DOMContentLoaded', attachCopyTargets, false);
document.addEventListener('DOMContentLoaded', function () {
attachCopyTargets();
attachDocInfoLink();
}, false);
})();