浏览代码

Merge remote-tracking branch 'upstream/master' into whiteboards

Peng Xiao 3 年之前
父节点
当前提交
eaec72e676
共有 47 个文件被更改,包括 716 次插入654 次删除
  1. 0 1
      .github/workflows/build-android.yml
  2. 1 1
      Dockerfile
  3. 2 2
      android/app/build.gradle
  4. 1 2
      deps.edn
  5. 4 4
      ios/App/App.xcodeproj/project.pbxproj
  6. 2 0
      ios/App/App/FileSync/FileSync.m
  7. 42 1
      ios/App/App/FileSync/FileSync.swift
  8. 7 7
      package.json
  9. 0 15
      public/workspaces/index.html
  10. 2 2
      resources/package.json
  11. 2 15
      shadow-cljs.edn
  12. 11 11
      src/electron/electron/core.cljs
  13. 3 2
      src/electron/electron/exceptions.cljs
  14. 6 3
      src/electron/electron/fs_watcher.cljs
  15. 3 2
      src/electron/electron/git.cljs
  16. 43 27
      src/electron/electron/handler.cljs
  17. 31 0
      src/electron/electron/logger.cljs
  18. 4 3
      src/electron/electron/plugin.cljs
  19. 3 3
      src/electron/electron/search.cljs
  20. 7 6
      src/electron/electron/updater.cljs
  21. 4 2
      src/electron/electron/utils.cljs
  22. 4 3
      src/electron/electron/window.cljs
  23. 20 3
      src/main/frontend/components/encryption.cljs
  24. 5 1
      src/main/frontend/components/sidebar.css
  25. 7 3
      src/main/frontend/core.cljs
  26. 22 20
      src/main/frontend/dicts.cljc
  27. 14 1
      src/main/frontend/encrypt.cljs
  28. 2 2
      src/main/frontend/fs/capacitor_fs.cljs
  29. 1 1
      src/main/frontend/handler.cljs
  30. 1 1
      src/main/frontend/handler/events.cljs
  31. 13 10
      src/main/frontend/handler/file.cljs
  32. 9 5
      src/main/frontend/handler/global_config.cljs
  33. 13 10
      src/main/frontend/handler/repo.cljs
  34. 4 3
      src/main/frontend/handler/repo_config.cljs
  35. 15 11
      src/main/frontend/handler/ui.cljs
  36. 8 6
      src/main/frontend/handler/web/nfs.cljs
  37. 0 2
      src/main/frontend/mobile/core.cljs
  38. 13 12
      src/main/frontend/modules/file/core.cljs
  39. 7 7
      src/main/frontend/modules/shortcut/dicts.cljc
  40. 2 2
      src/main/frontend/state.cljs
  41. 8 6
      src/main/frontend/util/fs.cljs
  42. 20 18
      src/main/frontend/util/persist_var.cljs
  43. 1 1
      src/main/frontend/version.cljs
  44. 0 79
      src/workspaces/workspaces/cards.cljs
  45. 0 5
      src/workspaces/workspaces/main.cljs
  46. 1 1
      templates/config.edn
  47. 348 332
      yarn.lock

+ 0 - 1
.github/workflows/build-android.yml

@@ -125,7 +125,6 @@ jobs:
         run: |
           cp -r static public/
           rm -rvf public/static/js/publishing
-          rm -rvf public/workspaces
           rm -rvf public/static/js/*.js.map || true
           rm -rvf public/static/*.*
           rm -rvf public/static/ios

+ 1 - 1
Dockerfile

@@ -17,7 +17,7 @@ RUN apt-get update && apt-get install ca-certificates && \
 WORKDIR /data/
 
 # Build for static resources
-RUN git clone https://github.com/logseq/logseq.git &&  cd /data/logseq && yarn && yarn release && mv ./static ./public && rm -r ./public/workspaces
+RUN git clone https://github.com/logseq/logseq.git &&  cd /data/logseq && yarn && yarn release && mv ./static ./public
 
 # Web App Runner image
 FROM nginx:stable-alpine

+ 2 - 2
android/app/build.gradle

@@ -6,8 +6,8 @@ android {
         applicationId "com.logseq.app"
         minSdkVersion rootProject.ext.minSdkVersion
         targetSdkVersion rootProject.ext.targetSdkVersion
-        versionCode 39
-        versionName "0.8.5"
+        versionCode 40
+        versionName "0.8.6"
         testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
         aaptOptions {
              // Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.

+ 1 - 2
deps.edn

@@ -1,4 +1,4 @@
-{:paths ["src/main" "src/electron" "src/workspaces" "templates"]
+{:paths ["src/main" "src/electron" "templates"]
  :deps
  {org.clojure/clojure                   {:mvn/version "1.10.0"}
   rum/rum                               {:mvn/version "0.12.9"}
@@ -28,7 +28,6 @@
   binaryage/devtools                    {:mvn/version "1.0.5"}
   camel-snake-kebab/camel-snake-kebab   {:mvn/version "0.4.2"}
   instaparse/instaparse                 {:mvn/version "1.4.10"}
-  nubank/workspaces                     {:mvn/version "1.1.1"}
   org.clojars.mmb90/cljs-cache          {:mvn/version "0.1.4"}
   logseq/graph-parser                   {:local/root "deps/graph-parser"}}
 

+ 4 - 4
ios/App/App.xcodeproj/project.pbxproj

@@ -547,7 +547,7 @@
 				INFOPLIST_FILE = App/Info.plist;
 				IPHONEOS_DEPLOYMENT_TARGET = 13.0;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
-				MARKETING_VERSION = 0.8.5;
+				MARKETING_VERSION = 0.8.6;
 				OTHER_SWIFT_FLAGS = "$(inherited) \"-D\" \"COCOAPODS\" \"-DDEBUG\"";
 				PRODUCT_BUNDLE_IDENTIFIER = com.logseq.logseq;
 				PRODUCT_NAME = "$(TARGET_NAME)";
@@ -574,7 +574,7 @@
 				INFOPLIST_FILE = App/Info.plist;
 				IPHONEOS_DEPLOYMENT_TARGET = 13.0;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
-				MARKETING_VERSION = 0.8.5;
+				MARKETING_VERSION = 0.8.6;
 				PRODUCT_BUNDLE_IDENTIFIER = com.logseq.logseq;
 				PRODUCT_NAME = "$(TARGET_NAME)";
 				SWIFT_ACTIVE_COMPILATION_CONDITIONS = "";
@@ -599,7 +599,7 @@
 				INFOPLIST_KEY_NSHumanReadableCopyright = "";
 				IPHONEOS_DEPLOYMENT_TARGET = 13.0;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
-				MARKETING_VERSION = 0.8.5;
+				MARKETING_VERSION = 0.8.6;
 				MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
 				MTL_FAST_MATH = YES;
 				PRODUCT_BUNDLE_IDENTIFIER = com.logseq.logseq.ShareViewController;
@@ -626,7 +626,7 @@
 				INFOPLIST_KEY_NSHumanReadableCopyright = "";
 				IPHONEOS_DEPLOYMENT_TARGET = 13.0;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
-				MARKETING_VERSION = 0.8.5;
+				MARKETING_VERSION = 0.8.6;
 				MTL_FAST_MATH = YES;
 				PRODUCT_BUNDLE_IDENTIFIER = com.logseq.logseq.ShareViewController;
 				PRODUCT_NAME = "$(TARGET_NAME)";

+ 2 - 0
ios/App/App/FileSync/FileSync.m

@@ -19,5 +19,7 @@ CAP_PLUGIN(FileSync, "FileSync",
            CAP_PLUGIN_METHOD(updateRemoteFiles, CAPPluginReturnPromise);
            CAP_PLUGIN_METHOD(encryptFnames, CAPPluginReturnPromise);
            CAP_PLUGIN_METHOD(decryptFnames, CAPPluginReturnPromise);
+           CAP_PLUGIN_METHOD(decryptWithPassphrase, CAPPluginReturnPromise);
+           CAP_PLUGIN_METHOD(encryptWithPassphrase, CAPPluginReturnPromise);
            CAP_PLUGIN_METHOD(updateLocalVersionFiles, CAPPluginReturnPromise);
 )

+ 42 - 1
ios/App/App/FileSync/FileSync.swift

@@ -119,7 +119,7 @@ public struct SyncMetadata: CustomStringConvertible, Equatable {
 @objc(FileSync)
 public class FileSync: CAPPlugin, SyncDebugDelegate {
     override public func load() {
-        print("debug File sync iOS plugin loaded!")
+        print("debug FileSync iOS plugin loaded!")
 
         AWSMobileClient.default().initialize { (userState, error) in
             guard error == nil else {
@@ -218,6 +218,47 @@ public class FileSync: CAPPlugin, SyncDebugDelegate {
         }
         call.resolve(["value": fnames])
     }
+    
+    @objc func encryptWithPassphrase(_ call: CAPPluginCall) {
+        guard let passphrase = call.getString("passphrase"),
+              let content = call.getString("content") else {
+                  call.reject("required parameters: passphrase, content")
+                  return
+              }
+        guard let ciphertext = content.data(using: .utf8) else {
+            call.reject("cannot decode ciphertext with utf8")
+            return
+        }
+        call.keepAlive = true
+        DispatchQueue.global(qos: .background).async {
+            if let encrypted = AgeEncryption.encryptWithPassphrase(ciphertext, passphrase, armor: true) {
+                call.resolve(["data": String(data: encrypted, encoding: .utf8) as Any])
+            } else {
+                call.reject("cannot encrypt with passphrase")
+            }
+        }
+    }
+    
+    
+    @objc func decryptWithPassphrase(_ call: CAPPluginCall) {
+        guard let passphrase = call.getString("passphrase"),
+              let content = call.getString("content") else {
+                  call.reject("required parameters: passphrase, content")
+                  return
+              }
+        guard let ciphertext = content.data(using: .utf8) else {
+            call.reject("cannot decode ciphertext with utf8")
+            return
+        }
+        call.keepAlive = true
+        DispatchQueue.global(qos: .background).async {
+            if let decrypted = AgeEncryption.decryptWithPassphrase(ciphertext, passphrase) {
+                call.resolve(["data": String(data: decrypted, encoding: .utf8) as Any])
+            } else {
+                call.reject("cannot decrypt with passphrase")
+            }
+        }
+    }
 
     @objc func getLocalFilesMeta(_ call: CAPPluginCall) {
         // filePaths are url encoded

+ 7 - 7
package.json

@@ -10,17 +10,17 @@
         "@tailwindcss/ui": "0.7.2",
         "@types/gulp": "^4.0.7",
         "cross-env": "^7.0.3",
-        "cssnano": "^4.1.10",
+        "cssnano": "^5.1.13",
         "del": "^6.0.0",
         "gulp": "^4.0.2",
         "gulp-clean-css": "^4.3.0",
         "npm-run-all": "^4.1.5",
         "playwright": "^1.24.2",
-        "postcss": "8.2.13",
-        "postcss-cli": "8.3.1",
-        "postcss-import": "^14.0.0",
+        "postcss": "8.4.16",
+        "postcss-cli": "10.0.0",
+        "postcss-import": "^15.0.0",
         "postcss-import-ext-glob": "^2.0.1",
-        "postcss-nested": "5.0.5",
+        "postcss-nested": "5.0.6",
         "purgecss": "4.0.2",
         "shadow-cljs": "2.17.5",
         "stylelint": "^13.8.0",
@@ -107,7 +107,7 @@
         "highlight.js": "10.4.1",
         "ignore": "5.1.8",
         "is-svg": "4.3.0",
-        "jszip": "3.5.0",
+        "jszip": "3.7.0",
         "mldoc": "1.4.0",
         "mobx": "^6.5.0",
         "path": "0.12.7",
@@ -124,7 +124,7 @@
         "react-textarea-autosize": "8.3.3",
         "react-tippy": "1.4.0",
         "react-transition-group": "4.3.0",
-        "reakit": "0.11.1",
+        "reakit": "1.3.11",
         "remove-accents": "0.4.2",
         "send-intent": "3.0.11",
         "threads": "1.6.5",

+ 0 - 15
public/workspaces/index.html

@@ -1,15 +0,0 @@
-<!DOCTYPE html>
-<html>
-  <head>
-    <meta charset="UTF-8">
-    <meta name="viewport" content="width=device-width, initial-scale=1">
-    <link href="/static/css/style.css" rel="stylesheet" type="text/css">
-    <link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet">
-  </head>
-  <body>
-    <div id="app"></div>
-    <!-- you might need to change the js path depending on your configuration -->
-    <script src="/static/js/workspaces/main.js" type="text/javascript"></script>
-    <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/github.min.css">
-  </body>
-</html>

+ 2 - 2
resources/package.json

@@ -1,6 +1,6 @@
 {
   "name": "Logseq",
-  "version": "0.8.5",
+  "version": "0.8.6",
   "main": "electron.js",
   "author": "Logseq",
   "license": "AGPL-3.0",
@@ -28,7 +28,7 @@
     "electron-squirrel-startup": "1.0.0",
     "electron-window-state": "5.0.3",
     "fs-extra": "9.1.0",
-    "node-fetch": "2.6.1",
+    "node-fetch": "2.6.7",
     "open": "7.3.1",
     "semver": "7.3.5",
     "update-electron-app": "2.0.1",

+ 2 - 15
shadow-cljs.edn

@@ -3,8 +3,7 @@
  :nrepl {:port 8701}
 
  ;; "." for /static
- :dev-http {3001 ["static" "."]
-            3002 ["public/workspaces" "."]}
+ :dev-http {3001 ["static" "."]}
 
  :js-options {:js-package-dirs ["node_modules" "tldraw/apps"]}
 
@@ -105,16 +104,4 @@
                :devtools         {:before-load frontend.core/stop
                                   :after-load  frontend.core/start
                                   :preloads    [devtools.preload]}}
-
-  :cards {:target     nubank.workspaces.shadow-cljs.target
-          :ns-regexp  "(test|cards)$"
-          :output-dir "./public/workspaces/static/js/workspaces"
-          :asset-path "/static/js/workspaces"
-          :preloads   [] ;; optional, list namespaces to be pre loaded
-          :devtools   {:after-load  nubank.workspaces.core/after-load
-                       :loader-mode :eval
-                       :watch-path  "/static"
-                       :watch-dir   "static"
-                       :preloads    [devtools.preload
-                                     shadow.remote.runtime.cljs.browser]}
-          :modules    {:main {:entries [workspaces.main]}}}}}
+  }}

+ 11 - 11
src/electron/electron/core.cljs

@@ -2,8 +2,9 @@
   (:require [electron.handler :as handler]
             [electron.search :as search]
             [electron.updater :refer [init-updater] :as updater]
-            [electron.utils :refer [*win mac? linux? dev? logger get-win-from-sender restore-user-fetch-agent get-graph-name]]
+            [electron.utils :refer [*win mac? linux? dev? get-win-from-sender restore-user-fetch-agent get-graph-name]]
             [electron.url :refer [logseq-url-handler]]
+            [electron.logger :as logger]
             [clojure.string :as string]
             [promesa.core :as p]
             [cljs-bean.core :as bean]
@@ -39,14 +40,13 @@
   ;; manual/auto updater
   (when-not linux?
     (init-updater {:repo   "logseq/logseq"
-                   :logger logger
                    :win    win})))
 
 (defn open-url-handler
   "win - the main window instance (first renderer process)
    url - the input URL"
   [win url]
-  (.info logger "open-url" (str {:url url}))
+  (logger/info "open-url" {:url url})
 
   (let [parsed-url (js/URL. url)
         url-protocol (.-protocol parsed-url)]
@@ -106,7 +106,7 @@
                              (-> (. fs copy (path/join assets-from-dir filename) (path/join assets-to-dir filename))
                                  (p/catch
                                   (fn [e]
-                                    (.error logger "Failed to copy"
+                                    (logger/error "Failed to copy"
                                             (str {:from (path/join assets-from-dir filename)
                                                   :to (path/join assets-to-dir filename)})
                                             e)))))
@@ -167,7 +167,7 @@
                  (try
                    (js-invoke app type args)
                    (catch js/Error e
-                     (.error logger (str call-app-channel " " e))))))
+                     (logger/error (str call-app-channel " " e))))))
 
       (.handle call-win-channel
                (fn [^js e type & args]
@@ -175,7 +175,7 @@
                    (try
                      (js-invoke win type args)
                      (catch js/Error e
-                       (.error logger (str call-win-channel " " e))))))))
+                       (logger/error (str call-win-channel " " e))))))))
 
     #(do (clear-win-effects!)
          (.removeHandler ipcMain toggle-win-channel)
@@ -272,19 +272,19 @@
                (win/switch-to-window! window))))
 
       (.on app "window-all-closed" (fn []
-                                     (.debug logger "window-all-closed" "Quiting...")
+                                     (logger/debug "window-all-closed" "Quiting...")
                                      (try
                                        (fs-watcher/close-watcher!)
                                        (search/close!)
                                        (catch js/Error e
-                                         (.error logger "window-all-closed" e)))
+                                         (logger/error "window-all-closed" e)))
                                      (.quit app)))
       (.on app "ready"
            (fn []
              (let [t0 (setup-interceptor! app)
                    ^js win (win/create-main-window)
                    _ (reset! *win win)]
-               (.. logger (info (str "Logseq App(" (.getVersion app) ") Starting... ")))
+               (logger/info (str "Logseq App(" (.getVersion app) ") Starting... "))
 
                (restore-user-fetch-agent)
 
@@ -343,9 +343,9 @@
                (.on app "activate" #(when @*win (.show win)))))))))
 
 (defn start []
-  (.debug logger "Main - start")
+  (logger/debug "Main - start")
   (when @*setup-fn (@*setup-fn)))
 
 (defn stop []
-  (.debug logger "Main - stop")
+  (logger/debug "Main - stop")
   (when @*teardown-fn (@*teardown-fn)))

+ 3 - 2
src/electron/electron/exceptions.cljs

@@ -1,5 +1,6 @@
 (ns electron.exceptions
-  (:require [electron.utils :as utils]
+  (:require [electron.logger :as logger]
+            [electron.utils :as utils]
             [clojure.string :as string]))
 
 (defonce uncaughtExceptionChan "uncaughtException")
@@ -17,7 +18,7 @@
     (show-error-tip "[Main Exception]" msg stack))
 
   ;; for debug log
-  (.error utils/logger uncaughtExceptionChan (str e)))
+  (logger/error uncaughtExceptionChan (str e)))
 
 (defn setup-exception-listeners!
   []

+ 6 - 3
src/electron/electron/fs_watcher.cljs

@@ -6,6 +6,7 @@
             ["fs" :as fs]
             ["chokidar" :as watcher]
             [electron.utils :as utils]
+            [electron.logger :as logger]
             ["electron" :refer [app]]
             [electron.window :as window]))
 
@@ -38,8 +39,8 @@
       ;; Should only send to one window; then dbsync will do his job
       ;; If no window is on this graph, just ignore
       (let [sent? (some send-fn wins)]
-        (when-not sent? (.warn utils/logger
-                               (str "unhandled file event will cause uncatched file modifications!. target:" dir)))))))
+        (when-not sent? (logger/warn ::send
+                                     "unhandled file event will cause uncatched file modifications!. target:" dir))))))
 
 (defn- publish-file-event!
   [dir path event options]
@@ -73,6 +74,7 @@
     ;; TODO: batch sender
     (.on dir-watcher "unlinkDir"
          (fn [path]
+           (logger/warn ::on-unlink-dir {:path path})
            (when (= dir path)
              (publish-file-event! dir dir "unlinkDir" options))))
     (.on dir-watcher "addDir"
@@ -88,12 +90,13 @@
     (.on dir-watcher "unlink"
          ;; delay 500ms for syncing disks
          (fn [path]
+           (logger/debug ::on-unlink {:path path})
            (js/setTimeout #(when (not (fs/existsSync path))
                              (publish-file-event! dir path "unlink" options))
                           500)))
     (.on dir-watcher "error"
          (fn [path]
-           (.warn utils/logger "Watch error happened: " (str {:path path}))))
+           (logger/warn ::on-error "Watch error happened:" {:path path})))
 
     dir-watcher))
 

+ 3 - 2
src/electron/electron/git.cljs

@@ -2,14 +2,15 @@
   (:require ["dugite" :refer [GitProcess]]
             [goog.object :as gobj]
             [electron.state :as state]
-            [electron.utils :refer [logger] :as utils]
+            [electron.utils :as utils]
+            [electron.logger :as logger]
             [promesa.core :as p]
             [clojure.string :as string]
             ["fs-extra" :as fs]
             ["path" :as path]
             ["os" :as os]))
 
-(def log-error (partial (.-error logger) "[Git]"))
+(def log-error (partial logger/error "[Git]"))
 
 (defn get-graph-git-dir
   []

+ 43 - 27
src/electron/electron/handler.cljs

@@ -16,6 +16,7 @@
             [promesa.core :as p]
             [clojure.string :as string]
             [electron.utils :as utils]
+            [electron.logger :as logger]
             [electron.state :as state]
             [clojure.core.async :as async]
             [electron.search :as search]
@@ -39,33 +40,38 @@
 (defn- readdir
   [dir]
   (->> (tree-seq
-        (fn [^js f]
-          (.isDirectory (fs/statSync f) ()))
-        (fn [d]
-          (let [files (fs/readdirSync d (clj->js {:withFileTypes true}))]
+        (fn [^js fpath]
+          (.isDirectory (fs/statSync fpath)))
+        (fn [dir]
+          (let [files (fs/readdirSync dir (clj->js {:withFileTypes true}))]
             (->> files
                  (remove #(.isSymbolicLink ^js %))
                  (remove #(string/starts-with? (.-name ^js %) "."))
-                 (map #(.join path d (.-name %))))))
+                 (map #(.join path dir (.-name %))))))
         dir)
        (doall)
        (vec)))
 
 (defmethod handle :readdir [_window [_ dir]]
-  (readdir dir))
+  (let [entries (readdir dir)]
+    (js/console.log entries)
+    entries))
 
-(defmethod handle :unlink [_window [_ repo path]]
+(defmethod handle :unlink [_window [_ repo-dir path]]
   (if (plugin/dotdir-file? path)
     (fs/unlinkSync path)
     (try
-      (let [file-name   (-> (string/replace path (str repo "/") "")
-                           (string/replace "/" "_")
-                           (string/replace "\\" "_"))
-           recycle-dir (str repo "/logseq/.recycle")
-           _           (fs-extra/ensureDirSync recycle-dir)
-           new-path    (str recycle-dir "/" file-name)]
-        (fs/renameSync path new-path))
-      (catch :default _e
+      (logger/info ::unlink {:path path})
+      (let [file-name   (-> (string/replace path (str repo-dir "/") "")
+                            (string/replace "/" "_")
+                            (string/replace "\\" "_"))
+            recycle-dir (str repo-dir "/logseq/.recycle")
+            _           (fs-extra/ensureDirSync recycle-dir)
+            new-path    (str recycle-dir "/" file-name)] 
+        (fs/renameSync path new-path)
+        (logger/debug ::unlink "recycle to" new-path))
+      (catch :default e
+        (logger/error ::unlink path e)
         nil))))
 
 (defonce Diff (google-diff.))
@@ -78,6 +84,7 @@
   (when (and (string? db-content)
              (string? new-content)
              (string-some-deleted? db-content new-content))
+    (logger/info ::backup "backup db file" path)
     (backup-file/backup-file repo :backup-dir path (path/extname path) db-content)))
 
 (defmethod handle :addVersionFile [_window [_ repo path content]]
@@ -110,10 +117,11 @@
       (fs/writeFileSync path content)
       (fs/statSync path)
       (catch :default e
+        (logger/warn ::write-file path e)
         (let [backup-path (try
                             (backup-file/backup-file repo :backup-dir path (path/extname path) content)
                             (catch :default e
-                              (.error utils/logger (str "Backup file failed: " e))))]
+                              (logger/error ::write-file "backup file failed:" e)))]
           (utils/send-to-renderer window "notification" {:type "error"
                                                          :payload (str "Write to the file " path
                                                                        " failed, "
@@ -124,6 +132,7 @@
                                                                               ".")))}))))))
 
 (defmethod handle :rename [_window [_ old-path new-path]]
+  (logger/info ::rename "from" old-path "to" new-path)
   (fs/renameSync old-path new-path))
 
 (defmethod handle :stat [_window [_ path]]
@@ -160,12 +169,15 @@
     (p/resolved (first result))))
 
 (defmethod handle :openDir [^js _window _messages]
+  (logger/info ::open-dir "open folder selection dialog")
   (p/let [path (open-dir-dialog)]
+    (logger/debug ::open-dir {:path path})
     (if path
       (p/resolved (bean/->js (get-files path)))
       (p/rejected (js/Error "path empty")))))
 
 (defmethod handle :getFiles [_window [_ path]]
+  (logger/debug ::get-files {:path path})
   (get-files path))
 
 (defn- sanitize-graph-name
@@ -305,10 +317,11 @@
         (try
           (fs-extra/removeSync path)
           (catch js/Error e
-            (.error utils/logger (str "Clear cache: " e))))))
+            (logger/error "Clear cache:" e)))))
     (utils/send-to-renderer window "redirect" {:payload {:to :home}})))
 
 (defmethod handle :clearCache [window _]
+  (logger/info ::clear-cache)
   (search/close!)
   (clear-cache! window)
   (search/ensure-search-dir!))
@@ -329,7 +342,7 @@
 (defmethod handle :httpFetchJSON [_win [_ url options]]
   (p/let [res (utils/fetch url options)
           json (.json res)]
-         json))
+    json))
 
 (defmethod handle :getUserDefaultPlugins []
   (utils/get-ls-default-plugins))
@@ -364,7 +377,7 @@
 (defmethod handle :getAssetsFiles [^js win [_ {:keys [exts]}]]
   (when-let [graph-path (state/get-window-graph-path win)]
     (p/let [^js files (js-utils/getAllFiles (.join path graph-path "assets") (clj->js exts))]
-           files)))
+      files)))
 
 (defn close-watcher-when-orphaned!
   "When it's the last window for the directory, close the watcher."
@@ -442,14 +455,15 @@
              ;; TODO: handle special cases
              (throw e)))
           (p/finally
-           (fn []
-             (swap! *request-abort-signals dissoc req-id)))))))
+            (fn []
+              (swap! *request-abort-signals dissoc req-id)))))))
 
 (defmethod handle :httpRequestAbort [_ [_ req-id]]
   (when-let [^js controller (get @*request-abort-signals req-id)]
     (.abort controller)))
 
 (defmethod handle :quitAndInstall []
+  (logger/info ::quick-and-install)
   (.quitAndInstall autoUpdater))
 
 (defmethod handle :graphUnlinked [^js _win [_ repo]]
@@ -479,11 +493,13 @@
   ;;    1. there is no one window on the same dir
   ;;    2. reset file watcher to resend `add` event on window refreshing
   (when dir
+    (logger/debug ::watch-dir {:path dir})
     (watcher/watch-dir! dir options)
     nil))
 
 (defmethod handle :unwatchDir [^js _window [_ dir]]
   (when dir
+    (logger/debug ::unwatch-dir {:path dir})
     (watcher/close-watcher! dir)
     nil))
 
@@ -496,6 +512,7 @@
     win))
 
 (defmethod handle :openNewWindow [_window [_]]
+  (logger/info ::open-new-window)
   (open-new-window!)
   nil)
 
@@ -508,12 +525,11 @@
   [^js _win [_ graph]]
   (search/version-changed? graph))
 
-
 (defmethod handle :reloadWindowPage [^js win]
+  (logger/warn ::reload-window-page)
   (when-let [web-content (.-webContents win)]
     (.reload web-content)))
 
-
 (defmethod handle :setHttpsAgent [^js _win [_ opts]]
   (utils/set-fetch-agent opts))
 
@@ -567,7 +583,7 @@
   (apply rsapi/decrypt-with-passphrase (rest args)))
 
 (defmethod handle :default [args]
-  (.error utils/logger "Error: no ipc handler for: " (bean/->js args)))
+  (logger/error "Error: no ipc handler for:" args))
 
 (defn broadcast-persist-graph!
   "Receive graph-name (not graph path)
@@ -612,8 +628,8 @@
                    (bean/->js (handle (or (utils/get-win-from-sender event) window) message)))
                  (catch js/Error e
                    (when-not (contains? #{"mkdir" "stat"} (nth args-js 0))
-                     (.error utils/logger "IPC error: " (str {:event event
-                                                              :args args-js})
-                              e))
+                     (logger/error "IPC error: " {:event event
+                                                  :args args-js}
+                                   e))
                    e))))
     #(.removeHandler ipcMain main-channel)))

+ 31 - 0
src/electron/electron/logger.cljs

@@ -0,0 +1,31 @@
+(ns electron.logger
+  "Electron logger, do not depends other libs"
+  (:require ["electron-log" :as logger]))
+
+
+(defn- transform-args [args]
+  (map #(cond
+          (or (keyword? %) (map? %) (seq? %))
+          (str %)
+
+          :else
+          %)
+       args))
+
+
+(defn debug
+  [& args]
+  (apply (.-debug logger) (transform-args args)))
+
+(defn info
+  [& args]
+  (apply (.-info logger) (transform-args args)))
+
+(defn warn
+  [& args]
+  (apply (.-warn logger) (transform-args args)))
+
+(defn error
+  [& args]
+  (apply (.-error logger) (transform-args args)))
+

+ 4 - 3
src/electron/electron/plugin.cljs

@@ -6,13 +6,14 @@
             ["fs-extra" :as fs]
             ["path" :as path]
             [clojure.string :as string]
-            [electron.utils :refer [logger fetch extract-zip] :as utils]
+            [electron.utils :refer [fetch extract-zip] :as utils]
+            [electron.logger :as logger]
             [electron.configs :as cfgs]
             [electron.window :refer [get-all-windows]]))
 
 ;; update & install
 ;;(def *installing-or-updating (atom nil))
-(def debug (fn [& args] (apply (.-info logger) (conj args "[Marketplace]"))))
+(def debug (partial logger/debug "[Marketplace]"))
 (def emit (fn [type payload]
             (doseq [^js win (get-all-windows)]
               (.. win -webContents
@@ -161,7 +162,7 @@
 
                           dest (.join path cfgs/dot-root "plugins" (:id item))
                           _ (when-not only-check (download-asset-zip item dl-url latest-version dest))
-                          _ (debug "[" (if only-check "Checked" "Updated") "DONE] " latest-version)]
+                          _ (debug (str "[" (if only-check "Checked" "Updated") "DONE]") latest-version)]
 
                     (emit :lsp-installed
                           {:status     :completed

+ 3 - 3
src/electron/electron/search.cljs

@@ -4,7 +4,7 @@
             ["better-sqlite3" :as sqlite3]
             [clojure.string :as string]
             ["electron" :refer [app]]
-            [electron.utils :refer [logger]]))
+            [electron.logger :as logger]))
 
 ;; version of the search cache
 ;; ver. 0.0.1: initial version
@@ -128,7 +128,7 @@
              (add-triggers! db)
              (swap! databases assoc db-sanitized-name db))
            (catch :default e
-             (.error logger (str e ": " db-name))
+             (logger/error (str e ": " db-name))
              (fs/unlinkSync db-full-path)))))
 
 (defn open-dbs!
@@ -225,7 +225,7 @@
   (when-let [database (get-db repo)]
     (.close database)
     (let [[db-name db-full-path db-ver-path] (get-db-version-path repo)]
-      (.info logger "Delete search indice" (str {:path db-full-path}))
+      (logger/info "Delete search indice" {:path db-full-path})
       (fs/unlinkSync db-full-path)
       (fs/unlinkSync db-ver-path)
       (swap! databases dissoc db-name))))

+ 7 - 6
src/electron/electron/updater.cljs

@@ -1,5 +1,6 @@
 (ns electron.updater
-  (:require [electron.utils :refer [mac? win32? prod? open fetch logger *win]]
+  (:require [electron.utils :refer [mac? win32? prod? open fetch *win]]
+            [electron.logger :as logger]
             [frontend.version :refer [version]]
             [clojure.string :as string]
             [promesa.core :as p]
@@ -13,7 +14,7 @@
 
 (def *update-ready-to-install (atom nil))
 (def *update-pending (atom nil))
-(def debug (partial (.-debug logger) "[updater]"))
+(def debug (partial logger/debug "[updater]"))
 
 ;Event: 'error'
 ;Event: 'checking-for-update'
@@ -41,7 +42,7 @@
            (bean/->clj info))
          (throw (js/Error. (str "[" status "] " text)))))
      (fn [e]
-       (.warn logger "[update server error]" e)
+       (logger/warn "[update server error]" e)
        (throw e)))))
 
 (defn check-for-updates
@@ -111,7 +112,7 @@
 
 (defn- new-version-downloaded-cb
   [_ notes name date url]
-  (.info logger "[update-downloaded]" name notes date url)
+  (logger/info "[update-downloaded]" name notes date url)
   (when-let [web-contents (and @*win (. ^js @*win -webContents))]
     (.send web-contents "auto-updater-downloaded"
            (bean/->js {:notes notes :name name :date date :url url}))))
@@ -131,14 +132,14 @@
               (debug "forward update to autoUpdater")
               ;; FIXME: It seems that update-electron-app doesn't work on linux
               (when-let [f (js/require "update-electron-app")]
-                (f #js{:notifyUser false :logger logger})
+                (f #js{:notifyUser false})
                 (.once autoUpdater "update-downloaded"
                        new-version-downloaded-cb))))
 
           (debug "Skip remote version [ahead of pre-release]" remote-version))))))
 
 (defn init-updater
-  [{:keys [repo _logger ^js _win] :as opts}]
+  [{:keys [repo ^js _win] :as opts}]
   (and prod? (not= false (cfgs/get-item :auto-update)) (init-auto-updater repo))
   (let [check-channel "check-for-updates"
         install-channel "install-updates"

+ 4 - 2
src/electron/electron/utils.cljs

@@ -3,22 +3,24 @@
             ["fs-extra" :as fs]
             ["path" :as path]
             [electron.configs :as cfgs]
+            [electron.logger :as logger]
             [cljs-bean.core :as bean]
             ["electron" :refer [app BrowserWindow]]))
 
 (defonce *win (atom nil)) ;; The main window
+
 (defonce mac? (= (.-platform js/process) "darwin"))
 (defonce win32? (= (.-platform js/process) "win32"))
 (defonce linux? (= (.-platform js/process) "linux"))
 
 (defonce prod? (= js/process.env.NODE_ENV "production"))
 
+;; Under e2e testing?
 (defonce ci? (let [v js/process.env.CI]
                (or (true? v)
                    (= v "true"))))
 
 (defonce dev? (not prod?))
-(defonce logger (js/require "electron-log"))
 (defonce *fetchAgent (atom nil))
 
 (defonce open (js/require "open"))
@@ -97,7 +99,7 @@
     (when (fs/existsSync path)
       (.toString (fs/readFileSync path)))
     (catch js/Error e
-      (.error logger (str "Read file: " e)))))
+      (logger/error "Read file:" e))))
 
 (defn get-focused-window
   []

+ 4 - 3
src/electron/electron/window.cljs

@@ -1,8 +1,9 @@
 (ns electron.window
   (:require ["electron-window-state" :as windowStateKeeper]
-            [electron.utils :refer [mac? win32? linux? dev? logger open] :as utils]
+            [electron.utils :refer [mac? win32? linux? dev? open] :as utils]
             [electron.configs :as cfgs]
             [electron.context-menu :as context-menu]
+            [electron.logger :as logger]
             ["electron" :refer [BrowserWindow app session shell] :as electron]
             ["path" :as path]
             ["url" :as URL]
@@ -124,12 +125,12 @@
             (let [url (if (string/starts-with? url "file:")
                         (js/decodeURIComponent url) url)
                   url (if-not win32? (string/replace url "file://" "") url)]
-              (.. logger (info "new-window" url))
+              (logger/info "new-window" url)
               (if (some #(string/includes?
                           (.normalize path url)
                           (.join path (. app getAppPath) %))
                         ["index.html" "electron.html"])
-                (.info logger "pass-window" url)
+                (logger/info "pass-window" url)
                 (open-default-app! url open)))
             (.preventDefault e))
 

+ 20 - 3
src/main/frontend/components/encryption.cljs

@@ -51,10 +51,20 @@
   (fn [close-fn]
     (encryption-dialog-inner repo-url close-fn)))
 
+(rum/defc show-password-cp
+  [*show-password?]
+  [:div.flex.flex-row.items-center
+   [:label {:for "show-password"}
+    (ui/checkbox {:checked? @*show-password?
+                  :on-change (fn [e]
+                               (reset! *show-password? (util/echecked? e)))})]
+   [:span.text-sm.ml-1.opacity-80 "Show password"]])
+
 (rum/defcs ^:large-vars/cleanup-todo input-password-inner < rum/reactive
   (rum/local "" ::password)
   (rum/local "" ::pw-confirm)
   (rum/local false ::pw-confirm-focused?)
+  (rum/local false ::show-password?)
   {:will-mount (fn [state]
                  ;; try to close tour tips
                  (some->> (state/sub :file-sync/jstour-inst)
@@ -64,6 +74,7 @@
   (let [*password (get state ::password)
         *pw-confirm (get state ::pw-confirm)
         *pw-confirm-focused? (get state ::pw-confirm-focused?)
+        *show-password? (get state ::show-password?)
         *input-ref-0 (rum/create-ref)
         *input-ref-1 (rum/create-ref)
         remote-pw? (= type :input-pwd-remote)
@@ -213,7 +224,7 @@
                        :class (when (>= (int (:id pw-strength)) i) "active")} i])]]])]))
 
       [:input.form-input.block.w-full.sm:text-sm.sm:leading-5.my-2
-       {:type        "password"
+       {:type        (if @*show-password? "text" "password")
         :ref         *input-ref-0
         :placeholder "Password"
         :auto-focus  true
@@ -226,7 +237,7 @@
 
       (when init-graph-keys
         [:input.form-input.block.w-full.sm:text-sm.sm:leading-5.my-2
-         {:type        "password"
+         {:type        (if @*show-password? "text" "password")
           :ref         *input-ref-1
           :placeholder "Re-enter the password"
           :on-focus    #(reset! *pw-confirm-focused? true)
@@ -236,6 +247,8 @@
           :on-change   (fn [^js e]
                          (reset! *pw-confirm (util/evalue e)))}])
 
+      (show-password-cp *show-password?)
+
       (when init-graph-keys
         [:div.init-remote-pw-tips.space-x-4.pt-2.hidden.sm:flex
          [:div.flex-1.flex.items-center
@@ -307,9 +320,11 @@
 (rum/defcs encryption-input-secret-inner <
   (rum/local "" ::secret)
   (rum/local false ::loading)
+  (rum/local false ::show-password?)
   [state _repo-url db-encrypted-secret close-fn]
   (let [secret (::secret state)
         loading (::loading state)
+        *show-password? (::show-password? state)
         on-click-fn (fn []
                       (reset! loading true)
                       (let [value @secret]
@@ -330,7 +345,7 @@
         "Enter your password"]]]
 
      [:input.form-input.block.w-full.sm:text-sm.sm:leading-5.my-2
-      {:type "password"
+      {:type (if @*show-password? "text" "password")
        :auto-focus true
        :on-change (fn [e]
                     (reset! secret (util/evalue e)))
@@ -338,6 +353,8 @@
                       (when (= (.-key e) "Enter")
                         (on-click-fn)))}]
 
+     (show-password-cp *show-password?)
+
      [:div.mt-5.sm:mt-4.sm:flex.sm:flex-row-reverse
       [:span.flex.w-full.rounded-md.shadow-sm.sm:ml-3.sm:w-auto
        [:button.inline-flex.justify-center.w-full.rounded-md.border.border-transparent.px-4.py-2.bg-indigo-600.text-base.leading-6.font-medium.text-white.shadow-sm.hover:bg-indigo-500.focus:outline-none.focus:border-indigo-700.focus:shadow-outline-indigo.transition.ease-in-out.duration-150.sm:text-sm.sm:leading-5

+ 5 - 1
src/main/frontend/components/sidebar.css

@@ -329,7 +329,7 @@
 
     .left-sidebar-inner {
       transform: translate3d(0, 0, 0);
-      overflow: visible;
+      overflow: hidden;
     }
 
     > .shade-mask {
@@ -361,6 +361,10 @@
 
     &.is-open {
       width: var(--ls-left-sidebar-width);
+
+      .left-sidebar-inner {
+        overflow: visible;
+      }
     }
 
     > .shade-mask {

+ 7 - 3
src/main/frontend/core.cljs

@@ -11,7 +11,9 @@
             [reitit.frontend :as rf]
             [reitit.frontend.easy :as rfe]
             [logseq.api]
-            [frontend.fs.sync :as sync]))
+            [frontend.fs.sync :as sync]
+            [frontend.config :as config]
+            [frontend.util :as util]))
 
 (defn set-router!
   []
@@ -46,7 +48,8 @@
     (rum/mount (page/current-page) node)
     (display-welcome-message)
     (persist-var/load-vars)
-    (js/setTimeout #(sync/sync-start) 1000)))
+    (when (and config/dev? (util/electron?))
+      (js/setTimeout #(sync/sync-start) 1000))))
 
 (defn ^:export init []
   ;; init is called ONCE when the page loads
@@ -66,5 +69,6 @@
   ;; stop is called before any code is reloaded
   ;; this is controlled by :before-load in the config
   (handler/stop!)
-  (sync/<sync-stop)
+  (when (and config/dev? (util/electron?))
+    (sync/<sync-stop))
   (js/console.log "stop"))

+ 22 - 20
src/main/frontend/dicts.cljc

@@ -4054,8 +4054,8 @@
                                 :default "tutorial-tr.md")
         :tutorial/dummy-notes #?(:cljs (rc/inline "dummy-notes-tr.md")
                                        :default "dummy-notes-tr.md")
-        :on-boarding/demo-graph "Bu bir demo çizelgedir, yerel bir klasör açana kadar değişiklikler kaydedilmeyecektir."
-        :on-boarding/add-graph "Bir çizelge ekle"
+        :on-boarding/demo-graph "Bu bir demo graftır, yerel bir klasör açana kadar değişiklikler kaydedilmeyecektir."
+        :on-boarding/add-graph "Bir graf ekle"
         :on-boarding/open-local-dir "Yerel bir dizin açın"
         :on-boarding/new-graph-desc-1 "Logseq, hem Markdown hem de Org modunu destekler. Cihazınızda var olan bir dizini (klasörü) açabilir veya yeni bir tane oluşturabilirsiniz. Verileriniz yalnızca bu cihazda saklanacaktır."
         :on-boarding/new-graph-desc-2 "Dizininizi açtıktan sonra, o dizinde üç klasör oluşturacaktır:"
@@ -4108,9 +4108,9 @@
         :right-side-bar/recent "En son"
         :right-side-bar/contents "İçindekiler"
         :right-side-bar/favorites "Sık kullanılanlar"
-        :right-side-bar/page-graph "Sayfa çizelgesi"
+        :right-side-bar/page-graph "Sayfa grafı"
         :right-side-bar/block-ref "Blok referansı"
-        :right-side-bar/graph-view "Çizelge görünümü"
+        :right-side-bar/graph-view "Graf görünümü"
         :right-side-bar/all-pages "Bütün sayfalar"
         :right-side-bar/flashcards "Bilgi kartları"
         :right-side-bar/new-page "Yeni sayfa"
@@ -4199,9 +4199,11 @@
         :settings-page/git-switcher-label "Git otomatik commit'i etkinleştir"
         :settings-page/git-commit-delay "Git otomatik commit saniyesi"
         :settings-page/edit-config-edn "config.edn dosyasını düzenle"
+        :settings-page/edit-global-config-edn "Genel config.edn dosyasını düzenle"
         :settings-page/edit-custom-css "custom.css dosyasını düzenle"
         :settings-page/edit-export-css "export.css dosyasını düzenle"
         :settings-page/custom-configuration "Özel yapılandırma"
+        :settings-page/custom-global-configuration "Özel genel yapılandırma"
         :settings-page/custom-theme "Özel tema"
         :settings-page/export-theme "Temayı dışarı aktar"
         :settings-page/show-brackets "Köşeli ayraçları göster"
@@ -4229,7 +4231,7 @@
         :settings-page/disable-developer-mode "Geliştirici modunu devre dışı bırak"
         :settings-page/developer-mode-desc "Geliştirici modu, katkıda bulunanların ve eklenti geliştiricilerinin Logseq ile entegrasyonlarını daha verimli bir şekilde test etmesine yardımcı olur."
         :settings-page/current-version "Geçerli sürüm"
-        :settings-page/current-graph "Geçerli çizelge"
+        :settings-page/current-graph "Geçerli graf"
         :settings-page/tab-general "Genel"
         :settings-page/tab-editor "Düzenleyici"
         :settings-page/tab-shortcuts "Kısayollar"
@@ -4256,7 +4258,7 @@
         :port "Bağlantı Noktası"
         :re-index "Yeniden dizin oluştur"
         :re-index-detail "Grafiği yeniden oluştur"
-        :re-index-multiple-windows-warning "Bu çizelge için yeniden dizin oluşturmadan önce diğer pencereleri kapatmanız gerekiyor."
+        :re-index-multiple-windows-warning "Bu graf için yeniden dizin oluşturmadan önce diğer pencereleri kapatmanız gerekiyor."
         :re-index-discard-unsaved-changes-warning "Yeniden dizin oluşturmak mevcut grafiği siler ve ardından tüm dosyaları o anda diskte depolandıkları şekilde yeniden işler. Kaydedilmemiş değişiklikleri kaybedeceksiniz ve bu biraz zaman alabilir. Devam edilsin mi?"
         :open-new-window "Yeni pencere"
         :sync-from-local-files "Yenile"
@@ -4267,24 +4269,24 @@
         :search/publishing "Ara"
         :search "Ara veya sayfa oluştur"
         :page-search "Geçerli sayfada ara"
-        :graph-search "Çizelgede ara"
+        :graph-search "Grafta ara"
         :new-page "Yeni sayfa"
         :new-file "Yeni dosya"
-        :new-graph "Yeni çizelge ekle"
-        :graph "Çizelge"
-        :graph-view "Çizelgeyi görüntüle"
+        :new-graph "Yeni graf ekle"
+        :graph "Graf"
+        :graph-view "Grafı görüntüle"
         :graph/persist "Logseq dahili durumu senkronize ediyor, lütfen birkaç saniye bekleyin."
         :graph/persist-error "Dahili durum senkronize edilemedi."
         :graph/save "Kaydediliyor..."
         :graph/save-success "Başarıyla Kaydedildi"
         :graph/save-error "Kaydedilemedi"
-        :graph/all-graphs "Tüm çizelgeler"
-        :graph/local-graphs "Yerel çizelgeler"
-        :graph/remote-graphs "Uzak çizelgeler"
+        :graph/all-graphs "Tüm graflar"
+        :graph/local-graphs "Yerel graflar"
+        :graph/remote-graphs "Uzak graflar"
         :cards-view "Kartları görüntüle"
         :publishing "Yayımlama"
         :export "Dışarı aktar"
-        :export-graph "Çizelgeyi dışarı aktar"
+        :export-graph "Grafı dışarı aktar"
         :export-page "Sayfayı dışarı aktar"
         :export-markdown "Standart Markdown olarak dışarı aktar (blok özelliği yok)"
         :export-opml "OPML olarak dışarı aktar"
@@ -4294,7 +4296,7 @@
         :export-edn "EDN olarak dışarı aktar"
         :export-datascript-edn "EDN datascript öğesini dışarı aktar"
         :convert-markdown "Markdown başlıklarını sırasız listelere dönüştürün (# -> -)"
-        :all-graphs "Tüm çizelgeler"
+        :all-graphs "Tüm graflar"
         :all-pages "Tüm sayfalar"
         :all-files "Tüm dosyalar"
         :remove-orphaned-pages "Yalnız bırakılmış sayfaları kaldır"
@@ -4383,12 +4385,12 @@
 
         :command-palette/prompt "Bir komut yazın"
         :select/default-prompt "Birini seçin"
-        :select.graph/prompt "Bir çizelge seçin"
-        :select.graph/empty-placeholder-description "Eşleşen çizelge yok. Bir tane daha eklemek ister misin?"
-        :select.graph/add-graph "Evet, başka bir çizelge ekle"
+        :select.graph/prompt "Bir graf seçin"
+        :select.graph/empty-placeholder-description "Eşleşen graf yok. Bir tane daha eklemek ister misin?"
+        :select.graph/add-graph "Evet, başka bir graf ekle"
 
-        :file-sync/other-user-graph "Geçerli yerel çizelge, diğer kullanıcının uzak çizelgesine bağlıdır. Bu yüzden senkronizasyon başlatılamıyor."
-        :file-sync/graph-deleted "Geçerli uzak çizelge silindi"}
+        :file-sync/other-user-graph "Geçerli yerel graf, diğer kullanıcının uzak grafına bağlıdır. Bu yüzden senkronizasyon başlatılamıyor."
+        :file-sync/graph-deleted "Geçerli uzak graf silindi"}
 
    :ko {:tutorial/text #?(:cljs (rc/inline "tutorial-ko.md")
                           :default "tutorial-ko.md")

+ 14 - 1
src/main/frontend/encrypt.cljs

@@ -9,7 +9,8 @@
             [promesa.core :as p]
             [electron.ipc :as ipc]
             [shadow.loader :as loader]
-            [lambdaisland.glogi :as log]))
+            [lambdaisland.glogi :as log]
+            [frontend.mobile.util :as mobile-util]))
 
 (defonce age-pem-header-line "-----BEGIN AGE ENCRYPTED FILE-----")
 (defonce age-version-line "age-encryption.org/v1")
@@ -96,6 +97,12 @@
             encrypted (ipc/ipc "encrypt-with-passphrase" passphrase raw-content)]
       (utf8/decode encrypted))
 
+    (mobile-util/native-ios?)
+    (p/chain (.encryptWithPassphrase mobile-util/file-sync
+                                     (clj->js {:passphrase passphrase :content content}))
+             #(js->clj % :keywordize-keys true)
+             :data)
+
     :else
     (p/let [lazy-encrypt-with-user-passphrase (resolve 'frontend.extensions.age-encryption/encrypt-with-user-passphrase)
             content (utf8/encode content)
@@ -110,6 +117,12 @@
             decrypted (ipc/ipc "decrypt-with-passphrase" passphrase raw-content)]
       (utf8/decode decrypted))
 
+    (mobile-util/native-ios?)
+    (p/chain (.decryptWithPassphrase mobile-util/file-sync
+                                     (clj->js {:passphrase passphrase :content content}))
+             #(js->clj % :keywordize-keys true)
+             :data)
+    
     :else
     (p/let [_ (loader/load :age-encryption)
             lazy-decrypt-with-user-passphrase (resolve 'frontend.extensions.age-encryption/decrypt-with-user-passphrase)

+ 2 - 2
src/main/frontend/fs/capacitor_fs.cljs

@@ -54,8 +54,8 @@
 
 (defn- <readdir [path]
   (-> (p/chain (.readdir Filesystem (clj->js {:path path}))
-               js->clj
-               #(get % "files" nil))
+               #(js->clj % :keywordize-keys true)
+               :files)
       (p/catch (fn [error]
                  (js/console.error "readdir Error: " path ": " error)
                  nil))))

+ 1 - 1
src/main/frontend/handler.cljs

@@ -221,7 +221,7 @@
       (p/finally (fn []
                    (state/set-db-restoring! false))))
   (when (mobile-util/native-platform?)
-    (p/do! (mobile-util/hide-splash)))
+    (mobile-util/hide-splash))
 
   (db/run-batch-txs!)
   (file/<ratelimit-file-writes!)

+ 1 - 1
src/main/frontend/handler/events.cljs

@@ -80,7 +80,7 @@
         (do
           (state/set-state! :user/info result)
           (let [status (if (user-handler/alpha-user?) :welcome :unavailable)]
-            (when (= status :welcome)
+            (when (and (= status :welcome) (user-handler/logged-in?))
               (async/<! (file-sync-handler/load-session-graphs))
               (p/let [repos (repo-handler/refresh-repos!)]
                 (when-let [repo (state/get-current-repo)]

+ 13 - 10
src/main/frontend/handler/file.cljs

@@ -95,7 +95,9 @@
   (let [original-content (db/get-file repo path)
         write-file! (if from-disk?
                       #(p/resolved nil)
-                      #(let [path-dir (if (= (path/dirname path) (global-config-handler/global-config-dir))
+                      #(let [path-dir (if (and
+                                            (config/global-config-enabled?)
+                                            (= (path/dirname path) (global-config-handler/global-config-dir)))
                                         (global-config-handler/global-config-dir)
                                         (config/get-repo-dir repo))]
                          (fs/write-file! repo path-dir path content
@@ -117,21 +119,22 @@
                  (db/set-file-content! repo path content opts))]
     (util/p-handle (write-file!)
                    (fn [_]
+                     (when re-render-root? (ui-handler/re-render-root!))
+
                      (cond
+                       (= path (config/get-custom-css-path repo))
+                       (ui-handler/add-style-if-exists!)
+
                        (= path (config/get-repo-config-path repo))
-                       (p/let [_ (repo-config-handler/restore-repo-config! repo)]
+                       (p/let [_ (repo-config-handler/restore-repo-config! repo content)]
                          (state/pub-event! [:shortcut/refresh]))
 
-                       (= path (global-config-handler/global-config-path))
+                       (and (config/global-config-enabled?) (= path (global-config-handler/global-config-path)))
                        (p/let [_ (global-config-handler/restore-global-config!)]
-                         (state/pub-event! [:shortcut/refresh]))
-
-                       (= path (config/get-custom-css-path repo))
-                       (ui-handler/add-style-if-exists!))
-
-                     (when re-render-root? (ui-handler/re-render-root!)))
+                         (state/pub-event! [:shortcut/refresh]))))
                    (fn [error]
-                     (when (= path (global-config-handler/global-config-path))
+                     (when (and (config/global-config-enabled?)
+                                (= path (global-config-handler/global-config-path)))
                        (state/pub-event! [:notification/show
                                          {:content (str "Failed to write to file " path)
                                           :status :error}]))

+ 9 - 5
src/main/frontend/handler/global_config.cljs

@@ -58,8 +58,12 @@
 - Start a file watcher for global config dir if it's not already started.
   Watcher ensures client db is seeded with correct file data."
   [{:keys [repo]}]
-  (p/let [root-dir' (ipc/ipc "getLogseqDotDirRoot")
-          _ (reset! root-dir root-dir')
-          _ (restore-global-config!)
-          _ (create-global-config-file-if-not-exists repo)
-          _ (fs/watch-dir! (global-config-dir) {:global-dir true})]))
+  (-> (p/do!
+       (p/let [root-dir' (ipc/ipc "getLogseqDotDirRoot")]
+         (reset! root-dir root-dir'))
+       (restore-global-config!)
+       (create-global-config-file-if-not-exists repo)
+       (fs/watch-dir! (global-config-dir) {:global-dir true}))
+      (p/timeout 6000)
+      (p/catch (fn [e]
+                 (js/console.error "cannot start global-config" e)))))

+ 13 - 10
src/main/frontend/handler/repo.cljs

@@ -396,22 +396,25 @@
   (-> (setup-local-repo-if-not-exists-impl!)
       (p/timeout 3000)
       (p/catch (fn []
-                 (state/set-db-restoring! false)
-                 (prn "setup-local-repo failed! timeout 3000ms")))))
+                 (prn "setup-local-repo failed! timeout 3000ms")))
+      (p/finally (fn []
+                   (state/set-db-restoring! false)))))
 
 (defn restore-and-setup-repo!
   "Restore the db of a graph from the persisted data, and setup. Create a new
   conn, or replace the conn in state with a new one."
   [repo]
-  (p/let [_ (state/set-db-restoring! true)
-          _ (db/restore-graph! repo)
-          _ (repo-config-handler/restore-repo-config! repo)
-          _ (global-config-handler/restore-global-config!)]
+  (p/do!
+   (state/set-db-restoring! true)
+   (db/restore-graph! repo)
+   (repo-config-handler/restore-repo-config! repo)
+   (when (config/global-config-enabled?)
+     (global-config-handler/restore-global-config!))
     ;; Don't have to unlisten the old listener, as it will be destroyed with the conn
-    (db/listen-and-persist! repo)
-    (state/pub-event! [:shortcut/refresh])
-    (ui-handler/add-style-if-exists!)
-    (state/set-db-restoring! false)))
+   (db/listen-and-persist! repo)
+   (state/pub-event! [:shortcut/refresh])
+   (ui-handler/add-style-if-exists!)
+   (state/set-db-restoring! false)))
 
 (defn rebuild-index!
   [url]

+ 4 - 3
src/main/frontend/handler/repo_config.cljs

@@ -51,9 +51,10 @@
 
 (defn restore-repo-config!
   "Sets repo config state from db"
-  [repo-url]
-  (let [config-content (get-repo-config-content repo-url)]
-    (set-repo-config-state! repo-url config-content)))
+  ([repo-url]
+   (restore-repo-config! repo-url (get-repo-config-content repo-url)))
+  ([repo-url config-content]
+   (set-repo-config-state! repo-url config-content)))
 
 (defn start
   "This component only has one reponsibility on start, to manage db and ui state

+ 15 - 11
src/main/frontend/handler/ui.cljs

@@ -13,7 +13,8 @@
             [goog.object :as gobj]
             [clojure.string :as string]
             [rum.core :as rum]
-            [electron.ipc :as ipc]))
+            [electron.ipc :as ipc]
+            [promesa.core :as p]))
 
 (defn- get-css-var-value
   [var-name]
@@ -154,16 +155,19 @@
           (when (or (not should-ask?)
                     (ask-allow))
             (load href #(do (js/console.log "[custom js]" href) (execed))))
-          (util/p-handle
-           (fs/read-file (if (util/electron?) "" (config/get-repo-dir (state/get-current-repo))) href)
-           #(when-let [scripts (and % (string/trim %))]
-              (when-not (string/blank? scripts)
-                (when (or (not should-ask?) (ask-allow))
-                  (try
-                    (js/eval scripts)
-                    (execed)
-                    (catch js/Error e
-                      (js/console.error "[custom js]" e))))))))))))
+          (let [dir (if (util/electron?) "" (config/get-repo-dir (state/get-current-repo)))]
+            (p/let [exists? (fs/file-exists? dir href)]
+              (when exists?
+                (util/p-handle
+                 (fs/read-file dir href)
+                 #(when-let [scripts (and % (string/trim %))]
+                    (when-not (string/blank? scripts)
+                      (when (or (not should-ask?) (ask-allow))
+                        (try
+                          (js/eval scripts)
+                          (execed)
+                          (catch js/Error e
+                            (js/console.error "[custom js]" e)))))))))))))))
 
 (defn toggle-wide-mode!
   []

+ 8 - 6
src/main/frontend/handler/web/nfs.cljs

@@ -339,14 +339,16 @@
                                        (fn [path handle]
                                          (when nfs?
                                            (swap! path-handles assoc path handle))))
-                         global-dir (global-config-handler/global-config-dir)
-                         global-files-result (if (config/global-config-enabled?)
-                                               (fs/get-files global-dir (constantly nil))
-                                               [])
                          new-local-files (-> (->db-files mobile-native? electron? dir-name local-files-result)
                                              (remove-ignore-files dir-name nfs?))
-                         new-global-files (-> (->db-files mobile-native? electron? global-dir global-files-result)
-                                              (remove-ignore-files global-dir nfs?))
+                         new-global-files (if (config/global-config-enabled?)
+                                            (p/let [global-files-result (fs/get-files
+                                                                          (global-config-handler/global-config-dir)
+                                                                          (constantly nil))
+                                                    global-files (-> (->db-files mobile-native? electron? (global-config-handler/global-config-dir) global-files-result)
+                                                  (remove-ignore-files (global-config-handler/global-config-dir) nfs?))]
+                                              global-files)
+                                            (p/resolved []))
                          new-files (concat new-local-files new-global-files)
 
                          _ (when nfs?

+ 0 - 2
src/main/frontend/mobile/core.cljs

@@ -36,8 +36,6 @@
 
   (mobile-util/check-ios-zoomed-display)
 
-  (.removeAllListeners mobile-util/file-sync)
-
   (.addListener mobile-util/file-sync "debug"
                 (fn [event]
                   (js/console.log "🔄" event))))

+ 13 - 12
src/main/frontend/modules/file/core.cljs

@@ -133,18 +133,19 @@
 
 (defn save-tree-aux!
   [page-block tree]
-  (let [page-block (db/pull '[* {:block/file [:file/path]}] (:db/id page-block))
-        file-path (get-in page-block [:block/file :file/path])
-        whiteboard? (:block/whiteboard? page-block)
-        new-content (if whiteboard?
-                      (util/pp-str {:blocks (map remove-transit-ids tree)
-                                    :pages (list (remove-transit-ids page-block))})
-                      (tree->file-content tree {:init-level init-level}))
-        _ (assert (string? file-path) "File path should satisfy string?")
-        ;; FIXME: name conflicts between multiple graphs
-        files [[file-path new-content]]
-        repo (state/get-current-repo)]
-    (file-handler/alter-files-handler! repo files {} {})))
+  (let [page-block (db/pull (:db/id page-block))
+        file-db-id (-> page-block :block/file :db/id)
+        file-path (-> (db-utils/entity file-db-id) :file/path)]
+    (if (and (string? file-path) (not-empty file-path))
+      (let [new-content (if whiteboard?
+                          (util/pp-str {:blocks (map remove-transit-ids tree)
+                                        :pages (list (remove-transit-ids page-block))})
+                          (tree->file-content tree {:init-level init-level}))
+            files [[file-path new-content]]
+            repo (state/get-current-repo)]
+        (file-handler/alter-files-handler! repo files {} {}))
+      ;; In e2e tests, "card" page in db has no :file/path
+      (js/console.error "File path from page-block is not valid" page-block tree))))
 
 (defn save-tree!
   [page-block tree]

+ 7 - 7
src/main/frontend/modules/shortcut/dicts.cljc

@@ -1345,16 +1345,16 @@
              :command.sidebar/clear                  "Sağ kenar çubuğundaki herşeyi temizle"
              :command.misc/copy                      "mod+c"
              :command.command-palette/toggle         "Komut paletini aç"
-             :command.graph/open                     "Açılacak çizelgeyi seçin"
-             :command.graph/remove                   "Bir çizelgeyi kaldır"
-             :command.graph/add                      "Çizelge ekle"
-             :command.graph/save                     "Mevcut çizelgeyi diske kaydet"
-             :command.graph/re-index                 "Mevcut çizelgeyi yeniden oluştur"
+             :command.graph/open                     "Açılacak grafı seçin"
+             :command.graph/remove                   "Bir grafı kaldır"
+             :command.graph/add                      "Graf ekle"
+             :command.graph/save                     "Mevcut grafı diske kaydet"
+             :command.graph/re-index                 "Mevcut grafı yeniden oluştur"
              :command.command/run                    "Git komutunu çalıştır"
              :command.go/home                        "Ana sayfaya git"
-             :command.go/all-graphs                  "Bütün çizelgelere git"
+             :command.go/all-graphs                  "Bütün graflara git"
              :command.go/all-pages                   "Bütün sayfalara git"
-             :command.go/graph-view                  "Çizelge görünümüne git"
+             :command.go/graph-view                  "Graf görünümüne git"
              :command.go/keyboard-shortcuts          "Klavye kısayollarına git"
              :command.go/tomorrow                    "Yarının günlüğüne git"
              :command.go/next-journal                "Sonraki günlüğe git"

+ 2 - 2
src/main/frontend/state.cljs

@@ -1327,12 +1327,12 @@ Similar to re-frame subscriptions"
 
 (defn set-config!
   [repo-url value]
-  (set-state! [:config repo-url] value))
+  (when value (set-state! [:config repo-url] value)))
 
 (defn set-global-config!
   [value]
   ;; Placed under :config so cursors can work seamlessly
-  (set-config! ::global-config value))
+  (when value (set-config! ::global-config value)))
 
 (defn get-wide-mode?
   []

+ 8 - 6
src/main/frontend/util/fs.cljs

@@ -38,12 +38,14 @@
 (defn read-graphs-txid-info
   [root]
   (when (string? root)
-    (-> (p/let [txid-str (fs/read-file root "logseq/graphs-txid.edn")
-                txid-meta (and txid-str (reader/read-string txid-str))]
-          txid-meta)
-        (p/catch
-         (fn [^js e]
-           (js/console.error "[fs read txid data error]" e))))))
+    (p/let [exists? (fs/file-exists? root "logseq/graphs-txid.edn")]
+      (when exists?
+        (-> (p/let [txid-str (fs/read-file root "logseq/graphs-txid.edn")
+                    txid-meta (and txid-str (reader/read-string txid-str))]
+              txid-meta)
+            (p/catch
+                (fn [^js e]
+                  (js/console.error "[fs read txid data error]" e))))))))
 
 (defn inflate-graphs-info
   [graphs]

+ 20 - 18
src/main/frontend/util/persist_var.cljs

@@ -32,24 +32,26 @@
       (let [repo (state/get-current-repo)
             dir (config/get-repo-dir repo)
             path (load-path location)]
-        (-> (p/chain (fs/stat dir path)
-                     (fn [stat]
-                       (when stat
-                         (fs/read-file dir path)))
-                     (fn [content]
-                       (when (not-empty content)
-                         (try (cljs.reader/read-string content)
-                              (catch js/Error e
-                                (println (util/format "read persist-var failed: %s" (load-path location)))
-                                (js/console.dir e)))))
-                     (fn [value]
-                       (when (some? value)
-                         (swap! *value (fn [o]
-                                         (-> o
-                                             (assoc-in [repo :loaded?] true)
-                                             (assoc-in [repo :value] value)))))))
-            (p/catch (fn [e]
-                       (println (util/format "load persist-var failed: %s: %s" (load-path location) e))))))))
+        (p/let [file-exists? (fs/file-exists? dir path)]
+          (when file-exists?
+            (-> (p/chain (fs/stat dir path)
+                         (fn [stat]
+                           (when stat
+                             (fs/read-file dir path)))
+                         (fn [content]
+                           (when (not-empty content)
+                             (try (cljs.reader/read-string content)
+                                  (catch js/Error e
+                                    (println (util/format "read persist-var failed: %s" (load-path location)))
+                                    (js/console.dir e)))))
+                         (fn [value]
+                           (when (some? value)
+                             (swap! *value (fn [o]
+                                             (-> o
+                                                 (assoc-in [repo :loaded?] true)
+                                                 (assoc-in [repo :value] value)))))))
+                (p/catch (fn [e]
+                           (println (util/format "load persist-var failed: %s: %s" (load-path location) e))))))))))
   (-loaded? [_]
     (get-in @*value [(state/get-current-repo) :loaded?]))
 

+ 1 - 1
src/main/frontend/version.cljs

@@ -1,3 +1,3 @@
 (ns frontend.version)
 
-(defonce version "0.8.5")
+(defonce version "0.8.6")

+ 0 - 79
src/workspaces/workspaces/cards.cljs

@@ -1,79 +0,0 @@
-(ns workspaces.cards
-  (:require [frontend.extensions.graph :as graph]
-            [frontend.ui :as ui]
-            [nubank.workspaces.card-types.react :as ct.react]
-            [nubank.workspaces.core :as ws]
-            [rum.core :as rum]))
-
-;; simple function to create react elemnents
-(defn element [name props & children]
-  (apply js/React.createElement name (clj->js props) children))
-
-(ws/defcard hello-card
-  (ct.react/react-card
-   (element "div" {} "Hello World")))
-
-(rum/defc ui-button
-  []
-  (ui/button "Text"
-    :background "green"
-    :on-click (fn [] (js/alert "button clicked"))))
-
-(ws/defcard button-card
-  (ct.react/react-card
-   (ui-button)))
-
-(rum/defc graph
-  []
-  (graph/graph-2d
-   {:data {:nodes [{:id "a" :label "a"} {:id "b" :label "b"}]
-           :edges [{:source "a" :target "b"}]}
-    :width 150
-    :height 150
-    :fitView true}))
-
-(ws/defcard graph-card
-  (ct.react/react-card
-   (graph)))
-
-(defn random-graph
-  [n]
-  (let [nodes (for [i (range 0 n)]
-                {:id (str i)
-                 :label (str i)})
-        edges (->
-               (for [i (range 0 (/ n 2))]
-                 (let [source i
-                       target (inc i)]
-                   {:id (str source target)
-                    :source (str source)
-                    :target (str target)}))
-               (distinct))]
-    {:nodes nodes
-     :links edges}))
-
-;; (rum/defc pixi-graph
-;;   []
-;;   (let [{:keys [nodes links]} (random-graph 4000)]
-;;     (pixi/graph (fn []
-;;                   {:nodes nodes
-;;                   :links links
-;;                   :style {:node {:size 15
-;;                                  :color "#666666"
-;;                                  :border {:width 2
-;;                                           :color "#ffffff"}
-;;                                  :label {:content (fn [node] (.-id node))
-;;                                          :type js/window.PixiGraph.TextType.TEXT
-;;                                          :fontSize 12
-;;                                          :color "#333333"
-;;                                          :backgroundColor "rgba(255, 255, 255, 0.5)"
-;;                                          :padding 4}}
-;;                           :edge {:width 1
-;;                                  :color "#cccccc"}}
-;;                   :hover-style {:node {:border {:color "#000000"}
-;;                                        :label {:backgroundColor "rgba(238, 238, 238, 1)"}}
-;;                                 :edge {:color "#999999"}}}))))
-
-;; (ws/defcard pixi-graph-card
-;;   (ct.react/react-card
-;;    (pixi-graph)))

+ 0 - 5
src/workspaces/workspaces/main.cljs

@@ -1,5 +0,0 @@
-(ns workspaces.main
-  (:require [nubank.workspaces.core :as ws]
-            [workspaces.cards]))
-
-(defonce init (ws/mount))

+ 1 - 1
templates/config.edn

@@ -213,7 +213,7 @@
 
  :ref/linked-references-collapsed-threshold 50
 
- :favorites ["How to take dummy notes?"]
+ :favorites []
 
  ;; any number between 0 and 1 (the greater it is the faster the changes of the next-interval of card reviews) (default 0.5)
  ;; :srs/learning-fraction 0.5

文件差异内容过多而无法显示
+ 348 - 332
yarn.lock


部分文件因为文件数量过多而无法显示