Skip to content

Commit

Permalink
upgrade#0.6.4 元数据不显式展示
Browse files Browse the repository at this point in the history
  • Loading branch information
hqweay committed Jan 26, 2025
1 parent 17eb794 commit 526203d
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 42 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "siyuan-hqweay-go",
"version": "0.6.3",
"version": "0.6.4",
"type": "module",
"description": "恐龙工具箱",
"repository": "",
Expand Down
2 changes: 1 addition & 1 deletion plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "siyuan-hqweay-go",
"author": "养恐龙",
"url": "https://github.com/hqweay/siyuan-hqweay-go",
"version": "0.6.3",
"version": "0.6.4",
"minAppVersion": "3.0.0",
"backends": [
"windows",
Expand Down
23 changes: 15 additions & 8 deletions src/setting.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,13 @@ https://shibe.online/api/shibes?count=1`,
key: "fullSyncVoiceNotes",
value: "确认",
},
// {
// type: "textinput",
// title: "时间格式",
// description: "时间格式",
// key: "dateFormat",
// placeholder: "YYYY-MM-DD HH:mm:ss",
// },
{
type: "textarea",
title: "排除标签",
Expand All @@ -464,14 +471,14 @@ https://shibe.online/api/shibes?count=1`,
value: settings.getBySpace("voiceNotesConfig", "excludeTags"),
placeholder: "done,no",
},
{
type: "textarea",
title: "frontmatterTemplate",
description: "",
key: "frontmatterTemplate",
value: settings.getBySpace("voiceNotesConfig", "frontmatterTemplate"),
placeholder: "",
},
// {
// type: "textarea",
// title: "frontmatterTemplate",
// description: "",
// key: "frontmatterTemplate",
// value: settings.getBySpace("voiceNotesConfig", "frontmatterTemplate"),
// placeholder: "",
// },
{
type: "textarea",
title: "noteTemplate",
Expand Down
7 changes: 3 additions & 4 deletions src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,9 @@ https://shibe.online/api/shibes?count=1`,
dateFormat: "YYYY-MM-DD HH:mm:ss",
excludeTags: "",
notebook: "",
frontmatterTemplate: `duration: {{duration}}
created_at: {{created_at}}
updated_at: {{updated_at}}
{{tags}}`,
// frontmatterTemplate: `duration: {{duration}}
// created_at: {{created_at}}
// updated_at: {{updated_at}}`,
noteTemplate: `{% if summary %}
## Summary
Expand Down
85 changes: 57 additions & 28 deletions src/siyuan-voicenotes-sync/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export default class VoiceNotesPlugin extends AddIconThenClick {

// 打开随机文档,编辑sql选定范围
async exec(fullSync = false) {
console.log(settings.getBySpace("voiceNotesConfig", "excludeTags"));
showMessage(`开始同步`);
await this.sync(fullSync);
showMessage(`同步完成,此次同步 ${this.syncedNoteCount} 条笔记`);
Expand Down Expand Up @@ -234,12 +233,12 @@ export default class VoiceNotesPlugin extends AddIconThenClick {
.join("\n")
: null;

const formattedTags =
recording.tags && recording.tags.length > 0
? recording.tags
.map((tag) => `#${tag.name.replace(/\s+/g, "-")}#`)
.join(" ")
: null;
// const formattedTags =
// recording.tags && recording.tags.length > 0
// ? recording.tags
// .map((tag) => `#${tag.name.replace(/\s+/g, "-")}#`)
// .join(" ")
// : null;
// recording.tags && recording.tags.length > 0
// ? "tags: [" +
// recording.tags
Expand All @@ -255,15 +254,15 @@ export default class VoiceNotesPlugin extends AddIconThenClick {
recording.created_at,
settings.getBySpace("voiceNotesConfig", "dateFormat")
),
duration: formatDuration(recording.duration),
created_at: formatDate(
recording.created_at,
settings.getBySpace("voiceNotesConfig", "dateFormat")
),
updated_at: formatDate(
recording.updated_at,
settings.getBySpace("voiceNotesConfig", "dateFormat")
),
// duration: formatDuration(recording.duration),
// created_at: formatDate(
// recording.created_at,
// settings.getBySpace("voiceNotesConfig", "dateFormat")
// ),
// updated_at: formatDate(
// recording.updated_at,
// settings.getBySpace("voiceNotesConfig", "dateFormat")
// ),
transcript: transcript,
// audio_filename: audioFilenameMD,
summary: summary ? summary.markdown_content : null,
Expand All @@ -274,7 +273,7 @@ export default class VoiceNotesPlugin extends AddIconThenClick {
blog: blog ? blog.markdown_content : null,
email: email ? email.markdown_content : null,
custom: custom ? custom.markdown_content : null,
tags: formattedTags,
// tags: formattedTags,
// related_notes:
// recording.related_notes && recording.related_notes.length > 0
// ? recording.related_notes
Expand Down Expand Up @@ -313,17 +312,17 @@ export default class VoiceNotesPlugin extends AddIconThenClick {
// }

// 添加前置元数据
let recordingIdTemplate = `recording_id: {{recording_id}}\n`;
let renderedFrontmatter = jinja
.render(
recordingIdTemplate +
settings.getBySpace("voiceNotesConfig", "frontmatterTemplate"),
context
)
.replace(/\n{3,}/g, "\n\n");

const metadata = `---\n${renderedFrontmatter}\n---\n`;
note = metadata + note;
// let recordingIdTemplate = `recording_id: {{recording_id}}\n`;
// let renderedFrontmatter = jinja
// .render(
// recordingIdTemplate +
// settings.getBySpace("voiceNotesConfig", "frontmatterTemplate"),
// context
// )
// .replace(/\n{3,}/g, "\n\n");

// const metadata = `---\n${renderedFrontmatter}\n---\n`;
// note = metadata + note;
// 创建文档
const response = await fetch("/api/filetree/createDocWithMd", {
method: "POST",
Expand All @@ -349,6 +348,36 @@ export default class VoiceNotesPlugin extends AddIconThenClick {
);
}

const tagsStr =
recording.tags && recording.tags.length > 0
? recording.tags
// .map((tag) => `${tag.name.replace(/\s+/g, "-")}`)
.map((tag) => `${tag.name}`)
.join(",")
: "";
await fetch("/api/attr/setBlockAttrs", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
id: responseData.data,
attrs: {
tags: tagsStr,
"custom-duration": formatDuration(recording.duration),
"custom-createdAt": formatDate(
recording.created_at,
settings.getBySpace("voiceNotesConfig", "dateFormat")
),
"custom-updatedAt": formatDate(
recording.updated_at,
settings.getBySpace("voiceNotesConfig", "dateFormat")
),
"custom-recordingId": recording.recording_id,
},
}),
});

// if (this.settings.deleteSynced && this.settings.reallyDeleteSynced) {
// await this.vnApi.deleteRecording(recording.recording_id);
// }
Expand Down

0 comments on commit 526203d

Please sign in to comment.