mirror of
https://github.com/logseq/logseq.git
synced 2026-04-24 22:25:01 +00:00
chore: mv handler.common.file to file-based
now that this ns is only used by file graph namespaces. This is important as it then makes explicit that another 500+ lines in the graph-parser are file-graph specific. Also added docs to most graph-parser namespaces to make explicit which are file-graph specific and not
This commit is contained in:
committed by
Gabriel Horner
parent
885c06f1fb
commit
f597f7c9c0
@@ -97,7 +97,6 @@
|
||||
frontend.fs.nfs nfs
|
||||
frontend.handler.common common-handler
|
||||
frontend.handler.common.developer dev-common-handler
|
||||
frontend.handler.common.file file-common-handler
|
||||
frontend.handler.common.page page-common-handler
|
||||
frontend.handler.common.plugin plugin-common-handler
|
||||
frontend.handler.config config-handler
|
||||
@@ -114,6 +113,7 @@
|
||||
frontend.handler.file-based.property file-property-handler
|
||||
frontend.handler.file-based.property.util property-util
|
||||
frontend.handler.file-based.recent file-recent-handler
|
||||
frontend.handler.file-based.reset-file reset-file-handler
|
||||
frontend.handler.file-based.repo file-repo-handler
|
||||
frontend.handler.global-config global-config-handler
|
||||
frontend.handler.notification notification
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
(ns logseq.graph-parser
|
||||
"Main ns used by logseq app to parse graph from source files and then save to
|
||||
the given database connection"
|
||||
"For file graphs, provides main ns to parse graph from source files.
|
||||
Used by logseq app to parse graph and then save to the given database connection"
|
||||
(:require [clojure.set :as set]
|
||||
[clojure.string :as string]
|
||||
[datascript.core :as d]
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
(ns logseq.graph-parser.block
|
||||
"Given mldoc ast, prepares block data in preparation for db transaction"
|
||||
"Given mldoc ast, prepares block data in preparation for db transaction.
|
||||
Used by file and DB graphs"
|
||||
(:require [clojure.set :as set]
|
||||
[clojure.string :as string]
|
||||
[clojure.walk :as walk]
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
(ns ^:node-only logseq.graph-parser.cli
|
||||
"Primary ns to parse graphs with node.js based CLIs"
|
||||
"For file graphs, primary ns to parse graphs with node.js based CLIs"
|
||||
(:require ["fs" :as fs]
|
||||
["path" :as path]
|
||||
[clojure.edn :as edn]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
(ns logseq.graph-parser.extract
|
||||
"Handles extraction of blocks, pages and mldoc ast in preparation for db
|
||||
transaction"
|
||||
"For file graphs, handles extraction of blocks, pages and mldoc ast in
|
||||
preparation for db transaction"
|
||||
;; Disable clj linters since we don't support clj
|
||||
#?(:clj {:clj-kondo/config {:linters {:unresolved-namespace {:level :off}
|
||||
:unresolved-symbol {:level :off}}}})
|
||||
@@ -226,7 +226,7 @@
|
||||
:resolve-uuid-fn - Optional fn which is called to resolve uuids of each block. Enables diff-merge
|
||||
(2 ways diff) based uuid resolution upon external editing.
|
||||
returns a list of the uuids, given the receiving ast, or nil if not able to resolve.
|
||||
Implemented in file-common-handler/diff-merge-uuids for IoC
|
||||
Implemented in reset-file-handler/diff-merge-uuids-2ways for IoC
|
||||
Called in gp-extract/extract as AST is being parsed and properties are extracted there"
|
||||
[format ast properties file content {:keys [date-formatter db filename-format extracted-block-ids resolve-uuid-fn]
|
||||
:or {extracted-block-ids (atom #{})
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
(ns logseq.graph-parser.property
|
||||
"Core vars and util fns for properties and file based graphs"
|
||||
"For file graphs, core vars and util fns for properties"
|
||||
(:require [logseq.common.util :as common-util]
|
||||
[clojure.string :as string]
|
||||
[clojure.set :as set]
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
(ns logseq.graph-parser.text
|
||||
"Miscellaneous text util fns for the parser"
|
||||
"Miscellaneous text util fns for the parser. Used by file and DB graphs"
|
||||
(:require [goog.string :as gstring]
|
||||
[clojure.string :as string]
|
||||
[clojure.set :as set]
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
[frontend.fs :as fs]
|
||||
[frontend.fs.nfs :as nfs]
|
||||
[frontend.fs.capacitor-fs :as capacitor-fs]
|
||||
[frontend.handler.common.file :as file-common-handler]
|
||||
[frontend.handler.file-based.reset-file :as reset-file-handler]
|
||||
[frontend.handler.common.config-edn :as config-edn-common-handler]
|
||||
[frontend.handler.repo-config :as repo-config-handler]
|
||||
[frontend.handler.global-config :as global-config-handler]
|
||||
@@ -168,7 +168,7 @@
|
||||
[[:db/retract page-id :block/alias]
|
||||
[:db/retract page-id :block/tags]]
|
||||
opts)))
|
||||
(file-common-handler/reset-file!
|
||||
(reset-file-handler/reset-file!
|
||||
repo path content (merge opts
|
||||
;; To avoid skipping the `:or` bounds for keyword destructuring
|
||||
(when (some? extracted-block-ids) {:extracted-block-ids extracted-block-ids})
|
||||
@@ -248,7 +248,7 @@
|
||||
(when update-db?
|
||||
(doseq [[path content] files]
|
||||
(if reset?
|
||||
(file-common-handler/reset-file! repo path content)
|
||||
(reset-file-handler/reset-file! repo path content)
|
||||
(db/set-file-content! repo path content))))
|
||||
(alter-files-handler! repo files opts file->content)))
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
[frontend.fs :as fs]
|
||||
[frontend.handler.file-based.file :as file-handler]
|
||||
[frontend.handler.repo-config :as repo-config-handler]
|
||||
[frontend.handler.common.file :as file-common-handler]
|
||||
[frontend.handler.file-based.reset-file :as reset-file-handler]
|
||||
[frontend.handler.route :as route-handler]
|
||||
[frontend.handler.ui :as ui-handler]
|
||||
[frontend.spec :as spec]
|
||||
@@ -37,7 +37,7 @@
|
||||
(p/let [_ (fs/mkdir-if-not-exists (path/path-join repo-dir pages-dir))
|
||||
file-exists? (fs/create-if-not-exists repo-url repo-dir file-rpath default-content)]
|
||||
(when-not file-exists?
|
||||
(file-common-handler/reset-file! repo-url file-rpath default-content)))))))
|
||||
(reset-file-handler/reset-file! repo-url file-rpath default-content)))))))
|
||||
|
||||
(defn- create-custom-theme
|
||||
[repo-url]
|
||||
@@ -49,7 +49,7 @@
|
||||
(p/let [_ (fs/mkdir-if-not-exists (path/path-join repo-dir config/app-name))
|
||||
file-exists? (fs/create-if-not-exists repo-url repo-dir file-rpath default-content)]
|
||||
(when-not file-exists?
|
||||
(file-common-handler/reset-file! repo-url path default-content)))))
|
||||
(reset-file-handler/reset-file! repo-url path default-content)))))
|
||||
|
||||
(comment
|
||||
(defn- create-dummy-notes-page
|
||||
@@ -59,7 +59,7 @@
|
||||
file-rpath (str (config/get-pages-directory) "/how_to_make_dummy_notes.md")]
|
||||
(p/let [_ (fs/mkdir-if-not-exists (path/path-join repo-dir (config/get-pages-directory)))
|
||||
_file-exists? (fs/create-if-not-exists repo-url repo-dir file-rpath content)]
|
||||
(file-common-handler/reset-file! repo-url file-rpath content)))))
|
||||
(reset-file-handler/reset-file! repo-url file-rpath content)))))
|
||||
|
||||
(comment
|
||||
(defn- create-today-journal-if-not-exists
|
||||
@@ -93,7 +93,7 @@
|
||||
_ (fs/mkdir-if-not-exists (path/path-join repo-dir (config/get-journals-directory)))
|
||||
file-exists? (fs/file-exists? repo-dir file-rpath)]
|
||||
(when-not file-exists?
|
||||
(p/let [_ (file-common-handler/reset-file! repo-url file-rpath content)]
|
||||
(p/let [_ (reset-file-handler/reset-file! repo-url file-rpath content)]
|
||||
(fs/create-if-not-exists repo-url repo-dir file-rpath content)))))))))
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@
|
||||
path (str app-dir "/" config/config-file)]
|
||||
(p/let [file-exists? (fs/create-if-not-exists repo-url repo-dir "logseq/config.edn" default-content)]
|
||||
(when-not file-exists?
|
||||
(file-common-handler/reset-file! repo-url path default-content)
|
||||
(reset-file-handler/reset-file! repo-url path default-content)
|
||||
(repo-config-handler/set-repo-config-state! repo-url default-content)))))))
|
||||
|
||||
(defn- create-default-files!
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
(ns frontend.handler.common.file
|
||||
"Common file related fns for handlers"
|
||||
(ns frontend.handler.file-based.reset-file
|
||||
"Fns for resetting a db file with parsed file content"
|
||||
(:require [frontend.config :as config]
|
||||
[frontend.state :as state]
|
||||
[frontend.db :as db]
|
||||
@@ -3,7 +3,7 @@
|
||||
[cljs.test :refer [are deftest is]]
|
||||
[frontend.db.conn :as conn]
|
||||
[frontend.fs.diff-merge :as fs-diff]
|
||||
[frontend.handler.common.file :as file-common-handler]
|
||||
[frontend.handler.file-based.reset-file :as reset-file-handler]
|
||||
[logseq.graph-parser :as graph-parser]
|
||||
[logseq.graph-parser.db :as gp-db]
|
||||
[logseq.graph-parser.mldoc :as gp-mldoc]
|
||||
@@ -377,7 +377,7 @@
|
||||
(graph-parser/parse-file conn "bar.md" bar-content {})
|
||||
(are [ast content page-name uuids]
|
||||
(= (with-redefs [conn/get-db (constantly @conn)]
|
||||
(#'file-common-handler/diff-merge-uuids-2ways :markdown ast content {:page-name page-name
|
||||
(#'reset-file-handler/diff-merge-uuids-2ways :markdown ast content {:page-name page-name
|
||||
:block-pattern "-"}))
|
||||
uuids)
|
||||
|
||||
@@ -409,7 +409,7 @@
|
||||
;; Compare if the uuids are the same as those inside DB when the modified content (adding new line) is parsed
|
||||
(are [ast content page-name DB-uuids->new-uuids-fn]
|
||||
(= (with-redefs [conn/get-db (constantly @conn)]
|
||||
(#'file-common-handler/diff-merge-uuids-2ways :markdown ast content {:page-name page-name
|
||||
(#'reset-file-handler/diff-merge-uuids-2ways :markdown ast content {:page-name page-name
|
||||
:block-pattern "-"}))
|
||||
;; Get all uuids under the page
|
||||
(->> page-name
|
||||
@@ -441,7 +441,7 @@
|
||||
(= (with-redefs [conn/get-db (constantly @conn)
|
||||
;; Hijack the function to throw an exception
|
||||
fs-diff/db->diff-blocks #(throw (js/Error. "intentional exception for testing diff-merge-uuids-2ways error capture"))]
|
||||
(#'file-common-handler/diff-merge-uuids-2ways :markdown ast content {:page-name page-name
|
||||
(#'reset-file-handler/diff-merge-uuids-2ways :markdown ast content {:page-name page-name
|
||||
:block-pattern "-"}))
|
||||
nil)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user