mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-12 23:21:23 +08:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
406281bb12
@ -86,7 +86,7 @@ func getAttributeViewPrimaryKeyValues(c *gin.Context) {
|
|||||||
if keywordArg := arg["keyword"]; nil != keywordArg {
|
if keywordArg := arg["keyword"]; nil != keywordArg {
|
||||||
keyword = keywordArg.(string)
|
keyword = keywordArg.(string)
|
||||||
}
|
}
|
||||||
attributeViewName, rows, err := model.GetAttributeViewPrimaryKeyValues(id, keyword, page, pageSize)
|
attributeViewName, databaseBlockIDs, rows, err := model.GetAttributeViewPrimaryKeyValues(id, keyword, page, pageSize)
|
||||||
if nil != err {
|
if nil != err {
|
||||||
ret.Code = -1
|
ret.Code = -1
|
||||||
ret.Msg = err.Error()
|
ret.Msg = err.Error()
|
||||||
@ -94,8 +94,9 @@ func getAttributeViewPrimaryKeyValues(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ret.Data = map[string]interface{}{
|
ret.Data = map[string]interface{}{
|
||||||
"name": attributeViewName,
|
"name": attributeViewName,
|
||||||
"rows": rows,
|
"blockIDs": databaseBlockIDs,
|
||||||
|
"rows": rows,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -501,9 +501,9 @@ func NewFormattedValueDate(content, content2 int64, format DateFormat, isNotTime
|
|||||||
formatted = contentTime.Format("2006-01-02 15:04")
|
formatted = contentTime.Format("2006-01-02 15:04")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
content2Time := time.UnixMilli(content2)
|
||||||
if hasEndDate {
|
if hasEndDate {
|
||||||
var formattedContent2 string
|
var formattedContent2 string
|
||||||
content2Time := time.UnixMilli(content2)
|
|
||||||
if isNotTime {
|
if isNotTime {
|
||||||
formattedContent2 = content2Time.Format("2006-01-02")
|
formattedContent2 = content2Time.Format("2006-01-02")
|
||||||
} else {
|
} else {
|
||||||
@ -523,6 +523,8 @@ func NewFormattedValueDate(content, content2 int64, format DateFormat, isNotTime
|
|||||||
ret = &ValueDate{
|
ret = &ValueDate{
|
||||||
Content: content,
|
Content: content,
|
||||||
Content2: content2,
|
Content2: content2,
|
||||||
|
IsNotEmpty: true,
|
||||||
|
IsNotEmpty2: !content2Time.IsZero(),
|
||||||
HasEndDate: hasEndDate,
|
HasEndDate: hasEndDate,
|
||||||
IsNotTime: true,
|
IsNotTime: true,
|
||||||
FormattedContent: formatted,
|
FormattedContent: formatted,
|
||||||
|
@ -76,7 +76,7 @@ func Icons() (icons []*Icon) {
|
|||||||
icon.IconURL = util.BazaarOSSServer + "/package/" + repoURL + "/icon.png"
|
icon.IconURL = util.BazaarOSSServer + "/package/" + repoURL + "/icon.png"
|
||||||
icon.Funding = repo.Package.Funding
|
icon.Funding = repo.Package.Funding
|
||||||
icon.PreferredFunding = getPreferredFunding(icon.Funding)
|
icon.PreferredFunding = getPreferredFunding(icon.Funding)
|
||||||
icon.PreferredName = getPreferredName(icon.Package)
|
icon.PreferredName = GetPreferredName(icon.Package)
|
||||||
icon.PreferredDesc = getPreferredDesc(icon.Description)
|
icon.PreferredDesc = getPreferredDesc(icon.Description)
|
||||||
icon.Updated = repo.Updated
|
icon.Updated = repo.Updated
|
||||||
icon.Stars = repo.Stars
|
icon.Stars = repo.Stars
|
||||||
@ -140,7 +140,7 @@ func InstalledIcons() (ret []*Icon) {
|
|||||||
icon.PreviewURLThumb = "/appearance/icons/" + dirName + "/preview.png"
|
icon.PreviewURLThumb = "/appearance/icons/" + dirName + "/preview.png"
|
||||||
icon.IconURL = "/appearance/icons/" + dirName + "/icon.png"
|
icon.IconURL = "/appearance/icons/" + dirName + "/icon.png"
|
||||||
icon.PreferredFunding = getPreferredFunding(icon.Funding)
|
icon.PreferredFunding = getPreferredFunding(icon.Funding)
|
||||||
icon.PreferredName = getPreferredName(icon.Package)
|
icon.PreferredName = GetPreferredName(icon.Package)
|
||||||
icon.PreferredDesc = getPreferredDesc(icon.Description)
|
icon.PreferredDesc = getPreferredDesc(icon.Description)
|
||||||
info, statErr := os.Stat(filepath.Join(installPath, "README.md"))
|
info, statErr := os.Stat(filepath.Join(installPath, "README.md"))
|
||||||
if nil != statErr {
|
if nil != statErr {
|
||||||
|
@ -161,7 +161,7 @@ func getPreferredReadme(readme *Readme) string {
|
|||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
func getPreferredName(pkg *Package) string {
|
func GetPreferredName(pkg *Package) string {
|
||||||
if nil == pkg.DisplayName {
|
if nil == pkg.DisplayName {
|
||||||
return pkg.Name
|
return pkg.Name
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,7 @@ func Plugins(frontend string) (plugins []*Plugin) {
|
|||||||
plugin.IconURL = util.BazaarOSSServer + "/package/" + repoURL + "/icon.png"
|
plugin.IconURL = util.BazaarOSSServer + "/package/" + repoURL + "/icon.png"
|
||||||
plugin.Funding = repo.Package.Funding
|
plugin.Funding = repo.Package.Funding
|
||||||
plugin.PreferredFunding = getPreferredFunding(plugin.Funding)
|
plugin.PreferredFunding = getPreferredFunding(plugin.Funding)
|
||||||
plugin.PreferredName = getPreferredName(plugin.Package)
|
plugin.PreferredName = GetPreferredName(plugin.Package)
|
||||||
plugin.PreferredDesc = getPreferredDesc(plugin.Description)
|
plugin.PreferredDesc = getPreferredDesc(plugin.Description)
|
||||||
plugin.Updated = repo.Updated
|
plugin.Updated = repo.Updated
|
||||||
plugin.Stars = repo.Stars
|
plugin.Stars = repo.Stars
|
||||||
@ -136,7 +136,7 @@ func ParseInstalledPlugin(name, frontend string) (found bool, displayName string
|
|||||||
}
|
}
|
||||||
|
|
||||||
found = true
|
found = true
|
||||||
displayName = getPreferredName(plugin.Package)
|
displayName = GetPreferredName(plugin.Package)
|
||||||
incompatible = isIncompatiblePlugin(plugin, frontend)
|
incompatible = isIncompatiblePlugin(plugin, frontend)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
@ -179,7 +179,7 @@ func InstalledPlugins(frontend string, checkUpdate bool) (ret []*Plugin) {
|
|||||||
plugin.PreviewURLThumb = "/plugins/" + dirName + "/preview.png"
|
plugin.PreviewURLThumb = "/plugins/" + dirName + "/preview.png"
|
||||||
plugin.IconURL = "/plugins/" + dirName + "/icon.png"
|
plugin.IconURL = "/plugins/" + dirName + "/icon.png"
|
||||||
plugin.PreferredFunding = getPreferredFunding(plugin.Funding)
|
plugin.PreferredFunding = getPreferredFunding(plugin.Funding)
|
||||||
plugin.PreferredName = getPreferredName(plugin.Package)
|
plugin.PreferredName = GetPreferredName(plugin.Package)
|
||||||
plugin.PreferredDesc = getPreferredDesc(plugin.Description)
|
plugin.PreferredDesc = getPreferredDesc(plugin.Description)
|
||||||
info, statErr := os.Stat(filepath.Join(installPath, "README.md"))
|
info, statErr := os.Stat(filepath.Join(installPath, "README.md"))
|
||||||
if nil != statErr {
|
if nil != statErr {
|
||||||
|
@ -78,7 +78,7 @@ func Templates() (templates []*Template) {
|
|||||||
template.IconURL = util.BazaarOSSServer + "/package/" + repoURL + "/icon.png"
|
template.IconURL = util.BazaarOSSServer + "/package/" + repoURL + "/icon.png"
|
||||||
template.Funding = repo.Package.Funding
|
template.Funding = repo.Package.Funding
|
||||||
template.PreferredFunding = getPreferredFunding(template.Funding)
|
template.PreferredFunding = getPreferredFunding(template.Funding)
|
||||||
template.PreferredName = getPreferredName(template.Package)
|
template.PreferredName = GetPreferredName(template.Package)
|
||||||
template.PreferredDesc = getPreferredDesc(template.Description)
|
template.PreferredDesc = getPreferredDesc(template.Description)
|
||||||
template.Updated = repo.Updated
|
template.Updated = repo.Updated
|
||||||
template.Stars = repo.Stars
|
template.Stars = repo.Stars
|
||||||
@ -142,7 +142,7 @@ func InstalledTemplates() (ret []*Template) {
|
|||||||
template.PreviewURLThumb = "/templates/" + dirName + "/preview.png"
|
template.PreviewURLThumb = "/templates/" + dirName + "/preview.png"
|
||||||
template.IconURL = "/templates/" + dirName + "/icon.png"
|
template.IconURL = "/templates/" + dirName + "/icon.png"
|
||||||
template.PreferredFunding = getPreferredFunding(template.Funding)
|
template.PreferredFunding = getPreferredFunding(template.Funding)
|
||||||
template.PreferredName = getPreferredName(template.Package)
|
template.PreferredName = GetPreferredName(template.Package)
|
||||||
template.PreferredDesc = getPreferredDesc(template.Description)
|
template.PreferredDesc = getPreferredDesc(template.Description)
|
||||||
info, statErr := os.Stat(filepath.Join(installPath, "README.md"))
|
info, statErr := os.Stat(filepath.Join(installPath, "README.md"))
|
||||||
if nil != statErr {
|
if nil != statErr {
|
||||||
|
@ -78,7 +78,7 @@ func Themes() (ret []*Theme) {
|
|||||||
theme.IconURL = util.BazaarOSSServer + "/package/" + repoURL + "/icon.png"
|
theme.IconURL = util.BazaarOSSServer + "/package/" + repoURL + "/icon.png"
|
||||||
theme.Funding = repo.Package.Funding
|
theme.Funding = repo.Package.Funding
|
||||||
theme.PreferredFunding = getPreferredFunding(theme.Funding)
|
theme.PreferredFunding = getPreferredFunding(theme.Funding)
|
||||||
theme.PreferredName = getPreferredName(theme.Package)
|
theme.PreferredName = GetPreferredName(theme.Package)
|
||||||
theme.PreferredDesc = getPreferredDesc(theme.Description)
|
theme.PreferredDesc = getPreferredDesc(theme.Description)
|
||||||
theme.Updated = repo.Updated
|
theme.Updated = repo.Updated
|
||||||
theme.Stars = repo.Stars
|
theme.Stars = repo.Stars
|
||||||
@ -142,7 +142,7 @@ func InstalledThemes() (ret []*Theme) {
|
|||||||
theme.PreviewURLThumb = "/appearance/themes/" + dirName + "/preview.png"
|
theme.PreviewURLThumb = "/appearance/themes/" + dirName + "/preview.png"
|
||||||
theme.IconURL = "/appearance/themes/" + dirName + "/icon.png"
|
theme.IconURL = "/appearance/themes/" + dirName + "/icon.png"
|
||||||
theme.PreferredFunding = getPreferredFunding(theme.Funding)
|
theme.PreferredFunding = getPreferredFunding(theme.Funding)
|
||||||
theme.PreferredName = getPreferredName(theme.Package)
|
theme.PreferredName = GetPreferredName(theme.Package)
|
||||||
theme.PreferredDesc = getPreferredDesc(theme.Description)
|
theme.PreferredDesc = getPreferredDesc(theme.Description)
|
||||||
info, statErr := os.Stat(filepath.Join(installPath, "README.md"))
|
info, statErr := os.Stat(filepath.Join(installPath, "README.md"))
|
||||||
if nil != statErr {
|
if nil != statErr {
|
||||||
|
@ -78,7 +78,7 @@ func Widgets() (widgets []*Widget) {
|
|||||||
widget.IconURL = util.BazaarOSSServer + "/package/" + repoURL + "/icon.png"
|
widget.IconURL = util.BazaarOSSServer + "/package/" + repoURL + "/icon.png"
|
||||||
widget.Funding = repo.Package.Funding
|
widget.Funding = repo.Package.Funding
|
||||||
widget.PreferredFunding = getPreferredFunding(widget.Funding)
|
widget.PreferredFunding = getPreferredFunding(widget.Funding)
|
||||||
widget.PreferredName = getPreferredName(widget.Package)
|
widget.PreferredName = GetPreferredName(widget.Package)
|
||||||
widget.PreferredDesc = getPreferredDesc(widget.Description)
|
widget.PreferredDesc = getPreferredDesc(widget.Description)
|
||||||
widget.Updated = repo.Updated
|
widget.Updated = repo.Updated
|
||||||
widget.Stars = repo.Stars
|
widget.Stars = repo.Stars
|
||||||
@ -140,7 +140,7 @@ func InstalledWidgets() (ret []*Widget) {
|
|||||||
widget.PreviewURLThumb = "/widgets/" + dirName + "/preview.png"
|
widget.PreviewURLThumb = "/widgets/" + dirName + "/preview.png"
|
||||||
widget.IconURL = "/widgets/" + dirName + "/icon.png"
|
widget.IconURL = "/widgets/" + dirName + "/icon.png"
|
||||||
widget.PreferredFunding = getPreferredFunding(widget.Funding)
|
widget.PreferredFunding = getPreferredFunding(widget.Funding)
|
||||||
widget.PreferredName = getPreferredName(widget.Package)
|
widget.PreferredName = GetPreferredName(widget.Package)
|
||||||
widget.PreferredDesc = getPreferredDesc(widget.Description)
|
widget.PreferredDesc = getPreferredDesc(widget.Description)
|
||||||
info, statErr := os.Stat(filepath.Join(installPath, "README.md"))
|
info, statErr := os.Stat(filepath.Join(installPath, "README.md"))
|
||||||
if nil != statErr {
|
if nil != statErr {
|
||||||
|
@ -55,7 +55,7 @@ func SetDatabaseBlockView(blockID, viewID string) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetAttributeViewPrimaryKeyValues(avID, keyword string, page, pageSize int) (attributeViewName string, keyValues *av.KeyValues, err error) {
|
func GetAttributeViewPrimaryKeyValues(avID, keyword string, page, pageSize int) (attributeViewName string, databaseBlockIDs []string, keyValues *av.KeyValues, err error) {
|
||||||
waitForSyncingStorages()
|
waitForSyncingStorages()
|
||||||
|
|
||||||
attrView, err := av.ParseAttributeView(avID)
|
attrView, err := av.ParseAttributeView(avID)
|
||||||
@ -65,6 +65,8 @@ func GetAttributeViewPrimaryKeyValues(avID, keyword string, page, pageSize int)
|
|||||||
}
|
}
|
||||||
attributeViewName = attrView.Name
|
attributeViewName = attrView.Name
|
||||||
|
|
||||||
|
databaseBlockIDs = treenode.GetMirrorAttrViewBlockIDs(avID)
|
||||||
|
|
||||||
keyValues = attrView.GetBlockKeyValues()
|
keyValues = attrView.GetBlockKeyValues()
|
||||||
// 过滤掉不在视图中的值
|
// 过滤掉不在视图中的值
|
||||||
tmp := map[string]*av.Value{}
|
tmp := map[string]*av.Value{}
|
||||||
|
@ -369,7 +369,7 @@ func SearchRefBlock(id, rootID, keyword string, beforeLen int, isSquareBrackets
|
|||||||
b.RefText = getBlockRefText(b.ID, tree)
|
b.RefText = getBlockRefText(b.ID, tree)
|
||||||
|
|
||||||
hitFirstChildID := false
|
hitFirstChildID := false
|
||||||
if b.IsContainerBlock() {
|
if b.IsContainerBlock() && "NodeDocument" != b.Type {
|
||||||
// `((` 引用候选中排除当前块的父块 https://github.com/siyuan-note/siyuan/issues/4538
|
// `((` 引用候选中排除当前块的父块 https://github.com/siyuan-note/siyuan/issues/4538
|
||||||
tree := cachedTrees[b.RootID]
|
tree := cachedTrees[b.RootID]
|
||||||
if nil == tree {
|
if nil == tree {
|
||||||
|
@ -22,54 +22,45 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/siyuan-note/logging"
|
"github.com/siyuan-note/logging"
|
||||||
"github.com/siyuan-note/siyuan/kernel/search"
|
"github.com/siyuan-note/siyuan/kernel/bazaar"
|
||||||
"github.com/siyuan-note/siyuan/kernel/util"
|
"github.com/siyuan-note/siyuan/kernel/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
func SearchWidget(keyword string) (ret []*Block) {
|
func SearchWidget(keyword string) (ret []*Block) {
|
||||||
ret = []*Block{}
|
ret = []*Block{}
|
||||||
widgets := filepath.Join(util.DataDir, "widgets")
|
widgetsDir := filepath.Join(util.DataDir, "widgets")
|
||||||
entries, err := os.ReadDir(widgets)
|
entries, err := os.ReadDir(widgetsDir)
|
||||||
if nil != err {
|
if nil != err {
|
||||||
logging.LogErrorf("read dir [%s] failed: %s", widgets, err)
|
logging.LogErrorf("read dir [%s] failed: %s", widgetsDir, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
k := strings.ToLower(keyword)
|
k := strings.ToLower(keyword)
|
||||||
|
var widgets []*bazaar.Widget
|
||||||
for _, entry := range entries {
|
for _, entry := range entries {
|
||||||
if !util.IsDirRegularOrSymlink(entry) {
|
if !util.IsDirRegularOrSymlink(entry) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if strings.HasPrefix(entry.Name(), ".") {
|
||||||
isWidgetDir := false
|
|
||||||
subEntries, readErr := os.ReadDir(filepath.Join(widgets, entry.Name()))
|
|
||||||
if nil != readErr {
|
|
||||||
logging.LogWarnf("read dir [%s] failed: %s", filepath.Join(widgets, entry.Name()), readErr)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
for _, subEntry := range subEntries {
|
|
||||||
if !subEntry.IsDir() && "widget.json" == subEntry.Name() {
|
|
||||||
isWidgetDir = true
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if !isWidgetDir {
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
name := strings.ToLower(entry.Name())
|
widget, _ := bazaar.WidgetJSON(entry.Name())
|
||||||
if strings.HasPrefix(name, ".") {
|
if nil == widget {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.Contains(name, k) {
|
widgets = append(widgets, widget)
|
||||||
name = entry.Name()
|
|
||||||
if "" != keyword {
|
|
||||||
_, name = search.MarkText(entry.Name(), keyword, 32, Conf.Search.CaseSensitive)
|
|
||||||
}
|
|
||||||
b := &Block{Content: name}
|
|
||||||
ret = append(ret, b)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
widgets = filterWidgets(widgets, k)
|
||||||
|
for _, widget := range widgets {
|
||||||
|
b := &Block{
|
||||||
|
Name: bazaar.GetPreferredName(widget.Package),
|
||||||
|
Content: widget.Name,
|
||||||
|
}
|
||||||
|
ret = append(ret, b)
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user