update
This commit is contained in:
@@ -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;
|
||||
|
||||
17
src/fs.ts
17
src/fs.ts
@@ -40,6 +40,7 @@ export function featurePath(
|
||||
}
|
||||
|
||||
export async function ensureFolder(app: App, path: string): Promise<void> {
|
||||
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("/");
|
||||
let idx = 0;
|
||||
if (PROJECTS_ROOT) {
|
||||
if (parts[0] !== PROJECTS_ROOT) return null;
|
||||
if (parts.length < 3) return null;
|
||||
const project = parts[1];
|
||||
const rest = parts.slice(2);
|
||||
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";
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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() + "/")) {
|
||||
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;
|
||||
|
||||
12
styles.css
12
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);
|
||||
|
||||
Reference in New Issue
Block a user