added last edited indicator
This commit is contained in:
parent
ac8946c945
commit
74903b64ba
|
|
@ -7,7 +7,7 @@ import re
|
|||
import shutil
|
||||
from pathlib import Path
|
||||
from typing import List, Dict, Optional, Tuple
|
||||
from datetime import datetime
|
||||
from datetime import datetime, timezone
|
||||
|
||||
|
||||
# In-memory cache for parsed tags
|
||||
|
|
@ -201,7 +201,7 @@ def get_all_notes(notes_dir: str) -> List[Dict]:
|
|||
"name": md_file.stem,
|
||||
"path": str(relative_path.as_posix()),
|
||||
"folder": str(relative_path.parent.as_posix()) if str(relative_path.parent) != "." else "",
|
||||
"modified": datetime.fromtimestamp(stat.st_mtime).isoformat(),
|
||||
"modified": datetime.fromtimestamp(stat.st_mtime, tz=timezone.utc).isoformat(),
|
||||
"size": stat.st_size,
|
||||
"type": "note",
|
||||
"tags": tags
|
||||
|
|
@ -354,8 +354,8 @@ def create_note_metadata(notes_dir: str, note_path: str) -> Dict:
|
|||
line_count = sum(1 for _ in f)
|
||||
|
||||
return {
|
||||
"created": datetime.fromtimestamp(stat.st_ctime).isoformat(),
|
||||
"modified": datetime.fromtimestamp(stat.st_mtime).isoformat(),
|
||||
"created": datetime.fromtimestamp(stat.st_ctime, tz=timezone.utc).isoformat(),
|
||||
"modified": datetime.fromtimestamp(stat.st_mtime, tz=timezone.utc).isoformat(),
|
||||
"size": stat.st_size,
|
||||
"lines": line_count
|
||||
}
|
||||
|
|
@ -477,7 +477,7 @@ def get_all_images(notes_dir: str) -> List[Dict]:
|
|||
"name": image_file.name,
|
||||
"path": str(relative_path.as_posix()),
|
||||
"folder": str(relative_path.parent.as_posix()),
|
||||
"modified": datetime.fromtimestamp(stat.st_mtime).isoformat(),
|
||||
"modified": datetime.fromtimestamp(stat.st_mtime, tz=timezone.utc).isoformat(),
|
||||
"size": stat.st_size,
|
||||
"type": "image"
|
||||
})
|
||||
|
|
@ -667,7 +667,7 @@ def get_notes_by_tag(notes_dir: str, tag: str) -> List[Dict]:
|
|||
"name": md_file.stem,
|
||||
"path": str(relative_path.as_posix()),
|
||||
"folder": str(relative_path.parent.as_posix()) if str(relative_path.parent) != "." else "",
|
||||
"modified": datetime.fromtimestamp(stat.st_mtime).isoformat(),
|
||||
"modified": datetime.fromtimestamp(stat.st_mtime, tz=timezone.utc).isoformat(),
|
||||
"size": stat.st_size,
|
||||
"tags": tags
|
||||
})
|
||||
|
|
@ -712,7 +712,7 @@ def get_templates(notes_dir: str) -> List[Dict]:
|
|||
templates.append({
|
||||
"name": template_file.stem,
|
||||
"path": str(template_file.relative_to(notes_dir).as_posix()),
|
||||
"modified": datetime.fromtimestamp(stat.st_mtime).isoformat()
|
||||
"modified": datetime.fromtimestamp(stat.st_mtime, tz=timezone.utc).isoformat()
|
||||
})
|
||||
except Exception as e:
|
||||
print(f"Error reading template {template_file}: {e}")
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@
|
|||
- **Shareable links** - Bookmark or share direct links to notes with highlighted terms
|
||||
- **Refresh safe** - Page reload keeps you on the same note with search context
|
||||
- **Copy link button** - One-click copy of note URL to clipboard
|
||||
- **Last edited indicator** - Shows relative time since last edit (e.g., "Edited 2h ago")
|
||||
|
||||
## 🎨 Customization
|
||||
|
||||
|
|
|
|||
|
|
@ -940,6 +940,29 @@ function noteApp() {
|
|||
return note && note.tags ? note.tags : [];
|
||||
},
|
||||
|
||||
// Get current note's last modified time as relative string
|
||||
get lastEditedText() {
|
||||
if (!this.currentNote) return '';
|
||||
const note = this.notes.find(n => n.path === this.currentNote);
|
||||
if (!note || !note.modified) return '';
|
||||
|
||||
const modified = new Date(note.modified);
|
||||
const now = new Date();
|
||||
const diffMs = now - modified;
|
||||
const diffSecs = Math.floor(diffMs / 1000);
|
||||
const diffMins = Math.floor(diffSecs / 60);
|
||||
const diffHours = Math.floor(diffMins / 60);
|
||||
const diffDays = Math.floor(diffHours / 24);
|
||||
|
||||
if (diffSecs < 60) return 'just now';
|
||||
if (diffMins < 60) return `${diffMins}m ago`;
|
||||
if (diffHours < 24) return `${diffHours}h ago`;
|
||||
if (diffDays < 7) return `${diffDays}d ago`;
|
||||
|
||||
// For older dates, show the date
|
||||
return modified.toLocaleDateString(undefined, { month: 'short', day: 'numeric' });
|
||||
},
|
||||
|
||||
// Parse tags from markdown content (matches backend logic)
|
||||
parseTagsFromContent(content) {
|
||||
if (!content || !content.trim().startsWith('---')) {
|
||||
|
|
|
|||
|
|
@ -1889,6 +1889,7 @@
|
|||
</button>
|
||||
<span x-show="isSaving" class="text-xs" style="color: var(--text-secondary);">Saving...</span>
|
||||
<span x-show="!isSaving && lastSaved" class="text-xs" style="color: var(--success);">✓ Saved</span>
|
||||
<span x-show="!isSaving && !lastSaved && lastEditedText" class="text-xs hidden md:inline" style="color: var(--text-tertiary);" x-text="'Edited ' + lastEditedText"></span>
|
||||
</div>
|
||||
|
||||
<!-- Demo Mode Warning Banner -->
|
||||
|
|
|
|||
Loading…
Reference in New Issue