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