mirror of
https://github.com/logseq/logseq.git
synced 2026-02-01 22:47:36 +00:00
enhance: add export option to exclude-files
Useful for demo graphs as it's noisy and not useful to include since imported graphs already have it. Also added descriptions for properties graph to share it
This commit is contained in:
7
deps/db/script/export_graph.cljs
vendored
7
deps/db/script/export_graph.cljs
vendored
@@ -44,8 +44,8 @@
|
||||
:desc "Namespaces to exclude from properties and classes"}
|
||||
:exclude-built-in-pages? {:alias :b
|
||||
:desc "Exclude built-in pages"}
|
||||
:export-options {:alias :E
|
||||
:desc "Raw options map to pass to export"}})
|
||||
:exclude-files? {:alias :F
|
||||
:desc "Exclude :file/path files"}})
|
||||
|
||||
(defn -main [args]
|
||||
(let [{options :opts args' :args} (cli/parse-args args {:spec spec})
|
||||
@@ -56,8 +56,7 @@
|
||||
(js/process.exit 1))
|
||||
[dir db-name] (get-dir-and-db-name graph-dir)
|
||||
conn (sqlite-cli/open-db! dir db-name)
|
||||
export-options (merge (dissoc options :file :export-options)
|
||||
(edn/read-string (:export-options options)))
|
||||
export-options (dissoc options :file)
|
||||
export-map (sqlite-export/build-export @conn {:export-type :graph :graph-options export-options})]
|
||||
(if (:file options)
|
||||
(do
|
||||
|
||||
17
deps/db/src/logseq/db/sqlite/export.cljs
vendored
17
deps/db/src/logseq/db/sqlite/export.cljs
vendored
@@ -632,12 +632,13 @@
|
||||
|
||||
(defn- build-graph-export
|
||||
"Exports whole graph. Has the following options:
|
||||
* :include-timestamps? - When set timestamps are included on all blocks
|
||||
* :include-timestamps? - When set, timestamps are included on all blocks
|
||||
* :exclude-namespaces - A set of parent namespaces to exclude from properties and classes.
|
||||
This is useful for graphs seeded with an ontology e.g. schema.org as it eliminates noisy and needless
|
||||
export+import
|
||||
* :exclude-built-in-pages? - When set built-in pages are excluded from export"
|
||||
[db options*]
|
||||
* :exclude-built-in-pages? - When set, built-in pages are excluded from export
|
||||
* :exclude-files? - When set, files are excluded from export"
|
||||
[db {:keys [exclude-files?] :as options*}]
|
||||
(let [options (merge options* {:property-value-uuids? true})
|
||||
content-ref-uuids (get-graph-content-ref-uuids db options)
|
||||
ontology-options (merge options {:include-uuid? true})
|
||||
@@ -650,15 +651,17 @@
|
||||
(assoc graph-export* ::auto-include-namespaces (:exclude-namespaces options))
|
||||
graph-export*)
|
||||
all-ref-uuids (set/union content-ref-uuids ontology-pvalue-uuids (:pvalue-uuids pages-export))
|
||||
files (build-graph-files db options)
|
||||
files (when-not exclude-files? (build-graph-files db options))
|
||||
kv-values (build-kv-values db)
|
||||
;; Remove all non-ref uuids after all nodes are built.
|
||||
;; Only way to ensure all pvalue uuids present across block types
|
||||
graph-export' (-> (remove-uuids-if-not-ref graph-export all-ref-uuids)
|
||||
(update :pages-and-blocks sort-pages-and-blocks))]
|
||||
(merge graph-export'
|
||||
{::graph-files files
|
||||
::kv-values kv-values})))
|
||||
(cond-> graph-export'
|
||||
(not exclude-files?)
|
||||
(assoc ::graph-files files)
|
||||
true
|
||||
(assoc ::kv-values kv-values))))
|
||||
|
||||
(defn- find-undefined-classes-and-properties [{:keys [classes properties pages-and-blocks]}]
|
||||
(let [referenced-classes
|
||||
|
||||
@@ -90,7 +90,9 @@
|
||||
{:page {:build/journal (date-time-util/date->int two-days-ago)}}
|
||||
|
||||
;; Block property blocks and queries
|
||||
{:page {:block/title "Block Properties"}
|
||||
{:page {:block/title "Block Properties"
|
||||
:build/properties
|
||||
{:logseq.property/description "This page demonstrates all the combinations of property types and single/multiple values that are possible."}}
|
||||
:blocks
|
||||
[{:block/title "default property block" :build/properties {:default "haha"}}
|
||||
{:block/title "default property block" :build/properties {:default-many #{"yee" "haw" "sir"}}}
|
||||
@@ -109,7 +111,9 @@
|
||||
{:block/title "date-many property block" :build/properties {:date-many #{[:build/page {:build/journal today-int}]
|
||||
[:build/page {:build/journal yesterday-int}]}}}
|
||||
{:block/title "datetime property block" :build/properties {:datetime timestamp}}]}
|
||||
{:page {:block/title "Property Queries"}
|
||||
{:page {:block/title "Property Queries"
|
||||
:build/properties
|
||||
{:logseq.property/description "This page demonstrates all property type combinations being queried for a specific value. There should be 2 results for each query, one block and one page."}}
|
||||
:blocks
|
||||
[(query "(property default \"haha\")")
|
||||
(query "(property default-many \"haw\")")
|
||||
@@ -147,7 +151,9 @@
|
||||
[:build/page {:build/journal yesterday-int}]}}}}
|
||||
{:page {:block/title "datetime page" :build/properties {:datetime timestamp}}}
|
||||
|
||||
{:page {:block/title "Has Property Queries"}
|
||||
{:page {:block/title "Has Property Queries"
|
||||
:build/properties
|
||||
{:logseq.property/description "This page demonstrates all property type combinations being queried for having a specific property. There should be 2 results for each query, one block and one page."}}
|
||||
:blocks
|
||||
[(query "(property default)")
|
||||
(query "(property default-many)")
|
||||
|
||||
Reference in New Issue
Block a user