From 87fde9a1e87c9f5d428d358517b10cc027b971fa Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Wed, 16 Nov 2022 16:22:34 +0800 Subject: [PATCH 1/6] =?UTF-8?q?:art:=20=E5=9C=A8=20=E8=AE=BE=E7=BD=AE=20-?= =?UTF-8?q?=20=E6=90=9C=E7=B4=A2=20=E4=B8=AD=E5=88=86=E5=88=AB=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E8=99=9A=E6=8B=9F=E5=BC=95=E7=94=A8=E5=92=8C=E5=8F=8D?= =?UTF-8?q?=E9=93=BE=E6=8F=90=E5=8F=8A=20`=E6=9C=80=E5=A4=A7=E5=85=B3?= =?UTF-8?q?=E9=94=AE=E5=AD=97=E6=95=B0=E9=87=8F=E9=99=90=E5=88=B6`=20https?= =?UTF-8?q?://github.com/siyuan-note/siyuan/issues/6603?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/appearance/langs/en_US.json | 2 +- app/appearance/langs/es_ES.json | 2 +- app/appearance/langs/fr_FR.json | 2 +- app/appearance/langs/zh_CHT.json | 2 +- app/appearance/langs/zh_CN.json | 2 +- kernel/conf/search.go | 4 ++++ kernel/model/backlink.go | 2 +- kernel/model/conf.go | 6 ++++++ kernel/model/virutalref.go | 6 +++--- 9 files changed, 19 insertions(+), 9 deletions(-) diff --git a/app/appearance/langs/en_US.json b/app/appearance/langs/en_US.json index af6a9c1c3..2af5c263b 100644 --- a/app/appearance/langs/en_US.json +++ b/app/appearance/langs/en_US.json @@ -864,7 +864,7 @@ "35": "Rebuilding index, please wait...", "36": "There is too much content in the historical document, in order not to affect performance, it has been switched to plain text display", "37": "Do not include spaces and special symbols in the name of the cloud sync directory", - "38": "The number of mentioned keywords [%d] is too many, currently only supports up to [512] keywords", + "38": "Too many keywords mentioned [%d], adjust if necessary [Settings - Search - Backlink Mentions - Keyword Limit]", "39": "Deleting index %s", "40": "Inserting index %s", "41": "Upload completed", diff --git a/app/appearance/langs/es_ES.json b/app/appearance/langs/es_ES.json index a4d82cfb7..f2c62fccc 100644 --- a/app/appearance/langs/es_ES.json +++ b/app/appearance/langs/es_ES.json @@ -864,7 +864,7 @@ "35": "Reconstruyendo el índice, por favor espere...", "36": "Hay demasiado contenido en el documento historico, para no afectar el rendimiento, se ha cambiado a visualizacion de texto sin formato", "37": "No incluyas espacios ni símbolos especiales en el nombre del directorio de sincronización con la nube", - "38": "El número de palabras clave mencionadas [%d] son demasiados, actualmente solo admite hasta [512] palabras clave", + "38": "Demasiadas palabras clave mencionadas [%d], ajústelas si es necesario [Configuración - Búsqueda - Menciones de backlinks - Límite de palabras clave]", "39": "Eliminando índice %s", "40": "Insertando índice %s", "41": "Carga completada", diff --git a/app/appearance/langs/fr_FR.json b/app/appearance/langs/fr_FR.json index 778429ea3..ab4fad965 100644 --- a/app/appearance/langs/fr_FR.json +++ b/app/appearance/langs/fr_FR.json @@ -864,7 +864,7 @@ "35": "Recréation de l'index, veuillez patienter...", "36": "Il y a trop de contenu dans le document historique, afin de ne pas affecter les performances, il a été basculé sur l'affichage en texte brut", "37": "N'incluez pas d'espaces et de symboles spéciaux dans le nom du répertoire de synchronisation cloud", - "38": "Le nombre de mots-clés mentionnés [%d] est trop élevé, ne prend actuellement en charge que jusqu'à [512] mots-clés", + "38": "Trop de mots-clés mentionnés [%d], ajustez si nécessaire [Paramètres - Recherche - Mentions de backlink - Limite de mots-clés]", "39": "Suppression de l'index %s", "40": "Insertion de l'index %s", "41": "Transfert complété", diff --git a/app/appearance/langs/zh_CHT.json b/app/appearance/langs/zh_CHT.json index 9f7961088..eb234e307 100644 --- a/app/appearance/langs/zh_CHT.json +++ b/app/appearance/langs/zh_CHT.json @@ -864,7 +864,7 @@ "35": "正在重建索引,請稍等...", "36": "歷史文檔內容太多,為了不影響性能,已經切換為純文本顯示", "37": "雲端同步目錄的名稱請勿包含空格和特殊符號", - "38": "提及關鍵字數量 [%d] 過多,目前最多僅支援搜索 [512] 個關鍵字", + "38": "提及關鍵字數量 [%d] 過多,如有需要可以調整 [設置 - 搜索 - 反鏈提及 - 關鍵字數量限制]", "39": "正在刪除索引 %s", "40": "正在插入索引 %s", "41": "上傳完畢", diff --git a/app/appearance/langs/zh_CN.json b/app/appearance/langs/zh_CN.json index 9f7e30bd1..cd6e26e82 100644 --- a/app/appearance/langs/zh_CN.json +++ b/app/appearance/langs/zh_CN.json @@ -864,7 +864,7 @@ "35": "正在重建索引,请稍等...", "36": "历史文档内容太多,为了不影响性能,已经切换为纯文本显示", "37": "云端同步目录的名称请勿包含空格和特殊符号", - "38": "提及关键字数量 [%d] 过多,目前最多仅支持搜索 [512] 个关键字", + "38": "提及关键字数量 [%d] 过多,如有需要可以调整 [设置 - 搜索 - 反链提及 - 关键字数量限制]", "39": "正在删除索引 %s", "40": "正在插入索引 %s", "41": "上传完毕", diff --git a/kernel/conf/search.go b/kernel/conf/search.go index c85d368fa..a9e1cf740 100644 --- a/kernel/conf/search.go +++ b/kernel/conf/search.go @@ -49,11 +49,13 @@ type Search struct { BacklinkMentionAlias bool `json:"backlinkMentionAlias"` BacklinkMentionAnchor bool `json:"backlinkMentionAnchor"` BacklinkMentionDoc bool `json:"backlinkMentionDoc"` + BacklinkMentionLimit int `json:"backlinkMentionLimit"` VirtualRefName bool `json:"virtualRefName"` VirtualRefAlias bool `json:"virtualRefAlias"` VirtualRefAnchor bool `json:"virtualRefAnchor"` VirtualRefDoc bool `json:"virtualRefDoc"` + VirtualRefLimit int `json:"virtualRefLimit"` } func NewSearch() *Search { @@ -82,11 +84,13 @@ func NewSearch() *Search { BacklinkMentionAlias: false, BacklinkMentionAnchor: true, BacklinkMentionDoc: true, + BacklinkMentionLimit: 512, VirtualRefName: true, VirtualRefAlias: false, VirtualRefAnchor: true, VirtualRefDoc: true, + VirtualRefLimit: 512, } } diff --git a/kernel/model/backlink.go b/kernel/model/backlink.go index 66da9cc01..372c3d817 100644 --- a/kernel/model/backlink.go +++ b/kernel/model/backlink.go @@ -737,7 +737,7 @@ func searchBackmention(mentionKeywords []string, keyword string, excludeBacklink buf := bytes.Buffer{} buf.WriteString("SELECT * FROM " + table + " WHERE " + table + " MATCH '{content}:(") for i, mentionKeyword := range mentionKeywords { - if 511 < i { // 提及搜索最大限制 https://github.com/siyuan-note/siyuan/issues/3715 + if Conf.Search.BacklinkMentionLimit < i { util.PushMsg(fmt.Sprintf(Conf.Language(38), len(mentionKeywords)), 5000) mentionKeyword = strings.ReplaceAll(mentionKeyword, "\"", "\"\"") buf.WriteString("\"" + mentionKeyword + "\"") diff --git a/kernel/model/conf.go b/kernel/model/conf.go index 52c5b9af1..2576ca6ca 100644 --- a/kernel/model/conf.go +++ b/kernel/model/conf.go @@ -278,6 +278,12 @@ func InitConf() { if 1 > Conf.Search.Limit { Conf.Search.Limit = 64 } + if 1 > Conf.Search.BacklinkMentionLimit { + Conf.Search.BacklinkMentionLimit = 512 + } + if 1 > Conf.Search.VirtualRefLimit { + Conf.Search.VirtualRefLimit = 512 + } if nil == Conf.Stat { Conf.Stat = conf.NewStat() diff --git a/kernel/model/virutalref.go b/kernel/model/virutalref.go index 0e7614955..4fa5173d0 100644 --- a/kernel/model/virutalref.go +++ b/kernel/model/virutalref.go @@ -109,9 +109,9 @@ func getVirtualRefKeywords(docName string) (ret []string) { // 虚拟引用排除当前文档名 https://github.com/siyuan-note/siyuan/issues/4537 ret = gulu.Str.ExcludeElem(ret, []string{docName}) ret = prepareMarkKeywords(ret) - // 虚拟引用搜索关键字最多支持 `搜索结果显示数` 的 8 倍 https://github.com/siyuan-note/siyuan/issues/6603 - if Conf.Search.Limit*8 < len(ret) { - ret = ret[:Conf.Search.Limit*8] + + if Conf.Search.VirtualRefLimit < len(ret) { + ret = ret[:Conf.Search.VirtualRefLimit] } return } From deba07c4ad01ddc090c1dbd1b11b1059f4408d4d Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Wed, 16 Nov 2022 17:41:45 +0800 Subject: [PATCH 2/6] =?UTF-8?q?:art:=20=E5=9C=A8=20=E8=AE=BE=E7=BD=AE=20-?= =?UTF-8?q?=20=E6=90=9C=E7=B4=A2=20=E4=B8=AD=E5=88=86=E5=88=AB=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E8=99=9A=E6=8B=9F=E5=BC=95=E7=94=A8=E5=92=8C=E5=8F=8D?= =?UTF-8?q?=E9=93=BE=E6=8F=90=E5=8F=8A=20`=E5=85=B3=E9=94=AE=E5=AD=97?= =?UTF-8?q?=E6=95=B0=E9=87=8F=E9=99=90=E5=88=B6`=20https://github.com/siyu?= =?UTF-8?q?an-note/siyuan/issues/6603?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/appearance/langs/en_US.json | 1 + app/appearance/langs/es_ES.json | 1 + app/appearance/langs/fr_FR.json | 1 + app/appearance/langs/zh_CHT.json | 1 + app/appearance/langs/zh_CN.json | 1 + app/src/config/query.ts | 15 +++++++++++- app/src/types/index.d.ts | 2 ++ kernel/conf/search.go | 40 ++++++++++++++++---------------- kernel/model/backlink.go | 2 +- kernel/model/conf.go | 8 +++---- kernel/model/virutalref.go | 4 ++-- 11 files changed, 48 insertions(+), 28 deletions(-) diff --git a/app/appearance/langs/en_US.json b/app/appearance/langs/en_US.json index 2af5c263b..f3f1a4bf6 100644 --- a/app/appearance/langs/en_US.json +++ b/app/appearance/langs/en_US.json @@ -1,4 +1,5 @@ { + "keywordsLimit": "Keywords Limit", "exportAsImage": "Export as image", "exportBySiYuan": "Export by SiYuan", "featureBetaStage": "This feature support is currently in the free public beta stage, and there is no clear charging plan yet, please know", diff --git a/app/appearance/langs/es_ES.json b/app/appearance/langs/es_ES.json index f2c62fccc..58a2d1060 100644 --- a/app/appearance/langs/es_ES.json +++ b/app/appearance/langs/es_ES.json @@ -1,4 +1,5 @@ { + "keywordsLimit": "Límite de palabras clave", "exportAsImage": "Exportar como imagen", "exportBySiYuan": "Exportar por SiYuan", "featureBetaStage": "El soporte de esta función se encuentra actualmente en la etapa beta pública gratuita, y aún no hay un plan de carga claro, tenga en cuenta", diff --git a/app/appearance/langs/fr_FR.json b/app/appearance/langs/fr_FR.json index ab4fad965..2ca003d39 100644 --- a/app/appearance/langs/fr_FR.json +++ b/app/appearance/langs/fr_FR.json @@ -1,4 +1,5 @@ { + "keywordsLimit": "Limite de mots clés", "exportAsImage": "Exporter en tant qu'image", "exportBySiYuan": "Exporter par SiYuan", "featureBetaStage": "La prise en charge de cette fonctionnalité est actuellement en phase de bêta publique gratuite et il n'y a pas encore de plan de facturation clair, veuillez savoir", diff --git a/app/appearance/langs/zh_CHT.json b/app/appearance/langs/zh_CHT.json index eb234e307..28c67c6b5 100644 --- a/app/appearance/langs/zh_CHT.json +++ b/app/appearance/langs/zh_CHT.json @@ -1,4 +1,5 @@ { + "keywordsLimit": "關鍵字數量限制", "exportAsImage": "導出為圖片", "exportBySiYuan": "由思源筆記導出", "featureBetaStage": "該特性支持目前處於免費公測階段,目前尚未有明確的收費計劃,請悉知", diff --git a/app/appearance/langs/zh_CN.json b/app/appearance/langs/zh_CN.json index cd6e26e82..cdf940fe2 100644 --- a/app/appearance/langs/zh_CN.json +++ b/app/appearance/langs/zh_CN.json @@ -1,4 +1,5 @@ { + "keywordsLimit": "关键字数量限制", "exportAsImage": "导出为图片", "exportBySiYuan": "由思源笔记导出", "featureBetaStage": "该特性支持目前处于免费公测阶段,目前尚未有明确的收费计划,请悉知", diff --git a/app/src/config/query.ts b/app/src/config/query.ts index 15ad23069..aadf80139 100644 --- a/app/src/config/query.ts +++ b/app/src/config/query.ts @@ -149,6 +149,10 @@ export const query = { + + ${window.siyuan.languages.keywordsLimit} + +
@@ -182,7 +186,14 @@ export const query = { -
+ + +`; } return ""; @@ -222,6 +254,7 @@ const bindProviderEvent = () => { bucket: (providerPanelElement.querySelector("#bucket") as HTMLInputElement).value, pathStyle: (providerPanelElement.querySelector("#pathStyle") as HTMLInputElement).value === "true", region: (providerPanelElement.querySelector("#region") as HTMLInputElement).value, + skipTlsVerify: (providerPanelElement.querySelector("#s3SkipTlsVerify") as HTMLInputElement).value === "true", }; fetchPost("/api/sync/setSyncProviderS3", {s3}, () => { window.siyuan.config.sync.s3 = s3; @@ -231,6 +264,7 @@ const bindProviderEvent = () => { endpoint: (providerPanelElement.querySelector("#endpoint") as HTMLInputElement).value, username: (providerPanelElement.querySelector("#username") as HTMLInputElement).value, password: (providerPanelElement.querySelector("#password") as HTMLInputElement).value, + skipTlsVerify: (providerPanelElement.querySelector("#webdavSkipTlsVerify") as HTMLInputElement).value === "true", }; fetchPost("/api/sync/setSyncProviderWebDAV", {webdav}, () => { window.siyuan.config.sync.webdav = webdav; diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.ts index 9f5c2ea15..554faa45e 100644 --- a/app/src/types/index.d.ts +++ b/app/src/types/index.d.ts @@ -340,11 +340,13 @@ declare interface IConfig { secretKey: string bucket: string region: string + skipTlsVerify: boolean } webdav: { endpoint: string username: string password: string + skipTlsVerify: boolean } }, lang: string diff --git a/kernel/go.mod b/kernel/go.mod index 8f8de19b3..a998cab6d 100644 --- a/kernel/go.mod +++ b/kernel/go.mod @@ -36,7 +36,7 @@ require ( github.com/panjf2000/ants/v2 v2.6.0 github.com/patrickmn/go-cache v2.1.0+incompatible github.com/radovskyb/watcher v1.0.7 - github.com/siyuan-note/dejavu v0.0.0-20221116031102-5d5af638b8e5 + github.com/siyuan-note/dejavu v0.0.0-20221116103627-5fbf73fe103e github.com/siyuan-note/encryption v0.0.0-20220713091850-5ecd92177b75 github.com/siyuan-note/eventbus v0.0.0-20220916025349-3ac6e75522da github.com/siyuan-note/filelock v0.0.0-20221007163134-7e64809023ef diff --git a/kernel/go.sum b/kernel/go.sum index 7fcc2e2e7..b9bdab187 100644 --- a/kernel/go.sum +++ b/kernel/go.sum @@ -359,8 +359,8 @@ github.com/shurcooL/reactions v0.0.0-20181006231557-f2e0b4ca5b82/go.mod h1:TCR1l github.com/shurcooL/sanitized_anchor_name v0.0.0-20170918181015-86672fcb3f95/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/shurcooL/users v0.0.0-20180125191416-49c67e49c537/go.mod h1:QJTqeLYEDaXHZDBsXlPCDqdhQuJkuw4NOtaxYe3xii4= github.com/shurcooL/webdavfs v0.0.0-20170829043945-18c3829fa133/go.mod h1:hKmq5kWdCj2z2KEozexVbfEZIWiTjhE0+UjmZgPqehw= -github.com/siyuan-note/dejavu v0.0.0-20221116031102-5d5af638b8e5 h1:m4+9OWYEKS832LJ9E1eAiUz0ATQAUo7gFs7E5S9JSho= -github.com/siyuan-note/dejavu v0.0.0-20221116031102-5d5af638b8e5/go.mod h1:PiWhnZhdVqhY0FifDg6kXwn75V97Dg3U/nFeD76fBis= +github.com/siyuan-note/dejavu v0.0.0-20221116103627-5fbf73fe103e h1:gwI3Zo+ce5GPZlau8kMcUipZwY1yJFjeG8ghwxB6YW4= +github.com/siyuan-note/dejavu v0.0.0-20221116103627-5fbf73fe103e/go.mod h1:PiWhnZhdVqhY0FifDg6kXwn75V97Dg3U/nFeD76fBis= github.com/siyuan-note/encryption v0.0.0-20220713091850-5ecd92177b75 h1:Bi7/7f29LW+Fm0cHc0J1NO1cZqyJwljSWVmfOqVZgaE= github.com/siyuan-note/encryption v0.0.0-20220713091850-5ecd92177b75/go.mod h1:H8fyqqAbp9XreANjeSbc72zEdFfKTXYN34tc1TjZwtw= github.com/siyuan-note/eventbus v0.0.0-20220916025349-3ac6e75522da h1:/jNhl7LC+9BhkWvNxuJDdsNfA/2wvfuj9mqWx4CbV90= diff --git a/kernel/model/repository.go b/kernel/model/repository.go index e35f5b1a6..9ff57f12f 100644 --- a/kernel/model/repository.go +++ b/kernel/model/repository.go @@ -828,7 +828,7 @@ func newRepository() (ret *dejavu.Repo, err error) { s3HTTPClient.Timeout = 30 * time.Second cloudRepo = cloud.NewS3(&cloud.BaseCloud{Conf: cloudConf}, s3HTTPClient) case conf.ProviderWebDAV: - webdavClient := gowebdav.NewClient(cloudConf.Endpoint, cloudConf.WebDAV.Username, cloudConf.WebDAV.Password) + webdavClient := gowebdav.NewClient(cloudConf.WebDAV.Endpoint, cloudConf.WebDAV.Username, cloudConf.WebDAV.Password) a := cloudConf.WebDAV.Username + ":" + cloudConf.WebDAV.Password auth := "Basic " + base64.StdEncoding.EncodeToString([]byte(a)) webdavClient.SetHeader("Authorization", auth) @@ -1049,18 +1049,22 @@ func buildCloudConf() (ret *cloud.Conf, err error) { case conf.ProviderSiYuan: ret.Endpoint = "https://siyuan-data.b3logfile.com/" case conf.ProviderS3: - ret.Endpoint = Conf.Sync.S3.Endpoint - ret.S3.AccessKey = Conf.Sync.S3.AccessKey - ret.S3.SecretKey = Conf.Sync.S3.SecretKey - ret.S3.Bucket = Conf.Sync.S3.Bucket - ret.S3.Region = Conf.Sync.S3.Region - ret.S3.PathStyle = Conf.Sync.S3.PathStyle - ret.S3.SkipTlsVerify = Conf.Sync.S3.SkipTlsVerify + ret.S3 = &cloud.ConfS3{ + Endpoint: Conf.Sync.S3.Endpoint, + AccessKey: Conf.Sync.S3.AccessKey, + SecretKey: Conf.Sync.S3.SecretKey, + Bucket: Conf.Sync.S3.Bucket, + Region: Conf.Sync.S3.Region, + PathStyle: Conf.Sync.S3.PathStyle, + SkipTlsVerify: Conf.Sync.S3.SkipTlsVerify, + } case conf.ProviderWebDAV: - ret.Endpoint = Conf.Sync.WebDAV.Endpoint - ret.WebDAV.Username = Conf.Sync.WebDAV.Username - ret.WebDAV.Password = Conf.Sync.WebDAV.Password - ret.WebDAV.SkipTlsVerify = Conf.Sync.WebDAV.SkipTlsVerify + ret.WebDAV = &cloud.ConfWebDAV{ + Endpoint: Conf.Sync.WebDAV.Endpoint, + Username: Conf.Sync.WebDAV.Username, + Password: Conf.Sync.WebDAV.Password, + SkipTlsVerify: Conf.Sync.WebDAV.SkipTlsVerify, + } default: err = fmt.Errorf("invalid provider [%d]", Conf.Sync.Provider) return