Skip to content

Commit

Permalink
feat: update plugin to 1.7.2
Browse files Browse the repository at this point in the history
  • Loading branch information
quanru committed Dec 8, 2023
1 parent 33b3d48 commit c7d659f
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 78 deletions.
124 changes: 64 additions & 60 deletions .obsidian/plugins/periodic-para/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -36145,7 +36145,7 @@ var import_obsidian14 = require("obsidian");
var import_obsidian_dataview = __toESM(require_lib());

// src/para/Project.ts
var import_obsidian4 = require("obsidian");
var import_obsidian5 = require("obsidian");

// src/periodic/Date.ts
var import_obsidian = require("obsidian");
Expand Down Expand Up @@ -36309,7 +36309,7 @@ var Markdown = class extends import_obsidian2.MarkdownRenderChild {
};

// src/para/Project.ts
var import_obsidian5 = require("obsidian");
var import_obsidian6 = require("obsidian");

// src/para/Item.ts
var import_obsidian3 = require("obsidian");
Expand Down Expand Up @@ -36354,6 +36354,55 @@ var Item = class {
}
};

// src/util.ts
var import_obsidian4 = require("obsidian");
function renderError(app, msg, containerEl, sourcePath) {
const component = new import_obsidian4.Component();
return import_obsidian4.MarkdownRenderer.render(app, msg, containerEl, sourcePath, component);
}
function isDarkTheme() {
var _a;
const el = document.querySelector("body");
return (_a = el == null ? void 0 : el.className.includes("theme-dark")) != null ? _a : false;
}
function formatDailyRecord(record) {
const { createdTs, createdAt, content, resourceList } = record;
const timeStamp = createdAt ? (0, import_obsidian4.moment)(createdAt).unix() : createdTs;
const [date4, time] = (0, import_obsidian4.moment)(timeStamp * 1e3).format("YYYY-MM-DD HH:mm").split(" ");
const [firstLine, ...otherLine] = content.trim().split("\n");
const isTask = /^- \[.*?\]/.test(firstLine);
const targetFirstLine = (
// 将标签和时间戳加到第一行
(isTask ? `- [ ] ${time} ${firstLine.replace(/^- \[.*?\]/, "")}` : `- ${time} ${firstLine.replace(/^- /, "")}`) + ` #daily-record ^${timeStamp}`
);
const targetOtherLine = (otherLine == null ? void 0 : otherLine.length) ? "\n" + otherLine.map((line2) => /^[ \t]/.test(line2) ? line2 : ` ${line2}`).join("\n").trimEnd() : "";
const targetResourceLine = (resourceList == null ? void 0 : resourceList.length) ? "\n" + (resourceList == null ? void 0 : resourceList.map(
(resource) => ` - ![[${generateFileName(resource)}]]`
).join("\n")) : "";
const finalTargetContent = targetFirstLine + targetOtherLine + targetResourceLine;
return [date4, timeStamp, finalTargetContent].map(String);
}
function generateFileName(resource) {
return `${resource.id}-${resource.filename.replace(/[/\\?%*:|"<>]/g, "-")}`;
}
function logMessage(message, level = 0 /* info */) {
new import_obsidian4.Notice(message);
if (level === 0 /* info */) {
console.info(message);
} else if (level === 1 /* warn */) {
console.warn(message);
} else if (level === 2 /* error */) {
console.error(message);
throw Error(message);
}
}
function generateHeaderRegExp(header) {
const formattedHeader = /^#+/.test(header.trim()) ? header.trim() : `# ${header.trim()}`;
const reg = new RegExp(`(${formattedHeader}[^
]*)([\\s\\S]*?)(?=\\n##|$)`);
return reg;
}

// src/para/Project.ts
var Project = class extends Item {
constructor() {
Expand All @@ -36375,7 +36424,7 @@ var Project = class extends Item {
);
});
const component = new Markdown(div);
import_obsidian5.MarkdownRenderer.render(
import_obsidian6.MarkdownRenderer.render(
this.app,
list.join("\n"),
div,
Expand Down Expand Up @@ -36430,17 +36479,17 @@ var Project = class extends Item {
let totalTime = "";
const tasks = [];
while (true) {
const momentDay = (0, import_obsidian4.moment)(day);
const momentDay = (0, import_obsidian5.moment)(day);
const link = `${momentDay.format("YYYY-MM-DD")}.md`;
const file = this.file.get(link, "", this.settings.periodicNotesPath);
if (file instanceof import_obsidian4.TFile) {
const reg = new RegExp(`# ${header}([\\s\\S]*?)(?=\\n##|$)`);
if (file instanceof import_obsidian5.TFile) {
const reg = generateHeaderRegExp(header);
let todayTotalTime = "0hr0";
tasks.push(async () => {
var _a;
const fileContent = await this.app.vault.cachedRead(file);
const regMatch = fileContent.match(reg);
const projectContent = (regMatch == null ? void 0 : regMatch.length) ? (_a = regMatch[1]) == null ? void 0 : _a.split("\n") : [];
const projectContent = (regMatch == null ? void 0 : regMatch.length) ? (_a = regMatch[2]) == null ? void 0 : _a.split("\n") : [];
projectContent.map((project) => {
var _a2, _b;
if (!project) {
Expand Down Expand Up @@ -36487,7 +36536,7 @@ var Project = class extends Item {
};

// src/para/Area.ts
var import_obsidian6 = require("obsidian");
var import_obsidian7 = require("obsidian");
var Area = class extends Item {
constructor() {
super(...arguments);
Expand All @@ -36506,7 +36555,7 @@ var Area = class extends Item {
);
});
const component = new Markdown(div);
import_obsidian6.MarkdownRenderer.render(
import_obsidian7.MarkdownRenderer.render(
this.app,
list.join("\n"),
div,
Expand All @@ -36531,14 +36580,14 @@ var Area = class extends Item {
const quarter = quarterList[index2];
const link = `${year}-${quarter}.md`;
const file = this.file.get(link, "", this.settings.periodicNotesPath);
if (file instanceof import_obsidian6.TFile) {
const reg = new RegExp(`# ${header}([\\s\\S]*?)(?=\\n##|$)`);
if (file instanceof import_obsidian7.TFile) {
const reg = generateHeaderRegExp(header);
if (file) {
tasks.push(async () => {
var _a;
const fileContent = await this.app.vault.cachedRead(file);
const regMatch = fileContent.match(reg);
const areaContent = (regMatch == null ? void 0 : regMatch.length) ? (_a = regMatch[1]) == null ? void 0 : _a.split("\n") : [];
const areaContent = (regMatch == null ? void 0 : regMatch.length) ? (_a = regMatch[2]) == null ? void 0 : _a.split("\n") : [];
areaContent.map((area) => {
var _a2;
if (!area) {
Expand Down Expand Up @@ -36600,51 +36649,6 @@ var YEARLY = "Yearly";

// src/periodic/File.ts
var import_obsidian8 = require("obsidian");

// src/util.ts
var import_obsidian7 = require("obsidian");
function renderError(app, msg, containerEl, sourcePath) {
const component = new import_obsidian7.Component();
return import_obsidian7.MarkdownRenderer.render(app, msg, containerEl, sourcePath, component);
}
function isDarkTheme() {
var _a;
const el = document.querySelector("body");
return (_a = el == null ? void 0 : el.className.includes("theme-dark")) != null ? _a : false;
}
function formatDailyRecord(record) {
const { createdTs, createdAt, content, resourceList } = record;
const timeStamp = createdAt ? (0, import_obsidian7.moment)(createdAt).unix() : createdTs;
const [date4, time] = (0, import_obsidian7.moment)(timeStamp * 1e3).format("YYYY-MM-DD HH:mm").split(" ");
const [firstLine, ...otherLine] = content.split("\n");
const isTask = /^- \[.*?\]/.test(firstLine);
const targetFirstLine = (
// 将标签和时间戳加到第一行
(isTask ? `- [ ] ${time} ${firstLine.replace(/^- \[.*?\]/, "")}` : `- ${time} ${firstLine.replace(/^- /, "")}`) + ` #daily-record ^${timeStamp}`
);
const targetOtherLine = (otherLine == null ? void 0 : otherLine.length) ? "\n" + otherLine.map((line2) => /^[ \t]/.test(line2) ? line2 : ` ${line2}`).join("\n").replace(/[\n\s]*$/, "") : "";
const targetResourceLine = (resourceList == null ? void 0 : resourceList.length) ? "\n" + (resourceList == null ? void 0 : resourceList.map(
(resource) => ` - ![[${generateFileName(resource)}]]`
).join("\n")) : "";
const finalTargetContent = targetFirstLine + targetOtherLine + targetResourceLine;
return [date4, timeStamp, finalTargetContent].map(String);
}
function generateFileName(resource) {
return `${resource.id}-${resource.filename.replace(/[/\\?%*:|"<>]/g, "-")}`;
}
function logMessage(message, level = 0 /* info */) {
new import_obsidian7.Notice(message);
if (level === 0 /* info */) {
console.info(message);
} else if (level === 1 /* warn */) {
console.warn(message);
} else if (level === 2 /* error */) {
console.error(message);
throw Error(message);
}
}

// src/periodic/File.ts
var File = class {
constructor(app, settings, dataview) {
this.app = app;
Expand Down Expand Up @@ -39049,7 +39053,7 @@ var DailyRecord = class {
2 /* error */
);
}
const reg = new RegExp(`# ${header}([\\s\\S]*?)(?=\\n##|$)`);
const reg = generateHeaderRegExp(header);
if (targetFile instanceof import_obsidian10.TFile) {
const originFileContent = await this.app.vault.read(targetFile);
const regMatch = originFileContent.match(reg);
Expand All @@ -39062,8 +39066,8 @@ var DailyRecord = class {
}
return;
}
const localRecordContent = (_a2 = regMatch[1]) == null ? void 0 : _a2.trim();
const from2 = (regMatch == null ? void 0 : regMatch.index) + header.length + 3;
const localRecordContent = (_a2 = regMatch[2]) == null ? void 0 : _a2.trim();
const from2 = (regMatch == null ? void 0 : regMatch.index) + regMatch[1].length + 1;
const to = from2 + localRecordContent.length;
const prefix = originFileContent.slice(0, from2);
const suffix = originFileContent.slice(to);
Expand Down
4 changes: 2 additions & 2 deletions .obsidian/plugins/periodic-para/manifest.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"id": "periodic-para",
"name": "Periodic PARA",
"version": "1.7.0",
"version": "1.7.2",
"minAppVersion": "0.15.0",
"description": "Assist in practicing the PARA system with periodic notes and usememos.",
"description": "Assist in practicing the PARA method with periodic notes and usememos.",
"author": "YiBing Lin",
"authorUrl": "https://quanru.github.io",
"fundingUrl": "https://www.buymeacoffee.com/leyang",
Expand Down
23 changes: 7 additions & 16 deletions .obsidian/workspace.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,15 @@
"type": "split",
"children": [
{
"id": "e66bc67306d9a8b6",
"id": "641a43a8f8cafbf9",
"type": "tabs",
"children": [
{
"id": "c336d5cfe662ab18",
"id": "7236c6ac303bd9aa",
"type": "leaf",
"state": {
"type": "markdown",
"state": {
"file": "0. PeriodicNotes/2023/Daily/06/2023-06-02.md",
"mode": "source",
"backlinks": true,
"source": false
}
"type": "empty",
"state": {}
}
}
]
Expand Down Expand Up @@ -121,7 +116,6 @@
"state": {
"type": "outgoing-link",
"state": {
"file": "0. PeriodicNotes/2023/Daily/06/2023-06-02.md",
"linksCollapsed": false,
"unlinkedCollapsed": true
}
Expand All @@ -132,9 +126,7 @@
"type": "leaf",
"state": {
"type": "outline",
"state": {
"file": "0. PeriodicNotes/2023/Daily/06/2023-06-02.md"
}
"state": {}
}
},
{
Expand All @@ -143,7 +135,6 @@
"state": {
"type": "backlink",
"state": {
"file": "0. PeriodicNotes/2023/Daily/06/2023-06-02.md",
"collapseAll": false,
"extraContext": false,
"sortOrder": "alphabetical",
Expand Down Expand Up @@ -184,8 +175,9 @@
"periodic-para:Periodic PARA": false
}
},
"active": "c336d5cfe662ab18",
"active": "7236c6ac303bd9aa",
"lastOpenFiles": [
"0. PeriodicNotes/2023/Daily/06/2023-06-02.md",
"0. PeriodicNotes/2023/Daily/11/2023-11-07.md",
"0. PeriodicNotes/2023/Daily/11",
"5. Expres/README.md",
Expand All @@ -204,7 +196,6 @@
"0. PeriodicNotes/2023/Daily/09",
"HOME.canvas",
"0. PeriodicNotes/2023/Daily/06/2023-06-01.md",
"0. PeriodicNotes/2023/Daily/06/2023-06-02.md",
"0. PeriodicNotes/2023/Daily/08/2023-08-26.md",
"0. PeriodicNotes/2023/Daily/08",
"4. Archives/Template.md",
Expand Down

0 comments on commit c7d659f

Please sign in to comment.