add optional prefix to url
This commit is contained in:
@@ -26,7 +26,7 @@
|
||||
<button id="upload-btn" class="btn-primary">
|
||||
<i class="fas fa-upload mr-2"></i>Upload File
|
||||
</button>
|
||||
<a href="/editor/create?folder={{.folder_path}}" class="btn-secondary">
|
||||
<a href="{{url (print "/editor/create?folder=" .folder_path)}}" class="btn-secondary">
|
||||
<i class="fas fa-plus mr-2"></i>New Note
|
||||
</a>
|
||||
</div>
|
||||
@@ -70,22 +70,22 @@
|
||||
</div>
|
||||
<div class="flex items-center space-x-2">
|
||||
{{if eq .Type "md"}}
|
||||
<a href="/editor/edit/{{.Path}}" class="text-blue-400 hover:text-blue-300 p-2" title="Edit">
|
||||
<a href="{{url (print "/editor/edit/" .Path)}}" class="text-blue-400 hover:text-blue-300 p-2" title="Edit">
|
||||
<i class="fas fa-edit"></i>
|
||||
</a>
|
||||
{{end}}
|
||||
{{if eq .Type "text"}}
|
||||
<a href="/editor/edit_text/{{.Path}}" class="text-blue-400 hover:text-blue-300 p-2" title="Edit">
|
||||
<a href="{{url (print "/editor/edit_text/" .Path)}}" class="text-blue-400 hover:text-blue-300 p-2" title="Edit">
|
||||
<i class="fas fa-edit"></i>
|
||||
</a>
|
||||
{{end}}
|
||||
{{if eq .Type "image"}}
|
||||
<a href="/serve_attached_image/{{.Path}}" target="_blank" class="text-yellow-400 hover:text-yellow-300 p-2" title="View">
|
||||
<a href="{{url (print "/serve_attached_image/" .Path)}}" target="_blank" class="text-yellow-400 hover:text-yellow-300 p-2" title="View">
|
||||
<i class="fas fa-eye"></i>
|
||||
</a>
|
||||
{{end}}
|
||||
{{if ne .Type "dir"}}
|
||||
<a href="/download/{{.Path}}" class="text-green-400 hover:text-green-300 p-2" title="Download">
|
||||
<a href="{{url (print "/download/" .Path)}}" class="text-green-400 hover:text-green-300 p-2" title="Download">
|
||||
<i class="fas fa-download"></i>
|
||||
</a>
|
||||
{{end}}
|
||||
@@ -181,7 +181,7 @@
|
||||
|
||||
const m = document.cookie.match(/(?:^|; )csrf_token=([^;]+)/);
|
||||
const csrf = m && m[1] ? decodeURIComponent(m[1]) : '';
|
||||
fetch('/editor/upload', {
|
||||
fetch(window.prefix('/editor/upload'), {
|
||||
method: 'POST',
|
||||
headers: csrf ? { 'X-CSRF-Token': csrf } : {},
|
||||
body: formData
|
||||
@@ -213,13 +213,13 @@
|
||||
const type = itemCard.dataset.type;
|
||||
|
||||
if (type === 'dir') {
|
||||
window.location.href = '/folder/' + path;
|
||||
window.location.href = window.prefix('/folder/' + path);
|
||||
} else if (type === 'md') {
|
||||
window.location.href = '/note/' + path;
|
||||
window.location.href = window.prefix('/note/' + path);
|
||||
} else if (type === 'image') {
|
||||
window.open('/serve_attached_image/' + path, '_blank');
|
||||
window.open(window.prefix('/serve_attached_image/' + path), '_blank');
|
||||
} else {
|
||||
window.location.href = '/view_text/' + path;
|
||||
window.location.href = window.prefix('/view_text/' + path);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -242,7 +242,7 @@
|
||||
if (deleteTarget) {
|
||||
const m = document.cookie.match(/(?:^|; )csrf_token=([^;]+)/);
|
||||
const csrf = m && m[1] ? decodeURIComponent(m[1]) : '';
|
||||
fetch('/editor/delete/' + deleteTarget, {
|
||||
fetch(window.prefix('/editor/delete/' + deleteTarget), {
|
||||
method: 'DELETE',
|
||||
headers: csrf ? { 'X-CSRF-Token': csrf } : {}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user