mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-22 01:20:12 +01:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
c455f876ba
4 changed files with 61 additions and 5 deletions
|
|
@ -38,6 +38,10 @@ type Search struct {
|
||||||
HTMLBlock bool `json:"htmlBlock"`
|
HTMLBlock bool `json:"htmlBlock"`
|
||||||
EmbedBlock bool `json:"embedBlock"`
|
EmbedBlock bool `json:"embedBlock"`
|
||||||
DatabaseBlock bool `json:"databaseBlock"`
|
DatabaseBlock bool `json:"databaseBlock"`
|
||||||
|
AudioBlock bool `json:"audioBlock"`
|
||||||
|
VideoBlock bool `json:"videoBlock"`
|
||||||
|
IFrameBlock bool `json:"iframeBlock"`
|
||||||
|
WidgetBlock bool `json:"widgetBlock"`
|
||||||
|
|
||||||
Limit int `json:"limit"`
|
Limit int `json:"limit"`
|
||||||
CaseSensitive bool `json:"caseSensitive"`
|
CaseSensitive bool `json:"caseSensitive"`
|
||||||
|
|
@ -76,6 +80,10 @@ func NewSearch() *Search {
|
||||||
HTMLBlock: true,
|
HTMLBlock: true,
|
||||||
EmbedBlock: false,
|
EmbedBlock: false,
|
||||||
DatabaseBlock: true,
|
DatabaseBlock: true,
|
||||||
|
AudioBlock: true,
|
||||||
|
VideoBlock: true,
|
||||||
|
IFrameBlock: true,
|
||||||
|
WidgetBlock: true,
|
||||||
|
|
||||||
Limit: 64,
|
Limit: 64,
|
||||||
CaseSensitive: false,
|
CaseSensitive: false,
|
||||||
|
|
@ -195,11 +203,30 @@ func (s *Search) TypeFilter() string {
|
||||||
buf.WriteByte('\'')
|
buf.WriteByte('\'')
|
||||||
buf.WriteString(",")
|
buf.WriteString(",")
|
||||||
}
|
}
|
||||||
|
if s.AudioBlock {
|
||||||
// 无法搜索到 iframe 块、视频块和音频块 https://github.com/siyuan-note/siyuan/issues/3604
|
buf.WriteByte('\'')
|
||||||
buf.WriteString("'iframe','video','audio',")
|
buf.WriteString(treenode.TypeAbbr(ast.NodeAudio.String()))
|
||||||
// 挂件块支持内置属性搜索 https://github.com/siyuan-note/siyuan/issues/4497
|
buf.WriteByte('\'')
|
||||||
buf.WriteString("'widget',")
|
buf.WriteString(",")
|
||||||
|
}
|
||||||
|
if s.VideoBlock {
|
||||||
|
buf.WriteByte('\'')
|
||||||
|
buf.WriteString(treenode.TypeAbbr(ast.NodeVideo.String()))
|
||||||
|
buf.WriteByte('\'')
|
||||||
|
buf.WriteString(",")
|
||||||
|
}
|
||||||
|
if s.IFrameBlock {
|
||||||
|
buf.WriteByte('\'')
|
||||||
|
buf.WriteString(treenode.TypeAbbr(ast.NodeIFrame.String()))
|
||||||
|
buf.WriteByte('\'')
|
||||||
|
buf.WriteString(",")
|
||||||
|
}
|
||||||
|
if s.WidgetBlock {
|
||||||
|
buf.WriteByte('\'')
|
||||||
|
buf.WriteString(treenode.TypeAbbr(ast.NodeWidget.String()))
|
||||||
|
buf.WriteByte('\'')
|
||||||
|
buf.WriteString(",")
|
||||||
|
}
|
||||||
|
|
||||||
ret := buf.String()
|
ret := buf.String()
|
||||||
if "" == ret {
|
if "" == ret {
|
||||||
|
|
|
||||||
|
|
@ -99,6 +99,10 @@ func GetAssetAbsPath(asset string) (ret string) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetMimeTypeByExt(ext string) string {
|
||||||
|
return util.GetMimeTypeByExt(ext)
|
||||||
|
}
|
||||||
|
|
||||||
func SetTimezone(container, appDir, timezoneID string) {
|
func SetTimezone(container, appDir, timezoneID string) {
|
||||||
if "ios" == container {
|
if "ios" == container {
|
||||||
os.Setenv("ZONEINFO", filepath.Join(appDir, "app", "zoneinfo.zip"))
|
os.Setenv("ZONEINFO", filepath.Join(appDir, "app", "zoneinfo.zip"))
|
||||||
|
|
|
||||||
|
|
@ -971,6 +971,10 @@ func buildTypeFilter(types map[string]bool) string {
|
||||||
s.HTMLBlock = types["htmlBlock"]
|
s.HTMLBlock = types["htmlBlock"]
|
||||||
s.EmbedBlock = types["embedBlock"]
|
s.EmbedBlock = types["embedBlock"]
|
||||||
s.DatabaseBlock = types["databaseBlock"]
|
s.DatabaseBlock = types["databaseBlock"]
|
||||||
|
s.AudioBlock = types["audioBlock"]
|
||||||
|
s.VideoBlock = types["videoBlock"]
|
||||||
|
s.IFrameBlock = types["iFrameBlock"]
|
||||||
|
s.WidgetBlock = types["widgetBlock"]
|
||||||
} else {
|
} else {
|
||||||
s.Document = Conf.Search.Document
|
s.Document = Conf.Search.Document
|
||||||
s.Heading = Conf.Search.Heading
|
s.Heading = Conf.Search.Heading
|
||||||
|
|
@ -985,6 +989,10 @@ func buildTypeFilter(types map[string]bool) string {
|
||||||
s.HTMLBlock = Conf.Search.HTMLBlock
|
s.HTMLBlock = Conf.Search.HTMLBlock
|
||||||
s.EmbedBlock = Conf.Search.EmbedBlock
|
s.EmbedBlock = Conf.Search.EmbedBlock
|
||||||
s.DatabaseBlock = Conf.Search.DatabaseBlock
|
s.DatabaseBlock = Conf.Search.DatabaseBlock
|
||||||
|
s.AudioBlock = Conf.Search.AudioBlock
|
||||||
|
s.VideoBlock = Conf.Search.VideoBlock
|
||||||
|
s.IFrameBlock = Conf.Search.IFrameBlock
|
||||||
|
s.WidgetBlock = Conf.Search.WidgetBlock
|
||||||
}
|
}
|
||||||
return s.TypeFilter()
|
return s.TypeFilter()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"io"
|
"io"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
|
"mime"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
@ -28,10 +29,26 @@ import (
|
||||||
|
|
||||||
"github.com/88250/gulu"
|
"github.com/88250/gulu"
|
||||||
"github.com/88250/lute/ast"
|
"github.com/88250/lute/ast"
|
||||||
|
"github.com/gabriel-vasile/mimetype"
|
||||||
"github.com/siyuan-note/filelock"
|
"github.com/siyuan-note/filelock"
|
||||||
"github.com/siyuan-note/logging"
|
"github.com/siyuan-note/logging"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func GetMimeTypeByExt(filePath string) (ret string) {
|
||||||
|
ret = mime.TypeByExtension(filepath.Ext(filePath))
|
||||||
|
if "" == ret {
|
||||||
|
m, err := mimetype.DetectFile(filePath)
|
||||||
|
if nil != err {
|
||||||
|
logging.LogErrorf("detect mime type of [%s] failed: %s", filePath, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if nil != m {
|
||||||
|
ret = m.String()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func IsSymlinkPath(absPath string) bool {
|
func IsSymlinkPath(absPath string) bool {
|
||||||
fi, err := os.Lstat(absPath)
|
fi, err := os.Lstat(absPath)
|
||||||
if nil != err {
|
if nil != err {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue