Compare commits

...

8 commits

Author SHA1 Message Date
Vanessa
3ba4985126 Merge remote-tracking branch 'origin/dev' into dev 2025-08-28 17:47:16 +08:00
Vanessa
c4770d4f88 🎨 https://github.com/siyuan-note/siyuan/pull/15610 2025-08-28 17:47:01 +08:00
Daniel
4fd57efd68
🐛 When "Default fill created time" is enabled for database date fields, the automatically filled time value is incorrect https://github.com/siyuan-note/siyuan/issues/15684 2025-08-28 17:02:55 +08:00
Jeffrey Chen
f0f15673f0
Add plugin event bus code-languages-prepare and code-languages-change (#15610) 2025-08-28 16:37:54 +08:00
Yingyi / 颖逸
ff4d215f78
🎨 Add cookie-based auth in publish proxy (#15692)
* chore(publish-auth): Add TODO for cookie-based auth in publish proxy

A TODO comment was added to indicate future implementation of authentication using cookies in the PublishServiceTransport RoundTrip method.

* 🎨 Add session-based authentication for publish proxy

Introduces session management using cookies for the publish reverse proxy server. Adds session ID generation, storage, and validation in kernel/model/auth.go, and updates the proxy transport to check for valid sessions before falling back to basic authentication. Sets a session cookie upon successful basic auth login.

* 🐛 Fixed the issue of repeatedly setting cookies

* 🎨 Dynamically remove invalid session IDs

* ♻️ Revert changes in pnpm-lock.yaml
2025-08-28 16:20:12 +08:00
Daniel
2a4adf089f
🐛 The update time of the database checkbox field keeps changing https://github.com/siyuan-note/siyuan/issues/15707 2025-08-28 16:18:35 +08:00
Daniel
810ea23bfd
📝 New template functions ISOYear, ISOMonth and ISOWeekDate https://github.com/siyuan-note/siyuan/issues/15679 2025-08-28 15:54:31 +08:00
Daniel
0f087bf1e4
🐛 Database relative date filtering is incorrect https://github.com/siyuan-note/siyuan/issues/15710 2025-08-28 15:35:09 +08:00
12 changed files with 791 additions and 51 deletions

View file

@ -6,7 +6,7 @@
"id": "20201204184532-3qm9l8n",
"title": "Template snippet",
"type": "doc",
"updated": "20250801152837"
"updated": "20250828155251"
},
"Children": [
{
@ -57,7 +57,7 @@
"HeadingLevel": 2,
"Properties": {
"id": "20210104091444-jy56z0p",
"updated": "20250801152821"
"updated": "20250828155251"
},
"Children": [
{
@ -215,7 +215,7 @@
"ListData": {},
"Properties": {
"id": "20210104091444-mwbvc9m",
"updated": "20250801152821"
"updated": "20250828155251"
},
"Children": [
{
@ -1190,7 +1190,7 @@
"Type": "NodeParagraph",
"Properties": {
"id": "20240308162632-akk8sxn",
"updated": "20240308162632"
"updated": "20250828155241"
},
"Children": [
{
@ -1204,7 +1204,136 @@
},
{
"Type": "NodeText",
"Data": ": This function is used to return the week"
"Data": ": This function returns the current week"
}
]
}
]
},
{
"ID": "20250828155216-zn0i9zg",
"Type": "NodeListItem",
"ListData": {
"BulletChar": 42,
"Marker": "Kg=="
},
"Properties": {
"id": "20250828155216-zn0i9zg",
"updated": "20250828155216"
},
"Children": [
{
"ID": "20250828155216-p5tgk3f",
"Type": "NodeParagraph",
"Properties": {
"id": "20250828155216-p5tgk3f",
"updated": "20250828155232"
},
"Children": [
{
"Type": "NodeText",
"Data": ""
},
{
"Type": "NodeTextMark",
"TextMarkType": "code",
"TextMarkTextContent": "ISOMonth"
},
{
"Type": "NodeText",
"Data": ": This function returns the current month"
}
]
}
]
},
{
"ID": "20250828155242-k9x8rc7",
"Type": "NodeListItem",
"ListData": {
"BulletChar": 42,
"Marker": "Kg=="
},
"Properties": {
"id": "20250828155242-k9x8rc7",
"updated": "20250828155242"
},
"Children": [
{
"ID": "20250828155242-zwalrdw",
"Type": "NodeParagraph",
"Properties": {
"id": "20250828155242-zwalrdw",
"updated": "20250828155246"
},
"Children": [
{
"Type": "NodeText",
"Data": ""
},
{
"Type": "NodeTextMark",
"TextMarkType": "code",
"TextMarkTextContent": "ISOYear"
},
{
"Type": "NodeText",
"Data": ": This function returns the current year"
}
]
}
]
},
{
"ID": "20250828155247-992wou3",
"Type": "NodeListItem",
"ListData": {
"BulletChar": 42,
"Marker": "Kg=="
},
"Properties": {
"id": "20250828155247-992wou3",
"updated": "20250828155251"
},
"Children": [
{
"ID": "20250828155247-ow57gpr",
"Type": "NodeParagraph",
"Properties": {
"id": "20250828155247-ow57gpr",
"updated": "20250828155251"
},
"Children": [
{
"Type": "NodeText",
"Data": ""
},
{
"Type": "NodeTextMark",
"TextMarkType": "code",
"TextMarkTextContent": "ISOWeekDate"
},
{
"Type": "NodeText",
"Data": ": This function returns the date of a specified day of the week using "
},
{
"Type": "NodeTextMark",
"TextMarkType": "code",
"TextMarkTextContent": "time.Time"
},
{
"Type": "NodeText",
"Data": ". For example, "
},
{
"Type": "NodeTextMark",
"TextMarkType": "code",
"TextMarkTextContent": ".action{ now | ISOWeekDate 4 | date \"2006-01-02\" }"
},
{
"Type": "NodeText",
"Data": " returns the date of this Thursday"
}
]
}

View file

@ -6,7 +6,7 @@
"id": "20201204181006-7bkppue",
"title": "模板片段",
"type": "doc",
"updated": "20250801152724"
"updated": "20250828154937"
},
"Children": [
{
@ -69,7 +69,7 @@
"HeadingLevel": 2,
"Properties": {
"id": "20210104091309-fhb549c",
"updated": "20250801152510"
"updated": "20250828154937"
},
"Children": [
{
@ -237,7 +237,7 @@
"ListData": {},
"Properties": {
"id": "20210104091309-gjkg3u5",
"updated": "20250801152510"
"updated": "20250828154937"
},
"Children": [
{
@ -271,7 +271,15 @@
},
{
"Type": "NodeText",
"Data": "​:该变量用于插入当前文档名。比如模板内容为 "
"Data": "​:该变量用于插入当前文档名。比如"
},
{
"Type": "NodeText",
"Data": "模板"
},
{
"Type": "NodeText",
"Data": "内容为 "
},
{
"Type": "NodeTextMark",
@ -391,7 +399,11 @@
},
{
"Type": "NodeText",
"Data": "​:该变量用于插入当前文档别名"
"Data": "​:该变量用于插入当前"
},
{
"Type": "NodeText",
"Data": "文档别名"
}
]
}
@ -465,7 +477,19 @@
},
{
"Type": "NodeText",
"Data": "​:该函数用于查询数据库,返回值为 blocks 列表"
"Data": "​:该函数用于查询"
},
{
"Type": "NodeText",
"Data": "数据库"
},
{
"Type": "NodeText",
"Data": ",返回值为 blocks "
},
{
"Type": "NodeText",
"Data": "列表"
}
]
},
@ -530,7 +554,15 @@
},
{
"Type": "NodeText",
"Data": "​:该函数用于根据块 ID 查询数据库,返回值为 block"
"Data": "​:该函数用于根据块 ID 查询"
},
{
"Type": "NodeText",
"Data": "数据库"
},
{
"Type": "NodeText",
"Data": ",返回值为 block"
}
]
},
@ -594,7 +626,19 @@
},
{
"Type": "NodeText",
"Data": "​:该函数用于查询数据库,返回值为 spans 列表"
"Data": "​:该函数用于查询"
},
{
"Type": "NodeText",
"Data": "数据库"
},
{
"Type": "NodeText",
"Data": ",返回值为 spans "
},
{
"Type": "NodeText",
"Data": "列表"
}
]
},
@ -659,7 +703,15 @@
},
{
"Type": "NodeText",
"Data": "​:该函数用于查询数据库,返回值为结果集"
"Data": "​:该函数用于查询"
},
{
"Type": "NodeText",
"Data": "数据库"
},
{
"Type": "NodeText",
"Data": ",返回值为结果集"
}
]
},
@ -1204,7 +1256,7 @@
},
"Properties": {
"id": "20240308162139-yt96e2z",
"updated": "20240308162139"
"updated": "20250828154937"
},
"Children": [
{
@ -1212,7 +1264,7 @@
"Type": "NodeParagraph",
"Properties": {
"id": "20240308162139-x4evb04",
"updated": "20240308162153"
"updated": "20250828154937"
},
"Children": [
{
@ -1226,7 +1278,136 @@
},
{
"Type": "NodeText",
"Data": "​:该函数用于返回第几周"
"Data": "​:该函数用于返回当前周"
}
]
}
]
},
{
"ID": "20250828154237-r8vhx3a",
"Type": "NodeListItem",
"ListData": {
"BulletChar": 42,
"Marker": "Kg=="
},
"Properties": {
"id": "20250828154237-r8vhx3a",
"updated": "20250828154248"
},
"Children": [
{
"ID": "20250828154237-2kgeyrr",
"Type": "NodeParagraph",
"Properties": {
"id": "20250828154237-2kgeyrr",
"updated": "20250828154248"
},
"Children": [
{
"Type": "NodeText",
"Data": ""
},
{
"Type": "NodeTextMark",
"TextMarkType": "code",
"TextMarkTextContent": "ISOMonth"
},
{
"Type": "NodeText",
"Data": "​:该函数用于返回当前月份"
}
]
}
]
},
{
"ID": "20250828154157-thdko4b",
"Type": "NodeListItem",
"ListData": {
"BulletChar": 42,
"Marker": "Kg=="
},
"Properties": {
"id": "20250828154157-thdko4b",
"updated": "20250828154157"
},
"Children": [
{
"ID": "20250828154157-s8wsy4j",
"Type": "NodeParagraph",
"Properties": {
"id": "20250828154157-s8wsy4j",
"updated": "20250828154231"
},
"Children": [
{
"Type": "NodeText",
"Data": ""
},
{
"Type": "NodeTextMark",
"TextMarkType": "code",
"TextMarkTextContent": "ISOYear"
},
{
"Type": "NodeText",
"Data": "​:该函数用于返回当前年份"
}
]
}
]
},
{
"ID": "20250828154232-7ryi07m",
"Type": "NodeListItem",
"ListData": {
"BulletChar": 42,
"Marker": "Kg=="
},
"Properties": {
"id": "20250828154232-7ryi07m",
"updated": "20250828154731"
},
"Children": [
{
"ID": "20250828154232-97gwy4i",
"Type": "NodeParagraph",
"Properties": {
"id": "20250828154232-97gwy4i",
"updated": "20250828154731"
},
"Children": [
{
"Type": "NodeText",
"Data": ""
},
{
"Type": "NodeTextMark",
"TextMarkType": "code",
"TextMarkTextContent": "ISOWeekDate"
},
{
"Type": "NodeText",
"Data": "​:该函数用于返回指定周几的日期 "
},
{
"Type": "NodeTextMark",
"TextMarkType": "code",
"TextMarkTextContent": "time.Time"
},
{
"Type": "NodeText",
"Data": "​,例如返回本周四的日期 "
},
{
"Type": "NodeTextMark",
"TextMarkType": "code",
"TextMarkTextContent": ".action{ now | ISOWeekDate 4 | date \"2006-01-02\" }"
},
{
"Type": "NodeText",
"Data": ""
}
]
}

View file

@ -6,7 +6,7 @@
"id": "20211226123004-dplpw0o",
"title": "範本片段",
"type": "doc",
"updated": "20250801152721"
"updated": "20250828155154"
},
"Children": [
{
@ -53,7 +53,7 @@
"HeadingLevel": 2,
"Properties": {
"id": "20211226123024-eyagqur",
"updated": "20250801152602"
"updated": "20250828155154"
},
"Children": [
{
@ -208,7 +208,7 @@
"ListData": {},
"Properties": {
"id": "20211226123024-pjvw31z",
"updated": "20250801152602"
"updated": "20250828155154"
},
"Children": [
{
@ -436,7 +436,19 @@
},
{
"Type": "NodeText",
"Data": "​:該函數用於查詢資料庫,返回值為 blocks 列表"
"Data": "​:該函數用於查詢"
},
{
"Type": "NodeText",
"Data": "資料庫"
},
{
"Type": "NodeText",
"Data": ",返回值為 blocks "
},
{
"Type": "NodeText",
"Data": "列表"
}
]
},
@ -501,7 +513,15 @@
},
{
"Type": "NodeText",
"Data": "​:函數用於根據塊 ID 查詢資料庫,傳回值為 block"
"Data": "​:函數用於根據塊 ID 查詢"
},
{
"Type": "NodeText",
"Data": "資料庫"
},
{
"Type": "NodeText",
"Data": ",傳回值為 block"
}
]
},
@ -565,7 +585,19 @@
},
{
"Type": "NodeText",
"Data": "​:該函數用於查詢資料庫,返回值為 spans 列表"
"Data": "​:該函數用於查詢"
},
{
"Type": "NodeText",
"Data": "資料庫"
},
{
"Type": "NodeText",
"Data": ",返回值為 spans "
},
{
"Type": "NodeText",
"Data": "列表"
}
]
},
@ -630,7 +662,15 @@
},
{
"Type": "NodeText",
"Data": "​:函數用於查詢資料庫,傳回值為結果集"
"Data": "​:函數用於查詢"
},
{
"Type": "NodeText",
"Data": "資料庫"
},
{
"Type": "NodeText",
"Data": ",傳回值為結果集"
}
]
},
@ -1183,7 +1223,7 @@
"Type": "NodeParagraph",
"Properties": {
"id": "20240308162753-tde2ifs",
"updated": "20240308162753"
"updated": "20250828154943"
},
"Children": [
{
@ -1197,7 +1237,136 @@
},
{
"Type": "NodeText",
"Data": "​:此函數用於傳回第幾週"
"Data": "​:此函數用於傳回目前週"
}
]
}
]
},
{
"ID": "20250828154909-wxnydc5",
"Type": "NodeListItem",
"ListData": {
"BulletChar": 42,
"Marker": "Kg=="
},
"Properties": {
"id": "20250828154909-wxnydc5",
"updated": "20250828154909"
},
"Children": [
{
"ID": "20250828154909-3grwety",
"Type": "NodeParagraph",
"Properties": {
"id": "20250828154909-3grwety",
"updated": "20250828154910"
},
"Children": [
{
"Type": "NodeText",
"Data": ""
},
{
"Type": "NodeTextMark",
"TextMarkType": "code",
"TextMarkTextContent": "ISOMonth"
},
{
"Type": "NodeText",
"Data": "​:此函數用於傳回目前月份"
}
]
}
]
},
{
"ID": "20250828154911-8n67tvc",
"Type": "NodeListItem",
"ListData": {
"BulletChar": 42,
"Marker": "Kg=="
},
"Properties": {
"id": "20250828154911-8n67tvc",
"updated": "20250828154911"
},
"Children": [
{
"ID": "20250828154911-bb7z59o",
"Type": "NodeParagraph",
"Properties": {
"id": "20250828154911-bb7z59o",
"updated": "20250828154916"
},
"Children": [
{
"Type": "NodeText",
"Data": ""
},
{
"Type": "NodeTextMark",
"TextMarkType": "code",
"TextMarkTextContent": "ISOYear"
},
{
"Type": "NodeText",
"Data": "​:此函數用於傳回目前年份"
}
]
}
]
},
{
"ID": "20250828154949-xhbwn4e",
"Type": "NodeListItem",
"ListData": {
"BulletChar": 42,
"Marker": "Kg=="
},
"Properties": {
"id": "20250828154949-xhbwn4e",
"updated": "20250828155154"
},
"Children": [
{
"ID": "20250828154949-5lcfpbs",
"Type": "NodeParagraph",
"Properties": {
"id": "20250828154949-5lcfpbs",
"updated": "20250828155154"
},
"Children": [
{
"Type": "NodeText",
"Data": ""
},
{
"Type": "NodeTextMark",
"TextMarkType": "code",
"TextMarkTextContent": "ISOWeekDate"
},
{
"Type": "NodeText",
"Data": "​:此函數用於傳回指定週幾的日期 "
},
{
"Type": "NodeTextMark",
"TextMarkType": "code",
"TextMarkTextContent": "time.Time"
},
{
"Type": "NodeText",
"Data": "​,例如傳回本週四的日期 "
},
{
"Type": "NodeTextMark",
"TextMarkType": "code",
"TextMarkTextContent": ".action{ now | ISOWeekDate 4 | date \"2006-01-02\" }"
},
{
"Type": "NodeText",
"Data": ""
}
]
}

View file

@ -7,7 +7,7 @@
"id": "20240530101000-6x9ivi7",
"title": "テンプレートスニペット",
"type": "doc",
"updated": "20250801152939"
"updated": "20250828155138"
},
"Children": [
{
@ -66,7 +66,7 @@
"Properties": {
"ID": "20240530101000-5nvn9ad",
"id": "20240530101000-pi05yzt",
"updated": "20250801152922"
"updated": "20250828155138"
},
"Children": [
{
@ -226,7 +226,7 @@
"ListData": {},
"Properties": {
"id": "20240530101000-by5hqnb",
"updated": "20250801152922"
"updated": "20250828155138"
},
"Children": [
{
@ -260,7 +260,15 @@
},
{
"Type": "NodeText",
"Data": ": この変数は現在のドキュメント名を挿入します。たとえば、テンプレートの内容が "
"Data": ": この変数は現在のドキュメント名を挿入します。たとえば、"
},
{
"Type": "NodeText",
"Data": "テンプレート"
},
{
"Type": "NodeText",
"Data": "の内容が "
},
{
"Type": "NodeTextMark",
@ -454,7 +462,15 @@
},
{
"Type": "NodeText",
"Data": ": この関数はデータベースをクエリしてブロックのリストを返します"
"Data": ": この関数は"
},
{
"Type": "NodeText",
"Data": "データベース"
},
{
"Type": "NodeText",
"Data": "をクエリしてブロックのリストを返します"
}
]
},
@ -519,7 +535,15 @@
},
{
"Type": "NodeText",
"Data": ": この関数はブロックIDに基づいてデータベースを照会するために使用され、戻り値はブロックです"
"Data": ": この関数はブロックIDに基づいて"
},
{
"Type": "NodeText",
"Data": "データベース"
},
{
"Type": "NodeText",
"Data": "を照会するために使用され、戻り値はブロックです"
}
]
},
@ -583,7 +607,15 @@
},
{
"Type": "NodeText",
"Data": ": この関数はデータベースをクエリしてスパンのリストを返します"
"Data": ": この関数は"
},
{
"Type": "NodeText",
"Data": "データベース"
},
{
"Type": "NodeText",
"Data": "をクエリしてスパンのリストを返します"
}
]
},
@ -648,7 +680,15 @@
},
{
"Type": "NodeText",
"Data": ": この関数はデータベースへのクエリに使用され、戻り値は結果セットです"
"Data": ": この関数は"
},
{
"Type": "NodeText",
"Data": "データベース"
},
{
"Type": "NodeText",
"Data": "へのクエリに使用され、戻り値は結果セットです"
}
]
},
@ -1221,6 +1261,135 @@
}
]
},
{
"ID": "20250828155049-69k1o8n",
"Type": "NodeListItem",
"ListData": {
"BulletChar": 42,
"Marker": "Kg=="
},
"Properties": {
"id": "20250828155049-69k1o8n",
"updated": "20250828155049"
},
"Children": [
{
"ID": "20250828155049-vbcmh76",
"Type": "NodeParagraph",
"Properties": {
"id": "20250828155049-vbcmh76",
"updated": "20250828155051"
},
"Children": [
{
"Type": "NodeText",
"Data": ""
},
{
"Type": "NodeTextMark",
"TextMarkType": "code",
"TextMarkTextContent": "ISOMonth"
},
{
"Type": "NodeText",
"Data": ": この関数は現在の月を返します"
}
]
}
]
},
{
"ID": "20250828155051-8r71644",
"Type": "NodeListItem",
"ListData": {
"BulletChar": 42,
"Marker": "Kg=="
},
"Properties": {
"id": "20250828155051-8r71644",
"updated": "20250828155051"
},
"Children": [
{
"ID": "20250828155051-d8e3faa",
"Type": "NodeParagraph",
"Properties": {
"id": "20250828155051-d8e3faa",
"updated": "20250828155057"
},
"Children": [
{
"Type": "NodeText",
"Data": ""
},
{
"Type": "NodeTextMark",
"TextMarkType": "code",
"TextMarkTextContent": "ISOYear"
},
{
"Type": "NodeText",
"Data": ": この関数は現在の年を返します"
}
]
}
]
},
{
"ID": "20250828155057-hqlahyc",
"Type": "NodeListItem",
"ListData": {
"BulletChar": 42,
"Marker": "Kg=="
},
"Properties": {
"id": "20250828155057-hqlahyc",
"updated": "20250828155138"
},
"Children": [
{
"ID": "20250828155057-s2ugs9d",
"Type": "NodeParagraph",
"Properties": {
"id": "20250828155057-s2ugs9d",
"updated": "20250828155138"
},
"Children": [
{
"Type": "NodeText",
"Data": ""
},
{
"Type": "NodeTextMark",
"TextMarkType": "code",
"TextMarkTextContent": "ISOWeekDate"
},
{
"Type": "NodeText",
"Data": ": この関数は、"
},
{
"Type": "NodeTextMark",
"TextMarkType": "code",
"TextMarkTextContent": "time.Time"
},
{
"Type": "NodeText",
"Data": " を使用して指定された曜日の日付を返します。例えば、"
},
{
"Type": "NodeTextMark",
"TextMarkType": "code",
"TextMarkTextContent": ".action{now | ISOWeekDate 4 | date \"2006-01-02\" }"
},
{
"Type": "NodeText",
"Data": " は今週の木曜日の日付を返します"
}
]
}
]
},
{
"ID": "20240530101000-q2rf0ys",
"Type": "NodeListItem",

View file

@ -1227,7 +1227,16 @@ export class Toolbar {
window.siyuan.menus.menu.remove();
this.range = getEditorRange(nodeElement);
let html = `<div class="b3-list-item">${window.siyuan.languages.clear}</div>`;
const hljsLanguages = Constants.ALIAS_CODE_LANGUAGES.concat(window.hljs?.listLanguages() ?? []).sort();
let hljsLanguages = Constants.ALIAS_CODE_LANGUAGES.concat(window.hljs?.listLanguages() ?? []).sort();
const eventDetail = {languages: hljsLanguages};
if (protyle.app && protyle.app.plugins) {
protyle.app.plugins.forEach((plugin: any) => {
plugin.eventBus.emit("code-language-before", eventDetail);
});
}
hljsLanguages = eventDetail.languages;
hljsLanguages.forEach((item, index) => {
html += `<div class="b3-list-item${index === 0 ? " b3-list-item--focus" : ""}">${item}</div>`;
});
@ -1744,15 +1753,26 @@ ${item.name}
}
}
private updateLanguage(languageElement: HTMLElement[], protyle: IProtyle, selectedLang: string) {
private updateLanguage(languageElements: HTMLElement[], protyle: IProtyle, selectedLang: string) {
const currentLang = selectedLang === window.siyuan.languages.clear ? "" : selectedLang;
if (protyle.app && protyle.app.plugins) {
protyle.app.plugins.forEach((plugin: any) => {
plugin.eventBus.emit("code-language-change", {
language: currentLang,
languageElements,
protyle: protyle
});
});
}
if (!Constants.SIYUAN_RENDER_CODE_LANGUAGES.includes(currentLang)) {
window.siyuan.storage[Constants.LOCAL_CODELANG] = currentLang;
setStorageVal(Constants.LOCAL_CODELANG, window.siyuan.storage[Constants.LOCAL_CODELANG]);
}
const doOperations: IOperation[] = [];
const undoOperations: IOperation[] = [];
languageElement.forEach(item => {
languageElements.forEach(item => {
const nodeElement = hasClosestBlock(item);
if (nodeElement) {
const id = nodeElement.getAttribute("data-node-id");

View file

@ -85,7 +85,8 @@ type TEventBus = "ws-main" | "sync-start" | "sync-end" | "sync-fail" |
"switch-protyle" | "switch-protyle-mode" |
"destroy-protyle" |
"lock-screen" |
"mobile-keyboard-show" | "mobile-keyboard-hide"
"mobile-keyboard-show" | "mobile-keyboard-hide" |
"code-language-before" | "code-language-change"
type TAVView = "table" | "gallery"
type TAVCol =
"text"

View file

@ -285,10 +285,8 @@ func (value *Value) filter(other *Value, relativeDate, relativeDate2 *RelativeDa
}
}
case KeyTypeDate:
if nil != value.Date && nil != other && nil != other.Date {
if !other.Date.IsNotEmpty {
return true
}
if nil != value.Date && nil != other && nil != other.Date && nil == relativeDate && !other.Date.IsNotEmpty {
return true
}
if nil != value.Date {

View file

@ -37,6 +37,7 @@ require (
github.com/go-ole/go-ole v1.3.0
github.com/gofrs/flock v0.12.1
github.com/golang-jwt/jwt/v5 v5.2.2
github.com/google/uuid v1.6.0
github.com/gorilla/css v1.0.1
github.com/gorilla/websocket v1.5.3
github.com/imroc/req/v3 v3.54.2
@ -129,7 +130,6 @@ require (
github.com/goccy/go-json v0.10.5 // indirect
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect
github.com/google/pprof v0.0.0-20250607225305-033d6d78b36a // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gopherjs/gopherjs v1.17.2 // indirect
github.com/gorilla/context v1.1.2 // indirect
github.com/gorilla/securecookie v1.1.2 // indirect

View file

@ -154,6 +154,10 @@ func getAttrViewAddingBlockDefaultValues(attrView *av.AttributeView, view, group
nearValue := getNewValueByNearItem(nearItem, keyValues.Key, addingItemID)
newValue.Date.IsNotTime = nearValue.Date.IsNotTime
}
if nil != keyValues.Key.Date && keyValues.Key.Date.AutoFillNow {
newValue.Date.Content = time.Now().UnixMilli()
}
}
ret[keyValues.Key.ID] = newValue
@ -219,7 +223,12 @@ func getAttrViewAddingBlockDefaultValues(attrView *av.AttributeView, view, group
if nil != nearItem && filterKeyIDs[groupKey.ID] {
// 临近项不为空并且分组字段和过滤字段相同时,优先使用临近项 https://github.com/siyuan-note/siyuan/issues/15591
ret[groupKey.ID] = getNewValueByNearItem(nearItem, groupKey, addingItemID)
newValue = getNewValueByNearItem(nearItem, groupKey, addingItemID)
ret[groupKey.ID] = newValue
if nil != keyValues.Key.Date && keyValues.Key.Date.AutoFillNow {
newValue.Date.Content = time.Now().UnixMilli()
}
return
}
@ -254,6 +263,10 @@ func getAttrViewAddingBlockDefaultValues(attrView *av.AttributeView, view, group
if nil != newValue && !filterKeyIDs[groupKey.ID] {
ret[groupKey.ID] = newValue
if nil != keyValues.Key.Date && keyValues.Key.Date.AutoFillNow {
newValue.Date.Content = time.Now().UnixMilli()
}
}
return
}

View file

@ -19,8 +19,10 @@ package model
import (
"crypto/rand"
"net/http"
"sync"
"github.com/golang-jwt/jwt/v5"
"github.com/google/uuid"
"github.com/siyuan-note/logging"
)
@ -29,12 +31,15 @@ type Account struct {
Password string
Token string
}
type AccountsMap map[string]*Account
type AccountsMap map[string]*Account // username -> account
type SessionsMap map[string]string // sessionID -> username
type ClaimsKeyType string
const (
XAuthTokenKey = "X-Auth-Token"
SessionIdCookieName = "publish-visitor-session-id"
ClaimsContextKey = "claims"
iss = "siyuan-publish-reverse-proxy-server"
@ -46,13 +51,37 @@ const (
var (
accountsMap = AccountsMap{}
jwtKey = make([]byte, 32)
sessionsMap = SessionsMap{}
sessionLock = sync.Mutex{}
jwtKey = make([]byte, 32)
)
func GetBasicAuthAccount(username string) *Account {
return accountsMap[username]
}
func GetBasicAuthUsernameBySessionID(sessionID string) string {
return sessionsMap[sessionID]
}
func GetNewSessionID() string {
sessionID := uuid.New().String()
return sessionID
}
func AddSession(sessionID, username string) {
sessionLock.Lock()
defer sessionLock.Unlock()
sessionsMap[sessionID] = username
}
func DeleteSession(sessionID string) {
sessionLock.Lock()
defer sessionLock.Unlock()
delete(sessionsMap, sessionID)
}
func InitAccounts() {
accountsMap = AccountsMap{
"": &Account{}, // 匿名用户

View file

@ -125,10 +125,28 @@ func rewrite(r *httputil.ProxyRequest) {
func (PublishServiceTransport) RoundTrip(request *http.Request) (response *http.Response, err error) {
if model.Conf.Publish.Auth.Enable {
// Session Auth
sessionIdCookie, cookieErr := request.Cookie(model.SessionIdCookieName)
if cookieErr == nil {
// Check session ID
sessionID := sessionIdCookie.Value
if username := model.GetBasicAuthUsernameBySessionID(sessionID); username != "" {
// Valid session
if account := model.GetBasicAuthAccount(username); account != nil {
// Valid account
request.Header.Set(model.XAuthTokenKey, account.Token)
response, err = http.DefaultTransport.RoundTrip(request)
return
} else {
// Invalid account, remove session
model.DeleteSession(sessionID)
}
}
}
// Basic Auth
username, password, ok := request.BasicAuth()
account := model.GetBasicAuthAccount(username)
if !ok ||
account == nil ||
account.Username == "" || // 匿名用户
@ -149,13 +167,26 @@ func (PublishServiceTransport) RoundTrip(request *http.Request) (response *http.
ContentLength: -1,
}, nil
} else {
// set session cookie
sessionID := model.GetNewSessionID()
cookie := &http.Cookie{
Name: model.SessionIdCookieName,
Value: sessionID,
Path: "/",
HttpOnly: true,
}
model.AddSession(sessionID, username)
// set JWT
request.Header.Set(model.XAuthTokenKey, account.Token)
response, err = http.DefaultTransport.RoundTrip(request)
response.Header.Add("Set-Cookie", cookie.String())
return
}
} else {
request.Header.Set(model.XAuthTokenKey, model.GetBasicAuthAccount("").Token)
response, err = http.DefaultTransport.RoundTrip(request)
return
}
response, err = http.DefaultTransport.RoundTrip(request)
return
}

View file

@ -84,7 +84,7 @@ func RenderAttributeViewTable(attrView *av.AttributeView, view *av.View, query s
if nil == tableCell {
tableCell = &av.TableCell{
BaseValue: &av.BaseValue{
ID: ast.NewNodeID(),
ID: rowID[:14] + ast.NewNodeID()[14:],
ValueType: col.Type,
},
}