From c31695159285e1ac85f60df5e301092f0d8a2cfa Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Mon, 17 Apr 2023 22:47:25 +0800 Subject: [PATCH 1/3] :art: Content type filtering when inserting reference links via `((`, `[[` https://github.com/siyuan-note/siyuan/issues/8009 --- kernel/api/search.go | 7 ++++++- kernel/model/search.go | 15 ++++++++++----- kernel/sql/block_ref_query.go | 9 +++++++-- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/kernel/api/search.go b/kernel/api/search.go index 31a5877c7..1620b0392 100644 --- a/kernel/api/search.go +++ b/kernel/api/search.go @@ -191,11 +191,16 @@ func searchRefBlock(c *gin.Context) { return } + onlyDoc := false + if nil != arg["onlyDoc"] { + onlyDoc = arg["onlyDoc"].(bool) + } + rootID := arg["rootID"].(string) id := arg["id"].(string) keyword := arg["k"].(string) beforeLen := int(arg["beforeLen"].(float64)) - blocks, newDoc := model.SearchRefBlock(id, rootID, keyword, beforeLen) + blocks, newDoc := model.SearchRefBlock(id, rootID, keyword, beforeLen, onlyDoc) ret.Data = map[string]interface{}{ "blocks": blocks, "newDoc": newDoc, diff --git a/kernel/model/search.go b/kernel/model/search.go index d397a8bdf..493d529a4 100644 --- a/kernel/model/search.go +++ b/kernel/model/search.go @@ -120,12 +120,12 @@ func searchEmbedBlock(embedBlockID, stmt string, excludeIDs []string, headingMod return } -func SearchRefBlock(id, rootID, keyword string, beforeLen int) (ret []*Block, newDoc bool) { +func SearchRefBlock(id, rootID, keyword string, beforeLen int, onlyDoc bool) (ret []*Block, newDoc bool) { cachedTrees := map[string]*parse.Tree{} if "" == keyword { // 查询为空时默认的块引排序规则按最近使用优先 https://github.com/siyuan-note/siyuan/issues/3218 - refs := sql.QueryRefsRecent() + refs := sql.QueryRefsRecent(onlyDoc) for _, ref := range refs { tree := cachedTrees[ref.DefBlockRootID] if nil == tree { @@ -157,7 +157,7 @@ func SearchRefBlock(id, rootID, keyword string, beforeLen int) (ret []*Block, ne return } - ret = fullTextSearchRefBlock(keyword, beforeLen) + ret = fullTextSearchRefBlock(keyword, beforeLen, onlyDoc) tmp := ret[:0] for _, b := range ret { tree := cachedTrees[b.RootID] @@ -624,7 +624,7 @@ func searchBySQL(stmt string, beforeLen int) (ret []*Block, matchedBlockCount, m return } -func fullTextSearchRefBlock(keyword string, beforeLen int) (ret []*Block) { +func fullTextSearchRefBlock(keyword string, beforeLen int, onlyDoc bool) (ret []*Block) { keyword = gulu.Str.RemoveInvisible(keyword) if ast.IsNodeIDPattern(keyword) { @@ -646,7 +646,12 @@ func fullTextSearchRefBlock(keyword string, beforeLen int) (ret []*Block) { "tag, " + "snippet(" + table + ", 11, '" + search.SearchMarkLeft + "', '" + search.SearchMarkRight + "', '...', 64) AS content, " + "fcontent, markdown, length, type, subtype, ial, sort, created, updated" - stmt := "SELECT " + projections + " FROM " + table + " WHERE " + table + " MATCH '" + columnFilter() + ":(" + quotedKeyword + ")' AND type IN " + Conf.Search.TypeFilter() + stmt := "SELECT " + projections + " FROM " + table + " WHERE " + table + " MATCH '" + columnFilter() + ":(" + quotedKeyword + ")' AND type" + if onlyDoc { + stmt += " = 'd'" + } else { + stmt += " IN " + Conf.Search.TypeFilter() + } orderBy := ` order by case when name = '${keyword}' then 10 when alias = '${keyword}' then 20 diff --git a/kernel/sql/block_ref_query.go b/kernel/sql/block_ref_query.go index 80cde1f18..348b39def 100644 --- a/kernel/sql/block_ref_query.go +++ b/kernel/sql/block_ref_query.go @@ -335,8 +335,13 @@ func QueryRefIDsByDefID(defID string, containChildren bool) (refIDs, refTexts [] return } -func QueryRefsRecent() (ret []*Ref) { - rows, err := query("SELECT * FROM refs GROUP BY def_block_id ORDER BY id desc LIMIT 32") +func QueryRefsRecent(onlyDoc bool) (ret []*Ref) { + stmt := "SELECT * FROM refs" + if onlyDoc { + stmt = "SELECT * FROM refs WHERE def_block_type = 'd'" + } + stmt += " GROUP BY def_block_id ORDER BY id DESC LIMIT 32" + rows, err := query(stmt) if nil != err { logging.LogErrorf("sql query failed: %s", err) return From f0e80505f0a15a7c4fac44b52e49f10e123fa3f7 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Mon, 17 Apr 2023 22:53:07 +0800 Subject: [PATCH 2/3] :art: Content type filtering when inserting reference links via `((`, `[[` https://github.com/siyuan-note/siyuan/issues/8009 --- kernel/sql/block_ref_query.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/sql/block_ref_query.go b/kernel/sql/block_ref_query.go index 348b39def..e0a7bb562 100644 --- a/kernel/sql/block_ref_query.go +++ b/kernel/sql/block_ref_query.go @@ -336,11 +336,11 @@ func QueryRefIDsByDefID(defID string, containChildren bool) (refIDs, refTexts [] } func QueryRefsRecent(onlyDoc bool) (ret []*Ref) { - stmt := "SELECT * FROM refs" + stmt := "SELECT * FROM refs AS r" if onlyDoc { - stmt = "SELECT * FROM refs WHERE def_block_type = 'd'" + stmt = "SELECT r.* FROM refs AS r, blocks AS b WHERE b.type = 'd' AND b.id = r.def_block_id" } - stmt += " GROUP BY def_block_id ORDER BY id DESC LIMIT 32" + stmt += " GROUP BY r.def_block_id ORDER BY r.id DESC LIMIT 32" rows, err := query(stmt) if nil != err { logging.LogErrorf("sql query failed: %s", err) From e041cf2183e13185228e2a1e95d8d9d3c20da87b Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Tue, 18 Apr 2023 09:05:15 +0800 Subject: [PATCH 3/3] :art: Appearance text `Bazaar` change to `Marketplace` https://github.com/siyuan-note/siyuan/issues/8020 --- app/appearance/langs/en_US.json | 2 +- app/appearance/langs/es_ES.json | 3 +- app/appearance/langs/fr_FR.json | 2 +- .../20200923234011-ieuun1p.sy | 14 +++---- .../20200924095938-a9p5450.sy | 37 +++++++++---------- .../20200924100110-vcg96wy.sy | 30 +++++++-------- .../20201204184532-3qm9l8n.sy | 11 +++--- .../20210824202056-udkf7wg.sy | 14 +++---- 8 files changed, 56 insertions(+), 57 deletions(-) diff --git a/app/appearance/langs/en_US.json b/app/appearance/langs/en_US.json index 98bc9639d..9e928707b 100644 --- a/app/appearance/langs/en_US.json +++ b/app/appearance/langs/en_US.json @@ -541,7 +541,7 @@ "download": "Download", "uninstall": "Uninstall", "all": "All", - "bazaar": "Bazaar", + "bazaar": "Marketplace", "revolve": "Revolve", "useDefault": "Open with default program", "previous": "Previous", diff --git a/app/appearance/langs/es_ES.json b/app/appearance/langs/es_ES.json index 9a28b361d..ebb2cceb1 100644 --- a/app/appearance/langs/es_ES.json +++ b/app/appearance/langs/es_ES.json @@ -1,5 +1,4 @@ { - "ocrResult": "Texte du résultat OCR", "ocrResult": "Texto de resultado de OCR", "reOCR": "Re-OCR", "continueReview1": "Continuar revisión", @@ -542,7 +541,7 @@ "download": "Descargar", "uninstall": "Desinstalar", "all": "Todo", - "bazaar": "Bazar", + "bazaar": "Mercado", "revolve": "Girar", "useDefault": "Abrir con el programa por defecto", "previous": "Anterior", diff --git a/app/appearance/langs/fr_FR.json b/app/appearance/langs/fr_FR.json index cf4daf82f..d4d41ecc1 100644 --- a/app/appearance/langs/fr_FR.json +++ b/app/appearance/langs/fr_FR.json @@ -540,7 +540,7 @@ "download": "Télécharger", "uninstall": "Désinstaller", "all": "Tous", - "bazaar": "Bazaar", + "bazaar": "Marché", "revolve": "Revolve", "useDefault": "Ouvrir avec le programme par défaut", "previous": "Précédent", diff --git a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p.sy b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p.sy index cb1976282..67138af5f 100644 --- a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p.sy +++ b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p.sy @@ -8,7 +8,7 @@ "title": "Please Start Here", "title-img": "background-color:#556;background-image: linear-gradient(30deg, #445 12%, transparent 12.5%, transparent 87%, #445 87.5%, #445),linear-gradient(150deg, #445 12%, transparent 12.5%, transparent 87%, #445 87.5%, #445),linear-gradient(30deg, #445 12%, transparent 12.5%, transparent 87%, #445 87.5%, #445),linear-gradient(150deg, #445 12%, transparent 12.5%, transparent 87%, #445 87.5%, #445),linear-gradient(60deg, #99a 25%, transparent 25.5%, transparent 75%, #99a 75%, #99a),linear-gradient(60deg, #99a 25%, transparent 25.5%, transparent 75%, #99a 75%, #99a);background-size:80px 140px;background-position: 0 0, 0 0, 40px 70px, 40px 70px, 0 0, 40px 70px;", "type": "doc", - "updated": "20230415112503" + "updated": "20230418085821" }, "Children": [ { @@ -391,7 +391,7 @@ "Type": "NodeSuperBlock", "Properties": { "id": "20210528120236-zyh2t7d", - "updated": "20210428231747" + "updated": "20230418085821" }, "Children": [ { @@ -484,7 +484,7 @@ "Type": "NodeSuperBlock", "Properties": { "id": "20210528120308-9wuiyyz", - "updated": "20221114173245" + "updated": "20230418085821" }, "Children": [ { @@ -515,7 +515,7 @@ "ListData": {}, "Properties": { "id": "20210317214434-nx9mt0d", - "updated": "20221114173245" + "updated": "20230418085821" }, "Children": [ { @@ -558,7 +558,7 @@ }, "Properties": { "id": "20221114173201-njmd9n7", - "updated": "20221114173211" + "updated": "20230418085821" }, "Children": [ { @@ -566,14 +566,14 @@ "Type": "NodeParagraph", "Properties": { "id": "20221114173201-7ilqkuo", - "updated": "20221114173211" + "updated": "20230418085821" }, "Children": [ { "Type": "NodeTextMark", "TextMarkType": "a", "TextMarkAHref": "https://github.com/siyuan-note/bazaar", - "TextMarkTextContent": "Community bazaar" + "TextMarkTextContent": "Community marketplace" } ] } diff --git a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-axh6q1d/20200924095938-a9p5450.sy b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-axh6q1d/20200924095938-a9p5450.sy index bc90bfccf..d3ecaf0ff 100644 --- a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-axh6q1d/20200924095938-a9p5450.sy +++ b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-axh6q1d/20200924095938-a9p5450.sy @@ -6,7 +6,7 @@ "id": "20200924095938-a9p5450", "title": "Theme", "type": "doc", - "updated": "20230417141811" + "updated": "20230418085902" }, "Children": [ { @@ -482,16 +482,13 @@ "Type": "NodeHeading", "HeadingLevel": 3, "Properties": { - "id": "20201225221416-enetgqg" + "id": "20201225221416-enetgqg", + "updated": "20230418085213" }, "Children": [ - { - "Type": "NodeHeadingC8hMarker", - "Data": "### " - }, { "Type": "NodeText", - "Data": "Community Bazaar" + "Data": "Community Marketplace" } ] }, @@ -506,7 +503,8 @@ "Num": -1 }, "Properties": { - "id": "20201225221416-chyd31p" + "id": "20201225221416-chyd31p", + "updated": "20230418085223" }, "Children": [ { @@ -521,7 +519,8 @@ "Num": -1 }, "Properties": { - "id": "20201225221416-fwq6l32" + "id": "20201225221416-fwq6l32", + "updated": "20230418085223" }, "Children": [ { @@ -529,7 +528,7 @@ "Type": "NodeParagraph", "Properties": { "id": "20210131162108-dtskbvb", - "updated": "20210512161531" + "updated": "20230418085223" }, "Children": [ { @@ -543,7 +542,7 @@ }, { "Type": "NodeText", - "Data": " - " + "Data": "​ - " }, { "Type": "NodeTextMark", @@ -552,7 +551,7 @@ }, { "Type": "NodeText", - "Data": " - " + "Data": "​ - " }, { "Type": "NodeTextMark", @@ -561,16 +560,16 @@ }, { "Type": "NodeText", - "Data": " - " + "Data": "​ - " }, { "Type": "NodeTextMark", "TextMarkType": "kbd", - "TextMarkTextContent": "Bazaar" + "TextMarkTextContent": "Marketplace" }, { "Type": "NodeText", - "Data": ", browse online themes contributed by community developers" + "Data": "​, browse online themes contributed by community developers" } ] } @@ -1324,12 +1323,12 @@ "HeadingLevel": 2, "Properties": { "id": "20201225222754-u4sica8", - "updated": "20201225222754" + "updated": "20230418085639" }, "Children": [ { "Type": "NodeText", - "Data": "Push to theme bazaar" + "Data": "Push to theme marketplace" } ] }, @@ -1338,7 +1337,7 @@ "Type": "NodeParagraph", "Properties": { "id": "20221114173346-65wavr3", - "updated": "20221114173347" + "updated": "20230418085902" }, "Children": [ { @@ -1349,7 +1348,7 @@ "Type": "NodeTextMark", "TextMarkType": "a", "TextMarkAHref": "https://github.com/siyuan-note/bazaar", - "TextMarkTextContent": "Community Bazaar README" + "TextMarkTextContent": "Community marketplace README" }, { "Type": "NodeText", diff --git a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-axh6q1d/20200924100110-vcg96wy.sy b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-axh6q1d/20200924100110-vcg96wy.sy index cbd09af0b..6c9b2c309 100644 --- a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-axh6q1d/20200924100110-vcg96wy.sy +++ b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-axh6q1d/20200924100110-vcg96wy.sy @@ -6,7 +6,7 @@ "id": "20200924100110-vcg96wy", "title": "Icon", "type": "doc", - "updated": "20221114173333" + "updated": "20230418085910" }, "Children": [ { @@ -633,7 +633,7 @@ "ListData": {}, "Properties": { "id": "20210104091404-ewdyw7f", - "updated": "20210104091404" + "updated": "20230418085705" }, "Children": [ { @@ -817,7 +817,8 @@ "Marker": "Kg==" }, "Properties": { - "id": "20210104091404-dkmivym" + "id": "20210104091404-dkmivym", + "updated": "20230418085705" }, "Children": [ { @@ -857,7 +858,8 @@ "Type": "NodeList", "ListData": {}, "Properties": { - "id": "20210104091404-rfqjpsy" + "id": "20210104091404-rfqjpsy", + "updated": "20230418085705" }, "Children": [ { @@ -868,24 +870,22 @@ "Marker": "Kg==" }, "Properties": { - "id": "20210104091404-08zo0iy" + "id": "20210104091404-08zo0iy", + "updated": "20230418085705" }, "Children": [ { "ID": "20210302223515-3y0helv", "Type": "NodeParagraph", "Properties": { - "id": "20210302223515-3y0helv" + "id": "20210302223515-3y0helv", + "updated": "20230418085705" }, "Children": [ { "Type": "NodeText", "Data": "Click on " }, - { - "Type": "NodeTextMark", - "TextMarkType": "code" - }, { "Type": "NodeTextMark", "TextMarkType": "code", @@ -893,7 +893,7 @@ }, { "Type": "NodeText", - "Data": " in the upper right corner to import the pictures made in the previous step" + "Data": "​ in the upper right corner to import the pictures made in the previous step" } ] } @@ -1359,12 +1359,12 @@ "HeadingLevel": 2, "Properties": { "id": "20210601103837-057w6ot", - "updated": "20210601103841" + "updated": "20230418085722" }, "Children": [ { "Type": "NodeText", - "Data": "Push to icon bazaar" + "Data": "Push to icon marketplace" } ] }, @@ -1373,7 +1373,7 @@ "Type": "NodeParagraph", "Properties": { "id": "20221114173333-rfx8ewj", - "updated": "20221114173333" + "updated": "20230418085910" }, "Children": [ { @@ -1384,7 +1384,7 @@ "Type": "NodeTextMark", "TextMarkType": "a", "TextMarkAHref": "https://github.com/siyuan-note/bazaar", - "TextMarkTextContent": "Community Bazaar README" + "TextMarkTextContent": "Community marketplace README" }, { "Type": "NodeText", diff --git a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20201204184532-3qm9l8n.sy b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20201204184532-3qm9l8n.sy index bf3eaeff1..dad46d2fe 100644 --- a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20201204184532-3qm9l8n.sy +++ b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20201204184532-3qm9l8n.sy @@ -6,7 +6,7 @@ "id": "20201204184532-3qm9l8n", "title": "Template snippet", "type": "doc", - "updated": "20221114173406" + "updated": "20230418085914" }, "Children": [ { @@ -668,12 +668,13 @@ "Type": "NodeHeading", "HeadingLevel": 2, "Properties": { - "id": "20210131162806-sk9tg4q" + "id": "20210131162806-sk9tg4q", + "updated": "20230418085727" }, "Children": [ { "Type": "NodeText", - "Data": "Push to template bazaar" + "Data": "Push to template marketplace" } ] }, @@ -682,7 +683,7 @@ "Type": "NodeParagraph", "Properties": { "id": "20221114173406-3h4imbx", - "updated": "20221114173406" + "updated": "20230418085914" }, "Children": [ { @@ -693,7 +694,7 @@ "Type": "NodeTextMark", "TextMarkType": "a", "TextMarkAHref": "https://github.com/siyuan-note/bazaar", - "TextMarkTextContent": "Community Bazaar README" + "TextMarkTextContent": "Community marketplace README" }, { "Type": "NodeText", diff --git a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20210824202056-udkf7wg.sy b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20210824202056-udkf7wg.sy index bffd54309..729bc0362 100644 --- a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20210824202056-udkf7wg.sy +++ b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20210824202056-udkf7wg.sy @@ -5,7 +5,7 @@ "Properties": { "id": "20210824202056-udkf7wg", "title": "Widgets", - "updated": "20221114173356" + "updated": "20230418085917" }, "Children": [ { @@ -66,12 +66,12 @@ "Type": "NodeParagraph", "Properties": { "id": "20210824202107-cmsetzk", - "updated": "20211230224119" + "updated": "20230418085759" }, "Children": [ { "Type": "NodeText", - "Data": "The widgets are installed through the widget bazaar. After installation, the widgets will be placed in the workspace/widgets folder. In the editor, use the slash menu to trigger the call search. After selecting the widget you need, the widget will be inserted into the document in the form of a widget block." + "Data": "The widgets are installed through the widget marketplace. After installation, the widgets will be placed in the workspace/widgets folder. In the editor, use the slash menu to trigger the call search. After selecting the widget you need, the widget will be inserted into the document in the form of a widget block." } ] }, @@ -81,12 +81,12 @@ "HeadingLevel": 2, "Properties": { "id": "20211222095842-700ar7j", - "updated": "20211222095930" + "updated": "20230418085731" }, "Children": [ { "Type": "NodeText", - "Data": "Push to widget bazaar" + "Data": "Push to widget marketplace" } ] }, @@ -95,7 +95,7 @@ "Type": "NodeParagraph", "Properties": { "id": "20221114173356-q17x02u", - "updated": "20221114173356" + "updated": "20230418085917" }, "Children": [ { @@ -106,7 +106,7 @@ "Type": "NodeTextMark", "TextMarkType": "a", "TextMarkAHref": "https://github.com/siyuan-note/bazaar", - "TextMarkTextContent": "Community Bazaar README" + "TextMarkTextContent": "Community marketplace README" }, { "Type": "NodeText",