diff --git a/package.json b/package.json index a47c543..158e4e3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "folio", - "version": "0.1.8", + "version": "0.1.7", "description": "A simple, local, open-source desktop writing app.", "productName": "Folio", "author": "Folio Contributors", diff --git a/src/main/index.ts b/src/main/index.ts index 24cd5fa..4bf7926 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -246,30 +246,13 @@ async function openBookAt(p: string): Promise { } } -// Create a new book as a dedicated folder / inside the user's chosen -// storage folder (Settings → Folder), falling back to Documents when none is -// set or the stored one no longer exists, then open it. The folder name is -// the sanitized book title; if a folder with that name already exists we -// append a numeric suffix. -function getBooksDir(): string { - // One storage folder drives everything (snapshots, recovery, new books). - // snapshotLocation is the one the Settings modal writes; backupLocation is - // the older key — honor both so an existing choice keeps working. - for (const key of ["snapshotLocation", "backupLocation"]) { - const v = String(getSetting(key, "") || "").trim(); - try { - if (v && fs.statSync(v).isDirectory()) return v; - } catch { - // stale or unreadable path — fall through to the next candidate - } - } - return app.getPath("documents"); -} - +// Create a new book as a dedicated folder / inside the user's Documents +// directory, then open it. The folder name is the sanitized book title; if a +// folder with that name already exists we append a numeric suffix. handleIpc("folio:newBookNamed", async (_e, name: string) => { const title = (name || "").trim(); if (!title) return { error: "Please provide a book name." }; - const base = getBooksDir(); + const base = app.getPath("documents"); const folder = sanitizeBookFolderName(title) || "Untitled"; let target = path.join(base, folder); let n = 2; @@ -608,7 +591,7 @@ function exportDefaultPath(filename: string): string { const dir = last && fs.existsSync(last) && fs.statSync(last).isDirectory() ? last - : getBooksDir(); + : app.getPath("documents"); return path.join(dir, filename); } @@ -989,7 +972,6 @@ function snapshotSettingsSnapshot() { keep: clampInt(getSetting("snapshotKeep", SNAPSHOT_DEFAULTS.keep), SNAPSHOT_DEFAULTS.keep, 0, 200), location, resolvedRoot: resolved, - booksDir: getBooksDir(), snapshotCount: snaps.length, lastSnapshot: snaps.length ? snaps[snaps.length - 1] : null, }; @@ -1026,7 +1008,7 @@ handleIpc("folio:setSnapshotSettings", (_e, patch: unknown) => { handleIpc("folio:pickSnapshotFolder", async () => { const { canceled, filePaths } = await showOpenDialog({ properties: ["openDirectory"], - title: "Choose storage folder (new books + snapshots)", + title: "Choose snapshot folder", }); return { canceled, filePaths }; }); @@ -1107,14 +1089,14 @@ handleIpc("folio:importMarkdown", async () => { filters: [{ name: "Markdown and text", extensions: ["md", "markdown", "txt"] }], }); if (canceled || !filePaths.length) return { canceled: true } as const; - return importMarkdownFiles(filePaths, getBooksDir()); + return importMarkdownFiles(filePaths, app.getPath("documents")); }); // Open a path that may be either a Folio book directory or a Markdown file // (the desktop launcher can be handed either via file associations). handleIpc("folio:openPathOrImport", async (_e, p: string) => { if (p && isImportableMarkdown(p)) { - const results = importMarkdownFiles([p], getBooksDir()); + const results = importMarkdownFiles([p], app.getPath("documents")); const r = results[0]; if (!r.ok) return { error: r.error }; return openBookAt(r.bookPath as string); @@ -1318,7 +1300,7 @@ function fileArgFrom(argv: string[]): string | null { function openFromArg(p: string): void { if (isImportableMarkdown(p)) { - const results = importMarkdownFiles([p], getBooksDir()); + const results = importMarkdownFiles([p], app.getPath("documents")); const r = results[0]; if (r.ok) { openBookAt(r.bookPath as string); diff --git a/src/renderer/book/settings.ts b/src/renderer/book/settings.ts index 9cb3949..c9adad1 100644 --- a/src/renderer/book/settings.ts +++ b/src/renderer/book/settings.ts @@ -23,8 +23,6 @@ interface SnapshotSettings { keep: number; location: string; resolvedRoot: string; - /** Where new books are saved (Settings → Storage folder). */ - booksDir?: string; snapshotCount: number; lastSnapshot: string | null; } @@ -61,10 +59,8 @@ export function createSettingsFeature(ctx: BookCtx): SettingsFeature { intervalInput.value = String(s.intervalMin ?? 5); keepInput.value = String(s.keep ?? 20); locationInput.value = s.location || ""; - locationInput.placeholder = "Default: Documents (books) · /Folio-Backups (snapshots)"; - resolvedEl.textContent = s.booksDir - ? `New books save to: ${shortPath(s.booksDir)}` - : `Saving to: ${shortPath(s.resolvedRoot || "—")}`; + locationInput.placeholder = "Default: /Folio-Backups"; + resolvedEl.textContent = `Saving to: ${shortPath(s.resolvedRoot || "—")}`; lastSnapEl.textContent = s.lastSnapshot ? `${s.snapshotCount} snapshot${s.snapshotCount === 1 ? "" : "s"} · latest ${s.lastSnapshot.split("/").pop()}` : "No snapshots yet."; diff --git a/src/renderer/index.html b/src/renderer/index.html index 8bb16c8..d41d81b 100644 --- a/src/renderer/index.html +++ b/src/renderer/index.html @@ -343,9 +343,9 @@
- Storage folder - - + Folder + +