mirror of
https://github.com/siyuan-note/siyuan
synced 2026-04-21 13:37:52 +00:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
0f83e59272
11 changed files with 84 additions and 89 deletions
|
|
@ -34,7 +34,7 @@ jobs:
|
|||
- name: Create PKGBUILD
|
||||
run: |
|
||||
cat << EOF >> PKGBUILD
|
||||
# maintainer: zxkmm (IHp4a21tQGhvdG1haWwuY29t)
|
||||
# maintainer: SiYuan community (https://github.com/siyuan-note/siyuan/issues/new/choose)
|
||||
# auto running on siyuan official repo
|
||||
# PKGBUILD is modified from https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=siyuan-appimage
|
||||
# which is made by vvxxp8 <concatenate[g] the characters[x] in square[b] brackets[1] in[5] order[3] at gmail dot com>
|
||||
|
|
@ -97,7 +97,7 @@ jobs:
|
|||
EOF
|
||||
|
||||
- name: Publish AUR package
|
||||
uses: KSXGitHub/github-actions-deploy-aur@v4.1.1
|
||||
uses: KSXGitHub/github-actions-deploy-aur@v4.1.2
|
||||
with:
|
||||
pkgname: siyuan-bin
|
||||
pkgbuild: ./PKGBUILD
|
||||
|
|
|
|||
|
|
@ -73,6 +73,8 @@ func buildUpdatedTaskListItemBlockDOM(id, marker string, luteEngine *lute.Lute)
|
|||
markerNode.TaskListItemMarker = liMarker
|
||||
markerNode.TaskListItemChecked = ' ' != markerNode.TaskListItemMarker
|
||||
|
||||
treenode.RefreshUpdated(li)
|
||||
|
||||
return luteEngine.RenderNodeBlockDOM(li), nil
|
||||
}
|
||||
|
||||
|
|
@ -107,11 +109,7 @@ func updateTaskListItemMarker(c *gin.Context) {
|
|||
transactions := []*model.Transaction{
|
||||
{
|
||||
DoOperations: []*model.Operation{
|
||||
{
|
||||
Action: "update",
|
||||
ID: id,
|
||||
Data: data,
|
||||
},
|
||||
{Action: "update", ID: id, Data: data},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
@ -172,11 +170,7 @@ func batchUpdateTaskListItemMarker(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
ops = append(ops, &model.Operation{
|
||||
Action: "update",
|
||||
ID: id,
|
||||
Data: data,
|
||||
})
|
||||
ops = append(ops, &model.Operation{Action: "update", ID: id, Data: data})
|
||||
}
|
||||
|
||||
tx := &model.Transaction{DoOperations: ops}
|
||||
|
|
|
|||
|
|
@ -79,6 +79,7 @@ func renameTag(c *gin.Context) {
|
|||
) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := model.RenameTag(oldLabel, newLabel); err != nil {
|
||||
ret.Code = -1
|
||||
ret.Msg = err.Error()
|
||||
|
|
|
|||
|
|
@ -935,6 +935,7 @@ func RenameAsset(oldPath, newName string) (newPath string, err error) {
|
|||
return
|
||||
}
|
||||
|
||||
historyDir, err := getHistoryDir(HistoryOpReplace, time.Now())
|
||||
luteEngine := util.NewLute()
|
||||
for _, notebook := range notebooks {
|
||||
pages := pagedPaths(filepath.Join(util.DataDir, notebook.ID), 32)
|
||||
|
|
@ -967,6 +968,7 @@ func RenameAsset(oldPath, newName string) (newPath string, err error) {
|
|||
continue
|
||||
}
|
||||
|
||||
generateTreeHistory(historyDir, tree)
|
||||
treenode.UpsertBlockTree(tree)
|
||||
sql.UpsertTreeQueue(tree)
|
||||
|
||||
|
|
@ -974,6 +976,7 @@ func RenameAsset(oldPath, newName string) (newPath string, err error) {
|
|||
}
|
||||
}
|
||||
}
|
||||
indexHistoryDir(filepath.Base(historyDir), util.NewLute())
|
||||
|
||||
storageAvDir := filepath.Join(util.DataDir, "storage", "av")
|
||||
if gulu.File.IsDir(storageAvDir) {
|
||||
|
|
|
|||
|
|
@ -507,8 +507,8 @@ func SwapBlockRef(refID, defID string, includeChildren bool) (err error) {
|
|||
}
|
||||
}
|
||||
|
||||
refreshUpdated(defNode)
|
||||
refreshUpdated(refNode)
|
||||
treenode.RefreshUpdated(defNode)
|
||||
treenode.RefreshUpdated(refNode)
|
||||
|
||||
refPivot := treenode.NewParagraph("")
|
||||
refNode.InsertBefore(refPivot)
|
||||
|
|
|
|||
|
|
@ -826,6 +826,16 @@ func generateOpTypeHistory(tree *parse.Tree, opType string) {
|
|||
return
|
||||
}
|
||||
|
||||
if err = generateTreeHistory(historyDir, tree); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
generateAvHistoryInTree(tree, historyDir)
|
||||
|
||||
indexHistoryDir(filepath.Base(historyDir), util.NewLute())
|
||||
}
|
||||
|
||||
func generateTreeHistory(historyDir string, tree *parse.Tree) (err error) {
|
||||
historyPath := filepath.Join(historyDir, tree.Box, tree.Path)
|
||||
if err = os.MkdirAll(filepath.Dir(historyPath), 0755); err != nil {
|
||||
logging.LogErrorf("generate history failed: %s", err)
|
||||
|
|
@ -842,10 +852,7 @@ func generateOpTypeHistory(tree *parse.Tree, opType string) {
|
|||
logging.LogErrorf("generate history failed: %s", err)
|
||||
return
|
||||
}
|
||||
|
||||
generateAvHistoryInTree(tree, historyDir)
|
||||
|
||||
indexHistoryDir(filepath.Base(historyDir), util.NewLute())
|
||||
return
|
||||
}
|
||||
|
||||
func generateAvHistoryInTree(tree *parse.Tree, historyDir string) {
|
||||
|
|
|
|||
|
|
@ -41,7 +41,6 @@ import (
|
|||
"github.com/88250/lute/parse"
|
||||
"github.com/88250/vitess-sqlparser/sqlparser"
|
||||
"github.com/jinzhu/copier"
|
||||
"github.com/siyuan-note/filelock"
|
||||
"github.com/siyuan-note/logging"
|
||||
"github.com/siyuan-note/siyuan/kernel/conf"
|
||||
"github.com/siyuan-note/siyuan/kernel/search"
|
||||
|
|
@ -544,22 +543,7 @@ func FindReplace(keyword, replacement string, replaceTypes map[string]bool, ids
|
|||
continue
|
||||
}
|
||||
|
||||
historyPath := filepath.Join(historyDir, tree.Box, tree.Path)
|
||||
if err = os.MkdirAll(filepath.Dir(historyPath), 0755); err != nil {
|
||||
logging.LogErrorf("generate history failed: %s", err)
|
||||
return
|
||||
}
|
||||
|
||||
var data []byte
|
||||
if data, err = filelock.ReadFile(filepath.Join(util.DataDir, tree.Box, tree.Path)); err != nil {
|
||||
logging.LogErrorf("generate history failed: %s", err)
|
||||
return
|
||||
}
|
||||
|
||||
if err = gulu.File.WriteFileSafer(historyPath, data, 0644); err != nil {
|
||||
logging.LogErrorf("generate history failed: %s", err)
|
||||
return
|
||||
}
|
||||
generateTreeHistory(historyDir, tree)
|
||||
|
||||
cachedTrees[bt.RootID] = tree
|
||||
}
|
||||
|
|
@ -1103,7 +1087,7 @@ func replaceTextNode(text *ast.Node, method int, keyword string, replacement str
|
|||
text.InsertBefore(rNode)
|
||||
}
|
||||
block := treenode.ParentBlock(text)
|
||||
refreshUpdated(block)
|
||||
treenode.RefreshUpdated(block)
|
||||
return true
|
||||
}
|
||||
} else if 3 == method {
|
||||
|
|
@ -1123,7 +1107,7 @@ func replaceTextNode(text *ast.Node, method int, keyword string, replacement str
|
|||
text.InsertBefore(rNode)
|
||||
}
|
||||
block := treenode.ParentBlock(text)
|
||||
refreshUpdated(block)
|
||||
treenode.RefreshUpdated(block)
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,8 +19,10 @@ package model
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/88250/gulu"
|
||||
"github.com/88250/lute/ast"
|
||||
|
|
@ -150,6 +152,7 @@ func RenameTag(oldLabel, newLabel string) (err error) {
|
|||
|
||||
var reloadTreeIDs []string
|
||||
updateNodes := map[string]*ast.Node{}
|
||||
historyDir, err := getHistoryDir(HistoryOpReplace, time.Now())
|
||||
|
||||
for treeID, blocks := range treeBlocks {
|
||||
util.PushEndlessProgress("[" + treeID + "]")
|
||||
|
|
@ -159,6 +162,8 @@ func RenameTag(oldLabel, newLabel string) (err error) {
|
|||
return e
|
||||
}
|
||||
|
||||
generateTreeHistory(historyDir, tree)
|
||||
|
||||
for _, blockID := range blocks {
|
||||
node := treenode.GetNodeInTree(tree, blockID)
|
||||
if nil == node {
|
||||
|
|
@ -202,6 +207,7 @@ func RenameTag(oldLabel, newLabel string) (err error) {
|
|||
reloadTreeIDs = append(reloadTreeIDs, tree.ID)
|
||||
}
|
||||
|
||||
indexHistoryDir(filepath.Base(historyDir), util.NewLute())
|
||||
sql.FlushQueue()
|
||||
|
||||
reloadTreeIDs = gulu.Str.RemoveDuplicatedElem(reloadTreeIDs)
|
||||
|
|
|
|||
|
|
@ -374,7 +374,7 @@ func RenderTemplate(p, id string, preview bool) (tree *parse.Tree, dom string, e
|
|||
n.RemoveIALAttr(av.NodeAttrNameAvs)
|
||||
|
||||
// Blocks created via template update time earlier than creation time https://github.com/siyuan-note/siyuan/issues/8607
|
||||
refreshUpdated(n)
|
||||
treenode.RefreshUpdated(n)
|
||||
}
|
||||
|
||||
if (ast.NodeListItem == n.Type && (nil == n.FirstChild ||
|
||||
|
|
|
|||
|
|
@ -526,9 +526,9 @@ func (tx *Transaction) doMove(operation *Operation) (ret *TxErr) {
|
|||
srcEmptyList.Unlink()
|
||||
}
|
||||
|
||||
refreshUpdated(srcNode)
|
||||
treenode.RefreshUpdated(srcNode)
|
||||
tx.nodes[srcNode.ID] = srcNode
|
||||
refreshUpdated(srcTree.Root)
|
||||
treenode.RefreshUpdated(srcTree.Root)
|
||||
tx.writeTree(srcTree)
|
||||
if !isSameTree {
|
||||
tx.writeTree(targetTree)
|
||||
|
|
@ -607,9 +607,9 @@ func (tx *Transaction) doMove(operation *Operation) (ret *TxErr) {
|
|||
}
|
||||
}
|
||||
|
||||
refreshUpdated(srcNode)
|
||||
treenode.RefreshUpdated(srcNode)
|
||||
tx.nodes[srcNode.ID] = srcNode
|
||||
refreshUpdated(srcTree.Root)
|
||||
treenode.RefreshUpdated(srcTree.Root)
|
||||
tx.writeTree(srcTree)
|
||||
if !isSameTree {
|
||||
tx.writeTree(targetTree)
|
||||
|
|
@ -715,11 +715,11 @@ func (tx *Transaction) doPrependInsert(operation *Operation) (ret *TxErr) {
|
|||
node.InsertAfter(toInsert)
|
||||
}
|
||||
|
||||
createdUpdated(toInsert)
|
||||
treenode.CreatedUpdated(toInsert)
|
||||
tx.nodes[toInsert.ID] = toInsert
|
||||
}
|
||||
|
||||
createdUpdated(insertedNode)
|
||||
treenode.CreatedUpdated(insertedNode)
|
||||
tx.nodes[insertedNode.ID] = insertedNode
|
||||
tx.writeTree(tree)
|
||||
|
||||
|
|
@ -822,11 +822,11 @@ func (tx *Transaction) doAppendInsert(operation *Operation) (ret *TxErr) {
|
|||
}
|
||||
}
|
||||
|
||||
createdUpdated(toInsert)
|
||||
treenode.CreatedUpdated(toInsert)
|
||||
tx.nodes[toInsert.ID] = toInsert
|
||||
}
|
||||
|
||||
createdUpdated(insertedNode)
|
||||
treenode.CreatedUpdated(insertedNode)
|
||||
tx.nodes[insertedNode.ID] = insertedNode
|
||||
tx.writeTree(tree)
|
||||
|
||||
|
|
@ -1313,7 +1313,7 @@ func (tx *Transaction) doInsert0(operation *Operation, tree *parse.Tree) (ret *T
|
|||
}
|
||||
}
|
||||
|
||||
createdUpdated(insertedNode)
|
||||
treenode.CreatedUpdated(insertedNode)
|
||||
tx.nodes[insertedNode.ID] = insertedNode
|
||||
|
||||
// 收集引用的定义块 ID
|
||||
|
|
@ -1565,7 +1565,7 @@ func (tx *Transaction) doUpdate(operation *Operation) (ret *TxErr) {
|
|||
}()
|
||||
}
|
||||
|
||||
createdUpdated(updatedNode)
|
||||
treenode.CreatedUpdated(updatedNode)
|
||||
tx.nodes[updatedNode.ID] = updatedNode
|
||||
tx.writeTree(tree)
|
||||
|
||||
|
|
@ -1735,7 +1735,7 @@ func (tx *Transaction) doUpdateUpdated(operation *Operation) (ret *TxErr) {
|
|||
}
|
||||
|
||||
node.SetIALAttr("updated", operation.Data.(string))
|
||||
createdUpdated(node)
|
||||
treenode.CreatedUpdated(node)
|
||||
tx.nodes[node.ID] = node
|
||||
tx.writeTree(tree)
|
||||
return
|
||||
|
|
@ -1777,46 +1777,6 @@ func (tx *Transaction) doSetAttrs(operation *Operation) (ret *TxErr) {
|
|||
return
|
||||
}
|
||||
|
||||
func refreshUpdated(node *ast.Node) {
|
||||
updated := util.CurrentTimeSecondsStr()
|
||||
node.SetIALAttr("updated", updated)
|
||||
parents := treenode.ParentNodesWithHeadings(node)
|
||||
for _, parent := range parents { // 更新所有父节点的更新时间字段
|
||||
parent.SetIALAttr("updated", updated)
|
||||
}
|
||||
}
|
||||
|
||||
func createdUpdated(node *ast.Node) {
|
||||
// 补全子节点的更新时间 Improve block update time filling https://github.com/siyuan-note/siyuan/issues/12182
|
||||
ast.Walk(node, func(n *ast.Node, entering bool) ast.WalkStatus {
|
||||
if !entering || !n.IsBlock() || ast.NodeKramdownBlockIAL == n.Type {
|
||||
return ast.WalkContinue
|
||||
}
|
||||
|
||||
updated := n.IALAttr("updated")
|
||||
if "" == updated && ast.IsNodeIDPattern(n.ID) {
|
||||
created := util.TimeFromID(n.ID)
|
||||
n.SetIALAttr("updated", created)
|
||||
}
|
||||
return ast.WalkContinue
|
||||
})
|
||||
|
||||
created := util.TimeFromID(node.ID)
|
||||
updated := node.IALAttr("updated")
|
||||
if !util.IsTimeStr(updated) {
|
||||
updated = created
|
||||
node.SetIALAttr("updated", updated)
|
||||
}
|
||||
if updated < created {
|
||||
updated = created
|
||||
}
|
||||
parents := treenode.ParentNodesWithHeadings(node)
|
||||
for _, parent := range parents { // 更新所有父节点的更新时间字段
|
||||
parent.SetIALAttr("updated", updated)
|
||||
cache.PutBlockIAL(parent.ID, parse.IAL2Map(parent.KramdownIAL))
|
||||
}
|
||||
}
|
||||
|
||||
type Operation struct {
|
||||
Action string `json:"action"`
|
||||
Data any `json:"data"`
|
||||
|
|
|
|||
|
|
@ -486,3 +486,43 @@ func IsChartCodeBlockCode(code *ast.Node) bool {
|
|||
language = strings.ReplaceAll(language, editor.Caret, "")
|
||||
return render.NoHighlight(language)
|
||||
}
|
||||
|
||||
func RefreshUpdated(node *ast.Node) {
|
||||
updated := util.CurrentTimeSecondsStr()
|
||||
node.SetIALAttr("updated", updated)
|
||||
parents := ParentNodesWithHeadings(node)
|
||||
for _, parent := range parents { // 更新所有父节点的更新时间字段
|
||||
parent.SetIALAttr("updated", updated)
|
||||
}
|
||||
}
|
||||
|
||||
func CreatedUpdated(node *ast.Node) {
|
||||
// 补全子节点的更新时间 Improve block update time filling https://github.com/siyuan-note/siyuan/issues/12182
|
||||
ast.Walk(node, func(n *ast.Node, entering bool) ast.WalkStatus {
|
||||
if !entering || !n.IsBlock() || ast.NodeKramdownBlockIAL == n.Type {
|
||||
return ast.WalkContinue
|
||||
}
|
||||
|
||||
updated := n.IALAttr("updated")
|
||||
if "" == updated && ast.IsNodeIDPattern(n.ID) {
|
||||
created := util.TimeFromID(n.ID)
|
||||
n.SetIALAttr("updated", created)
|
||||
}
|
||||
return ast.WalkContinue
|
||||
})
|
||||
|
||||
created := util.TimeFromID(node.ID)
|
||||
updated := node.IALAttr("updated")
|
||||
if !util.IsTimeStr(updated) {
|
||||
updated = created
|
||||
node.SetIALAttr("updated", updated)
|
||||
}
|
||||
if updated < created {
|
||||
updated = created
|
||||
}
|
||||
parents := ParentNodesWithHeadings(node)
|
||||
for _, parent := range parents { // 更新所有父节点的更新时间字段
|
||||
parent.SetIALAttr("updated", updated)
|
||||
cache.PutBlockIAL(parent.ID, parse.IAL2Map(parent.KramdownIAL))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue