From e35ad61b2d5dd5a608e2719ff9e7a80dc2b145a4 Mon Sep 17 00:00:00 2001 From: team3 Date: Wed, 20 May 2026 21:37:48 +0200 Subject: [PATCH] update --- src/const.ts | 6 +++--- src/fs.ts | 19 +++++++++++-------- src/views/ProjectDetailsView.ts | 10 +++++----- src/views/ProjectView.ts | 7 ++++--- styles.css | 12 ++++++++++++ 5 files changed, 35 insertions(+), 19 deletions(-) diff --git a/src/const.ts b/src/const.ts index 320a92d..98fb6e1 100644 --- a/src/const.ts +++ b/src/const.ts @@ -1,4 +1,4 @@ -export const PROJECTS_ROOT = "projects"; +export const PROJECTS_ROOT = ""; export const TO_UPDATE_DIR = "_to-update"; export const IDEAS_DIR = "_ideas"; @@ -9,6 +9,6 @@ export const VIEW_TYPE_COLLECTION_VIEW = "projektkontext-details"; export const RIBBON_ICON = "layout-grid"; export const CORE_FILE = "_core.md"; -export const TARGET_FILE = "_target.md"; +export const DESCRIPTION_FILE = "_description.md"; -export const PROJECT_FILES = [CORE_FILE, TARGET_FILE] as const; +export const PROJECT_FILES = [CORE_FILE, DESCRIPTION_FILE] as const; diff --git a/src/fs.ts b/src/fs.ts index bc4c461..d8afdfd 100644 --- a/src/fs.ts +++ b/src/fs.ts @@ -40,6 +40,7 @@ export function featurePath( } export async function ensureFolder(app: App, path: string): Promise { + if (!path) return; const p = normalizePath(path); const exists = app.vault.getAbstractFileByPath(p); if (!exists) { @@ -55,8 +56,7 @@ export async function ensureFile(app: App, path: string, content = ""): Promise< } export function listFolders(app: App, path: string): TFolder[] { - const p = normalizePath(path); - const folder = app.vault.getAbstractFileByPath(p); + const folder = path ? app.vault.getAbstractFileByPath(normalizePath(path)) : app.vault.getRoot(); if (!(folder instanceof TFolder)) return []; return folder.children .filter((c): c is TFolder => c instanceof TFolder) @@ -65,8 +65,7 @@ export function listFolders(app: App, path: string): TFolder[] { } export function listMarkdownFiles(app: App, path: string, exclude: string[] = []): TFile[] { - const p = normalizePath(path); - const folder = app.vault.getAbstractFileByPath(p); + const folder = path ? app.vault.getAbstractFileByPath(normalizePath(path)) : app.vault.getRoot(); if (!(folder instanceof TFolder)) return []; return folder.children .filter((c): c is TFile => c instanceof TFile && c.extension === "md") @@ -153,10 +152,14 @@ export interface ProjectFileLocation { export function parseProjectFilePath(path: string): ProjectFileLocation | null { if (!path.endsWith(".md")) return null; const parts = normalizePath(path).split("/"); - if (parts[0] !== PROJECTS_ROOT) return null; - if (parts.length < 3) return null; - const project = parts[1]; - const rest = parts.slice(2); + let idx = 0; + if (PROJECTS_ROOT) { + if (parts[0] !== PROJECTS_ROOT) return null; + idx = 1; + } + if (parts.length < idx + 2) return null; + const project = parts[idx]; + const rest = parts.slice(idx + 1); let zone: Zone = "ready"; if (rest[0] === TO_UPDATE_DIR) { zone = "to-update"; diff --git a/src/views/ProjectDetailsView.ts b/src/views/ProjectDetailsView.ts index 66d3e68..1fce163 100644 --- a/src/views/ProjectDetailsView.ts +++ b/src/views/ProjectDetailsView.ts @@ -15,7 +15,7 @@ import { RIBBON_ICON, PROJECT_FILES, CORE_FILE, - TARGET_FILE, + DESCRIPTION_FILE, } from "../const"; import { Zone, @@ -109,10 +109,10 @@ export class ProjectDetailsView extends ItemView { const projRoot = projectPath(this.project); const corePath = normalizePath(`${projRoot}/${CORE_FILE}`); - const targetPath = normalizePath(`${projRoot}/${TARGET_FILE}`); - const [core, target] = await Promise.all([ + const descriptionPath = normalizePath(`${projRoot}/${DESCRIPTION_FILE}`); + const [core, description] = await Promise.all([ readFile(this.app, corePath), - readFile(this.app, targetPath), + readFile(this.app, descriptionPath), ]); if (token !== this.renderToken) return; @@ -126,7 +126,7 @@ export class ProjectDetailsView extends ItemView { const info = root.createDiv({ cls: "pk-info-grid" }); this.renderInfoCard(info, core, corePath); - this.renderInfoCard(info, target, targetPath); + this.renderInfoCard(info, description, descriptionPath); this.renderCollections(root); } diff --git a/src/views/ProjectView.ts b/src/views/ProjectView.ts index a65c669..aca4dfb 100644 --- a/src/views/ProjectView.ts +++ b/src/views/ProjectView.ts @@ -10,6 +10,7 @@ import { VIEW_TYPE_PROJECT_DETAILS_VIEW, RIBBON_ICON, CORE_FILE, + PROJECTS_ROOT, } from "../const"; import { projectsPath, @@ -60,9 +61,9 @@ export class ProjectView extends ItemView { this.registerEvent(this.app.vault.on("delete", () => this.render())); this.registerEvent(this.app.vault.on("rename", () => this.render())); this.registerEvent(this.app.vault.on("modify", (f) => { - if (f.path.endsWith("/" + CORE_FILE) && f.path.startsWith(projectsPath() + "/")) { - this.render(); - } + if (!f.path.endsWith("/" + CORE_FILE)) return; + if (PROJECTS_ROOT && !f.path.startsWith(projectsPath() + "/")) return; + this.render(); })); this.registerDomEvent(this.containerEl, "contextmenu", (ev) => { if (ev.defaultPrevented) return; diff --git a/styles.css b/styles.css index aa125e4..5cfc095 100644 --- a/styles.css +++ b/styles.css @@ -217,6 +217,18 @@ .pk-feature-body > ul:last-child, .pk-feature-body > ol:last-child { margin-bottom: 0; } +.pk-project-core p, +.pk-project-core ul, +.pk-project-core ol, +.pk-info-card p, +.pk-info-card ul, +.pk-info-card ol, +.pk-feature-body p, +.pk-feature-body ul, +.pk-feature-body ol { + margin: 0.25em 0; +} + .pk-drop-target { outline: 2px dashed var(--text-accent);