ops design and app
add more comments feature, more tags feature, and other frontend updates
This commit is contained in:
@@ -144,7 +144,7 @@
|
||||
|
||||
const html = document.documentElement.outerHTML;
|
||||
const title = document.title;
|
||||
const pagePath = window.MDHubCache.normalizePath(window.location.pathname);
|
||||
const pagePath = window.MDHubCache.normalizePath(window.location.pathname + window.location.search);
|
||||
window.MDHubCache.cachePage(pagePath, html, title).catch(function () {});
|
||||
}
|
||||
|
||||
@@ -373,4 +373,72 @@
|
||||
}).catch(function () {});
|
||||
}
|
||||
});
|
||||
|
||||
// Add folder button handlers
|
||||
if (browser) {
|
||||
browser.querySelectorAll(".miller-column-add-folder").forEach(function (button) {
|
||||
button.addEventListener("click", function (event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
var parentPath = button.getAttribute("data-folder-path");
|
||||
var folderName = window.prompt("Folder name:");
|
||||
if (!folderName || !folderName.trim()) return;
|
||||
folderName = folderName.trim().replace(/[\\/]/g, "-");
|
||||
var docPath = parentPath ? parentPath + "/" + folderName + "/index.md" : folderName + "/index.md";
|
||||
var displayPath = docPath.replace(/\.md$/, "");
|
||||
fetch("/api/documents/" + encodeURIComponent(displayPath).replace(/%2F/g, "/"), {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ content: "# " + folderName + "\n\n", baseHash: "" }),
|
||||
}).then(function (res) {
|
||||
if (res.ok) {
|
||||
return res.json().then(function (data) {
|
||||
var path = data.path || docPath;
|
||||
var urlPath = path.replace(/\.md$/, "");
|
||||
window.location.href = "/docs/" + encodeURIComponent(urlPath).replace(/%2F/g, "/");
|
||||
});
|
||||
} else {
|
||||
return res.json().then(function (data) {
|
||||
throw new Error(data.error || "Failed to create folder");
|
||||
});
|
||||
}
|
||||
}).catch(function (err) {
|
||||
window.alert(err.message);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
browser.querySelectorAll(".miller-column-new-file").forEach(function (button) {
|
||||
button.addEventListener("click", function (event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
var parentPath = button.getAttribute("data-folder-path");
|
||||
var fileName = window.prompt("File name:");
|
||||
if (!fileName || !fileName.trim()) return;
|
||||
fileName = fileName.trim().replace(/[\\/]/g, "-");
|
||||
if (!fileName.endsWith(".md")) fileName += ".md";
|
||||
var docPath = parentPath ? parentPath + "/" + fileName : fileName;
|
||||
var displayPath = docPath.replace(/\.md$/, "");
|
||||
fetch("/api/documents/" + encodeURIComponent(displayPath).replace(/%2F/g, "/"), {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ content: "# " + fileName.replace(/\.md$/, "") + "\n\n", baseHash: "" }),
|
||||
}).then(function (res) {
|
||||
if (res.ok) {
|
||||
return res.json().then(function (data) {
|
||||
var path = data.path || docPath;
|
||||
var urlPath = path.replace(/\.md$/, "");
|
||||
window.location.href = "/docs/" + encodeURIComponent(urlPath).replace(/%2F/g, "/");
|
||||
});
|
||||
} else {
|
||||
return res.json().then(function (data) {
|
||||
throw new Error(data.error || "Failed to create file");
|
||||
});
|
||||
}
|
||||
}).catch(function (err) {
|
||||
window.alert(err.message);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user