Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Vanessa 2023-06-26 21:55:58 +08:00
commit 3979b701db
6 changed files with 67 additions and 42 deletions

21
API.md
View file

@ -470,7 +470,8 @@ View API token in <kbd>Settings - About</kbd>, request header: `Authorization: T
* `"/assets/sub/"`: workspace/data/assets/sub/ folder
Under normal circumstances, it is recommended to use the first method, which is stored in the assets folder
of the workspace, putting in a subdirectory has some side effects, please refer to the assets chapter of the user guide.
of the workspace, putting in a subdirectory has some side effects, please refer to the assets chapter of the user
guide.
* `file[]`: Uploaded file list
* Return value
@ -829,9 +830,9 @@ View API token in <kbd>Settings - About</kbd>, request header: `Authorization: T
}
```
* `fromID`: Def block ID
* `toID`: Target block ID
* `refIDs`: Ref block IDs point to def block ID, optional, if not specified, all ref block IDs will be transferred
* `fromID`: Def block ID
* `toID`: Target block ID
* `refIDs`: Ref block IDs point to def block ID, optional, if not specified, all ref block IDs will be transferred
* Return value
```json
@ -1041,8 +1042,8 @@ View API token in <kbd>Settings - About</kbd>, request header: `Authorization: T
"newPath": "/data/assets/test-20230523085812-k3o9t32.png"
}
```
* `path`: the file path under the workspace path
* `newPath`: the new file path under the workspace path
* `path`: the file path under the workspace path
* `newPath`: the new file path under the workspace path
* Return value
```json
@ -1119,7 +1120,7 @@ View API token in <kbd>Settings - About</kbd>, request header: `Authorization: T
* `/api/convert/pandoc`
* Working directory
* Executing the pandoc command will set the working directory to `workspace/temp/convert/pandoc/`
* Executing the pandoc command will set the working directory to `workspace/temp/convert/pandoc/${dir}`
* API [`Put file`](#put-file) can be used to write the file to be converted to this directory first
* Then call the API for conversion, and the converted file will also be written to this directory
* Finally, call the API [`Get file`](#get-file) to get the converted file
@ -1129,6 +1130,7 @@ View API token in <kbd>Settings - About</kbd>, request header: `Authorization: T
```json
{
"dir": "test",
"args": [
"--to", "markdown_strict-raw_html",
"foo.epub",
@ -1144,9 +1146,12 @@ View API token in <kbd>Settings - About</kbd>, request header: `Authorization: T
{
"code": 0,
"msg": "",
"data": null
"data": {
"path": "/temp/convert/pandoc/test"
}
}
```
* `path`: the path under the workspace
## Notification

View file

@ -822,9 +822,9 @@
}
```
* `fromID`:定义块 ID
* `toID`:目标块 ID
* `refIDs`:指向定义块 ID 的引用所在块 ID可选如果不指定所有指向定义块 ID 的引用块 ID 都会被转移
* `fromID`:定义块 ID
* `toID`:目标块 ID
* `refIDs`:指向定义块 ID 的引用所在块 ID可选如果不指定所有指向定义块 ID 的引用块 ID 都会被转移
* 返回值
```json
@ -835,7 +835,6 @@
}
```
## 属性
### 设置块属性
@ -1035,8 +1034,8 @@
"newPath": "/data/assets/test-20230523085812-k3o9t32.png"
}
```
* `path`:工作空间路径下的文件路径
* `newPath`:新的文件路径
* `path`:工作空间路径下的文件路径
* `newPath`:新的文件路径
* 返回值
```json
@ -1113,7 +1112,7 @@
* `/api/convert/pandoc`
* 工作目录
* 执行调用 pandoc 命令时工作目录会被设置在 `工作空间/temp/convert/pandoc/` 下
* 执行调用 pandoc 命令时工作目录会被设置在 `工作空间/temp/convert/pandoc/${test}` 下
* 可先通过 API [`写入文件`](#写入文件) 将待转换文件写入该目录
* 然后再调用该 API 进行转换,转换后的文件也会被写入该目录
* 最后调用 API [`获取文件`](#获取文件) 获取转换后的文件内容
@ -1123,6 +1122,7 @@
```json
{
"dir": "test",
"args": [
"--to", "markdown_strict-raw_html",
"foo.epub",
@ -1138,9 +1138,12 @@
{
"code": 0,
"msg": "",
"data": null
"data": {
"path": "/temp/convert/pandoc/test"
}
}
```
* `path`:工作空间下的路径
## 通知

View file

@ -184,7 +184,7 @@ We release insider preview before major updates, please visit [https://github.co
## 🏘️ Community
* [English Discussion Forum](https://liuyun.io)
* [Discord](https://discord.com/invite/bzfCBwMzdP)
* [User community summary](https://liuyun.io/article/1687779743723)
* [Awesome SiYuan](https://github.com/siyuan-note/awesome)
## 🛠️ Development Guide

View file

@ -21,7 +21,7 @@
border: 1px solid rgba(0, 0, 0, .06);
min-height: 100vh;
box-sizing: border-box;
padding: 0 calc((100vw - 608px) / 2);
padding: 0 calc((100vw - 608px) * 0.3);
}
.fn__flex-1 {
@ -31,7 +31,7 @@
}
h2 {
margin: 0 0 4px 0;
margin: 0 0 12px 0;
line-height: 24px;
}
@ -200,7 +200,7 @@
<label class="b3-label">
<div>
🌐 外观语言
<div class="b3-label__text">用户界面语言,后续可在 <kbd>设置</kbd> - <kbd>外观</kbd> 中切换</div>
<div class="b3-label__text">用户界面语言,后续可<kbd>设置</kbd> - <kbd>外观</kbd>进行切换</div>
</div>
<div class="fn__space"></div>
<div class="fn__flex-1"></div>
@ -215,7 +215,7 @@
<label class="b3-label">
<div>
🗂️ 工作空间
<div class="b3-label__text"> 工作空间用于存放数据,后续可在顶栏菜单中切换</div>
<div class="b3-label__text"> 工作空间用于存放数据,后续可在顶栏左上角的主菜单中进行切换</div>
</div>
<div class="fn__space"></div>
<div class="fn__flex-1"></div>
@ -228,7 +228,7 @@
<div class="feedback">
<span>❤️ <a href="https://ld246.com/article/1649901726096" target="_blank">求助反馈建议</a></span>
<span>🏘️ <a href="https://ld246.com/article/1640266171309" target="_blank">用户社区汇总</a></span>
<span><a href="https://b3log.org/siyuan/download.html" target="_blank" class="version"></a></span>
<span>🔖 <a href="https://b3log.org/siyuan/download.html" target="_blank" class="version"></a></span>
</div>
<div class="fn__flex-1"></div>
</div>
@ -241,8 +241,7 @@
<label class="b3-label">
<div>
🌐 Language
<div class="b3-label__text">User interface language, which can be switched later in <br>
<kbd>Settings</kbd> - <kbd>Appearance</kbd>
<div class="b3-label__text">User interface language, which can be switched later in <kbd>Settings</kbd> - <kbd>Appearance</kbd>
</div>
</div>
<div class="fn__space"></div>
@ -258,8 +257,7 @@
<label class="b3-label">
<div>
🗂️ Workspace
<div class="b3-label__text">The workspace is used to store data, which can be switched <br>
later in the top bar menu later
<div class="b3-label__text">The workspace is used to store data, which can be switched later in the top bar menu later
</div>
</div>
<div class="fn__space"></div>
@ -268,11 +266,12 @@
</label>
<div class="fn__flex-1"></div>
<div class="fn__flex-1 notice">
<span>⚠️ Do not use a third-party synchronization disk to synchronize data, otherwise it will cause abnormal operation and data damage</span>
<span>⚠️ Do not use a third-party sync disk to sync data, otherwise it will cause abnormal operation and data damage</span>
</div>
<div class="feedback">
<span>❤️ <a href="https://liuyun.io/article/1686530886208" target="_blank">Feedback and support</a></span>
<span><a href="https://b3log.org/siyuan/en/download.html" target="_blank" class="version"></a></span>
<span>❤️ <a href="https://liuyun.io/article/1686530886208" target="_blank">Support and Feedback</a></span>
<span>🏘️ <a href="https://liuyun.io/article/1687779743723" target="_blank">User community summary</a></span>
<span>🔖 <a href="https://b3log.org/siyuan/en/download.html" target="_blank" class="version"></a></span>
</div>
<div class="fn__flex-1"></div>
</div>
@ -284,6 +283,10 @@
</svg>
<div class="drag"></div>
<script>
const isChinese = (lang) => {
return 'zh_CN' === lang || 'zh_CHT' === lang
}
const getSearch = (key) => {
if (window.location.search.indexOf('?') === -1) {
return ''
@ -302,7 +305,7 @@
let currentLang = decodeURIComponent(getSearch('lang'))
const setLang = (lang) => {
if ('zh_CN' === lang) {
if (isChinese(lang)) {
document.title = `思源笔记 v${getSearch('v')}`
document.getElementById('zhCN').classList.remove('fn__none')
document.getElementById('enUS').classList.add('fn__none')
@ -316,7 +319,7 @@
setLang(currentLang)
document.querySelectorAll('.version').forEach(item => {
item.textContent = `🔖 v${getSearch('v')}`
item.textContent = `v${getSearch('v')}`
})
document.querySelectorAll('.icon').forEach(item => {
@ -359,7 +362,7 @@
const initPath = result.filePaths[0]
if (isICloudPath(initPath)) {
let msg = '⚠️ This folder is under the iCloud sync path, please change another path'
if ('zh_CN' === currentLang) {
if (isChinese(currentLang)) {
msg = '⚠️ 该文件夹位于 iCloud 同步路径下,请更换其他路径'
}
alert(msg)
@ -368,7 +371,7 @@
if (isCloudDrivePath(initPath)) {
let msg = '⚠️ The folder path can not contain onedrive, dropbox, google drive, pcloud and 坚果云, please change another path'
if ('zh_CN' === currentLang) {
if (isChinese(currentLang)) {
msg = '⚠️ 文件夹路径不能包含 onedrive、dropbox、google drive、pcloud 和 坚果云,请更换其他路径'
}
alert(msg)
@ -376,7 +379,7 @@
}
let msg = '⚠️ Do not set the workspace under the path of a third-party sync disk, otherwise the data will be damaged (iCloud/OneDrive/Dropbox/Google Drive/Nutstore/Baidu Netdisk/Tencent Weiyun, etc.), continue?'
if ('zh_CN' === currentLang) {
if (isChinese(currentLang)) {
msg = '⚠️ 请勿将工作空间设置在第三方同步盘路径下否则数据会被损坏iCloud/OneDrive/Dropbox/Google Drive/坚果云/百度网盘/腾讯微云等),是否继续?'
}
if (!confirm(msg)) {

View file

@ -33,17 +33,27 @@ func pandoc(c *gin.Context) {
return
}
dir := gulu.Rand.String(7)
dirArg := arg["dir"]
if nil != dirArg {
dir = dirArg.(string)
}
pandocArgs := arg["args"].([]interface{})
var args []string
for _, v := range pandocArgs {
args = append(args, v.(string))
}
err := util.ConvertPandoc(args...)
path, err := util.ConvertPandoc(dir, args...)
if nil != err {
ret.Code = -1
ret.Msg = err.Error()
return
}
ret.Data = map[string]interface{}{
"path": path,
}
return
}

View file

@ -29,24 +29,28 @@ import (
"github.com/siyuan-note/logging"
)
func ConvertPandoc(args ...string) (err error) {
func ConvertPandoc(dir string, args ...string) (path string, err error) {
if "" == PandocBinPath || ContainerStd != Container {
return errors.New("not found executable pandoc")
err = errors.New("not found executable pandoc")
return
}
pandoc := exec.Command(PandocBinPath, args...)
gulu.CmdAttr(pandoc)
dir := filepath.Join(WorkspaceDir, "temp", "convert", "pandoc", gulu.Rand.String(7))
if err = os.MkdirAll(dir, 0755); nil != err {
logging.LogErrorf("mkdir [%s] failed: [%s]", dir, err)
path = filepath.Join("temp", "convert", "pandoc", dir)
absPath := filepath.Join(WorkspaceDir, path)
if err = os.MkdirAll(absPath, 0755); nil != err {
logging.LogErrorf("mkdir [%s] failed: [%s]", absPath, err)
return
}
pandoc.Dir = dir
pandoc.Dir = absPath
output, err := pandoc.CombinedOutput()
if nil != err {
logging.LogErrorf("pandoc convert output [%s]", string(output))
err = errors.Join(err, errors.New(string(output)))
logging.LogErrorf("pandoc convert output failed: %s", err)
return
}
path = "/" + filepath.ToSlash(path)
return
}