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 TO_UPDATE_DIR = "_to-update";
|
||||||
export const IDEAS_DIR = "_ideas";
|
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 RIBBON_ICON = "layout-grid";
|
||||||
|
|
||||||
export const CORE_FILE = "_core.md";
|
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> {
|
export async function ensureFolder(app: App, path: string): Promise<void> {
|
||||||
|
if (!path) return;
|
||||||
const p = normalizePath(path);
|
const p = normalizePath(path);
|
||||||
const exists = app.vault.getAbstractFileByPath(p);
|
const exists = app.vault.getAbstractFileByPath(p);
|
||||||
if (!exists) {
|
if (!exists) {
|
||||||
@@ -55,8 +56,7 @@ export async function ensureFile(app: App, path: string, content = ""): Promise<
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function listFolders(app: App, path: string): TFolder[] {
|
export function listFolders(app: App, path: string): TFolder[] {
|
||||||
const p = normalizePath(path);
|
const folder = path ? app.vault.getAbstractFileByPath(normalizePath(path)) : app.vault.getRoot();
|
||||||
const folder = app.vault.getAbstractFileByPath(p);
|
|
||||||
if (!(folder instanceof TFolder)) return [];
|
if (!(folder instanceof TFolder)) return [];
|
||||||
return folder.children
|
return folder.children
|
||||||
.filter((c): c is TFolder => c instanceof TFolder)
|
.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[] {
|
export function listMarkdownFiles(app: App, path: string, exclude: string[] = []): TFile[] {
|
||||||
const p = normalizePath(path);
|
const folder = path ? app.vault.getAbstractFileByPath(normalizePath(path)) : app.vault.getRoot();
|
||||||
const folder = app.vault.getAbstractFileByPath(p);
|
|
||||||
if (!(folder instanceof TFolder)) return [];
|
if (!(folder instanceof TFolder)) return [];
|
||||||
return folder.children
|
return folder.children
|
||||||
.filter((c): c is TFile => c instanceof TFile && c.extension === "md")
|
.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 {
|
export function parseProjectFilePath(path: string): ProjectFileLocation | null {
|
||||||
if (!path.endsWith(".md")) return null;
|
if (!path.endsWith(".md")) return null;
|
||||||
const parts = normalizePath(path).split("/");
|
const parts = normalizePath(path).split("/");
|
||||||
|
let idx = 0;
|
||||||
|
if (PROJECTS_ROOT) {
|
||||||
if (parts[0] !== PROJECTS_ROOT) return null;
|
if (parts[0] !== PROJECTS_ROOT) return null;
|
||||||
if (parts.length < 3) return null;
|
idx = 1;
|
||||||
const project = parts[1];
|
}
|
||||||
const rest = parts.slice(2);
|
if (parts.length < idx + 2) return null;
|
||||||
|
const project = parts[idx];
|
||||||
|
const rest = parts.slice(idx + 1);
|
||||||
let zone: Zone = "ready";
|
let zone: Zone = "ready";
|
||||||
if (rest[0] === TO_UPDATE_DIR) {
|
if (rest[0] === TO_UPDATE_DIR) {
|
||||||
zone = "to-update";
|
zone = "to-update";
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import {
|
|||||||
RIBBON_ICON,
|
RIBBON_ICON,
|
||||||
PROJECT_FILES,
|
PROJECT_FILES,
|
||||||
CORE_FILE,
|
CORE_FILE,
|
||||||
TARGET_FILE,
|
DESCRIPTION_FILE,
|
||||||
} from "../const";
|
} from "../const";
|
||||||
import {
|
import {
|
||||||
Zone,
|
Zone,
|
||||||
@@ -109,10 +109,10 @@ export class ProjectDetailsView extends ItemView {
|
|||||||
|
|
||||||
const projRoot = projectPath(this.project);
|
const projRoot = projectPath(this.project);
|
||||||
const corePath = normalizePath(`${projRoot}/${CORE_FILE}`);
|
const corePath = normalizePath(`${projRoot}/${CORE_FILE}`);
|
||||||
const targetPath = normalizePath(`${projRoot}/${TARGET_FILE}`);
|
const descriptionPath = normalizePath(`${projRoot}/${DESCRIPTION_FILE}`);
|
||||||
const [core, target] = await Promise.all([
|
const [core, description] = await Promise.all([
|
||||||
readFile(this.app, corePath),
|
readFile(this.app, corePath),
|
||||||
readFile(this.app, targetPath),
|
readFile(this.app, descriptionPath),
|
||||||
]);
|
]);
|
||||||
if (token !== this.renderToken) return;
|
if (token !== this.renderToken) return;
|
||||||
|
|
||||||
@@ -126,7 +126,7 @@ export class ProjectDetailsView extends ItemView {
|
|||||||
|
|
||||||
const info = root.createDiv({ cls: "pk-info-grid" });
|
const info = root.createDiv({ cls: "pk-info-grid" });
|
||||||
this.renderInfoCard(info, core, corePath);
|
this.renderInfoCard(info, core, corePath);
|
||||||
this.renderInfoCard(info, target, targetPath);
|
this.renderInfoCard(info, description, descriptionPath);
|
||||||
this.renderCollections(root);
|
this.renderCollections(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import {
|
|||||||
VIEW_TYPE_PROJECT_DETAILS_VIEW,
|
VIEW_TYPE_PROJECT_DETAILS_VIEW,
|
||||||
RIBBON_ICON,
|
RIBBON_ICON,
|
||||||
CORE_FILE,
|
CORE_FILE,
|
||||||
|
PROJECTS_ROOT,
|
||||||
} from "../const";
|
} from "../const";
|
||||||
import {
|
import {
|
||||||
projectsPath,
|
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("delete", () => this.render()));
|
||||||
this.registerEvent(this.app.vault.on("rename", () => this.render()));
|
this.registerEvent(this.app.vault.on("rename", () => this.render()));
|
||||||
this.registerEvent(this.app.vault.on("modify", (f) => {
|
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.render();
|
||||||
}
|
|
||||||
}));
|
}));
|
||||||
this.registerDomEvent(this.containerEl, "contextmenu", (ev) => {
|
this.registerDomEvent(this.containerEl, "contextmenu", (ev) => {
|
||||||
if (ev.defaultPrevented) return;
|
if (ev.defaultPrevented) return;
|
||||||
|
|||||||
12
styles.css
12
styles.css
@@ -217,6 +217,18 @@
|
|||||||
.pk-feature-body > ul:last-child,
|
.pk-feature-body > ul:last-child,
|
||||||
.pk-feature-body > ol:last-child { margin-bottom: 0; }
|
.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 {
|
.pk-drop-target {
|
||||||
outline: 2px dashed var(--text-accent);
|
outline: 2px dashed var(--text-accent);
|
||||||
|
|||||||
Reference in New Issue
Block a user