add optional prefix to url

This commit is contained in:
nahakubuilde
2025-08-26 20:55:08 +01:00
parent 6fb6054803
commit e8658f5aab
25 changed files with 196 additions and 127 deletions

View File

@@ -21,7 +21,7 @@
{{if .folder_path}}
<p class="text-gray-400">
<i class="fas fa-folder mr-2"></i>
<a href="/folder/{{.folder_path}}" class="text-blue-400 hover:text-blue-300">{{.folder_path}}</a>
<a href="{{url "/folder/"}}{{.folder_path}}" class="text-blue-400 hover:text-blue-300">{{.folder_path}}</a>
</p>
{{end}}
</div>
@@ -104,7 +104,7 @@
function buildImageURL(filename) {
// Map Obsidian embed to server URL
if (imageStorageMode === 2) {
return `/serve_stored_image/${filename}`;
return window.prefix(`/serve_stored_image/${filename}`);
}
let path = filename;
if (imageStorageMode === 3 && currentFolderPath) {
@@ -112,7 +112,7 @@
} else if (imageStorageMode === 4 && currentFolderPath) {
path = `${currentFolderPath}/${imageSubfolderName}/${filename}`;
}
return `/serve_attached_image/${path}`;
return window.prefix(`/serve_attached_image/${path}`);
}
function transformObsidianEmbeds(md) {
@@ -161,7 +161,7 @@
// CSRF token from cookie
const csrf = (document.cookie.match(/(?:^|; )csrf_token=([^;]+)/)||[])[1] ? decodeURIComponent((document.cookie.match(/(?:^|; )csrf_token=([^;]+)/)||[])[1]) : '';
fetch('/editor/edit/' + notePath, {
fetch(window.prefix('/editor/edit/' + notePath), {
method: 'POST',
headers: csrf ? { 'X-CSRF-Token': csrf } : {},
body: formData
@@ -300,7 +300,7 @@
formData.append('path', uploadPath);
try {
const resp = await fetch('/upload', { method: 'POST', body: formData });
const resp = await fetch(window.prefix('/upload'), { method: 'POST', body: formData });
const data = await resp.json();
if (!resp.ok || !data.success) throw new Error(data.error || 'Upload failed');