Added .sv_* files that are files for directories. So you can now edit

directories as files.
This commit is contained in:
sarah committed 2026-09-21 17:19:16 +02:00
1 parent 70a390f7cf
commit 6083e00504
9 files changed
+176 -18

No files matched your search

+5
View File
@@ -194,6 +194,11 @@ export function DeleteEntry(RootName, RelativePath) {
return FetchJson(`/tree?${Params}`, { method: "DELETE" });
}
export function EnsureDirectoryNote(RootName, RelativePath) {
const Params = new URLSearchParams({ Root: RootName, Path: RelativePath });
return FetchJson(`/note?${Params}`, { method: "POST" });
}
// --- Settings / themes -------------------------------------------------
export function FetchSettings() {
+49 -7
View File
@@ -7,7 +7,14 @@ import DirectoryPane from "./Components/DirectoryPane.jsx";
import TagPanel from "./Components/TagPanel.jsx";
import SettingsPanel from "./Components/SettingsPanel.jsx";
import LoginScreen from "./Components/LoginScreen.jsx";
import { FetchAuthStatus, FetchMe, FetchRoots, FetchSettings, FetchTheme } from "./Api.js";
import {
EnsureDirectoryNote,
FetchAuthStatus,
FetchMe,
FetchRoots,
FetchSettings,
FetchTheme,
} from "./Api.js";
import { PaletteRoles } from "./ThemeRoles.js";
function ApplyTheme(Palette) {
@@ -41,6 +48,7 @@ export default function App() {
const [ViewPath, SetViewPath] = useState("");
const [ViewIsDirectory, SetViewIsDirectory] = useState(true);
const [ViewFileType, SetViewFileType] = useState(null);
const [ViewNoteFilePath, SetViewNoteFilePath] = useState(null);
const [CurrentDirectoryPath, SetCurrentDirectoryPath] = useState("");
const [SidebarKey, SetSidebarKey] = useState(0);
const [Settings, SetSettings] = useState(null);
@@ -104,6 +112,7 @@ export default function App() {
SetViewPath(FilePath);
SetViewIsDirectory(false);
SetViewFileType(FileType);
SetViewNoteFilePath(null);
SetCurrentDirectoryPath(GetParentPath(FilePath));
}
@@ -111,6 +120,7 @@ export default function App() {
SetViewPath(DirectoryPath);
SetViewIsDirectory(true);
SetViewFileType(null);
SetViewNoteFilePath(null);
SetCurrentDirectoryPath(DirectoryPath);
}
@@ -118,9 +128,34 @@ export default function App() {
SetCurrentDirectoryPath(DirectoryPath);
}
function HandleEntrySelect(EntryPath, IsDirectory, FileType) {
// A directory is opened the same way a file is - via its own note file -
// rather than by drilling into its listing. Browsing a directory's
// contents happens separately, through the sidebar tree.
function HandleSelectDirectoryNote(DirectoryPath, NoteName, NoteFileType) {
SetViewPath(DirectoryPath);
SetViewIsDirectory(false);
SetViewFileType(NoteFileType);
SetViewNoteFilePath(`${DirectoryPath}/${NoteName}`);
SetCurrentDirectoryPath(DirectoryPath);
}
async function OpenDirectoryNote(DirectoryPath, Note) {
if (Note) {
HandleSelectDirectoryNote(DirectoryPath, Note.Name, Note.FileType);
return;
}
try {
const Created = await EnsureDirectoryNote(ActiveRoot, DirectoryPath);
HandleSelectDirectoryNote(DirectoryPath, Created.Name, Created.FileType);
} catch (Error) {
window.alert(Error.message);
}
}
function HandleEntrySelect(EntryPath, IsDirectory, FileType, Note) {
if (IsDirectory) {
HandleNavigateDirectory(EntryPath);
OpenDirectoryNote(EntryPath, Note);
} else {
HandleSelectFile(EntryPath, FileType);
}
@@ -133,7 +168,11 @@ export default function App() {
function HandleEntryRenamed(OldPath, NewPath, IsDirectory) {
RefreshSidebar();
if (!ViewIsDirectory && ViewPath === OldPath) {
if (ViewNoteFilePath && ViewPath === OldPath) {
// Viewing this directory's own note - the server already renamed the
// note file to match, so just re-resolve it under the new path.
OpenDirectoryNote(NewPath, null);
} else if (!ViewIsDirectory && ViewPath === OldPath) {
HandleSelectFile(NewPath, ViewFileType);
} else if (ViewIsDirectory && ViewPath === OldPath) {
HandleNavigateDirectory(NewPath);
@@ -178,6 +217,7 @@ export default function App() {
CurrentDirectoryPath={CurrentDirectoryPath}
CurrentUser={CurrentUser}
OnSelectFile={HandleSelectFile}
OnSelectDirectory={OpenDirectoryNote}
OnNavigateDirectory={HandleNavigateDirectory}
OnBrowseDirectory={HandleBrowseDirectory}
OnEntryRenamed={HandleEntryRenamed}
@@ -197,7 +237,7 @@ export default function App() {
<Breadcrumb
RootName={ActiveRoot}
FilePath={ViewPath}
IsDirectory={ViewIsDirectory}
IsDirectory={ViewIsDirectory || Boolean(ViewNoteFilePath)}
OnNavigate={HandleNavigateDirectory}
/>
) : (
@@ -234,7 +274,7 @@ export default function App() {
) : (
<PreviewPane
RootName={ActiveRoot}
FilePath={ViewPath}
FilePath={ViewNoteFilePath || ViewPath}
FileType={ViewFileType}
OnNavigateLink={HandleSelectFile}
ShowGitBlame={Settings ? Settings.ShowGitBlame : false}
@@ -242,7 +282,9 @@ export default function App() {
StickyToolbar={Settings ? Settings.StickyToolbar : true}
/>
)}
{!ViewIsDirectory && <TagPanel RootName={ActiveRoot} FilePath={ViewPath} />}
{!ViewIsDirectory && !ViewNoteFilePath && (
<TagPanel RootName={ActiveRoot} FilePath={ViewPath} />
)}
</div>
</div>
{IsSettingsOpen && (
+3 -1
View File
@@ -149,7 +149,9 @@ export default function DirectoryPane({
<div
className="DirectoryEntry"
key={Entry.Name}
onClick={() => OnEntrySelect(JoinPath(Entry.Name), Entry.IsDirectory, Entry.FileType)}
onClick={() =>
OnEntrySelect(JoinPath(Entry.Name), Entry.IsDirectory, Entry.FileType, Entry.Note)
}
>
<span className="TreeIcon">
{Entry.IsDirectory
@@ -323,6 +323,11 @@ export default function SettingsPanel({
<Switch Checked={Settings.ShowHiddenFolders} OnChange={(Event) => UpdateField("ShowHiddenFolders", Event.target.checked)} />
</div>
<div className="SettingsRowInline">
<label className="SettingsLabel">Show directory note files (.sv_*)</label>
<Switch Checked={Settings.ShowSvFiles} OnChange={(Event) => UpdateField("ShowSvFiles", Event.target.checked)} />
</div>
<div className="SettingsRowInline">
<label className="SettingsLabel">Show breadcrumbs</label>
<Switch Checked={Settings.ShowBreadcrumbs} OnChange={(Event) => UpdateField("ShowBreadcrumbs", Event.target.checked)} />
+5 -1
View File
@@ -20,6 +20,7 @@ function TreeNode({
SelectedFile,
CurrentDirectoryPath,
OnSelectFile,
OnSelectDirectory,
OnNavigateDirectory,
OnBrowseDirectory,
OnEntryRenamed,
@@ -65,7 +66,7 @@ function TreeNode({
OnBrowseDirectory(FullPath);
if (NavigateIntoDirectories) {
OnNavigateDirectory(FullPath);
OnSelectDirectory(FullPath, Entry.Note);
}
}
@@ -156,6 +157,7 @@ function TreeNode({
SelectedFile={SelectedFile}
CurrentDirectoryPath={CurrentDirectoryPath}
OnSelectFile={OnSelectFile}
OnSelectDirectory={OnSelectDirectory}
OnNavigateDirectory={OnNavigateDirectory}
OnBrowseDirectory={OnBrowseDirectory}
OnEntryRenamed={OnEntryRenamed}
@@ -213,6 +215,7 @@ export default function Sidebar({
CurrentDirectoryPath,
CurrentUser,
OnSelectFile,
OnSelectDirectory,
OnNavigateDirectory,
OnBrowseDirectory,
OnEntryRenamed,
@@ -319,6 +322,7 @@ export default function Sidebar({
SelectedFile={SelectedFile}
CurrentDirectoryPath={CurrentDirectoryPath}
OnSelectFile={OnSelectFile}
OnSelectDirectory={OnSelectDirectory}
OnNavigateDirectory={OnNavigateDirectory}
OnBrowseDirectory={OnBrowseDirectory}
OnEntryRenamed={OnEntryRenamed}