Remove deprecated PDF endpoint and update frontend download actions
Remove the old HTML-based PDF download endpoint in favor of the new WeasyPrint-based one, and replace the generic "Télécharger" button in popout.html with a dedicated .md download and a new PDF button. Also remove the unused generic download button from the main file view.
This commit is contained in:
+1
-7
@@ -3242,12 +3242,6 @@
|
||||
|
||||
const sourceBtn = el("button", { class: "btn-action", title: "Voir la source" }, [icon("code", 14), document.createTextNode("Source")]);
|
||||
|
||||
const downloadBtn = el("button", { class: "btn-action", title: "Télécharger" }, [icon("download", 14), document.createTextNode("Télécharger")]);
|
||||
downloadBtn.addEventListener("click", () => {
|
||||
const dlUrl = `/api/file/${encodeURIComponent(data.vault)}/download?path=${encodeURIComponent(data.path)}`;
|
||||
window.open(dlUrl, "_blank");
|
||||
});
|
||||
|
||||
// MD download button
|
||||
const mdBtn = el("button", { class: "btn-action", title: "Télécharger en .md" }, [icon("file-text", 14), document.createTextNode(".md")]);
|
||||
mdBtn.addEventListener("click", () => {
|
||||
@@ -3359,7 +3353,7 @@
|
||||
// Assemble
|
||||
area.innerHTML = "";
|
||||
area.appendChild(breadcrumb);
|
||||
area.appendChild(el("div", { class: "file-header" }, [el("div", { class: "file-title" }, [document.createTextNode(data.title)]), tagsDiv, el("div", { class: "file-actions" }, [copyBtn, sourceBtn, downloadBtn, mdBtn, pdfBtn, editBtn, openNewWindowBtn, tocBtn, shareBtn, bookmarkBtn])]));
|
||||
area.appendChild(el("div", { class: "file-header" }, [el("div", { class: "file-title" }, [document.createTextNode(data.title)]), tagsDiv, el("div", { class: "file-actions" }, [copyBtn, sourceBtn, mdBtn, pdfBtn, editBtn, openNewWindowBtn, tocBtn, shareBtn, bookmarkBtn])]));
|
||||
if (fmSection) area.appendChild(fmSection);
|
||||
area.appendChild(mdDiv);
|
||||
area.appendChild(rawDiv);
|
||||
|
||||
+53
-2
@@ -751,8 +751,8 @@ const RightSidebarManager = {
|
||||
|
||||
const dlBtn = document.createElement("button");
|
||||
dlBtn.className = "btn-action";
|
||||
dlBtn.title = "Télécharger";
|
||||
dlBtn.innerHTML = '<i data-lucide="download" style="width:14px;height:14px"></i> Télécharger';
|
||||
dlBtn.title = "Télécharger en .md";
|
||||
dlBtn.innerHTML = '<i data-lucide="file-text" style="width:14px;height:14px"></i> .md';
|
||||
dlBtn.addEventListener("click", () => {
|
||||
const a = document.createElement("a");
|
||||
a.href = `/api/file/${encodeURIComponent(vault)}/download?path=${encodeURIComponent(path)}`;
|
||||
@@ -763,6 +763,15 @@ const RightSidebarManager = {
|
||||
});
|
||||
actionsDiv.appendChild(dlBtn);
|
||||
|
||||
const pdfBtn = document.createElement("button");
|
||||
pdfBtn.className = "btn-action";
|
||||
pdfBtn.title = "Télécharger en PDF";
|
||||
pdfBtn.innerHTML = '<i data-lucide="file" style="width:14px;height:14px"></i> PDF';
|
||||
pdfBtn.addEventListener("click", () => {
|
||||
window.open(`/api/file/${encodeURIComponent(vault)}/pdf?path=${encodeURIComponent(path)}`, "_blank");
|
||||
});
|
||||
actionsDiv.appendChild(pdfBtn);
|
||||
|
||||
const editBtn = document.createElement("button");
|
||||
editBtn.className = "btn-action";
|
||||
editBtn.title = "Éditer";
|
||||
@@ -779,6 +788,48 @@ const RightSidebarManager = {
|
||||
tocBtn.innerHTML = '<i data-lucide="list" style="width:14px;height:14px"></i> TOC';
|
||||
tocBtn.addEventListener("click", () => { RightSidebarManager.toggle(); });
|
||||
actionsDiv.appendChild(tocBtn);
|
||||
|
||||
// Share button
|
||||
const shareBtn = document.createElement("button");
|
||||
shareBtn.className = "btn-action";
|
||||
shareBtn.title = "Partager ce document";
|
||||
shareBtn.innerHTML = '<i data-lucide="share-2" style="width:14px;height:14px"></i> Partager';
|
||||
shareBtn.addEventListener("click", async () => {
|
||||
try {
|
||||
const res = await fetch(`/api/share/${encodeURIComponent(vault)}`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ path }),
|
||||
credentials: "include",
|
||||
});
|
||||
if (!res.ok) throw new Error("Erreur");
|
||||
const share = await res.json();
|
||||
const url = window.location.origin + share.url;
|
||||
try { await navigator.clipboard.writeText(url); } catch { /* fallback */ }
|
||||
alert("Lien copié : " + url);
|
||||
} catch (err) { alert("Erreur: " + err.message); }
|
||||
});
|
||||
actionsDiv.appendChild(shareBtn);
|
||||
|
||||
// Bookmark button
|
||||
const bookmarkBtn = document.createElement("button");
|
||||
bookmarkBtn.className = "btn-action";
|
||||
bookmarkBtn.title = "Ajouter/Retirer des bookmarks";
|
||||
bookmarkBtn.innerHTML = '<i data-lucide="bookmark-plus" style="width:14px;height:14px"></i> Bookmark';
|
||||
bookmarkBtn.addEventListener("click", async () => {
|
||||
try {
|
||||
const res = await fetch("/api/bookmarks/toggle", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ vault, path, title: data.title }),
|
||||
credentials: "include",
|
||||
});
|
||||
if (!res.ok) throw new Error("Erreur");
|
||||
const bm = await res.json();
|
||||
bookmarkBtn.classList.toggle("active", bm.bookmarked);
|
||||
} catch (err) { alert("Erreur: " + err.message); }
|
||||
});
|
||||
actionsDiv.appendChild(bookmarkBtn);
|
||||
|
||||
header.appendChild(actionsDiv);
|
||||
area.appendChild(header);
|
||||
|
||||
Reference in New Issue
Block a user