mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 14:40:12 +01:00
🎨 Add Settings - Search - Index - Asset path Fix https://github.com/siyuan-note/siyuan/issues/8221
This commit is contained in:
parent
49c5e3be9d
commit
3790507ee2
16 changed files with 64 additions and 26 deletions
|
|
@ -268,8 +268,10 @@
|
|||
"cancelMerged": "Cancel cell merge",
|
||||
"useDefaultWidth": "Use Default Column Width",
|
||||
"type": "Type",
|
||||
"searchType": "Type (searches in the enabled types below, the filter option in the global search overrides this setting)",
|
||||
"searchAttr": "Attribute (search not only in the content, but also in the following enabled attributes)",
|
||||
"searchBlockType": "Block types (searches in the enabled types below, the filter option in the global search overrides this setting)",
|
||||
"searchBlockAttr": "Block attributes (search not only in the content, but also in the following enabled attributes)",
|
||||
"searchIndex": "Index",
|
||||
"indexAssetPath": "Asset path",
|
||||
"searchBackmention": "Backlink mentions (backlink mentions search keywords are obtained from)",
|
||||
"searchVirtualRef": "Virtual reference (virtual reference search keywords are obtained from)",
|
||||
"netImg2LocalAsset": "Convert network images to local images",
|
||||
|
|
|
|||
|
|
@ -268,8 +268,10 @@
|
|||
"cancelMerged": "Cancelar fusión de celda",
|
||||
"useDefaultWidth": "Usar el ancho de columna por defecto",
|
||||
"type": "Tipo",
|
||||
"searchType": "Tipos (busque en los tipos habilitados a continuación, la opción de filtro en la búsqueda global anula esta configuración)",
|
||||
"searchAttr": "Atributo (busca no sólo en el contenido, sino también en los siguientes atributos habilitados)",
|
||||
"searchBlockType": "Tipos de bloque (busque en los tipos habilitados a continuación, la opción de filtro en la búsqueda global anula esta configuración)",
|
||||
"searchBlockAttr": "Atributos de bloque (busca no sólo en el contenido, sino también en los siguientes atributos habilitados)",
|
||||
"searchIndex": "Índice",
|
||||
"indexAssetPath": "Chemin de l'actif",
|
||||
"searchBackmention": "Menciones de backlinks (las menciones de backlinks de las que se obtienen las palabras clave de la búsqueda)",
|
||||
"searchVirtualRef": "Referencia virtual (las palabras clave de búsqueda de referencias virtuales se obtienen a partir de ellas)",
|
||||
"netImg2LocalAsset": "Convertir imágenes de red en imágenes locales",
|
||||
|
|
|
|||
|
|
@ -268,8 +268,10 @@
|
|||
"cancelMerged": "Annuler la fusion de cellules",
|
||||
"useDefaultWidth": "Utiliser la largeur de colonne par défaut",
|
||||
"type": "Type",
|
||||
"searchType": "Types (recherche dans les types activés ci-dessous, l'option de filtre dans la recherche globale remplace ce paramètre)",
|
||||
"searchAttr": "Attribut (recherche non seulement dans le contenu, mais aussi dans les attributs activés suivants)",
|
||||
"searchBlockType": "Types de bloc (recherche dans les types activés ci-dessous, l'option de filtre dans la recherche globale remplace ce paramètre)",
|
||||
"searchBlockAttr": "Attributs de bloc (recherche non seulement dans le contenu, mais aussi dans les attributs activés suivants)",
|
||||
"searchIndex": "Index",
|
||||
"indexAssetPath": "Chemin de l'actif",
|
||||
"searchBackmention": "Mentions de backlink (les mentions de backlink à partir desquelles les mots-clés de recherche sont obtenus)",
|
||||
"searchVirtualRef": "Référence virtuelle (les mots-clés de recherche de référence virtuelle sont obtenus à partir de)",
|
||||
"netImg2LocalAsset": "Convertir des images réseau en images locales",
|
||||
|
|
|
|||
|
|
@ -268,8 +268,10 @@
|
|||
"cancelMerged": "拆分單元格",
|
||||
"useDefaultWidth": "使用預設列寬",
|
||||
"type": "類型",
|
||||
"searchType": "類型(在以下啟用的類型中進行搜索,全局搜索中的過濾選項會覆蓋該設置)",
|
||||
"searchAttr": "屬性(不僅在內容中進行搜索,同時也會在以下啟用的屬性中搜索)",
|
||||
"searchBlockType": "塊級類型(在以下啟用的類型中進行搜索,全局搜索中的過濾選項會覆蓋該設置)",
|
||||
"searchBlockAttr": "塊級屬性(不僅在內容中進行搜索,同時也會在以下啟用的屬性中搜索)",
|
||||
"searchIndex": "索引",
|
||||
"indexAssetPath": "資源文件路徑",
|
||||
"searchBackmention": "反鏈提及(反鏈提及搜索關鍵字從以下方式獲得)",
|
||||
"searchVirtualRef": "虛擬引用(虛擬引用搜索關鍵字從以下方式獲得)",
|
||||
"netImg2LocalAsset": "網絡圖片轉換為本地圖片",
|
||||
|
|
|
|||
|
|
@ -268,8 +268,10 @@
|
|||
"cancelMerged": "拆分单元格",
|
||||
"useDefaultWidth": "使用默认列宽",
|
||||
"type": "类型",
|
||||
"searchType": "类型(在以下启用的类型中进行搜索,全局搜索中的过滤选项会覆盖该设置)",
|
||||
"searchAttr": "属性(不仅在内容中进行搜索,同时也会在以下启用的属性中搜索)",
|
||||
"searchBlockType": "块级类型(在以下启用的类型中进行搜索,全局搜索中的过滤选项会覆盖该设置)",
|
||||
"searchBlockAttr": "块级属性(不仅在内容中进行搜索,同时也会在以下启用的属性中搜索)",
|
||||
"searchIndex": "索引",
|
||||
"indexAssetPath": "资源文件路径",
|
||||
"searchBackmention": "反链提及(反链提及搜索关键字从以下方式获得)",
|
||||
"searchVirtualRef": "虚拟引用(虚拟引用搜索关键字从以下方式获得)",
|
||||
"netImg2LocalAsset": "网络图片转换为本地图片",
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ export const query = {
|
|||
element: undefined as Element,
|
||||
genHTML: () => {
|
||||
return `<div class="b3-label">
|
||||
${window.siyuan.languages.searchType}
|
||||
${window.siyuan.languages.searchBlockType}
|
||||
<div class="fn__flex config-query">
|
||||
<label class="fn__flex">
|
||||
<svg class="svg"><use xlink:href="#iconMath"></use></svg>
|
||||
|
|
@ -117,7 +117,7 @@ export const query = {
|
|||
</div>
|
||||
</div>
|
||||
<div class="b3-label">
|
||||
${window.siyuan.languages.searchAttr}
|
||||
${window.siyuan.languages.searchBlockAttr}
|
||||
<div class="config-query">
|
||||
<label class="fn__flex">
|
||||
<svg class="svg"><use xlink:href="#iconN"></use></svg>
|
||||
|
|
@ -228,6 +228,18 @@ export const query = {
|
|||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="b3-label">
|
||||
${window.siyuan.languages.searchIndex}
|
||||
<div class="config-query">
|
||||
<label class="fn__flex">
|
||||
<div class="fn__flex-1">
|
||||
${window.siyuan.languages.indexAssetPath}
|
||||
</div>
|
||||
<span class="fn__space"></span>
|
||||
<input class="b3-switch" id="indexAssetPath" type="checkbox"${window.siyuan.config.search.indexAssetPath ? " checked" : ""}/>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<label class="fn__flex b3-label config__item">
|
||||
<div class="fn__flex-1">
|
||||
${window.siyuan.languages.searchLimit}
|
||||
|
|
@ -266,6 +278,7 @@ export const query = {
|
|||
alias: (query.element.querySelector("#alias") as HTMLInputElement).checked,
|
||||
memo: (query.element.querySelector("#memo") as HTMLInputElement).checked,
|
||||
ial: (query.element.querySelector("#ial") as HTMLInputElement).checked,
|
||||
indexAssetPath: (query.element.querySelector("#indexAssetPath") as HTMLInputElement).checked,
|
||||
limit: parseInt((query.element.querySelector("#limit") as HTMLInputElement).value),
|
||||
caseSensitive: (query.element.querySelector("#caseSensitive") as HTMLInputElement).checked,
|
||||
backlinkMentionName: (query.element.querySelector("#backlinkMentionName") as HTMLInputElement).checked,
|
||||
|
|
|
|||
1
app/src/types/index.d.ts
vendored
1
app/src/types/index.d.ts
vendored
|
|
@ -551,6 +551,7 @@ declare interface IConfig {
|
|||
name: boolean
|
||||
alias: boolean
|
||||
memo: boolean
|
||||
indexAssetPath: boolean
|
||||
ial: boolean
|
||||
limit: number
|
||||
caseSensitive: boolean
|
||||
|
|
|
|||
|
|
@ -310,6 +310,8 @@ func setSearch(c *gin.Context) {
|
|||
}
|
||||
|
||||
oldCaseSensitive := model.Conf.Search.CaseSensitive
|
||||
oldIndexAssetPath := model.Conf.Search.IndexAssetPath
|
||||
|
||||
oldVirtualRefName := model.Conf.Search.VirtualRefName
|
||||
oldVirtualRefAlias := model.Conf.Search.VirtualRefAlias
|
||||
oldVirtualRefAnchor := model.Conf.Search.VirtualRefAnchor
|
||||
|
|
@ -317,8 +319,11 @@ func setSearch(c *gin.Context) {
|
|||
|
||||
model.Conf.Search = s
|
||||
model.Conf.Save()
|
||||
|
||||
sql.SetCaseSensitive(s.CaseSensitive)
|
||||
if s.CaseSensitive != oldCaseSensitive {
|
||||
sql.SetIndexAssetPath(s.IndexAssetPath)
|
||||
|
||||
if needFullReindex := s.CaseSensitive != oldCaseSensitive || s.IndexAssetPath != oldIndexAssetPath; needFullReindex {
|
||||
model.FullReindex()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -46,6 +46,8 @@ type Search struct {
|
|||
Memo bool `json:"memo"`
|
||||
IAL bool `json:"ial"`
|
||||
|
||||
IndexAssetPath bool `json:"indexAssetPath"`
|
||||
|
||||
BacklinkMentionName bool `json:"backlinkMentionName"`
|
||||
BacklinkMentionAlias bool `json:"backlinkMentionAlias"`
|
||||
BacklinkMentionAnchor bool `json:"backlinkMentionAnchor"`
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ func main() {
|
|||
sql.InitDatabase(false)
|
||||
sql.InitHistoryDatabase(false)
|
||||
sql.SetCaseSensitive(model.Conf.Search.CaseSensitive)
|
||||
sql.SetIndexAssetPath(model.Conf.Search.IndexAssetPath)
|
||||
|
||||
model.BootSyncData()
|
||||
model.InitBoxes()
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ func StartKernel(container, appDir, workspaceBaseDir, timezoneID, localIPs, lang
|
|||
sql.InitDatabase(false)
|
||||
sql.InitHistoryDatabase(false)
|
||||
sql.SetCaseSensitive(model.Conf.Search.CaseSensitive)
|
||||
sql.SetIndexAssetPath(model.Conf.Search.IndexAssetPath)
|
||||
|
||||
model.BootSyncData()
|
||||
model.InitBoxes()
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ func SetBlockReminder(id string, timed string) (err error) {
|
|||
if ast.NodeDocument != node.Type && node.IsContainerBlock() {
|
||||
node = treenode.FirstLeafBlock(node)
|
||||
}
|
||||
content := treenode.NodeStaticContent(node, nil, false)
|
||||
content := treenode.NodeStaticContent(node, nil, false, false)
|
||||
content = gulu.Str.SubStr(content, 128)
|
||||
err = SetCloudBlockReminder(id, content, timedMills)
|
||||
if nil != err {
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ func renderOutline(heading *ast.Node, luteEngine *lute.Lute) (ret string) {
|
|||
}
|
||||
|
||||
func renderBlockText(node *ast.Node, excludeTypes []string) (ret string) {
|
||||
ret = treenode.NodeStaticContent(node, excludeTypes, false)
|
||||
ret = treenode.NodeStaticContent(node, excludeTypes, false, false)
|
||||
ret = strings.TrimSpace(ret)
|
||||
ret = strings.ReplaceAll(ret, "\n", "")
|
||||
ret = util.EscapeHTML(ret)
|
||||
|
|
@ -156,7 +156,7 @@ func renderBlockContentByNodes(nodes []*ast.Node) string {
|
|||
|
||||
buf := bytes.Buffer{}
|
||||
for _, n := range subNodes {
|
||||
buf.WriteString(treenode.NodeStaticContent(n, nil, false))
|
||||
buf.WriteString(treenode.NodeStaticContent(n, nil, false, false))
|
||||
}
|
||||
return buf.String()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ func getBlockVirtualRefKeywords(root *ast.Node) (ret []string) {
|
|||
return ast.WalkContinue
|
||||
}
|
||||
|
||||
content := treenode.NodeStaticContent(n, nil, false)
|
||||
content := treenode.NodeStaticContent(n, nil, false, false)
|
||||
buf.WriteString(content)
|
||||
return ast.WalkContinue
|
||||
})
|
||||
|
|
|
|||
|
|
@ -267,7 +267,10 @@ func initDBConnection() {
|
|||
db.SetConnMaxLifetime(365 * 24 * time.Hour)
|
||||
}
|
||||
|
||||
var caseSensitive bool
|
||||
var (
|
||||
caseSensitive bool
|
||||
indexAssetPath bool
|
||||
)
|
||||
|
||||
func SetCaseSensitive(b bool) {
|
||||
caseSensitive = b
|
||||
|
|
@ -278,6 +281,10 @@ func SetCaseSensitive(b bool) {
|
|||
}
|
||||
}
|
||||
|
||||
func SetIndexAssetPath(b bool) {
|
||||
indexAssetPath = b
|
||||
}
|
||||
|
||||
func refsFromTree(tree *parse.Tree) (refs []*Ref, fileAnnotationRefs []*FileAnnotationRef) {
|
||||
ast.Walk(tree.Root, func(n *ast.Node, entering bool) ast.WalkStatus {
|
||||
if entering {
|
||||
|
|
@ -701,9 +708,9 @@ func buildBlockFromNode(n *ast.Node, tree *parse.Tree) (block *Block, attributes
|
|||
length = utf8.RuneCountInString(fcontent)
|
||||
} else if n.IsContainerBlock() {
|
||||
markdown = treenode.ExportNodeStdMd(n, luteEngine)
|
||||
content = treenode.NodeStaticContent(n, nil, true)
|
||||
content = treenode.NodeStaticContent(n, nil, true, indexAssetPath)
|
||||
fc := treenode.FirstLeafBlock(n)
|
||||
fcontent = treenode.NodeStaticContent(fc, nil, false)
|
||||
fcontent = treenode.NodeStaticContent(fc, nil, false, false)
|
||||
parentID = n.Parent.ID
|
||||
// 将标题块作为父节点
|
||||
if h := heading(n); nil != h {
|
||||
|
|
@ -712,7 +719,7 @@ func buildBlockFromNode(n *ast.Node, tree *parse.Tree) (block *Block, attributes
|
|||
length = utf8.RuneCountInString(fcontent)
|
||||
} else {
|
||||
markdown = treenode.ExportNodeStdMd(n, luteEngine)
|
||||
content = treenode.NodeStaticContent(n, nil, true)
|
||||
content = treenode.NodeStaticContent(n, nil, true, indexAssetPath)
|
||||
parentID = n.Parent.ID
|
||||
// 将标题块作为父节点
|
||||
if h := heading(n); nil != h {
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ func ExportNodeStdMd(node *ast.Node, luteEngine *lute.Lute) string {
|
|||
return markdown
|
||||
}
|
||||
|
||||
func NodeStaticContent(node *ast.Node, excludeTypes []string, includeTextMarkATitleURL bool) string {
|
||||
func NodeStaticContent(node *ast.Node, excludeTypes []string, includeTextMarkATitleURL, includeAssetPath bool) string {
|
||||
if nil == node {
|
||||
return ""
|
||||
}
|
||||
|
|
@ -185,8 +185,7 @@ func NodeStaticContent(node *ast.Node, excludeTypes []string, includeTextMarkATi
|
|||
buf.WriteByte(' ')
|
||||
}
|
||||
if nil != linkDest {
|
||||
if !bytes.HasPrefix(linkDest.Tokens, []byte("assets/")) {
|
||||
// Assets hyperlinks are no longer included in the search index https://github.com/siyuan-note/siyuan/issues/8076
|
||||
if !bytes.HasPrefix(linkDest.Tokens, []byte("assets/")) || includeAssetPath {
|
||||
buf.Write(linkDest.Tokens)
|
||||
buf.WriteByte(' ')
|
||||
}
|
||||
|
|
@ -232,8 +231,7 @@ func NodeStaticContent(node *ast.Node, excludeTypes []string, includeTextMarkATi
|
|||
buf.WriteString(" " + n.TextMarkATitle)
|
||||
}
|
||||
|
||||
if !strings.HasPrefix(n.TextMarkAHref, "assets/") {
|
||||
// Assets hyperlinks are no longer included in the search index https://github.com/siyuan-note/siyuan/issues/8076
|
||||
if !strings.HasPrefix(n.TextMarkAHref, "assets/") || includeAssetPath {
|
||||
buf.WriteString(" " + n.TextMarkAHref)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue