add optional prefix to url
This commit is contained in:
@@ -10,11 +10,11 @@
|
||||
<h1 class="text-3xl font-bold text-white">{{.file_name}}</h1>
|
||||
<div class="flex items-center space-x-3">
|
||||
{{if and .Authenticated .is_editable}}
|
||||
<a href="/edit_text/{{.file_path}}" class="btn-primary">
|
||||
<a href="{{url (print "/editor/edit_text/" .file_path)}}" class="btn-primary">
|
||||
<i class="fas fa-edit mr-2"></i>Edit
|
||||
</a>
|
||||
{{end}}
|
||||
<a href="/download/{{.file_path}}" class="btn-secondary">
|
||||
<a href="{{url (print "/download/" .file_path)}}" class="btn-secondary">
|
||||
<i class="fas fa-download mr-2"></i>Download
|
||||
</a>
|
||||
{{if .Authenticated}}
|
||||
@@ -28,7 +28,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 (print "/folder/" .folder_path)}}" class="text-blue-400 hover:text-blue-300">{{.folder_path}}</a>
|
||||
</p>
|
||||
{{end}}
|
||||
</div>
|
||||
@@ -72,8 +72,11 @@
|
||||
|
||||
document.getElementById('confirm-delete').addEventListener('click', function() {
|
||||
if (deleteTarget) {
|
||||
fetch('/delete/' + deleteTarget, {
|
||||
method: 'DELETE'
|
||||
const m = document.cookie.match(/(?:^|; )csrf_token=([^;]+)/);
|
||||
const csrf = m && m[1] ? decodeURIComponent(m[1]) : '';
|
||||
fetch(window.prefix('/editor/delete/' + deleteTarget), {
|
||||
method: 'DELETE',
|
||||
headers: csrf ? { 'X-CSRF-Token': csrf } : {}
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
@@ -82,9 +85,9 @@
|
||||
// Redirect to folder or root
|
||||
const folderPath = '{{.folder_path}}';
|
||||
if (folderPath) {
|
||||
window.location.href = '/folder/' + folderPath;
|
||||
window.location.href = window.prefix('/folder/' + folderPath);
|
||||
} else {
|
||||
window.location.href = '/';
|
||||
window.location.href = window.prefix('/');
|
||||
}
|
||||
} else {
|
||||
throw new Error(data.error || 'Delete failed');
|
||||
|
||||
Reference in New Issue
Block a user