fix view
This commit is contained in:
@@ -328,13 +328,18 @@
|
||||
<!-- Breadcrumbs -->
|
||||
{{if .breadcrumbs}}
|
||||
<div class="bg-slate-800 border-b border-gray-700 px-6 py-3">
|
||||
<nav class="flex items-center space-x-2 text-sm">
|
||||
<nav class="flex items-center flex-wrap gap-1.5 text-sm">
|
||||
{{range $i, $crumb := .breadcrumbs}}
|
||||
{{if $i}}<i class="fas fa-chevron-right text-gray-500 text-xs"></i>{{end}}
|
||||
{{if $i}}<i class="fas fa-chevron-right text-gray-500 text-xs mx-1"></i>{{end}}
|
||||
{{if $crumb.URL}}
|
||||
<a href="{{url $crumb.URL}}" class="text-blue-400 hover:text-blue-300 transition-colors">{{$crumb.Name}}</a>
|
||||
<a href="{{url $crumb.URL}}" class="inline-flex items-center px-2.5 py-1 rounded-md border border-slate-600 bg-slate-700/40 text-blue-300 hover:bg-slate-700 hover:text-blue-200 transition-colors" aria-label="Breadcrumb: {{$crumb.Name}}">
|
||||
{{if and (eq $i 0) (eq $crumb.Name "/")}}<i class="fas fa-folder-tree mr-1.5"></i>{{end}}
|
||||
<span class="leading-none">{{$crumb.Name}}</span>
|
||||
</a>
|
||||
{{else}}
|
||||
<span class="text-gray-300">{{$crumb.Name}}</span>
|
||||
<span class="inline-flex items-center px-2.5 py-1 rounded-md border border-slate-600 bg-slate-700/60 text-gray-200">
|
||||
<span class="leading-none">{{$crumb.Name}}</span>
|
||||
</span>
|
||||
{{end}}
|
||||
{{end}}
|
||||
</nav>
|
||||
|
||||
@@ -263,7 +263,12 @@ console.log('Hello, World!');
|
||||
formData.append('path', uploadPath);
|
||||
|
||||
try {
|
||||
const resp = await fetch(window.prefix('/upload'), { method: 'POST', body: formData });
|
||||
const csrf = (document.cookie.match(/(?:^|; )csrf_token=([^;]+)/)||[])[1] ? decodeURIComponent((document.cookie.match(/(?:^|; )csrf_token=([^;]+)/)||[])[1]) : '';
|
||||
const resp = await fetch(window.prefix('/editor/upload'), {
|
||||
method: 'POST',
|
||||
headers: csrf ? { 'X-CSRF-Token': csrf } : {},
|
||||
body: formData
|
||||
});
|
||||
const data = await resp.json();
|
||||
if (!resp.ok || !data.success) throw new Error(data.error || 'Upload failed');
|
||||
|
||||
|
||||
@@ -300,7 +300,12 @@
|
||||
formData.append('path', uploadPath);
|
||||
|
||||
try {
|
||||
const resp = await fetch(window.prefix('/upload'), { method: 'POST', body: formData });
|
||||
const csrf = (document.cookie.match(/(?:^|; )csrf_token=([^;]+)/)||[])[1] ? decodeURIComponent((document.cookie.match(/(?:^|; )csrf_token=([^;]+)/)||[])[1]) : '';
|
||||
const resp = await fetch(window.prefix('/editor/upload'), {
|
||||
method: 'POST',
|
||||
headers: csrf ? { 'X-CSRF-Token': csrf } : {},
|
||||
body: formData
|
||||
});
|
||||
const data = await resp.json();
|
||||
if (!resp.ok || !data.success) throw new Error(data.error || 'Upload failed');
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
{{end}}
|
||||
</p>
|
||||
</div>
|
||||
{{if .Authenticated}}
|
||||
<div class="flex items-center space-x-3">
|
||||
<button id="upload-btn" class="btn-primary">
|
||||
<i class="fas fa-upload mr-2"></i>Upload File
|
||||
@@ -30,6 +31,7 @@
|
||||
<i class="fas fa-plus mr-2"></i>New Note
|
||||
</a>
|
||||
</div>
|
||||
{{end}}
|
||||
</div>
|
||||
|
||||
<!-- Upload Area (hidden by default) -->
|
||||
@@ -69,15 +71,17 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-center space-x-2">
|
||||
{{if eq .Type "md"}}
|
||||
<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="{{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>
|
||||
{{if $.Authenticated}}
|
||||
{{if eq .Type "md"}}
|
||||
<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="{{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}}
|
||||
{{end}}
|
||||
{{if eq .Type "image"}}
|
||||
<a href="{{url (print "/serve_attached_image/" .Path)}}" target="_blank" class="text-yellow-400 hover:text-yellow-300 p-2" title="View">
|
||||
@@ -89,9 +93,11 @@
|
||||
<i class="fas fa-download"></i>
|
||||
</a>
|
||||
{{end}}
|
||||
<button class="text-red-400 hover:text-red-300 p-2 delete-btn" data-path="{{.Path}}" title="Delete">
|
||||
<i class="fas fa-trash"></i>
|
||||
</button>
|
||||
{{if $.Authenticated}}
|
||||
<button class="text-red-400 hover:text-red-300 p-2 delete-btn" data-path="{{.Path}}" title="Delete">
|
||||
<i class="fas fa-trash"></i>
|
||||
</button>
|
||||
{{end}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -132,39 +138,47 @@
|
||||
let deleteTarget = null;
|
||||
|
||||
// Toggle upload area
|
||||
uploadBtn.addEventListener('click', function() {
|
||||
uploadArea.classList.toggle('hidden');
|
||||
});
|
||||
if (uploadBtn) {
|
||||
uploadBtn.addEventListener('click', function() {
|
||||
uploadArea && uploadArea.classList.toggle('hidden');
|
||||
});
|
||||
}
|
||||
|
||||
// File selection
|
||||
selectFilesBtn.addEventListener('click', function() {
|
||||
fileInput.click();
|
||||
});
|
||||
if (selectFilesBtn && fileInput) {
|
||||
selectFilesBtn.addEventListener('click', function() {
|
||||
fileInput.click();
|
||||
});
|
||||
}
|
||||
|
||||
fileInput.addEventListener('change', function() {
|
||||
if (this.files.length > 0) {
|
||||
uploadFiles(this.files);
|
||||
}
|
||||
});
|
||||
if (fileInput) {
|
||||
fileInput.addEventListener('change', function() {
|
||||
if (this.files.length > 0) {
|
||||
uploadFiles(this.files);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Drag and drop
|
||||
uploadArea.addEventListener('dragover', function(e) {
|
||||
e.preventDefault();
|
||||
this.classList.add('dragover');
|
||||
});
|
||||
if (uploadArea) {
|
||||
uploadArea.addEventListener('dragover', function(e) {
|
||||
e.preventDefault();
|
||||
this.classList.add('dragover');
|
||||
});
|
||||
|
||||
uploadArea.addEventListener('dragleave', function(e) {
|
||||
e.preventDefault();
|
||||
this.classList.remove('dragover');
|
||||
});
|
||||
uploadArea.addEventListener('dragleave', function(e) {
|
||||
e.preventDefault();
|
||||
this.classList.remove('dragover');
|
||||
});
|
||||
|
||||
uploadArea.addEventListener('drop', function(e) {
|
||||
e.preventDefault();
|
||||
this.classList.remove('dragover');
|
||||
if (e.dataTransfer.files.length > 0) {
|
||||
uploadFiles(e.dataTransfer.files);
|
||||
}
|
||||
});
|
||||
uploadArea.addEventListener('drop', function(e) {
|
||||
e.preventDefault();
|
||||
this.classList.remove('dragover');
|
||||
if (e.dataTransfer.files.length > 0) {
|
||||
uploadFiles(e.dataTransfer.files);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Upload files function
|
||||
function uploadFiles(files) {
|
||||
|
||||
@@ -10,6 +10,9 @@
|
||||
{{end}}
|
||||
<form method="POST" action="{{url "/editor/login"}}" class="space-y-4">
|
||||
<input type="hidden" name="csrf_token" value="{{.csrf_token}}" />
|
||||
{{if .return_to}}
|
||||
<input type="hidden" name="return_to" value="{{.return_to}}" />
|
||||
{{end}}
|
||||
<div>
|
||||
<label class="block text-sm text-gray-300 mb-1" for="username">Username or Email</label>
|
||||
<input id="username" name="username" type="text" required class="w-full bg-gray-700 border border-gray-600 rounded px-3 py-2 text-white" />
|
||||
|
||||
Reference in New Issue
Block a user