mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-03-10 22:52:34 +01:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
3a6dd1c5c1
9 changed files with 119 additions and 3 deletions
32
API.md
32
API.md
|
|
@ -415,7 +415,7 @@ View API token in <kbd>Settings - About</kbd>, request header: `Authorization: T
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Get human readable path based on path
|
### Get human-readable path based on path
|
||||||
|
|
||||||
* `/api/filetree/getHPathByPath`
|
* `/api/filetree/getHPathByPath`
|
||||||
* Parameters
|
* Parameters
|
||||||
|
|
@ -439,7 +439,7 @@ View API token in <kbd>Settings - About</kbd>, request header: `Authorization: T
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Get human readable path based on ID
|
### Get human-readable path based on ID
|
||||||
|
|
||||||
* `/api/filetree/getHPathByID`
|
* `/api/filetree/getHPathByID`
|
||||||
* Parameters
|
* Parameters
|
||||||
|
|
@ -461,6 +461,32 @@ View API token in <kbd>Settings - About</kbd>, request header: `Authorization: T
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Get IDs based on human-readable path
|
||||||
|
|
||||||
|
* `/api/filetree/getIDsByHPath`
|
||||||
|
* Parameters
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"path": "/foo/bar",
|
||||||
|
"notebook": "20210808180117-czj9bvb"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
* `path`: Human-readable path
|
||||||
|
* `notebook`: Notebook ID
|
||||||
|
* Return value
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"code": 0,
|
||||||
|
"msg": "",
|
||||||
|
"data": [
|
||||||
|
"20200813004931-q4cu8na"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## Assets
|
## Assets
|
||||||
|
|
||||||
### Upload assets
|
### Upload assets
|
||||||
|
|
@ -1335,7 +1361,7 @@ View API token in <kbd>Settings - About</kbd>, request header: `Authorization: T
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
* `bodyEncoding`:The encoding scheme used by `body`, is consistent with field `responseEncoding` in request, default is `text`, optional values are as follows
|
* `bodyEncoding`: The encoding scheme used by `body`, is consistent with field `responseEncoding` in request, default is `text`, optional values are as follows
|
||||||
|
|
||||||
* `text`
|
* `text`
|
||||||
* `base64` | `base64-std`
|
* `base64` | `base64-std`
|
||||||
|
|
|
||||||
27
API_zh_CN.md
27
API_zh_CN.md
|
|
@ -19,6 +19,7 @@
|
||||||
* [移动文档](#移动文档)
|
* [移动文档](#移动文档)
|
||||||
* [根据路径获取人类可读路径](#根据路径获取人类可读路径)
|
* [根据路径获取人类可读路径](#根据路径获取人类可读路径)
|
||||||
* [根据 ID 获取人类可读路径](#根据-ID-获取人类可读路径)
|
* [根据 ID 获取人类可读路径](#根据-ID-获取人类可读路径)
|
||||||
|
* [根据人类可读路径获取 IDs](#根据人类可读路径获取-IDs)
|
||||||
* [资源文件](#资源文件)
|
* [资源文件](#资源文件)
|
||||||
* [上传资源文件](#上传资源文件)
|
* [上传资源文件](#上传资源文件)
|
||||||
* [块](#块)
|
* [块](#块)
|
||||||
|
|
@ -459,6 +460,32 @@
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### 根据人类可读路径获取 IDs
|
||||||
|
|
||||||
|
* `/api/filetree/getIDsByHPath`
|
||||||
|
* 参数
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"path": "/foo/bar",
|
||||||
|
"notebook": "20210808180117-czj9bvb"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
* `path`:人类可读路径
|
||||||
|
* `notebook`:笔记本 ID
|
||||||
|
* 返回值
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"code": 0,
|
||||||
|
"msg": "",
|
||||||
|
"data": [
|
||||||
|
"20200813004931-q4cu8na"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## 资源文件
|
## 资源文件
|
||||||
|
|
||||||
### 上传资源文件
|
### 上传资源文件
|
||||||
|
|
|
||||||
|
|
@ -57,3 +57,4 @@ Below are the detailed changes in this version.
|
||||||
* [`resize` cannot be triggered after dragging to unpin the dock](https://github.com/siyuan-note/siyuan/issues/9640)
|
* [`resize` cannot be triggered after dragging to unpin the dock](https://github.com/siyuan-note/siyuan/issues/9640)
|
||||||
* [Add licenses for the template, widget, theme and icon samples](https://github.com/siyuan-note/siyuan/issues/9641)
|
* [Add licenses for the template, widget, theme and icon samples](https://github.com/siyuan-note/siyuan/issues/9641)
|
||||||
* [Kernel API `createDocWithMd` supports concurrent calls](https://github.com/siyuan-note/siyuan/issues/9644)
|
* [Kernel API `createDocWithMd` supports concurrent calls](https://github.com/siyuan-note/siyuan/issues/9644)
|
||||||
|
* [Add kernel API `/api/filetree/getIDsByHPath`](https://github.com/siyuan-note/siyuan/issues/9654)
|
||||||
|
|
|
||||||
|
|
@ -57,3 +57,4 @@
|
||||||
* [未固定的停靠面板拖曳寬度時未觸發 `resize`](https://github.com/siyuan-note/siyuan/issues/9640)
|
* [未固定的停靠面板拖曳寬度時未觸發 `resize`](https://github.com/siyuan-note/siyuan/issues/9640)
|
||||||
* [為範本、掛件、主題和圖示範例庫新增開源許可證](https://github.com/siyuan-note/siyuan/issues/9641)
|
* [為範本、掛件、主題和圖示範例庫新增開源許可證](https://github.com/siyuan-note/siyuan/issues/9641)
|
||||||
* [核心 API `createDocWithMd` 支援並發呼叫](https://github.com/siyuan-note/siyuan/issues/9644)
|
* [核心 API `createDocWithMd` 支援並發呼叫](https://github.com/siyuan-note/siyuan/issues/9644)
|
||||||
|
* [新增核心 API `/api/filetree/getIDsByHPath`](https://github.com/siyuan-note/siyuan/issues/9654)
|
||||||
|
|
|
||||||
|
|
@ -57,3 +57,4 @@
|
||||||
* [未固定的停靠面板拖拽宽度时未触发 `resize`](https://github.com/siyuan-note/siyuan/issues/9640)
|
* [未固定的停靠面板拖拽宽度时未触发 `resize`](https://github.com/siyuan-note/siyuan/issues/9640)
|
||||||
* [为模板、挂件、主题和图标示例库添加开源许可证](https://github.com/siyuan-note/siyuan/issues/9641)
|
* [为模板、挂件、主题和图标示例库添加开源许可证](https://github.com/siyuan-note/siyuan/issues/9641)
|
||||||
* [内核 API `createDocWithMd` 支持并发调用](https://github.com/siyuan-note/siyuan/issues/9644)
|
* [内核 API `createDocWithMd` 支持并发调用](https://github.com/siyuan-note/siyuan/issues/9644)
|
||||||
|
* [新增内核 API `/api/filetree/getIDsByHPath`](https://github.com/siyuan-note/siyuan/issues/9654)
|
||||||
|
|
|
||||||
|
|
@ -249,6 +249,36 @@ func getFullHPathByID(c *gin.Context) {
|
||||||
ret.Data = hPath
|
ret.Data = hPath
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getIDsByHPath(c *gin.Context) {
|
||||||
|
ret := gulu.Ret.NewResult()
|
||||||
|
defer c.JSON(http.StatusOK, ret)
|
||||||
|
|
||||||
|
arg, ok := util.JsonArg(c, ret)
|
||||||
|
if !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if nil == arg["path"] {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if nil == arg["notebook"] {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
notebook := arg["notebook"].(string)
|
||||||
|
if util.InvalidIDPattern(notebook, ret) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
p := arg["path"].(string)
|
||||||
|
ids, err := model.GetIDsByHPath(p, notebook)
|
||||||
|
if nil != err {
|
||||||
|
ret.Code = -1
|
||||||
|
ret.Msg = err.Error()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
ret.Data = ids
|
||||||
|
}
|
||||||
|
|
||||||
func moveDocs(c *gin.Context) {
|
func moveDocs(c *gin.Context) {
|
||||||
ret := gulu.Ret.NewResult()
|
ret := gulu.Ret.NewResult()
|
||||||
defer c.JSON(http.StatusOK, ret)
|
defer c.JSON(http.StatusOK, ret)
|
||||||
|
|
|
||||||
|
|
@ -106,6 +106,7 @@ func ServeAPI(ginServer *gin.Engine) {
|
||||||
ginServer.Handle("POST", "/api/filetree/getHPathsByPaths", model.CheckAuth, getHPathsByPaths)
|
ginServer.Handle("POST", "/api/filetree/getHPathsByPaths", model.CheckAuth, getHPathsByPaths)
|
||||||
ginServer.Handle("POST", "/api/filetree/getHPathByID", model.CheckAuth, getHPathByID)
|
ginServer.Handle("POST", "/api/filetree/getHPathByID", model.CheckAuth, getHPathByID)
|
||||||
ginServer.Handle("POST", "/api/filetree/getFullHPathByID", model.CheckAuth, getFullHPathByID)
|
ginServer.Handle("POST", "/api/filetree/getFullHPathByID", model.CheckAuth, getFullHPathByID)
|
||||||
|
ginServer.Handle("POST", "/api/filetree/getIDsByHPath", model.CheckAuth, getIDsByHPath)
|
||||||
ginServer.Handle("POST", "/api/filetree/doc2Heading", model.CheckAuth, model.CheckReadonly, doc2Heading)
|
ginServer.Handle("POST", "/api/filetree/doc2Heading", model.CheckAuth, model.CheckReadonly, doc2Heading)
|
||||||
ginServer.Handle("POST", "/api/filetree/heading2Doc", model.CheckAuth, model.CheckReadonly, heading2Doc)
|
ginServer.Handle("POST", "/api/filetree/heading2Doc", model.CheckAuth, model.CheckReadonly, heading2Doc)
|
||||||
ginServer.Handle("POST", "/api/filetree/li2Doc", model.CheckAuth, model.CheckReadonly, li2Doc)
|
ginServer.Handle("POST", "/api/filetree/li2Doc", model.CheckAuth, model.CheckReadonly, li2Doc)
|
||||||
|
|
|
||||||
|
|
@ -1183,6 +1183,19 @@ func GetFullHPathByID(id string) (hPath string, err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetIDsByHPath(hpath, boxID string) (ret []string, err error) {
|
||||||
|
roots := treenode.GetBlockTreeRootsByHPath(boxID, hpath)
|
||||||
|
if 1 > len(roots) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, root := range roots {
|
||||||
|
ret = append(ret, root.ID)
|
||||||
|
}
|
||||||
|
ret = gulu.Str.RemoveDuplicatedElem(ret)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func MoveDocs(fromPaths []string, toBoxID, toPath string, callback interface{}) (err error) {
|
func MoveDocs(fromPaths []string, toBoxID, toPath string, callback interface{}) (err error) {
|
||||||
toBox := Conf.Box(toBoxID)
|
toBox := Conf.Box(toBoxID)
|
||||||
if nil == toBox {
|
if nil == toBox {
|
||||||
|
|
|
||||||
|
|
@ -143,6 +143,22 @@ func GetBlockTreeRootByHPath(boxID, hPath string) (ret *BlockTree) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetBlockTreeRootsByHPath(boxID, hPath string) (ret []*BlockTree) {
|
||||||
|
hPath = gulu.Str.RemoveInvisible(hPath)
|
||||||
|
blockTrees.Range(func(key, value interface{}) bool {
|
||||||
|
slice := value.(*btSlice)
|
||||||
|
slice.m.Lock()
|
||||||
|
for _, b := range slice.data {
|
||||||
|
if b.BoxID == boxID && b.HPath == hPath && b.RootID == b.ID {
|
||||||
|
ret = append(ret, b)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
slice.m.Unlock()
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func GetBlockTreeRootByHPathPreferredParentID(boxID, hPath, preferredParentID string) (ret *BlockTree) {
|
func GetBlockTreeRootByHPathPreferredParentID(boxID, hPath, preferredParentID string) (ret *BlockTree) {
|
||||||
hPath = gulu.Str.RemoveInvisible(hPath)
|
hPath = gulu.Str.RemoveInvisible(hPath)
|
||||||
var roots []*BlockTree
|
var roots []*BlockTree
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue