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

This commit is contained in:
Vanessa 2022-08-31 12:57:49 +08:00
commit f9502f38ee
16 changed files with 75 additions and 59 deletions

View file

@ -810,7 +810,7 @@
"33": "Insufficient permissions to read and write files or access to the network, please check the permissions of the workspace folder and the settings of the anti-virus software/firewall. If you have run SiYuan as an administrator before, please consider switching to a new workspace directory, and do not run it as an administrator in the future (the current workspace directory may no longer be accessible by ordinary users)",
"34": "This operation is not supported in read-only mode",
"35": "Rebuilding index, please wait...",
"36": "TODO",
"36": "There is too much content in the historical document, in order not to affect performance, it has been switched to plain text display",
"37": "Do not include spaces and special symbols in the name of the cloud sync directory",
"38": "The number of mentioned keywords [%d] is too many, currently only supports up to [512] keywords",
"39": "Deleting index %s",

View file

@ -810,7 +810,7 @@
"33": "Permisos insuficientes para leer y escribir archivos o acceso a la red, por favor comprueba los permisos de la carpeta del espacio de trabajo y la configuración del software antivirus/firewall. Si has ejecutado SiYuan como administrador antes, por favor considera cambiar a un nuevo directorio de espacio de trabajo, y no lo ejecutes como administrador en el futuro (el directorio de espacio de trabajo actual puede que ya no sea accesible por los usuarios ordinarios)",
"34": "Esta operación no es compatible con el modo de sólo lectura",
"35": "Reconstruyendo el índice, por favor espere...",
"36": "TODO",
"36": "Hay demasiado contenido en el documento historico, para no afectar el rendimiento, se ha cambiado a visualizacion de texto sin formato",
"37": "No incluyas espacios ni símbolos especiales en el nombre del directorio de sincronización con la nube",
"38": "El número de palabras clave mencionadas [%d] son demasiados, actualmente solo admite hasta [512] palabras clave",
"39": "Eliminando índice %s",

View file

@ -810,7 +810,7 @@
"33": "Autorisations insuffisantes pour lire et écrire des fichiers ou accéder au réseau, veuillez vérifier les autorisations du dossier de l'espace de travail et les paramètres du logiciel anti-virus/pare-feu. Si vous avez déjà exécuté SiYuan en tant qu'administrateur, envisagez de passer à un nouveau répertoire d'espace de travail et ne l'exécutez plus en tant qu'administrateur à l'avenir (le répertoire d'espace de travail actuel peut ne plus être accessible aux utilisateurs ordinaires) ",
"34": "Cette opération n'est pas supportée en mode lecture seule.",
"35": "Recréation de l'index, veuillez patienter...",
"36": "TODO",
"36": "Il y a trop de contenu dans le document historique, afin de ne pas affecter les performances, il a été basculé sur l'affichage en texte brut",
"37": "N'incluez pas d'espaces et de symboles spéciaux dans le nom du répertoire de synchronisation cloud",
"38": "Le nombre de mots-clés mentionnés [%d] est trop élevé, ne prend actuellement en charge que jusqu'à [512] mots-clés",
"39": "Suppression de l'index %s",

View file

@ -810,7 +810,7 @@
"33": "讀寫檔或存取網路權限不足,請檢查工作空間資料夾權限和防毒軟體/防火牆的設置。如果你曾經使用管理員身份運行過思源,請考慮切換到新的工作空間目錄,後續請勿使用管理員身份運行(當前的工作空間目錄可能已經無法使用普通用戶存取)",
"34": "唯讀模式下不支援該操作",
"35": "正在重建索引,請稍等...",
"36": "TODO",
"36": "歷史文檔內容太多,為了不影響性能,已經切換為純文本顯示",
"37": "雲端同步目錄的名稱請勿包含空格和特殊符號",
"38": "提及關鍵字數量 [%d] 過多,目前最多僅支援搜索 [512] 個關鍵字",
"39": "正在刪除索引 %s",

View file

@ -811,7 +811,7 @@
"33": "读写文件或访问网络权限不足,请检查工作空间文件夹权限和杀毒软件/防火墙的设置。如果你曾经使用管理员身份运行过思源,请考虑切换到新的工作空间目录,后续请勿使用管理员身份运行(当前的工作空间目录可能已经无法使用普通用户访问)",
"34": "只读模式下不支持该操作",
"35": "正在重建索引,请稍等...",
"36": "TODO",
"36": "历史文档内容太多,为了不影响性能,已经切换为纯文本显示",
"37": "云端同步目录的名称请勿包含空格和特殊符号",
"38": "提及关键字数量 [%d] 过多,目前最多仅支持搜索 [512] 个关键字",
"39": "正在删除索引 %s",

View file

@ -82,7 +82,7 @@ func html2BlockDOM(c *gin.Context) {
n.Unlink()
}
if "std" == model.Conf.System.Container {
if util.ContainerStd == model.Conf.System.Container {
// 处理本地资源文件复制
ast.Walk(tree.Root, func(n *ast.Node, entering bool) ast.WalkStatus {
if !entering || ast.NodeLinkDest != n.Type {

View file

@ -31,7 +31,7 @@ import (
var assetsWatcher *fsnotify.Watcher
func WatchAssets() {
if "android" == util.Container || "ios" == util.Container {
if util.ContainerAndroid == util.Container || util.ContainerIOS == util.Container {
return
}

View file

@ -476,13 +476,13 @@ func ReindexTree(path string) (err error) {
func RefreshFileTree() {
WaitForWritingFiles()
util.PushEndlessProgress(Conf.Language(35))
if err := sql.InitDatabase(true); nil != err {
util.PushErrMsg(fmt.Sprintf(Conf.Language(85), err), 5000)
return
}
treenode.InitBlockTree(true)
util.PushEndlessProgress(Conf.Language(35))
openedBoxes := Conf.GetOpenedBoxes()
for _, openedBox := range openedBoxes {
openedBox.Index(true)

View file

@ -1198,7 +1198,6 @@ func RemoveDoc(boxID, p string) (err error) {
return errors.New(fmt.Sprintf(Conf.Language(70), box.Name, absPath, err))
}
indexHistoryDir(filepath.Base(historyDir), NewLute())
copyDocAssetsToDataAssets(boxID, p)
rootID := tree.ID
@ -1212,6 +1211,7 @@ func RemoveDoc(boxID, p string) (err error) {
return
}
}
indexHistoryDir(filepath.Base(historyDir), NewLute())
box.removeSort(rootID, p)
if err = box.Remove(p); nil != err {

View file

@ -161,62 +161,67 @@ func GetDocHistoryContent(historyPath, keyword string) (content string, isLargeD
return
}
renderTree := &parse.Tree{Root: &ast.Node{Type: ast.NodeDocument}}
keyword = strings.Join(strings.Split(keyword, " "), search.TermSep)
keywords := search.SplitKeyword(keyword)
if !isLargeDoc {
renderTree := &parse.Tree{Root: &ast.Node{Type: ast.NodeDocument}}
keyword = strings.Join(strings.Split(keyword, " "), search.TermSep)
keywords := search.SplitKeyword(keyword)
var unlinks []*ast.Node
ast.Walk(historyTree.Root, func(n *ast.Node, entering bool) ast.WalkStatus {
if !entering {
return ast.WalkContinue
}
var unlinks []*ast.Node
ast.Walk(historyTree.Root, func(n *ast.Node, entering bool) ast.WalkStatus {
if !entering {
return ast.WalkContinue
}
if ast.NodeBlockRef == n.Type {
appendRefTextRenderResultForBlockRef(n)
return ast.WalkSkipChildren
}
if ast.NodeBlockRef == n.Type {
appendRefTextRenderResultForBlockRef(n)
return ast.WalkSkipChildren
}
if ast.NodeText == n.Type {
if 0 < len(keywords) {
// 搜索高亮
text := string(n.Tokens)
text = search.EncloseHighlighting(text, keywords, "<span data-type=\"search-mark\">", "</span>", false)
n.Tokens = gulu.Str.ToBytes(text)
if bytes.Contains(n.Tokens, []byte("search-mark")) {
n.Tokens = bytes.ReplaceAll(n.Tokens, []byte("\\<span data-type=\"search-mark\">"), []byte("\\\\<span data-type=\"search-mark\">"))
linkTree := parse.Inline("", n.Tokens, luteEngine.ParseOptions)
var children []*ast.Node
for c := linkTree.Root.FirstChild.FirstChild; nil != c; c = c.Next {
children = append(children, c)
if ast.NodeText == n.Type {
if 0 < len(keywords) {
// 搜索高亮
text := string(n.Tokens)
text = search.EncloseHighlighting(text, keywords, "<span data-type=\"search-mark\">", "</span>", false)
n.Tokens = gulu.Str.ToBytes(text)
if bytes.Contains(n.Tokens, []byte("search-mark")) {
n.Tokens = bytes.ReplaceAll(n.Tokens, []byte("\\<span data-type=\"search-mark\">"), []byte("\\\\<span data-type=\"search-mark\">"))
linkTree := parse.Inline("", n.Tokens, luteEngine.ParseOptions)
var children []*ast.Node
for c := linkTree.Root.FirstChild.FirstChild; nil != c; c = c.Next {
children = append(children, c)
}
for _, c := range children {
n.InsertBefore(c)
}
unlinks = append(unlinks, n)
return ast.WalkContinue
}
for _, c := range children {
n.InsertBefore(c)
}
unlinks = append(unlinks, n)
return ast.WalkContinue
}
}
return ast.WalkContinue
})
for _, unlink := range unlinks {
unlink.Unlink()
}
return ast.WalkContinue
})
for _, unlink := range unlinks {
unlink.Unlink()
}
var appends []*ast.Node
for n := historyTree.Root.FirstChild; nil != n; n = n.Next {
appends = append(appends, n)
}
for _, n := range appends {
renderTree.Root.AppendChild(n)
}
var appends []*ast.Node
for n := historyTree.Root.FirstChild; nil != n; n = n.Next {
appends = append(appends, n)
}
for _, n := range appends {
renderTree.Root.AppendChild(n)
historyTree = renderTree
}
if isLargeDoc {
formatRenderer := render.NewFormatRenderer(renderTree, luteEngine.RenderOptions)
util.PushMsg(Conf.Language(36), 3000)
formatRenderer := render.NewFormatRenderer(historyTree, luteEngine.RenderOptions)
content = gulu.Str.FromBytes(formatRenderer.Render())
} else {
content = luteEngine.Tree2BlockDOM(renderTree, luteEngine.RenderOptions)
content = luteEngine.Tree2BlockDOM(historyTree, luteEngine.RenderOptions)
}
return
}

View file

@ -70,7 +70,7 @@ func Serve(fastMode bool) {
api.ServeAPI(ginServer)
var addr string
if model.Conf.System.NetworkServe || "docker" == util.Container {
if model.Conf.System.NetworkServe || util.ContainerDocker == util.Container {
addr = "0.0.0.0:" + util.ServerPort
} else {
addr = "127.0.0.1:" + util.ServerPort
@ -227,7 +227,7 @@ func serveDebug(ginServer *gin.Engine) {
func serveWebSocket(ginServer *gin.Engine) {
util.WebSocketServer.Config.MaxMessageSize = 1024 * 1024 * 8
if "docker" == util.Container { // Docker 容器运行时启用 WebSocket 传输压缩
if util.ContainerDocker == util.Container { // Docker 容器运行时启用 WebSocket 传输压缩
util.WebSocketServer.Config.EnableCompression = true
util.WebSocketServer.Config.CompressionLevel = 4
}

View file

@ -125,7 +125,7 @@ func queryBlockIDByParentID(parentID string) (ret []string) {
func QueryRecentUpdatedBlocks() (ret []*Block) {
sqlStmt := "SELECT * FROM blocks WHERE type = 'p' AND length > 1 ORDER BY updated DESC LIMIT 16"
if "ios" == util.Container || "android" == util.Container {
if util.ContainerIOS == util.Container || util.ContainerAndroid == util.Container {
sqlStmt = "SELECT * FROM blocks WHERE type = 'd' ORDER BY updated DESC LIMIT 16"
}
rows, err := query(sqlStmt)

View file

@ -59,6 +59,10 @@ func init() {
func InitDatabase(forceRebuild bool) (err error) {
util.IncBootProgress(2, "Initializing database...")
if forceRebuild {
WaitForWritingDatabase()
}
initDBConnection()
if !forceRebuild {

View file

@ -87,7 +87,7 @@ func IsIDPattern(str string) bool {
var LocalIPs []string
func GetLocalIPs() (ret []string) {
if "android" == Container {
if ContainerAndroid == Container {
// Android 上用不了 net.InterfaceAddrs() https://github.com/golang/go/issues/40569所以前面使用启动内核传入的参数 localIPs
LocalIPs = append(LocalIPs, "127.0.0.1")
LocalIPs = gulu.Str.RemoveDuplicatedElem(LocalIPs)

View file

@ -67,7 +67,7 @@ func RandomSleep(minMills, maxMills int) {
}
func GetDeviceID() string {
if "std" == Container {
if ContainerStd == Container {
machineID, err := machineid.ID()
if nil != err {
return gulu.Rand.String(12)

View file

@ -77,9 +77,9 @@ func Boot() {
Resident = *resident
ReadOnly = *readOnly
AccessAuthCode = *accessAuthCode
Container = "std"
Container = ContainerStd
if isRunningInDockerContainer() {
Container = "docker"
Container = ContainerDocker
}
UserAgent = UserAgent + " " + Container
@ -177,7 +177,7 @@ func initWorkspaceDir(workspaceArg string) {
userHomeConfDir := filepath.Join(HomeDir, ".config", "siyuan")
workspaceConf := filepath.Join(userHomeConfDir, "workspace.json")
if !gulu.File.IsExist(workspaceConf) {
IsNewbie = "std" == Container // 只有桌面端需要设置新手标识,前端自动挂载帮助文档
IsNewbie = ContainerStd == Container // 只有桌面端需要设置新手标识,前端自动挂载帮助文档
if err := os.MkdirAll(userHomeConfDir, 0755); nil != err && !os.IsExist(err) {
log.Printf("create user home conf folder [%s] failed: %s", userHomeConfDir, err)
os.Exit(ExitCodeCreateConfDirErr)
@ -276,6 +276,13 @@ var (
Container string // docker, android, ios, std
)
const (
ContainerStd = "std" // 桌面端
ContainerDocker = "docker" // Docker 容器端
ContainerAndroid = "android" // Android 端
ContainerIOS = "ios" // iOS 端
)
func initPathDir() {
if err := os.MkdirAll(ConfDir, 0755); nil != err && !os.IsExist(err) {
log.Fatalf("create conf folder [%s] failed: %s", ConfDir, err)