release: v0.19.0
Release v0.19.0. See the `## [0.19.0] — 2026-09-29` section of [CHANGELOG.md](https://github.com/ralksta/immich-folio/blob/dev/CHANGELOG.md) for the full list. Highlights: client proofing links (#683), custom content pages (#738), asset picker search (#740), concurrent-edit detection (#742), env-locked settings (#739), an accessibility baseline (#741), three security fixes with advisories (#737, #755, #759), and a pre-release quality pass (#780–#797). --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: ralksta <ralksta@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Claude Opus 5 <noreply@anthropic.com> Co-authored-by: Ralf <rohlenbo79@gmail.com> Co-authored-by: Paul Thies <110185070+ImScheinox@users.noreply.github.com> Co-authored-by: lancetm714 <108419425+lancetm714@users.noreply.github.com> Co-authored-by: Lance Martin <lancetaylor95@gmail.com>
This commit is contained in:
@@ -7,6 +7,8 @@ import fs from 'fs/promises';
|
||||
import nodeFs from 'fs';
|
||||
import path from 'path';
|
||||
import { atomicWrite } from '../atomicWrite';
|
||||
import { assertVersion, readVersioned, serializeContentWrite, versionOf } from './contentVersion';
|
||||
import { ParsedFileCache } from './parsedFileCache';
|
||||
import {
|
||||
parseJournalMarkdown,
|
||||
calculateReadingTime,
|
||||
@@ -184,10 +186,30 @@ export function loadEssayFromFile(filename: string): ParsedJournal | null {
|
||||
}
|
||||
}
|
||||
|
||||
/** What a listing needs from one file — everything but the name-derived fields. */
|
||||
type EntryFacts = Omit<JournalEntrySummary, 'slug' | 'filename'>;
|
||||
|
||||
/**
|
||||
* Parsed listing facts per file, reused while the file is unchanged: every
|
||||
* public page render lists the journal for the header nav (see
|
||||
* parsedFileCache.ts).
|
||||
*/
|
||||
const summaryCache = new ParsedFileCache<EntryFacts>((content) => {
|
||||
const parsed = parseJournalMarkdown(content);
|
||||
const { words, minutes } = calculateReadingTime(content);
|
||||
return {
|
||||
frontmatter: parsed.frontmatter,
|
||||
excerpt: extractExcerpt(parsed),
|
||||
wordCount: words,
|
||||
readingTimeMinutes: minutes,
|
||||
};
|
||||
});
|
||||
|
||||
/** List all journal entries */
|
||||
export async function listJournalEntries(): Promise<JournalEntrySummary[]> {
|
||||
const entries: JournalEntrySummary[] = [];
|
||||
const seenSlugs = new Set<string>();
|
||||
const listed = new Set<string>();
|
||||
|
||||
const scanDir = async (dir: string) => {
|
||||
try {
|
||||
@@ -205,19 +227,10 @@ export async function listJournalEntries(): Promise<JournalEntrySummary[]> {
|
||||
seenSlugs.add(slug);
|
||||
|
||||
try {
|
||||
const content = await fs.readFile(path.join(dir, file), 'utf8');
|
||||
const parsed = parseJournalMarkdown(content);
|
||||
const { words, minutes } = calculateReadingTime(content);
|
||||
const excerpt = extractExcerpt(parsed);
|
||||
|
||||
entries.push({
|
||||
slug,
|
||||
filename: file,
|
||||
frontmatter: parsed.frontmatter,
|
||||
excerpt,
|
||||
wordCount: words,
|
||||
readingTimeMinutes: minutes,
|
||||
});
|
||||
const filePath = path.join(dir, file);
|
||||
listed.add(filePath);
|
||||
const summary = await summaryCache.read(filePath);
|
||||
entries.push({ slug, filename: file, ...summary });
|
||||
} catch (err) {
|
||||
console.error(`[Journal] Failed to parse ${file}:`, err);
|
||||
}
|
||||
@@ -229,15 +242,19 @@ export async function listJournalEntries(): Promise<JournalEntrySummary[]> {
|
||||
|
||||
await scanDir(JOURNAL_DIR);
|
||||
await scanDir(LEGACY_ESSAYS_DIR);
|
||||
summaryCache.retain(listed);
|
||||
|
||||
// Sort: descending by date, fallback to title/slug
|
||||
return entries.sort((a, b) => {
|
||||
const dateA = a.frontmatter.date || '';
|
||||
const dateB = b.frontmatter.date || '';
|
||||
if (dateA && dateB) return dateB.localeCompare(dateA);
|
||||
if (dateA && dateB) return dateB.localeCompare(dateA) || a.slug.localeCompare(b.slug);
|
||||
if (dateA) return -1;
|
||||
if (dateB) return 1;
|
||||
return (a.frontmatter.title || a.slug).localeCompare(b.frontmatter.title || b.slug);
|
||||
return (
|
||||
(a.frontmatter.title || a.slug).localeCompare(b.frontmatter.title || b.slug) ||
|
||||
a.slug.localeCompare(b.slug)
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -246,14 +263,16 @@ export async function readJournalEntry(slug: string): Promise<{
|
||||
slug: string;
|
||||
rawMarkdown: string;
|
||||
parsed: ParsedJournal;
|
||||
/** Version of the file's bytes (#601), for the editor's If-Match. */
|
||||
version: string;
|
||||
} | null> {
|
||||
const filePath = resolveJournalFilePath(slug);
|
||||
if (!filePath) return null;
|
||||
|
||||
try {
|
||||
const rawMarkdown = await fs.readFile(filePath, 'utf8');
|
||||
const { text: rawMarkdown, version } = await readVersioned(filePath);
|
||||
const parsed = parseJournalMarkdown(rawMarkdown);
|
||||
return { slug, rawMarkdown, parsed };
|
||||
return { slug, rawMarkdown, parsed, version };
|
||||
} catch (err) {
|
||||
if ((err as NodeJS.ErrnoException).code === 'ENOENT') return null;
|
||||
throw err;
|
||||
@@ -358,3 +377,28 @@ export async function deleteJournalEntry(slug: string): Promise<boolean> {
|
||||
if (deletedAny) console.log(`[Journal] 🗑️ Deleted ${filename}`);
|
||||
return deletedAny;
|
||||
}
|
||||
|
||||
/**
|
||||
* The editor's save (#601): write `slug`, refusing with a VersionConflictError
|
||||
* when the file the editor loaded — `fromSlug`'s, for a rename — is no longer
|
||||
* at `baseVersion`. A rename writes the new file and then deletes the old one.
|
||||
* Check, write and delete run in the content write queue, so another save
|
||||
* cannot land between them. Returns the version of what was written.
|
||||
*/
|
||||
export function saveJournalEntry(
|
||||
slug: string,
|
||||
rawMarkdown: string,
|
||||
options: { baseVersion?: string; fromSlug?: string } = {},
|
||||
): Promise<string> {
|
||||
const fromSlug = options.fromSlug ?? slug;
|
||||
return serializeContentWrite(async () => {
|
||||
if (options.baseVersion !== undefined) {
|
||||
const loaded = resolveJournalFilePath(fromSlug);
|
||||
if (!loaded) throw new Error(`Invalid journal entry slug: "${fromSlug}"`);
|
||||
await assertVersion(loaded, options.baseVersion);
|
||||
}
|
||||
await writeJournalEntry(slug, rawMarkdown);
|
||||
if (fromSlug !== slug) await deleteJournalEntry(fromSlug);
|
||||
return versionOf(rawMarkdown);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user