This commit is contained in:
Daniel 2025-03-31 16:39:24 +08:00
parent 566c90cbba
commit 536aa39f95
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
5 changed files with 301 additions and 150 deletions

View file

@ -6,7 +6,7 @@
"id": "20201204184532-3qm9l8n", "id": "20201204184532-3qm9l8n",
"title": "Template snippet", "title": "Template snippet",
"type": "doc", "type": "doc",
"updated": "20250115153127" "updated": "20250331163727"
}, },
"Children": [ "Children": [
{ {
@ -57,7 +57,7 @@
"HeadingLevel": 2, "HeadingLevel": 2,
"Properties": { "Properties": {
"id": "20210104091444-jy56z0p", "id": "20210104091444-jy56z0p",
"updated": "20241225192808" "updated": "20250331163727"
}, },
"Children": [ "Children": [
{ {
@ -215,7 +215,7 @@
"ListData": {}, "ListData": {},
"Properties": { "Properties": {
"id": "20210104091444-mwbvc9m", "id": "20210104091444-mwbvc9m",
"updated": "20241225192808" "updated": "20250331163727"
}, },
"Children": [ "Children": [
{ {
@ -249,15 +249,7 @@
}, },
{ {
"Type": "NodeText", "Type": "NodeText",
"Data": ": Use this variable to insert the current document name. For example, if the " "Data": ": Use this variable to insert the current document name. For example, if the template content is "
},
{
"Type": "NodeText",
"Data": "template"
},
{
"Type": "NodeText",
"Data": " content is "
}, },
{ {
"Type": "NodeTextMark", "Type": "NodeTextMark",
@ -429,7 +421,7 @@
}, },
"Properties": { "Properties": {
"id": "20210121193829-wfzsf6m", "id": "20210121193829-wfzsf6m",
"updated": "20240403150956" "updated": "20250331163727"
}, },
"Children": [ "Children": [
{ {
@ -451,15 +443,7 @@
}, },
{ {
"Type": "NodeText", "Type": "NodeText",
"Data": ": This function is used to query the " "Data": ": This function is used to query the database, and the return value is a list of blocks"
},
{
"Type": "NodeText",
"Data": "database"
},
{
"Type": "NodeText",
"Data": ", and the return value is a list of blocks"
} }
] ]
}, },
@ -470,7 +454,7 @@
"Properties": { "Properties": {
"id": "20241213215602-dk7iion", "id": "20241213215602-dk7iion",
"style": "line-height: 22px;", "style": "line-height: 22px;",
"updated": "20241213215602" "updated": "20250331163727"
}, },
"Children": [ "Children": [
{ {
@ -482,7 +466,70 @@
}, },
{ {
"Type": "NodeCodeBlockCode", "Type": "NodeCodeBlockCode",
"Data": ".action{$today := now | date \"20060102150405\"}\n.action{$blocks :=queryBlocks \"SELECT * FROM blocks WHERE content LIKE '?' AND updated \u003e '?' LIMIT ?\" \"%foo%\" $today \"3\"}\n" "Data": ".action{$today := now | date \"20060102150405\"}\n.action{$blocks := queryBlocks \"SELECT * FROM blocks WHERE content LIKE '?' AND updated \u003e '?' LIMIT ?\" \"%foo%\" $today \"3\"}\n"
},
{
"Type": "NodeCodeBlockFenceCloseMarker",
"Data": "```"
}
]
}
]
},
{
"ID": "20250331163529-vixv1we",
"Type": "NodeListItem",
"ListData": {
"BulletChar": 42,
"Marker": "Kg=="
},
"Properties": {
"id": "20250331163529-vixv1we",
"updated": "20250331163604"
},
"Children": [
{
"ID": "20250331163529-m6ezl4h",
"Type": "NodeParagraph",
"Properties": {
"id": "20250331163529-m6ezl4h",
"updated": "20250331163547"
},
"Children": [
{
"Type": "NodeText",
"Data": ""
},
{
"Type": "NodeTextMark",
"TextMarkType": "code",
"TextMarkTextContent": "getBlock"
},
{
"Type": "NodeText",
"Data": ": This function is used to query the database based on the block ID, and the return value is block"
}
]
},
{
"ID": "20250331163550-2r69a54",
"Type": "NodeCodeBlock",
"IsFencedCodeBlock": true,
"Properties": {
"id": "20250331163550-2r69a54",
"updated": "20250331163604"
},
"Children": [
{
"Type": "NodeCodeBlockFenceOpenMarker",
"Data": "```"
},
{
"Type": "NodeCodeBlockFenceInfoMarker"
},
{
"Type": "NodeCodeBlockCode",
"Data": ".action{getBlock \"20250331163529-vixv1we\"}\n"
}, },
{ {
"Type": "NodeCodeBlockFenceCloseMarker", "Type": "NodeCodeBlockFenceCloseMarker",
@ -523,15 +570,7 @@
}, },
{ {
"Type": "NodeText", "Type": "NodeText",
"Data": ": This function is used to query the " "Data": ": This function is used to query the database, and the return value is a list of spans"
},
{
"Type": "NodeText",
"Data": "database"
},
{
"Type": "NodeText",
"Data": ", and the return value is a list of spans"
} }
] ]
}, },
@ -595,15 +634,7 @@
}, },
{ {
"Type": "NodeText", "Type": "NodeText",
"Data": ": This function is used to query the " "Data": ": This function is used to query the database and the return value is a result set"
},
{
"Type": "NodeText",
"Data": "database"
},
{
"Type": "NodeText",
"Data": " and the return value is a result set"
} }
] ]
}, },

View file

@ -6,7 +6,7 @@
"id": "20201204181006-7bkppue", "id": "20201204181006-7bkppue",
"title": "模板片段", "title": "模板片段",
"type": "doc", "type": "doc",
"updated": "20250115153028" "updated": "20250331163228"
}, },
"Children": [ "Children": [
{ {
@ -69,7 +69,7 @@
"HeadingLevel": 2, "HeadingLevel": 2,
"Properties": { "Properties": {
"id": "20210104091309-fhb549c", "id": "20210104091309-fhb549c",
"updated": "20241225192538" "updated": "20250331163228"
}, },
"Children": [ "Children": [
{ {
@ -237,7 +237,7 @@
"ListData": {}, "ListData": {},
"Properties": { "Properties": {
"id": "20210104091309-gjkg3u5", "id": "20210104091309-gjkg3u5",
"updated": "20241225192538" "updated": "20250331163228"
}, },
"Children": [ "Children": [
{ {
@ -271,15 +271,7 @@
}, },
{ {
"Type": "NodeText", "Type": "NodeText",
"Data": "​:该变量用于插入当前文档名。比如" "Data": "​:该变量用于插入当前文档名。比如模板内容为 "
},
{
"Type": "NodeText",
"Data": "模板"
},
{
"Type": "NodeText",
"Data": "内容为 "
}, },
{ {
"Type": "NodeTextMark", "Type": "NodeTextMark",
@ -451,7 +443,7 @@
}, },
"Properties": { "Properties": {
"id": "20210121193601-uwo8s5h", "id": "20210121193601-uwo8s5h",
"updated": "20240403150712" "updated": "20250331163052"
}, },
"Children": [ "Children": [
{ {
@ -473,15 +465,7 @@
}, },
{ {
"Type": "NodeText", "Type": "NodeText",
"Data": "​:该函数用于查询" "Data": "​:该函数用于查询数据库,返回值为 blocks 列表"
},
{
"Type": "NodeText",
"Data": "数据库"
},
{
"Type": "NodeText",
"Data": ",返回值为 blocks 列表"
} }
] ]
}, },
@ -492,7 +476,7 @@
"Properties": { "Properties": {
"id": "20210604111446-p6vadfc", "id": "20210604111446-p6vadfc",
"style": "line-height: 22px;", "style": "line-height: 22px;",
"updated": "20241213215118" "updated": "20250331163052"
}, },
"Children": [ "Children": [
{ {
@ -504,7 +488,70 @@
}, },
{ {
"Type": "NodeCodeBlockCode", "Type": "NodeCodeBlockCode",
"Data": ".action{$today := now | date \"20060102150405\"}\n.action{$blocks :=queryBlocks \"SELECT * FROM blocks WHERE content LIKE '?' AND updated \u003e '?' LIMIT ?\" \"%foo%\" $today \"3\"}\n" "Data": ".action{$today := now | date \"20060102150405\"}\n.action{$blocks := queryBlocks \"SELECT * FROM blocks WHERE content LIKE '?' AND updated \u003e '?' LIMIT ?\" \"%foo%\" $today \"3\"}\n"
},
{
"Type": "NodeCodeBlockFenceCloseMarker",
"Data": "```"
}
]
}
]
},
{
"ID": "20250331162928-53comqi",
"Type": "NodeListItem",
"ListData": {
"BulletChar": 42,
"Marker": "Kg=="
},
"Properties": {
"id": "20250331162928-53comqi",
"updated": "20250331163228"
},
"Children": [
{
"ID": "20250331162928-8ugpm3u",
"Type": "NodeParagraph",
"Properties": {
"id": "20250331162928-8ugpm3u",
"updated": "20250331163210"
},
"Children": [
{
"Type": "NodeText",
"Data": ""
},
{
"Type": "NodeTextMark",
"TextMarkType": "code",
"TextMarkTextContent": "getBlock"
},
{
"Type": "NodeText",
"Data": "​:该函数用于根据块 ID 查询数据库,返回值为 block"
}
]
},
{
"ID": "20250331163038-6j2ttlc",
"Type": "NodeCodeBlock",
"IsFencedCodeBlock": true,
"Properties": {
"id": "20250331163038-6j2ttlc",
"updated": "20250331163228"
},
"Children": [
{
"Type": "NodeCodeBlockFenceOpenMarker",
"Data": "```"
},
{
"Type": "NodeCodeBlockFenceInfoMarker"
},
{
"Type": "NodeCodeBlockCode",
"Data": ".action{getBlock \"20250331162928-53comqi\"}\n"
}, },
{ {
"Type": "NodeCodeBlockFenceCloseMarker", "Type": "NodeCodeBlockFenceCloseMarker",
@ -545,15 +592,7 @@
}, },
{ {
"Type": "NodeText", "Type": "NodeText",
"Data": "​:该函数用于查询" "Data": "​:该函数用于查询数据库,返回值为 spans 列表"
},
{
"Type": "NodeText",
"Data": "数据库"
},
{
"Type": "NodeText",
"Data": ",返回值为 spans 列表"
} }
] ]
}, },
@ -617,15 +656,7 @@
}, },
{ {
"Type": "NodeText", "Type": "NodeText",
"Data": "​:该函数用于查询" "Data": "​:该函数用于查询数据库,返回值为结果集"
},
{
"Type": "NodeText",
"Data": "数据库"
},
{
"Type": "NodeText",
"Data": ",返回值为结果集"
} }
] ]
}, },

View file

@ -6,7 +6,7 @@
"id": "20211226123004-dplpw0o", "id": "20211226123004-dplpw0o",
"title": "範本片段", "title": "範本片段",
"type": "doc", "type": "doc",
"updated": "20250115153115" "updated": "20250331163725"
}, },
"Children": [ "Children": [
{ {
@ -53,7 +53,7 @@
"HeadingLevel": 2, "HeadingLevel": 2,
"Properties": { "Properties": {
"id": "20211226123024-eyagqur", "id": "20211226123024-eyagqur",
"updated": "20241225192757" "updated": "20250331163725"
}, },
"Children": [ "Children": [
{ {
@ -208,7 +208,7 @@
"ListData": {}, "ListData": {},
"Properties": { "Properties": {
"id": "20211226123024-pjvw31z", "id": "20211226123024-pjvw31z",
"updated": "20241225192757" "updated": "20250331163725"
}, },
"Children": [ "Children": [
{ {
@ -414,7 +414,7 @@
}, },
"Properties": { "Properties": {
"id": "20211226123024-e42d7xq", "id": "20211226123024-e42d7xq",
"updated": "20240403150942" "updated": "20250331163725"
}, },
"Children": [ "Children": [
{ {
@ -436,15 +436,7 @@
}, },
{ {
"Type": "NodeText", "Type": "NodeText",
"Data": "​:該函數用於查詢" "Data": "​:該函數用於查詢資料庫,返回值為 blocks 列表"
},
{
"Type": "NodeText",
"Data": "資料庫"
},
{
"Type": "NodeText",
"Data": ",返回值為 blocks 列表"
} }
] ]
}, },
@ -455,7 +447,7 @@
"Properties": { "Properties": {
"id": "20241213215519-mfgruqs", "id": "20241213215519-mfgruqs",
"style": "line-height: 22px;", "style": "line-height: 22px;",
"updated": "20241213215519" "updated": "20250331163725"
}, },
"Children": [ "Children": [
{ {
@ -467,7 +459,70 @@
}, },
{ {
"Type": "NodeCodeBlockCode", "Type": "NodeCodeBlockCode",
"Data": ".action{$today := now | date \"20060102150405\"}\n.action{$blocks :=queryBlocks \"SELECT * FROM blocks WHERE content LIKE '?' AND updated \u003e '?' LIMIT ?\" \"%foo%\" $today \"3\"}\n" "Data": ".action{$today := now | date \"20060102150405\"}\n.action{$blocks := queryBlocks \"SELECT * FROM blocks WHERE content LIKE '?' AND updated \u003e '?' LIMIT ?\" \"%foo%\" $today \"3\"}\n"
},
{
"Type": "NodeCodeBlockFenceCloseMarker",
"Data": "```"
}
]
}
]
},
{
"ID": "20250331163425-s5u08ng",
"Type": "NodeListItem",
"ListData": {
"BulletChar": 42,
"Marker": "Kg=="
},
"Properties": {
"id": "20250331163425-s5u08ng",
"updated": "20250331163515"
},
"Children": [
{
"ID": "20250331163425-6fe2kvm",
"Type": "NodeParagraph",
"Properties": {
"id": "20250331163425-6fe2kvm",
"updated": "20250331163515"
},
"Children": [
{
"Type": "NodeText",
"Data": ""
},
{
"Type": "NodeTextMark",
"TextMarkType": "code",
"TextMarkTextContent": "getBlock"
},
{
"Type": "NodeText",
"Data": "​:函數用於根據塊 ID 查詢資料庫,傳回值為 block"
}
]
},
{
"ID": "20250331163435-irjmxt9",
"Type": "NodeCodeBlock",
"IsFencedCodeBlock": true,
"Properties": {
"id": "20250331163435-irjmxt9",
"updated": "20250331163452"
},
"Children": [
{
"Type": "NodeCodeBlockFenceOpenMarker",
"Data": "```"
},
{
"Type": "NodeCodeBlockFenceInfoMarker"
},
{
"Type": "NodeCodeBlockCode",
"Data": ".action{getBlock \"20250331163425-s5u08ng\"}\n"
}, },
{ {
"Type": "NodeCodeBlockFenceCloseMarker", "Type": "NodeCodeBlockFenceCloseMarker",
@ -508,15 +563,7 @@
}, },
{ {
"Type": "NodeText", "Type": "NodeText",
"Data": "​:該函數用於查詢" "Data": "​:該函數用於查詢資料庫,返回值為 spans 列表"
},
{
"Type": "NodeText",
"Data": "資料庫"
},
{
"Type": "NodeText",
"Data": ",返回值為 spans 列表"
} }
] ]
}, },
@ -580,15 +627,7 @@
}, },
{ {
"Type": "NodeText", "Type": "NodeText",
"Data": "​:函數用於查詢" "Data": "​:函數用於查詢資料庫,傳回值為結果集"
},
{
"Type": "NodeText",
"Data": "資料庫"
},
{
"Type": "NodeText",
"Data": ",傳回值為結果集"
} }
] ]
}, },

View file

@ -7,7 +7,7 @@
"id": "20240530101000-6x9ivi7", "id": "20240530101000-6x9ivi7",
"title": "テンプレートスニペット", "title": "テンプレートスニペット",
"type": "doc", "type": "doc",
"updated": "20241225192831" "updated": "20250331163729"
}, },
"Children": [ "Children": [
{ {
@ -66,7 +66,7 @@
"Properties": { "Properties": {
"ID": "20240530101000-5nvn9ad", "ID": "20240530101000-5nvn9ad",
"id": "20240530101000-pi05yzt", "id": "20240530101000-pi05yzt",
"updated": "20241225192831" "updated": "20250331163729"
}, },
"Children": [ "Children": [
{ {
@ -226,7 +226,7 @@
"ListData": {}, "ListData": {},
"Properties": { "Properties": {
"id": "20240530101000-by5hqnb", "id": "20240530101000-by5hqnb",
"updated": "20241225192831" "updated": "20250331163729"
}, },
"Children": [ "Children": [
{ {
@ -432,7 +432,7 @@
}, },
"Properties": { "Properties": {
"id": "20240530101000-0y2zlji", "id": "20240530101000-0y2zlji",
"updated": "20240530101000" "updated": "20250331163729"
}, },
"Children": [ "Children": [
{ {
@ -454,15 +454,7 @@
}, },
{ {
"Type": "NodeText", "Type": "NodeText",
"Data": ": この関数は" "Data": ": この関数はデータベースをクエリしてブロックのリストを返します"
},
{
"Type": "NodeText",
"Data": "データベース"
},
{
"Type": "NodeText",
"Data": "をクエリしてブロックのリストを返します"
} }
] ]
}, },
@ -473,7 +465,7 @@
"Properties": { "Properties": {
"id": "20241213215628-5gixpmp", "id": "20241213215628-5gixpmp",
"style": "line-height: 22px;", "style": "line-height: 22px;",
"updated": "20241213215628" "updated": "20250331163729"
}, },
"Children": [ "Children": [
{ {
@ -485,7 +477,70 @@
}, },
{ {
"Type": "NodeCodeBlockCode", "Type": "NodeCodeBlockCode",
"Data": ".action{$today := now | date \"20060102150405\"}\n.action{$blocks :=queryBlocks \"SELECT * FROM blocks WHERE content LIKE '?' AND updated \u003e '?' LIMIT ?\" \"%foo%\" $today \"3\"}\n" "Data": ".action{$today := now | date \"20060102150405\"}\n.action{$blocks := queryBlocks \"SELECT * FROM blocks WHERE content LIKE '?' AND updated \u003e '?' LIMIT ?\" \"%foo%\" $today \"3\"}\n"
},
{
"Type": "NodeCodeBlockFenceCloseMarker",
"Data": "```"
}
]
}
]
},
{
"ID": "20250331163610-n3e9zft",
"Type": "NodeListItem",
"ListData": {
"BulletChar": 42,
"Marker": "Kg=="
},
"Properties": {
"id": "20250331163610-n3e9zft",
"updated": "20250331163642"
},
"Children": [
{
"ID": "20250331163610-nbmwe90",
"Type": "NodeParagraph",
"Properties": {
"id": "20250331163610-nbmwe90",
"updated": "20250331163621"
},
"Children": [
{
"Type": "NodeText",
"Data": ""
},
{
"Type": "NodeTextMark",
"TextMarkType": "code",
"TextMarkTextContent": "getBlock"
},
{
"Type": "NodeText",
"Data": ": この関数はブロックIDに基づいてデータベースを照会するために使用され、戻り値はブロックです"
}
]
},
{
"ID": "20250331163621-j4iofxv",
"Type": "NodeCodeBlock",
"IsFencedCodeBlock": true,
"Properties": {
"id": "20250331163621-j4iofxv",
"updated": "20250331163642"
},
"Children": [
{
"Type": "NodeCodeBlockFenceOpenMarker",
"Data": "```"
},
{
"Type": "NodeCodeBlockFenceInfoMarker"
},
{
"Type": "NodeCodeBlockCode",
"Data": ".action{getBlock \"20250331163610-n3e9zft\"}\n"
}, },
{ {
"Type": "NodeCodeBlockFenceCloseMarker", "Type": "NodeCodeBlockFenceCloseMarker",
@ -526,15 +581,7 @@
}, },
{ {
"Type": "NodeText", "Type": "NodeText",
"Data": ": この関数は" "Data": ": この関数はデータベースをクエリしてスパンのリストを返します"
},
{
"Type": "NodeText",
"Data": "データベース"
},
{
"Type": "NodeText",
"Data": "をクエリしてスパンのリストを返します"
} }
] ]
}, },
@ -598,15 +645,7 @@
}, },
{ {
"Type": "NodeText", "Type": "NodeText",
"Data": ": この関数は" "Data": ": この関数はデータベースへのクエリに使用され、戻り値は結果セットです"
},
{
"Type": "NodeText",
"Data": "データベース"
},
{
"Type": "NodeText",
"Data": "へのクエリに使用され、戻り値は結果セットです"
} }
] ]
}, },

View file

@ -1518,6 +1518,17 @@ func SQLTemplateFuncs(templateFuncMap *template.FuncMap) {
retBlocks = SelectBlocksRawStmt(stmt, 1, 512) retBlocks = SelectBlocksRawStmt(stmt, 1, 512)
return return
} }
(*templateFuncMap)["getBlock"] = func(arg any) (retBlock *Block) {
switch v := arg.(type) {
case string:
retBlock = GetBlock(v)
case map[string]interface{}:
if id, ok := v["id"]; ok {
retBlock = GetBlock(id.(string))
}
}
return
}
(*templateFuncMap)["querySpans"] = func(stmt string, args ...string) (retSpans []*Span) { (*templateFuncMap)["querySpans"] = func(stmt string, args ...string) (retSpans []*Span) {
for _, arg := range args { for _, arg := range args {
stmt = strings.Replace(stmt, "?", arg, 1) stmt = strings.Replace(stmt, "?", arg, 1)