Ver código fonte

fix: rm file graph config from user config

Also remove unused helpers for file config keys and file graph code in
mobile.intent.  These removals also result in removing
frontend.common.file.util as it's no longer used
Gabriel Horner 1 semana atrás
pai
commit
35902e4835

+ 0 - 1
.clj-kondo/config.edn

@@ -71,7 +71,6 @@
              electron.utils utils
              frontend.commands commands
              frontend.common.date common-date
-             frontend.common.file.util wfu
              frontend.common.missionary-util c.m
              frontend.common.schema-register sr
              frontend.common.search-fuzzy fuzzy

+ 0 - 130
deps/common/resources/templates/config.edn

@@ -1,135 +1,5 @@
 {:meta/version 1
 
- ;; == FILE GRAPH CONFIG ==
- ;;
- ;; Set the preferred format.
- ;; This is _only_ for file graphs.
- ;; Available options:
- ;; - Markdown (default)
- ;; - Org
- ;; :preferred-format "Markdown"
-
- ;; Set the preferred workflow style.
- ;; This is _only_ for file graphs.
- ;; Available options:
- ;; - :now for NOW/LATER style (default)
- ;; - :todo for TODO/DOING style
- :preferred-workflow :now
-
- ;; Exclude directories/files.
- ;; This is _only_ for file graphs.
- ;; Example usage:
- ;; :hidden ["/archived" "/test.md" "../assets/archived"]
- :hidden []
-
- ;; Define the default journal page template.
- ;; Enter the template name between the quotes.
- ;; This is _only_ for file graphs.
- :default-templates
- {:journals ""}
-
- ;; Set a custom date format for the journal page title.
- ;; This is _only_ for file graphs.
- ;; Default value: "MMM do, yyyy"
- ;; e.g., "Jan 19th, 2038"
- ;; Example usage e.g., "Tue 19th, Jan 2038"
- ;; :journal/page-title-format "EEE do, MMM yyyy"
-
- ;; Specify the journal filename format using a valid date format string.
- ;; !Warning:
- ;;   This configuration is not retroactive and affects only new journals.
- ;;   To show old journal files in the app, manually rename the files in the
- ;;   journal directory to match the new format.
- ;; This is _only_ for file graphs.
- ;; Default value: "yyyy_MM_dd"
- ;; :journal/file-name-format "yyyy_MM_dd"
-
- ;; Set the default location for storing notes.
- ;; This is _only_ for file graphs.
- ;; Default value: "pages"
- ;; :pages-directory "pages"
-
- ;; Set the default location for storing journals.
- ;; This is _only_ for file graphs.
- ;; Default value: "journals"
- ;; :journals-directory "journals"
-
- ;; Set the default location for storing whiteboards.
- ;; This is _only_ for file graphs.
- ;; Default value: "whiteboards"
- ;; :whiteboards-directory "whiteboards"
-
- ;; Enabling this option converts
- ;; [[Grant Ideas]] to [[file:./grant_ideas.org][Grant Ideas]] for org-mode.
- ;; For more information, visit https://github.com/logseq/logseq/issues/672
- ;; This is _only_ for file graphs.
- ;; :org-mode/insert-file-link? false
-
-;; Favorites to list on the left sidebar
- ;; This is _only_ for file graphs.
- :favorites []
-
- ;; Set flashcards interval.
- ;; This is _only_ for file graphs.
- ;; Expected value:
- ;; - Float between 0 and 1
- ;; higher values result in faster changes to the next review interval.
- ;; Default value: 0.5
- ;; :srs/learning-fraction 0.5
-
- ;; Set the initial interval after the first successful review of a card.
- ;; This is _only_ for file graphs.
- ;; Default value: 4
- ;; :srs/initial-interval 4
-
- ;; Hide specific block properties.
- ;; This is _only_ for file graphs.
- ;; Example usage:
- ;; :block-hidden-properties #{:public :icon}
-
- ;; Create a page for all properties.
- ;; This is _only_ for file graphs.
- ;; Default value: true
- :property-pages/enabled? true
-
- ;; Properties to exclude from having property pages
- ;; This is _only_ for file graphs.
- ;; Example usage:
- ;; :property-pages/excludelist #{:duration :author}
-
- ;; By default, property value separated by commas will not be treated as
- ;; page references. You can add properties to enable it.
- ;; This is _only_ for file graphs.
- ;; Example usage:
- ;; :property/separated-by-commas #{:alias :tags}
-
- ;; Properties that are ignored when parsing property values for references
- ;; This is _only_ for file graphs.
- ;; Example usage:
- ;; :ignored-page-references-keywords #{:author :website}
-
- ;; logbook configuration.
- ;; This is _only_ for file graphs.
- ;; :logbook/settings
- ;; {:with-second-support? false ;limit logbook to minutes, seconds will be eliminated
- ;;  :enabled-in-all-blocks true ;display logbook in all blocks after timetracking
- ;;  :enabled-in-timestamped-blocks false ;don't display logbook at all
- ;; }
-
- ;; Configure the escaping method for special characters in page titles.
- ;; This is _only_ for file graphs.
- ;; Warning:
- ;;   This is a dangerous operation. To modify the setting,
- ;;   you'll need to manually rename all affected files and
- ;;   re-index them on all clients after synchronization.
- ;;   Incorrect handling may result in messy page titles.
- ;; Available options:
- ;;   - :triple-lowbar (default)
- ;;      ;use triple underscore `___` for slash `/` in page title
- ;;      ;use Percent-encoding for other invalid characters
- :file/name-format :triple-lowbar
- ;; == END OF FILE GRAPH CONFIG ==
-
  ;; Hide empty block properties
  ;; This is _only_ for DB graphs.
  ;; Default value: false

+ 0 - 28
deps/common/src/logseq/common/config.cljs

@@ -67,19 +67,11 @@
     s))
 
 (defonce default-draw-directory "draws")
-;; TODO read configurable value?
-(defonce default-whiteboards-directory "whiteboards")
 
 (defn draw?
   [path]
   (string/starts-with? path default-draw-directory))
 
-(defn whiteboard?
-  [path]
-  (and path
-       (string/includes? path (str default-whiteboards-directory "/"))
-       (string/ends-with? path ".edn")))
-
 ;; TODO: rename
 (defonce mldoc-support-formats
   #{:org :markdown :md})
@@ -97,21 +89,6 @@
   []
   #{:gif :svg :jpeg :ico :png :jpg :bmp :webp})
 
-(defn get-date-formatter
-  [config]
-  (or
-   (:journal/page-title-format config)
-   ;; for compatibility
-   (:date-formatter config)
-   "MMM do, yyyy"))
-
-(defn get-preferred-format
-  [config]
-  (or
-   (when-let [fmt (:preferred-format config)]
-     (keyword (string/lower-case (name fmt))))
-   :markdown))
-
 (defn get-block-pattern
   [format]
   (let [format' (keyword format)]
@@ -121,11 +98,6 @@
 
       "-")))
 
-(defn create-config-for-db-graph
-  "Given a new config.edn file string, creates a config.edn for use with only DB graphs"
-  [config]
-  (string/replace config #"(?m)[\s]*;; == FILE GRAPH CONFIG ==(?:.|\n)*?;; == END OF FILE GRAPH CONFIG ==\n?" ""))
-
 (def file-only-config
   "File only config keys that are deprecated in DB graphs along with
   descriptions for their deprecation."

+ 1 - 11
deps/common/src/logseq/common/date.cljs

@@ -5,8 +5,6 @@
             [logseq.common.util :as common-util]
             [clojure.string :as string]))
 
-(def default-journal-filename-formatter "yyyy_MM_dd")
-
 (defonce built-in-journal-title-formatters
   (list
    "do MMM yyyy"
@@ -79,12 +77,4 @@
 
 (defn ^:api valid-journal-title-with-slash?
   [title]
-  (some #(valid-journal-title? title %) slash-journal-title-formatters))
-
-(defn ^:api date->file-name
-  "Date object to filename format"
-  [date journal-filename-formatter]
-  (let [formatter (if journal-filename-formatter
-                    (tf/formatter journal-filename-formatter)
-                    (tf/formatter default-journal-filename-formatter))]
-    (tf/unparse formatter date)))
+  (some #(valid-journal-title? title %) slash-journal-title-formatters))

+ 2 - 25
deps/common/test/logseq/common/config_test.cljc

@@ -1,9 +1,5 @@
 (ns logseq.common.config-test
-  (:require ["fs" :as fs]
-            ["path" :as node-path]
-            #?(:org.babashka/nbb [nbb.classpath :as cp])
-            [cljs.test :refer [deftest is]]
-            [clojure.string :as string]
+  (:require [cljs.test :refer [deftest is]]
             [logseq.common.config :as common-config]))
 
 (deftest remove-hidden-files
@@ -23,23 +19,4 @@
             (map #(str "/" %) files)
             {:hidden ["script" "/dev"]}
             identity))
-        "Removes hidden files if they start with '/'")))
-
-(defn find-on-classpath [classpath rel-path]
-  (some (fn [dir]
-          (let [f (node-path/join dir rel-path)]
-            (when (fs/existsSync f) f)))
-        (string/split classpath #":")))
-
-#?(:org.babashka/nbb
-   (deftest create-config-for-db-graph
-     (let [original-config (some-> (find-on-classpath (cp/get-classpath) "templates/config.edn") fs/readFileSync str)
-           _ (assert original-config "config.edn must not be blank")
-           migrated-config (common-config/create-config-for-db-graph original-config)
-           forbidden-kws-regex (re-pattern (str (string/join "|" (keys common-config/file-only-config))))]
-      ;;  (println migrated-config)
-       (is (not (string/includes? migrated-config "== FILE ONLY CONFIG"))
-           "No longer includes file config header")
-       (assert (re-find forbidden-kws-regex original-config) "File config keys present in original config")
-       (is (not (re-find forbidden-kws-regex migrated-config))
-           "File config keys no longer present in migrated config"))))
+        "Removes hidden files if they start with '/'")))

+ 17 - 3
deps/graph-parser/src/logseq/graph_parser/exporter.cljs

@@ -314,11 +314,25 @@
           (dissoc :block/priority)))
     block))
 
+(defn- get-date-formatter
+  [config]
+  (or
+   (:journal/page-title-format config)
+   ;; for compatibility
+   (:date-formatter config)
+   "MMM do, yyyy"))
+
+(defn- config-whiteboard?
+  [path]
+  (and path
+       (string/includes? path (str "whiteboards" "/"))
+       (string/ends-with? path ".edn")))
+
 (defn- find-or-create-deadline-scheduled-value
   "Given a :block/scheduled or :block/deadline value, creates the datetime property value
    and any optional journal tx associated with that value"
   [date-int page-names-to-uuids user-config]
-  (let [title (date-time-util/int->journal-title date-int (common-config/get-date-formatter user-config))
+  (let [title (date-time-util/int->journal-title date-int (get-date-formatter user-config))
         existing-journal-page (some->> title
                                        common-util/page-name-sanity-lc
                                        (get @page-names-to-uuids)
@@ -1745,7 +1759,7 @@
                                    (map #(dissoc % :block.temp/original-page-name) pages)))
                   (update :blocks fix-extracted-block-tags-and-refs))
 
-              (common-config/whiteboard? file)
+              (config-whiteboard? file)
               (-> (extract/extract-whiteboard-edn file content extract-options')
                   (update :pages (fn [pages]
                                    (->> pages
@@ -2102,7 +2116,7 @@
 (defn build-doc-options
   "Builds options for use with export-doc-files and assets"
   [config options]
-  (-> {:extract-options {:date-formatter (common-config/get-date-formatter config)
+  (-> {:extract-options {:date-formatter (get-date-formatter config)
                          ;; Remove config keys that break importing
                          :user-config (dissoc config :property-pages/excludelist :property-pages/enabled?)
                          :filename-format (or (:file/name-format config) :legacy)

+ 0 - 3
deps/outliner/src/logseq/outliner/cli.cljs

@@ -5,7 +5,6 @@
             ["path" :as node-path]
             [borkdude.rewrite-edn :as rewrite]
             [clojure.string :as string]
-            [logseq.common.config :as common-config]
             [logseq.db :as ldb]
             [logseq.db.common.sqlite-cli :as sqlite-cli]
             [logseq.db.sqlite.build :as sqlite-build]
@@ -43,8 +42,6 @@
         (cond-> (or (some-> (find-on-classpath classpath "templates/config.edn") fs/readFileSync str)
                     (do (println "Setting graph's config to empty since no templates/config.edn was found.")
                         "{}"))
-          true
-          (common-config/create-config-for-db-graph)
           additional-config
           (pretty-print-merge additional-config))
         git-sha (get-git-sha)]

+ 0 - 79
src/main/frontend/common/file/util.cljs

@@ -1,79 +0,0 @@
-(ns frontend.common.file.util
-  "File name fns. Used by worker and frontend namespaces"
-  (:require [clojure.string :as string]
-            [logseq.common.util :as common-util]
-            [logseq.db :as ldb]))
-
-;; Update repo/invalid-graph-name-warning if characters change
-(def multiplatform-reserved-chars ":\\*\\?\"<>|\\#\\\\")
-
-(def reserved-chars-pattern
-  (re-pattern (str "[" multiplatform-reserved-chars "]+")))
-
-(defn- encode-url-lowbar
-  [input]
-  (string/replace input "_" "%5F"))
-
-(defn- encode-url-percent
-  [input]
-  (string/replace input "%" "%25"))
-
-(defn- escape-namespace-slashes-and-multilowbars
-  "Encode slashes / as triple lowbars ___
-   Don't encode _ in most cases, except causing ambiguation"
-  [string]
-  (-> string
-      ;; The ambiguation is caused by the unbounded _ (possible continuation of `_`s)
-      (string/replace "___" encode-url-lowbar)
-      (string/replace "_/" encode-url-lowbar)
-      (string/replace "/_" encode-url-lowbar)
-      ;; After ambiguaous _ encoded, encode the slash
-      (string/replace "/" "___")))
-
-(def windows-reserved-filebodies
-  (set '("CON" "PRN" "AUX" "NUL" "COM1" "COM2" "COM3" "COM4" "COM5" "COM6"
-               "COM7" "COM8" "COM9" "LPT1" "LPT2" "LPT3" "LPT4" "LPT5" "LPT6" "LPT7"
-               "LPT8" "LPT9")))
-
-(defn- escape-windows-reserved-filebodies
-  "Encode reserved file names in Windows"
-  [file-body]
-  (str file-body (when (or (contains? windows-reserved-filebodies file-body)
-                           (string/ends-with? file-body "."))
-                   "/"))) ;; "___" would not break the title, but follow the Windows ruling
-
-(defn- url-encode-file-name
-  [file-name]
-  (-> file-name
-      js/encodeURIComponent
-      (string/replace "*" "%2A") ;; extra token that not involved in URI encoding
-      ))
-
-(defn- tri-lb-file-name-sanity
-  "Sanitize page-name for file name (strict), for file name in file writing.
-   Use triple lowbar as namespace separator"
-  [title]
-  (some-> title
-          common-util/page-name-sanity ;; we want to preserve the case sensitive nature of most file systems, don't lowercase
-          (string/replace common-util/url-encoded-pattern encode-url-percent) ;; pre-encode % in title on demand
-          (string/replace reserved-chars-pattern url-encode-file-name)
-          (escape-windows-reserved-filebodies) ;; do this before the lowbar encoding to avoid ambiguity
-          (escape-namespace-slashes-and-multilowbars)))
-
-;; Register sanitization / parsing fns in:
-;; logseq.common.util (parsing only)
-;; frontend.util.fs         (sanitization only)
-(defn file-name-sanity
-  [title]
-  (when (string? title)
-    (tri-lb-file-name-sanity title)))
-
-(defn include-reserved-chars?
-  "Includes reserved characters that would broken FS"
-  [s]
-  (common-util/safe-re-find reserved-chars-pattern s))
-
-(defn post-message
-  [type data & {:keys [port]}]
-  (when-let [worker (or port js/self)]
-    (.postMessage worker (ldb/write-transit-str [type data]))))

+ 3 - 3
src/main/frontend/components/editor.cljs

@@ -210,7 +210,7 @@
       (set-matched-pages! result))))
 
 (rum/defc page-search-aux
-  [id format embed? db-tag? q current-pos input pos]
+  [id format embed? db-tag? q input pos]
   (let [q (string/trim q)
         [matched-pages set-matched-pages!] (rum/use-state nil)
         search-f #(search-pages q db-tag? set-matched-pages!)]
@@ -234,7 +234,7 @@
         matched-pages'
         {:on-chosen   (page-on-chosen-handler embed? input id q pos format)
          :on-enter    (fn []
-                        (page-handler/page-not-exists-handler input id q current-pos))
+                        (page-handler/page-not-exists-handler input))
          :item-render (fn [block _chosen?]
                         (node-render block q {:db-tag? db-tag?}))
          :empty-placeholder [:div.text-gray-500.text-sm.px-4.py-2 (if db-tag?
@@ -273,7 +273,7 @@
                (when (> (count edit-content) current-pos)
                  (common-util/safe-subs edit-content pos current-pos))
                "")]
-        (page-search-aux id format embed? db-tag? q current-pos input pos)))))
+        (page-search-aux id format embed? db-tag? q input pos)))))
 
 (defn- search-blocks!
   [state result]

+ 0 - 11
src/main/frontend/config.cljs

@@ -280,17 +280,6 @@
      (+ 3 (count label))]
     ["" 0]))
 
-(defonce default-journals-directory "journals")
-(defonce default-pages-directory "pages")
-
-(defn get-pages-directory
-  []
-  (or (state/get-pages-directory) default-pages-directory))
-
-(defn get-journals-directory
-  []
-  (or (state/get-journals-directory) default-journals-directory))
-
 (defonce demo-repo "Demo")
 
 (defn demo-graph?

+ 0 - 2
src/main/frontend/date.cljs

@@ -117,8 +117,6 @@
   [journal-title]
   (journal-title-> journal-title #(tc/to-long %)))
 
-(def default-journal-filename-formatter common-date/default-journal-filename-formatter)
-
 (defn int->local-time-2
   [n]
   (tf/unparse

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

@@ -127,12 +127,8 @@
                  :validate-db-options (:dev/validate-db-options (state/get-config))
                  :importing? (:graph/importing @state/state)
                  :date-formatter (state/get-date-formatter)
-                 :journal-file-name-format (or (state/get-journal-file-name-format)
-                                               date/default-journal-filename-formatter)
                  :export-bullet-indentation (state/get-export-bullet-indentation)
-                 :preferred-format (state/get-preferred-format)
-                 :journals-directory (config/get-journals-directory)
-                 :pages-directory (config/get-pages-directory)}]
+                 :preferred-format (state/get-preferred-format)}]
     (state/<invoke-db-worker :thread-api/set-context context)))
 
 ;; Hook on a graph is ready to be shown to the user.

+ 3 - 17
src/main/frontend/handler/page.cljs

@@ -27,7 +27,6 @@
             [frontend.util.ref :as ref]
             [frontend.util.url :as url-util]
             [goog.functions :refer [debounce]]
-            [goog.object :as gobj]
             [logseq.common.config :as common-config]
             [logseq.common.util :as common-util]
             [logseq.common.util.page-ref :as page-ref]
@@ -130,23 +129,10 @@
 
 ;; Editor
 (defn page-not-exists-handler
-  [input id q current-pos]
+  [input]
   (state/clear-editor-action!)
-  (if (state/org-mode-file-link? (state/get-current-repo))
-    (let [page-ref-text (get-page-ref-text q)
-          value (gobj/get input "value")
-          old-page-ref (ref/->page-ref q)
-          new-value (string/replace value
-                                    old-page-ref
-                                    page-ref-text)]
-      (state/set-edit-content! id new-value)
-      (let [new-pos (+ current-pos
-                       (- (count page-ref-text)
-                          (count old-page-ref))
-                       2)]
-        (cursor/move-cursor-to input new-pos)))
-    (let [current-selected (util/get-selected-text)]
-      (cursor/move-cursor-forward input (+ 2 (count current-selected))))))
+  (let [current-selected (util/get-selected-text)]
+    (cursor/move-cursor-forward input (+ 2 (count current-selected)))))
 
 (defn- tag-on-chosen-handler
   [input id pos format current-pos edit-content q]

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

@@ -20,7 +20,6 @@
             [frontend.undo-redo :as undo-redo]
             [frontend.util :as util]
             [frontend.util.text :as text-util]
-            [logseq.common.config :as common-config]
             [logseq.db.frontend.schema :as db-schema]
             [promesa.core :as p]))
 
@@ -135,7 +134,7 @@
 
 (defn- create-db [full-graph-name {:keys [file-graph-import?]}]
   (->
-   (p/let [config (common-config/create-config-for-db-graph config/config-default-content)
+   (p/let [config config/config-default-content
            _ (persist-db/<new full-graph-name
                               (cond-> {:config config
                                        :graph-git-sha config/revision}

+ 1 - 34
src/main/frontend/mobile/intent.cljs

@@ -16,11 +16,8 @@
             [frontend.mobile.util :as mobile-util]
             [frontend.state :as state]
             [frontend.util :as util]
-            [frontend.util.fs :as fs-util]
-            [frontend.util.ref :as ref]
             [goog.string :as gstring]
             [lambdaisland.glogi :as log]
-            [logseq.common.config :as common-config]
             [logseq.common.util :as common-util]
             [promesa.core :as p]))
 
@@ -122,33 +119,6 @@
                   (state/get-current-repo) [file] {})]
     (first result)))
 
-(defn- embed-text-file
-  "Store external content with url into Logseq repo"
-  [url title]
-  (p/let [time (date/get-current-time)
-          date-ref-name (date/today)
-          title (some-> (or title (node-path/basename url))
-                        common-util/safe-decode-uri-component
-                        util/node-path.name
-                        ;; make the title more user friendly
-                        common-util/page-name-sanity)
-          path (node-path/join (config/get-repo-dir (state/get-current-repo))
-                               (config/get-pages-directory)
-                               (str (js/encodeURI (fs-util/file-name-sanity title :markdown)) (node-path/extname url)))
-          _ (p/catch
-             (.copy Filesystem (clj->js {:from (normalize-native-file-path url) :to path}))
-             (fn [error]
-               (log/error :copy-file-error {:error error})))
-          url (ref/->page-ref title)
-          template (get-in (state/get-config)
-                           [:quick-capture-templates :text]
-                           "**{time}** [[quick capture]]: {url}")]
-    (-> template
-        (string/replace "{time}" time)
-        (string/replace "{date}" date-ref-name)
-        (string/replace "{text}" "")
-        (string/replace "{url}" (or url "")))))
-
 (defn- handle-received-media [result]
   (p/let [{:keys [url]} result
           page (or (state/get-current-page) (string/lower-case (date/journal-name)))
@@ -159,14 +129,11 @@
                    (notification/show! "Failed to import the shared media. Please try again." :error false))))))
 
 (defn- handle-received-application [result]
-  (p/let [{:keys [title url type]} result
+  (p/let [{:keys [url type]} result
           page (or (state/get-current-page) (string/lower-case (date/journal-name)))
           format (db/get-page-format page)
           application-type (last (string/split type "/"))
           content (cond
-                    (common-config/mldoc-support? application-type)
-                    (embed-text-file url title)
-
                     (contains? (set/union config/doc-formats config/media-formats)
                                (keyword application-type))
                     (do

+ 1 - 6
src/main/frontend/persist_db/browser.cljs

@@ -7,7 +7,6 @@
             [frontend.common.missionary :as c.m]
             [frontend.common.thread-api :as thread-api]
             [frontend.config :as config]
-            [frontend.date :as date]
             [frontend.db :as db]
             [frontend.db.transact :as db-transact]
             [frontend.handler.notification :as notification]
@@ -83,12 +82,8 @@
                  :validate-db-options (:dev/validate-db-options (state/get-config))
                  :importing? (:graph/importing @state/state)
                  :date-formatter (state/get-date-formatter)
-                 :journal-file-name-format (or (state/get-journal-file-name-format)
-                                               date/default-journal-filename-formatter)
                  :export-bullet-indentation (state/get-export-bullet-indentation)
-                 :preferred-format (state/get-preferred-format)
-                 :journals-directory (config/get-journals-directory)
-                 :pages-directory (config/get-pages-directory)}]
+                 :preferred-format (state/get-preferred-format)}]
     (state/<invoke-db-worker :thread-api/transact repo tx-data tx-meta context)))
 
 (defn- set-worker-fs

+ 1 - 21
src/main/frontend/schema/handler/common_config.cljc

@@ -6,12 +6,6 @@
   (mu/optional-keys
    [:map
     [:meta/version :int]
-    ;; Loose since it looks like capitalization and string are possible
-    [:preferred-format [:or :keyword :string]]
-    [:hidden [:vector :string]]
-    [:default-templates [:map
-                         [:journals {:optional true} :string]]]
-    [:journal/page-title-format :string]
     [:ui/enable-tooltip? :boolean]
     [:ui/show-brackets? :boolean]
     [:feature/enable-search-remove-accents? :boolean]
@@ -29,9 +23,6 @@
     [:default-home [:map
                     [:page {:optional true} :string]
                     [:sidebar {:optional true} [:or :string [:vector :string]]]]]
-    [:pages-directory :string]
-    [:journal-directory :string]
-    [:org-mode/insert-file-link? :boolean]
     [:shortcuts [:map-of
                  :keyword
                  [:or :string false? [:vector :string]]]]
@@ -61,16 +52,6 @@
     [:ref/default-open-blocks-level :int]
     [:graph/settings [:map-of :keyword [:or :boolean :int :nil]]]
     [:graph/forcesettings [:map-of :keyword :int]]
-    [:favorites [:vector :string]]
-    ;; There isn't a :float yet
-    [:srs/learning-fraction float?]
-    [:srs/initial-interval :int]
-    [:block-hidden-properties [:set :keyword]]
-    [:property-pages/enabled? :boolean]
-    [:property-pages/excludelist [:set :keyword]]
-    [:property/separated-by-commas [:set :keyword]]
-    [:ignored-page-references-keywords [:set :keyword]]
-    [:logbook/settings :map]
     [:mobile/photo [:map
                     [:allow-editing? {:optional true} :boolean]
                     [:quality {:optional true} :int]]]
@@ -85,5 +66,4 @@
     [:quick-capture-options (mu/optional-keys [:map
                                                [:insert-today? :boolean]
                                                [:redirect-page? :boolean]
-                                               [:default-page :string]])]
-    [:journal/file-name-format :string]]))
+                                               [:default-page :string]])]]))

+ 4 - 37
src/main/frontend/state.cljs

@@ -333,13 +333,7 @@
 (def common-default-config
   "Common default config for a user's repo config"
   {:feature/enable-search-remove-accents? true
-   :ui/auto-expand-block-refs? true
-
-   ;; For flushing the settings of old versions. Don't bump this value.
-   ;; There are only two kinds of graph, one is not upgraded (:legacy) and one is upgraded (:triple-lowbar)
-   ;; For not upgraded graphs, the config will have no key `:file/name-format`
-   ;; Then the default value is applied
-   :file/name-format :legacy})
+   :ui/auto-expand-block-refs? true})
 
 (def db-default-config
   "Default repo config for DB graphs"
@@ -461,43 +455,16 @@ should be done through this fn in order to get global config and config defaults
   []
   (some? (:page (get-default-home))))
 
+;; TODO: Move or remove as this is no longer stateful
 (defn get-preferred-format
-  ([]
-   (get-preferred-format (get-current-repo)))
-  ([repo-url]
-   (keyword
-    (or
-     (common-config/get-preferred-format (get-config repo-url))
-     (get-in @state [:me :preferred_format] "markdown")))))
+  [& _args]
+  :markdown)
 
 (defn markdown?
   []
   (= (keyword (get-preferred-format))
      :markdown))
 
-(defn get-pages-directory
-  []
-  (or
-   (when-let [repo (get-current-repo)]
-     (:pages-directory (get-config repo)))
-   "pages"))
-
-(defn get-journals-directory
-  []
-  (or
-   (when-let [repo (get-current-repo)]
-     (:journals-directory (get-config repo)))
-   "journals"))
-
-(defn org-mode-file-link?
-  [repo]
-  (:org-mode/insert-file-link? (get-config repo)))
-
-(defn get-journal-file-name-format
-  []
-  (when-let [repo (get-current-repo)]
-    (:journal/file-name-format (get-config repo))))
-
 (defn get-date-formatter
   []
   (or

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

@@ -4,7 +4,7 @@
   "Misc util fns built on top of frontend.fs"
   (:require ["path" :as node-path]
             [clojure.string :as string]
-            [frontend.common.file.util :as wfu]))
+            [logseq.common.util :as common-util]))
 
 ;; NOTE: This is not the same ignored-path? as src/electron/electron/utils.cljs.
 ;;       The assets directory is ignored.
@@ -37,8 +37,13 @@
            (some #(string/ends-with? path %)
                  [".md" ".markdown" ".org" ".js" ".edn" ".css"]))))))))
 
-(def include-reserved-chars? wfu/include-reserved-chars?)
-(def windows-reserved-filebodies wfu/windows-reserved-filebodies)
-(defn file-name-sanity
-  [name _format]
-  (wfu/file-name-sanity name))
+;; Update repo/invalid-graph-name-warning if characters change
+(def multiplatform-reserved-chars ":\\*\\?\"<>|\\#\\\\")
+
+(def reserved-chars-pattern
+  (re-pattern (str "[" multiplatform-reserved-chars "]+")))
+
+(defn include-reserved-chars?
+  "Includes reserved characters that would broken FS"
+  [s]
+  (common-util/safe-re-find reserved-chars-pattern s))

+ 4 - 8
src/main/frontend/worker/state.cljs

@@ -1,7 +1,6 @@
 (ns frontend.worker.state
   "State hub for worker"
-  (:require [logseq.common.config :as common-config]
-            [logseq.common.util :as common-util]))
+  (:require [logseq.common.util :as common-util]))
 
 (defonce *main-thread (atom nil))
 (defonce *infer-worker (atom nil))
@@ -96,10 +95,6 @@
          (fn [c]
            (merge c context))))
 
-(defn get-config
-  [repo]
-  (get-in @*state [:config repo]))
-
 (defn get-current-repo
   []
   (:git/current-repo @*state))
@@ -109,9 +104,10 @@
   (swap! *state (fn [old-state]
                   (merge old-state new-state))))
 
+;; TODO: Move or remove as this is no longer stateful
 (defn get-date-formatter
-  [repo]
-  (common-config/get-date-formatter (get-config repo)))
+  [_repo]
+  "MMM do, yyyy")
 
 (defn set-rtc-downloading-graph!
   [value]

+ 5 - 2
src/main/frontend/worker_common/util.cljc

@@ -7,7 +7,7 @@
                      [goog.crypt.Hmac]
                      [goog.crypt.Sha256]
                      [logseq.db.common.sqlite :as common-sqlite]
-                     [frontend.common.file.util :as wfu])))
+                     [logseq.db :as ldb])))
 
 ;; Copied from https://github.com/tonsky/datascript-todo
 #?(:clj
@@ -26,7 +26,10 @@
 
 #?(:cljs
    (do
-     (def post-message wfu/post-message)
+     (defn post-message
+       [type data & {:keys [port]}]
+       (when-let [worker (or port js/self)]
+         (.postMessage worker (ldb/write-transit-str [type data]))))
 
      (defn get-pool-name
        [graph-name]

+ 0 - 46
src/test/frontend/db/name_sanity_test.cljs

@@ -1,46 +0,0 @@
-(ns frontend.db.name-sanity-test
-  (:require [cljs.test :refer [deftest testing is]]
-            [clojure.string :as string]
-            [frontend.common.file.util :as wfu]
-            [frontend.util.fs :as fs-util]
-            [logseq.graph-parser.extract :as extract]))
-
-(defn- test-page-name
-  "Check if page name can be preserved after escaping"
-  [page-name]
-  (testing (str "Test sanitization page-name: " page-name)
-    (let [file-name   (#'wfu/tri-lb-file-name-sanity page-name)
-          page-name'  (#'extract/tri-lb-title-parsing file-name)
-          url-single  (js/encodeURIComponent file-name)
-          url-double  (js/encodeURIComponent url-single)
-          file-name'  (js/decodeURIComponent url-single)
-          file-name'' (js/decodeURIComponent (js/decodeURIComponent url-double))]
-      (is (= page-name page-name'))
-      (is (not (fs-util/include-reserved-chars? file-name)))
-      (is (not (contains? fs-util/windows-reserved-filebodies file-name)))
-      (is (not (string/ends-with? file-name ".")))
-      (is (= file-name' file-name))
-      (is (= file-name'' file-name)))))
-
-(deftest page-name-sanitization-tests
-  (test-page-name "Some.Content!")
-  (test-page-name "More _/_ Con tents")
-  (test-page-name "More _________/________ Con tents")
-  (test-page-name "More _________/___-_-_-_---___----__/_ Con tents")
-  (test-page-name "Cont./__cont_ cont/ lsdksdf")
-  (test-page-name "Cont.?/#__cont_ cont%/_ lsdksdf")
-  (test-page-name "Cont.?__byte/#__cont_ cont%/_ lsdksdf")
-  (test-page-name "__ont.?__byte/#__cont_ cont%/_ lsdksdf")
-  (test-page-name "______ont.?__byte/#__cont_ cont%/_ lsdksdf")
-  (test-page-name "__ont.?__byte/#__cont_ cont%/_ lsdksdf__")
-  (test-page-name "+*++***+++__byte/#__cont_ cont%/_ lsdksdf__")
-  (test-page-name "+*++_.x2A_.x2A***+++__byte/#__cont_ cont%/_ lsdksdf__")
-  (test-page-name "__ont.?__byte/#__0xbbcont_ cont%/_ lsdksdf__")
-  (test-page-name "__ont.?__byte/#_&amp;ont_ cont%/_ lsdksdf__")
-  (test-page-name "__ont.?__byte&lowbar;/#_&amp;ont_ cont%/_ lsdksdf__")
-  (test-page-name "dsa&amp&semi;l dsalfjk jkl")
-  (test-page-name "dsa&amp&semi;l dsalfjk jkl.")
-  (test-page-name "hls__&amp&semi;l dsalfjk jkl.")
-  (test-page-name "CON.")
-  (test-page-name ".NET.")
-  (mapv test-page-name fs-util/windows-reserved-filebodies))

+ 3 - 3
src/test/frontend/handler/common/config_edn_test.cljs

@@ -28,12 +28,12 @@
   (testing "Valid cases"
     (is (= true
            (config-edn-common-handler/validate-config-edn
-            "config.edn" "{:preferred-workflow :todo}" global-config-schema/Config-edn))
+            "config.edn" "{:macros {}}" global-config-schema/Config-edn))
         "global config.edn")
 
     (is (= true
            (config-edn-common-handler/validate-config-edn
-            "config.edn" "{:preferred-workflow :todo}" repo-config-schema/Config-edn))
+            "config.edn" "{:macros {}}" repo-config-schema/Config-edn))
         "repo config.edn"))
 
   (doseq [[file-type schema] {"global config.edn" global-config-schema/Config-edn
@@ -45,7 +45,7 @@
           (str "Not a map for " file-type))
 
       (is (string/includes?
-           (validation-config-error-for "{:preferred-workflow :todo" schema)
+           (validation-config-error-for "{:macros" schema)
            "Failed to read")
           (str "Invalid edn for " file-type))
 

+ 1 - 3
src/test/frontend/state_test.cljs

@@ -5,10 +5,8 @@
 (deftest merge-configs
   (let [global-config
         {:shortcuts {:ui/toggle-theme "t z"}
-         :hidden []
          :ui/enable-tooltip? true}
-        local-config {:hidden ["foo" "bar"]
-                      :ui/enable-tooltip? false}]
+        local-config {:ui/enable-tooltip? false}]
     (is (= local-config
            (dissoc (state/merge-configs global-config local-config) :shortcuts))
         "Later config overrides all non-map values")

+ 1 - 1
src/test/frontend/worker/rtc/rtc_fns_test.cljs

@@ -404,7 +404,7 @@ result:
   (deftest same-name-two-pages-merge-test
     (let [repo (state/get-current-repo)
           conn (conn/get-db repo false)
-          date-formatter (common-config/get-date-formatter (worker-state/get-config repo))
+          date-formatter (worker-state/get-date-formatter)
           opts {:persist-op? false
                 :transact-opts {:repo repo
                                 :conn conn}}