An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: 改进 `网络图片转换为本地图片` 文件名后缀 Fix https://github.com/siyuan-note/siyuan/issues/5053
Liang Dinga43c5c5b4048
diff --git a/README.md b/README.mdindex 8498841b28..3fc609e628 100644--- a/README.md+++ b/README.md@@ -261,6 +261,7 @@ SiYuan is made possible by the following open source projects.* [https://github.com/facette/natsort](https://github.com/facette/natsort) `BSD-3-Clause License`* [https://github.com/flopp/go-findfont](https://github.com/flopp/go-findfont) `MIT License`* [https://github.com/fsnotify/fsnotify](https://github.com/fsnotify/fsnotify) `BSD-3-Clause License`+* [https://github.com/gabriel-vasile/mimetype](https://github.com/gabriel-vasile/mimetype) `MIT License`* [https://github.com/gin-contrib/cors](https://github.com/gin-contrib/cors) `MIT License`* [https://github.com/gin-contrib/gzip](https://github.com/gin-contrib/gzip) `MIT License`* [https://github.com/gin-contrib/sessions](https://github.com/gin-contrib/sessions) `MIT License`diff --git a/README_zh_CN.md b/README_zh_CN.mdindex 1e1f28a355..e4bd426a1e 100644--- a/README_zh_CN.md+++ b/README_zh_CN.md@@ -269,6 +269,7 @@* [https://github.com/facette/natsort](https://github.com/facette/natsort) `BSD-3-Clause License`* [https://github.com/flopp/go-findfont](https://github.com/flopp/go-findfont) `MIT License`* [https://github.com/fsnotify/fsnotify](https://github.com/fsnotify/fsnotify) `BSD-3-Clause License`+* [https://github.com/gabriel-vasile/mimetype](https://github.com/gabriel-vasile/mimetype) `MIT License`* [https://github.com/gin-contrib/cors](https://github.com/gin-contrib/cors) `MIT License`* [https://github.com/gin-contrib/gzip](https://github.com/gin-contrib/gzip) `MIT License`* [https://github.com/gin-contrib/sessions](https://github.com/gin-contrib/sessions) `MIT License`diff --git a/app/guide/20210808180117-6v0mkxr/20201121224345-rc27qvo.sy b/app/guide/20210808180117-6v0mkxr/20201121224345-rc27qvo.syindex 88ca399f6c..5081bbf955 100644--- a/app/guide/20210808180117-6v0mkxr/20201121224345-rc27qvo.sy+++ b/app/guide/20210808180117-6v0mkxr/20201121224345-rc27qvo.sy@@ -6,7 +6,7 @@"id": "20201121224345-rc27qvo","title": "Acknowledgements","type": "doc",- "updated": "20220522101213"+ "updated": "20220530180108"},"Children": [{@@ -29,7 +29,7 @@"ListData": {},"Properties": {"id": "20220522101213-z3hokh2",- "updated": "20220522101213"+ "updated": "20220530180108"},"Children": [{@@ -1572,6 +1572,76 @@}]},+ {+ "ID": "20220530180107-u2pjucg",+ "Type": "NodeListItem",+ "ListData": {+ "BulletChar": 42,+ "Marker": "Kg=="+ },+ "Properties": {+ "id": "20220530180107-u2pjucg",+ "updated": "20220530180108"+ },+ "Children": [+ {+ "ID": "20220530180107-zbx81j2",+ "Type": "NodeParagraph",+ "Properties": {+ "id": "20220530180107-zbx81j2",+ "updated": "20220530180108"+ },+ "Children": [+ {+ "Type": "NodeLink",+ "Data": "span",+ "Children": [+ {+ "Type": "NodeOpenBracket"+ },+ {+ "Type": "NodeLinkText",+ "Data": "https://github.com/gabriel-vasile/mimetype"+ },+ {+ "Type": "NodeCloseBracket"+ },+ {+ "Type": "NodeOpenParen"+ },+ {+ "Type": "NodeLinkDest",+ "Data": "https://github.com/gabriel-vasile/mimetype"+ },+ {+ "Type": "NodeCloseParen"+ }+ ]+ },+ {+ "Type": "NodeText",+ "Data": " "+ },+ {+ "Type": "NodeCodeSpan",+ "Data": "code",+ "Children": [+ {+ "Type": "NodeCodeSpanOpenMarker"+ },+ {+ "Type": "NodeCodeSpanContent",+ "Data": "MIT License"+ },+ {+ "Type": "NodeCodeSpanCloseMarker"+ }+ ]+ }+ ]+ }+ ]+ },{"ID": "20220522101213-xvc77du","Type": "NodeListItem",diff --git a/app/guide/20210808180117-czj9bvb/20201121212605-9td1a62.sy b/app/guide/20210808180117-czj9bvb/20201121212605-9td1a62.syindex 998d3c2ec5..87a339b87d 100644--- a/app/guide/20210808180117-czj9bvb/20201121212605-9td1a62.sy+++ b/app/guide/20210808180117-czj9bvb/20201121212605-9td1a62.sy@@ -6,7 +6,7 @@"id": "20201121212605-9td1a62","title": "致谢","type": "doc",- "updated": "20220522101224"+ "updated": "20220530180055"},"Children": [{@@ -29,7 +29,7 @@"ListData": {},"Properties": {"id": "20220522101224-ctmcj3d",- "updated": "20220522101224"+ "updated": "20220530180055"},"Children": [{@@ -1511,7 +1511,7 @@},"Properties": {"id": "20220522101224-gbd2na7",- "updated": "20220522101224"+ "updated": "20220530180049"},"Children": [{@@ -1519,7 +1519,7 @@"Type": "NodeParagraph","Properties": {"id": "20220522101224-mwz2rxp",- "updated": "20220522101224"+ "updated": "20220530180049"},"Children": [{@@ -1572,6 +1572,76 @@}]},+ {+ "ID": "20220530180049-796wwcg",+ "Type": "NodeListItem",+ "ListData": {+ "BulletChar": 42,+ "Marker": "Kg=="+ },+ "Properties": {+ "id": "20220530180049-796wwcg",+ "updated": "20220530180055"+ },+ "Children": [+ {+ "ID": "20220530180049-qvs3gi0",+ "Type": "NodeParagraph",+ "Properties": {+ "id": "20220530180049-qvs3gi0",+ "updated": "20220530180055"+ },+ "Children": [+ {+ "Type": "NodeLink",+ "Data": "span",+ "Children": [+ {+ "Type": "NodeOpenBracket"+ },+ {+ "Type": "NodeLinkText",+ "Data": "https://github.com/gabriel-vasile/mimetype"+ },+ {+ "Type": "NodeCloseBracket"+ },+ {+ "Type": "NodeOpenParen"+ },+ {+ "Type": "NodeLinkDest",+ "Data": "https://github.com/gabriel-vasile/mimetype"+ },+ {+ "Type": "NodeCloseParen"+ }+ ]+ },+ {+ "Type": "NodeText",+ "Data": " "+ },+ {+ "Type": "NodeCodeSpan",+ "Data": "code",+ "Children": [+ {+ "Type": "NodeCodeSpanOpenMarker"+ },+ {+ "Type": "NodeCodeSpanContent",+ "Data": "MIT License"+ },+ {+ "Type": "NodeCodeSpanCloseMarker"+ }+ ]+ }+ ]+ }+ ]+ },{"ID": "20220522101224-rb7cnss","Type": "NodeListItem",diff --git a/app/guide/20211226090932-5lcq56f/20211226114929-08ap1r0.sy b/app/guide/20211226090932-5lcq56f/20211226114929-08ap1r0.syindex 4f97fe7630..b99deef9eb 100644--- a/app/guide/20211226090932-5lcq56f/20211226114929-08ap1r0.sy+++ b/app/guide/20211226090932-5lcq56f/20211226114929-08ap1r0.sy@@ -5,7 +5,7 @@"icon": "1f64f","id": "20211226114929-08ap1r0","title": "致謝",- "updated": "20220522101124"+ "updated": "20220530180118"},"Children": [{@@ -28,7 +28,7 @@"ListData": {},"Properties": {"id": "20220326092650-r61gazd",- "updated": "20220522101124"+ "updated": "20220530180118"},"Children": [{@@ -1571,6 +1571,76 @@}]},+ {+ "ID": "20220530180117-4u0c53m",+ "Type": "NodeListItem",+ "ListData": {+ "BulletChar": 42,+ "Marker": "Kg=="+ },+ "Properties": {+ "id": "20220530180117-4u0c53m",+ "updated": "20220530180118"+ },+ "Children": [+ {+ "ID": "20220530180117-wnowy4x",+ "Type": "NodeParagraph",+ "Properties": {+ "id": "20220530180117-wnowy4x",+ "updated": "20220530180118"+ },+ "Children": [+ {+ "Type": "NodeLink",+ "Data": "span",+ "Children": [+ {+ "Type": "NodeOpenBracket"+ },+ {+ "Type": "NodeLinkText",+ "Data": "https://github.com/gabriel-vasile/mimetype"+ },+ {+ "Type": "NodeCloseBracket"+ },+ {+ "Type": "NodeOpenParen"+ },+ {+ "Type": "NodeLinkDest",+ "Data": "https://github.com/gabriel-vasile/mimetype"+ },+ {+ "Type": "NodeCloseParen"+ }+ ]+ },+ {+ "Type": "NodeText",+ "Data": " "+ },+ {+ "Type": "NodeCodeSpan",+ "Data": "code",+ "Children": [+ {+ "Type": "NodeCodeSpanOpenMarker"+ },+ {+ "Type": "NodeCodeSpanContent",+ "Data": "MIT License"+ },+ {+ "Type": "NodeCodeSpanCloseMarker"+ }+ ]+ }+ ]+ }+ ]+ },{"ID": "20220326092650-zmj3bdd","Type": "NodeListItem",diff --git a/kernel/go.mod b/kernel/go.modindex 7d74fec5f5..03115553e0 100644--- a/kernel/go.mod+++ b/kernel/go.mod@@ -24,6 +24,7 @@ require (github.com/facette/natsort v0.0.0-20181210072756-2cd4dd1e2dcbgithub.com/flopp/go-findfont v0.1.0github.com/fsnotify/fsnotify v1.5.4+ github.com/gabriel-vasile/mimetype v1.4.0github.com/getsentry/sentry-go v0.13.0github.com/gin-contrib/cors v1.3.1github.com/gin-contrib/gzip v0.0.5@@ -32,6 +33,7 @@ require (github.com/imroc/req/v3 v3.11.3github.com/jinzhu/copier v0.3.5github.com/mattn/go-sqlite3 v2.0.3+incompatible+ github.com/mattn/go-zglob v0.0.3github.com/mitchellh/go-ps v1.0.0github.com/mssola/user_agent v0.5.3github.com/panjf2000/ants/v2 v2.5.0@@ -78,7 +80,6 @@ require (github.com/juju/errors v0.0.0-20220331221717-b38fca44723b // indirectgithub.com/leodido/go-urn v1.2.1 // indirectgithub.com/mattn/go-isatty v0.0.14 // indirect- github.com/mattn/go-zglob v0.0.3 // indirectgithub.com/mitchellh/copystructure v1.2.0 // indirectgithub.com/mitchellh/reflectwalk v1.0.2 // indirectgithub.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirectdiff --git a/kernel/go.sum b/kernel/go.sumindex 4ee08a108c..c06d3b2cce 100644--- a/kernel/go.sum+++ b/kernel/go.sum@@ -136,6 +136,8 @@ github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=github.com/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwVZI=github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU=+github.com/gabriel-vasile/mimetype v1.4.0 h1:Cn9dkdYsMIu56tGho+fqzh7XmvY2YyGU0FnbhiOsEro=+github.com/gabriel-vasile/mimetype v1.4.0/go.mod h1:fA8fi6KUiG7MgQQ+mEWotXoEOvmxRtOJlERCzSmRvr8=github.com/getsentry/sentry-go v0.13.0 h1:20dgTiUSfxRB/EhMPtxcL9ZEbM1ZdR+W/7f7NWD+xWo=github.com/getsentry/sentry-go v0.13.0/go.mod h1:EOsfu5ZdvKPfeHYV6pTVQnsjfp30+XA7//UooKNumH0=github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=@@ -554,6 +556,7 @@ golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9vgolang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc=golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=+golang.org/x/net v0.0.0-20210505024714-0287a6fb4125/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=golang.org/x/net v0.0.0-20210916014120-12bc252f5db8/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=diff --git a/kernel/model/assets.go b/kernel/model/assets.goindex 3ecbaba7f4..3f07737c8d 100644--- a/kernel/model/assets.go+++ b/kernel/model/assets.go@@ -34,6 +34,7 @@ import ("github.com/88250/gulu""github.com/88250/lute/ast""github.com/88250/lute/parse"+ "github.com/gabriel-vasile/mimetype""github.com/siyuan-note/siyuan/kernel/filesys""github.com/siyuan-note/siyuan/kernel/search""github.com/siyuan-note/siyuan/kernel/sql"@@ -116,6 +117,11 @@ func NetImg2LocalAssets(rootID string) (err error) {}name, _ = url.PathUnescape(name)ext := path.Ext(name)+ if "" == ext {+ if mtype := mimetype.Detect(data); nil != mtype {+ ext = mtype.Extension()+ }+ }if "" == ext {contentType := resp.Header.Get("Content-Type")exts, _ := mime.ExtensionsByType(contentType)