mirror of
https://github.com/kovetskiy/mark.git
synced 2025-04-24 05:42:40 +08:00
do not break ancestry tree
Running `mark` for updating page, deeply nested in some tree, ended up page being shifted to the Ctulhu's void, e.g. not belonging to any parent.
This commit is contained in:
parent
766aba2508
commit
064b3886ec
13
main.go
13
main.go
@ -57,9 +57,14 @@ Options:
|
||||
|
||||
type PageInfo struct {
|
||||
Title string `json:"title"`
|
||||
|
||||
Version struct {
|
||||
Number int64 `json:"number"`
|
||||
} `json:"version"`
|
||||
|
||||
Ancestors []struct {
|
||||
Id string `json:"id"`
|
||||
} `json:"ancestors"`
|
||||
}
|
||||
|
||||
func main() {
|
||||
@ -188,6 +193,9 @@ func updatePage(
|
||||
"number": nextPageVersion,
|
||||
"minorEdit": false,
|
||||
},
|
||||
"ancestors": []map[string]interface{}{
|
||||
{"id": pageInfo.Ancestors[len(pageInfo.Ancestors)-1].Id},
|
||||
},
|
||||
"body": map[string]interface{}{
|
||||
"storage": map[string]interface{}{
|
||||
"value": string(newContent),
|
||||
@ -220,7 +228,10 @@ func updatePage(
|
||||
func getPageInfo(
|
||||
api *gopencils.Resource, pageID string,
|
||||
) (PageInfo, error) {
|
||||
request, err := api.Res("content/"+pageID, &PageInfo{}).Get()
|
||||
request, err := api.Res(
|
||||
"content/"+pageID, &PageInfo{},
|
||||
).Get(map[string]string{"expand": "ancestors,version"})
|
||||
|
||||
if err != nil {
|
||||
return PageInfo{}, err
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user