Finish migration of publishing to deps

* Frontend and cmdline version use the same fns!
* Add docstrings and db tests
* Fix bug with intermittently failing asset copies
* Move publish cli to scripts since publish-spa shouldn't have graph-parser dependency
* Fix parse-graph bug noticed while testing publishing
This commit is contained in:
Gabriel Horner
2023-04-03 15:43:37 -04:00
committed by Tienson Qin
parent 9ac17d485a
commit 5186070248
24 changed files with 731 additions and 709 deletions

9
bb.edn
View File

@@ -34,9 +34,12 @@
dev:build-publishing dev:build-publishing
logseq.tasks.dev/build-publishing logseq.tasks.dev/build-publishing
dev:publish dev:publish-spa
(apply shell {:dir "deps/publish-spa"} "yarn -s nbb-logseq -cp src -m logseq.publish-spa.cli" {:depends [dev:build-publishing]
*command-line-args*) :doc "Build publish spa app given graph and output dirs"
:task (apply shell {:dir "scripts"}
"yarn -s nbb-logseq -cp src -m logseq.tasks.dev.publishing"
(into ["static"] *command-line-args*))}
dev:npx-cap-run-ios dev:npx-cap-run-ios
logseq.tasks.dev.mobile/npx-cap-run-ios logseq.tasks.dev.mobile/npx-cap-run-ios

View File

@@ -77,57 +77,58 @@ Options available:
which may be referenced elsewhere. which may be referenced elsewhere.
* :skip-db-transact? - Boolean which skips transacting in order to batch transactions. Default is false * :skip-db-transact? - Boolean which skips transacting in order to batch transactions. Default is false
* :extract-options - Options map to pass to extract/extract" * :extract-options - Options map to pass to extract/extract"
[conn file content {:keys [new? delete-blocks-fn extract-options skip-db-transact?] ([conn file content] (parse-file conn file content {}))
:or {new? true ([conn file content {:keys [new? delete-blocks-fn extract-options skip-db-transact?]
delete-blocks-fn (constantly []) :or {new? true
skip-db-transact? false} delete-blocks-fn (constantly [])
:as options}] skip-db-transact? false}
(let [format (gp-util/get-format file) :as options}]
file-content [{:file/path file}] (let [format (gp-util/get-format file)
{:keys [tx ast]} file-content [{:file/path file}]
(let [extract-options' (merge {:block-pattern (gp-config/get-block-pattern format) {:keys [tx ast]}
:date-formatter "MMM do, yyyy" (let [extract-options' (merge {:block-pattern (gp-config/get-block-pattern format)
:supported-formats (gp-config/supported-formats) :date-formatter "MMM do, yyyy"
:uri-encoded? false :supported-formats (gp-config/supported-formats)
:filename-format :legacy} :uri-encoded? false
extract-options :filename-format :legacy}
{:db @conn}) extract-options
{:keys [pages blocks ast] {:db @conn})
:or {pages [] {:keys [pages blocks ast]
blocks [] :or {pages []
ast []}} blocks []
(cond (contains? gp-config/mldoc-support-formats format) ast []}}
(extract/extract file content extract-options') (cond (contains? gp-config/mldoc-support-formats format)
(extract/extract file content extract-options')
(gp-config/whiteboard? file) (gp-config/whiteboard? file)
(extract/extract-whiteboard-edn file content extract-options') (extract/extract-whiteboard-edn file content extract-options')
:else nil) :else nil)
block-ids (map (fn [block] {:block/uuid (:block/uuid block)}) blocks) block-ids (map (fn [block] {:block/uuid (:block/uuid block)}) blocks)
delete-blocks (delete-blocks-fn @conn (first pages) file block-ids) delete-blocks (delete-blocks-fn @conn (first pages) file block-ids)
block-refs-ids (->> (mapcat :block/refs blocks) block-refs-ids (->> (mapcat :block/refs blocks)
(filter (fn [ref] (and (vector? ref) (filter (fn [ref] (and (vector? ref)
(= :block/uuid (first ref))))) (= :block/uuid (first ref)))))
(map (fn [ref] {:block/uuid (second ref)})) (map (fn [ref] {:block/uuid (second ref)}))
(seq)) (seq))
;; To prevent "unique constraint" on datascript ;; To prevent "unique constraint" on datascript
block-ids (set/union (set block-ids) (set block-refs-ids)) block-ids (set/union (set block-ids) (set block-refs-ids))
pages (extract/with-ref-pages pages blocks) pages (extract/with-ref-pages pages blocks)
pages-index (map #(select-keys % [:block/name]) pages)] pages-index (map #(select-keys % [:block/name]) pages)]
;; does order matter? ;; does order matter?
{:tx (concat file-content pages-index delete-blocks pages block-ids blocks) {:tx (concat file-content pages-index delete-blocks pages block-ids blocks)
:ast ast}) :ast ast})
tx (concat tx [(cond-> {:file/path file tx (concat tx [(cond-> {:file/path file
:file/content content} :file/content content}
new? new?
;; TODO: use file system timestamp? ;; TODO: use file system timestamp?
(assoc :file/created-at (date-time-util/time-ms)))]) (assoc :file/created-at (date-time-util/time-ms)))])
tx' (gp-util/fast-remove-nils tx) tx' (gp-util/fast-remove-nils tx)
result (if skip-db-transact? result (if skip-db-transact?
tx' tx'
(d/transact! conn tx' (select-keys options [:new-graph? :from-disk?])))] (d/transact! conn tx' (select-keys options [:new-graph? :from-disk?])))]
{:tx result {:tx result
:ast ast})) :ast ast})))
(defn filter-files (defn filter-files
"Filters files in preparation for parsing. Only includes files that are "Filters files in preparation for parsing. Only includes files that are

View File

@@ -26,9 +26,11 @@ TODO: Fail fast when process exits 1"
"Given a git graph directory, returns allowed file paths and their contents in "Given a git graph directory, returns allowed file paths and their contents in
preparation for parsing" preparation for parsing"
[dir] [dir]
(let [files (->> (str (.-stdout (sh ["git" "ls-files"] ;; -z needed to avoid quoting unusual paths that cause slurp failures.
;; See https://git-scm.com/docs/git-ls-files#_output for more
(let [files (->> (str (.-stdout (sh ["git" "ls-files" "-z"]
{:cwd dir :stdio nil}))) {:cwd dir :stdio nil})))
string/split-lines (#(string/split % #"\0"))
(map #(hash-map :file/path (str dir "/" %))) (map #(hash-map :file/path (str dir "/" %)))
graph-parser/filter-files)] graph-parser/filter-files)]
(mapv #(assoc % :file/content (slurp (:file/path %))) files))) (mapv #(assoc % :file/content (slurp (:file/path %))) files)))

View File

@@ -1,8 +1,7 @@
{:paths ["src"] {:paths ["src"]
:deps :deps
{logseq/graph-parser {logseq/graph-parser
;; Nbb bug. Should just be "../graph-parser" ;; Nbb bug. Should just be "../db"
{:local/root "../../../../graph-parser"} {:local/root "../../../../db"}
io.github.nextjournal/nbb-test-runner io.github.nextjournal/nbb-test-runner
{:git/sha "60ed57aa04bca8d604f5ba6b28848bd887109347" {:git/sha "60ed57aa04bca8d604f5ba6b28848bd887109347"}}}
#_#_:local/root "../../../../../../nbb-test-runner"}}}

View File

@@ -6,10 +6,9 @@
"@logseq/nbb-logseq": "^1.2.168" "@logseq/nbb-logseq": "^1.2.168"
}, },
"dependencies": { "dependencies": {
"mldoc": "^1.5.1",
"fs-extra": "9.1.0" "fs-extra": "9.1.0"
}, },
"scripts": { "scripts": {
"test": "nbb-logseq -cp src:test -m nextjournal.test-runner" "test": "yarn nbb-logseq -cp test:../graph-parser/src -m nextjournal.test-runner"
} }
} }

View File

@@ -1,24 +1,18 @@
(ns logseq.publish-spa (ns logseq.publish-spa
(:require [datascript.transit :as dt] "This node only ns provides api fns for exporting a publishing app"
[logseq.publish-spa.html :as html] (:require [logseq.publish-spa.html :as publish-html]
[logseq.publish-spa.export :as export] [logseq.publish-spa.export :as publish-export]))
[logseq.publish-spa.db :as db]))
(defn prep-for-export [db {:keys [app-state repo-config html-options]}] (defn export
(let [[db asset-filenames'] "Exports the given graph-dir and db to the specific output-dir. Most of the graph
(if (:publishing/all-pages-public? repo-config) configuration is done through logseq/config.edn. There are a few explicit options that
(db/clean-export! db) can be passed:
(db/filter-only-public-pages-and-blocks db)) * :ui/theme - Theme mode that can either be 'light' or 'dark'.
asset-filenames (remove nil? asset-filenames') * :html-options - A map of values that are inserted into index.html. Map keys
db-str (dt/write-transit-str db) can be icon, name, alias, title, description and url"
state (assoc (select-keys app-state [db static-dir graph-dir output-dir options]
[:ui/theme (let [options' (cond-> options
:ui/sidebar-collapsed-blocks]) (:ui/theme options)
:config {"local" repo-config}) (assoc :app-state {:ui/theme (:ui/theme options)}))
raw-html-str (html/publishing-html db-str state html-options)] {:keys [html asset-filenames]} (publish-html/build-html db options')]
{:html raw-html-str (publish-export/create-export html static-dir graph-dir output-dir {:asset-filenames asset-filenames})))
:asset-filenames asset-filenames}))
(defn publish [db static-dir graph-dir output-path options]
(let [{:keys [html asset-filenames]} (prep-for-export db options)]
(export/export html static-dir graph-dir output-path {:asset-filenames asset-filenames})))

View File

@@ -1,23 +0,0 @@
(ns logseq.publish-spa.cli
(:require [logseq.graph-parser.cli :as gp-cli]
[logseq.publish-spa :as publish-spa]
["fs" :as fs]
["path" :as path]
[clojure.edn :as edn]))
(defn- get-db [graph-dir]
(let [{:keys [conn]} (gp-cli/parse-graph graph-dir {:verbose false})] @conn))
(defn -main
[& args]
(let [graph-dir (or (first args)
(throw (ex-info "GRAPH DIR required" {})))
output-path (or (second args)
(throw (ex-info "OUT DIR required" {})))
repo-config (-> (path/join graph-dir "logseq" "config.edn") fs/readFileSync str edn/read-string)]
(publish-spa/publish (get-db graph-dir)
"../../static"
graph-dir
output-path
{:repo-config repo-config})))

View File

@@ -3,8 +3,9 @@
[logseq.db.schema :as db-schema] [logseq.db.schema :as db-schema]
[clojure.string :as string])) [clojure.string :as string]))
;; Copied from pdf-utils
(defn get-area-block-asset-url (defn get-area-block-asset-url
"Returns asset url for an area block used by pdf assets. This lives in this ns
because it is used by this dep and needs to be indepent from the frontend app"
[block page] [block page]
(when-some [props (and block page (:block/properties block))] (when-some [props (and block page (:block/properties block))]
(when-some [uuid (:block/uuid block)] (when-some [uuid (:block/uuid block)]
@@ -13,66 +14,61 @@
hl-page (:hl-page props) hl-page (:hl-page props)
encoded-chars? (boolean (re-find #"(?i)%[0-9a-f]{2}" group-key)) encoded-chars? (boolean (re-find #"(?i)%[0-9a-f]{2}" group-key))
group-key (if encoded-chars? (js/encodeURI group-key) group-key)] group-key (if encoded-chars? (js/encodeURI group-key) group-key)]
(str "./" "assets" "/" group-key "/" (str hl-page "_" uuid "_" stamp ".png"))))))) (str "./assets/" group-key "/" (str hl-page "_" uuid "_" stamp ".png")))))))
(defn clean-asset-path-prefix (defn- clean-asset-path-prefix
[path] [path]
(when (string? path) (when (string? path)
(string/replace-first path #"^[.\/\\]*(assets)[\/\\]+" ""))) (string/replace-first path #"^[.\/\\]*(assets)[\/\\]+" "")))
(defn seq-flatten [col] (defn- get-public-pages
(flatten (seq col)))
(defn pull
[eid db]
(d/pull db '[*] eid))
(defn get-public-pages
[db] [db]
(-> (d/q (->> (d/q
'[:find ?p '[:find ?p
:where :where
[?p :block/name] [?p :block/name]
[?p :block/properties ?properties] [?p :block/properties ?properties]
[(get ?properties :public) ?pub] [(get ?properties :public) ?pub]
[(= true ?pub)]] [(= true ?pub)]]
db) db)
(seq-flatten))) (map first)))
(defn get-public-false-pages (defn- get-public-false-pages
[db] [db]
(-> (d/q (->> (d/q
'[:find ?p '[:find ?p
:where :where
[?p :block/name] [?p :block/name]
[?p :block/properties ?properties] [?p :block/properties ?properties]
[(get ?properties :public) ?pub] [(get ?properties :public) ?pub]
[(= false ?pub)]] [(= false ?pub)]]
db) db)
(seq-flatten))) (map first)))
(defn get-public-false-block-ids (defn- get-public-false-block-ids
[db] [db]
(-> (d/q (->> (d/q
'[:find ?b '[:find ?b
:where :where
[?p :block/name] [?p :block/name]
[?p :block/properties ?properties] [?p :block/properties ?properties]
[(get ?properties :public) ?pub] [(get ?properties :public) ?pub]
[(= false ?pub)] [(= false ?pub)]
[?b :block/page ?p]] [?b :block/page ?p]]
db) db)
(seq-flatten))) (map first)))
(defn get-assets (defn- get-assets
[db datoms] [db datoms]
(let [get-page-by-eid (let [pull (fn [eid db]
(d/pull db '[*] eid))
get-page-by-eid
(memoize #(some-> (memoize #(some->
(pull % db) (pull % db)
:block/page :block/page
:db/id :db/id
(pull db)))] (pull db)))]
(flatten (->>
(keep (keep
(fn [datom] (fn [datom]
(cond-> [] (cond-> []
@@ -91,11 +87,14 @@
(get-page-by-eid (:e datom)))) (get-page-by-eid (:e datom))))
path (clean-asset-path-prefix path)] path (clean-asset-path-prefix path)]
(conj % path))))) (conj % path)))))
datoms)))) datoms)
flatten
distinct)))
(defn clean-export! (defn clean-export!
"Prepares a database assuming all pages are public unless a page has a 'public:: false'"
[db] [db]
(let [remove? #(contains? #{"me" "recent" "file"} %) (let [remove? #(contains? #{"recent" "file"} %)
non-public-pages (get-public-false-pages db) non-public-pages (get-public-false-pages db)
non-public-datoms (get-public-false-block-ids db) non-public-datoms (get-public-false-block-ids db)
non-public-datom-ids (set (concat non-public-pages non-public-datoms)) non-public-datom-ids (set (concat non-public-pages non-public-datoms))
@@ -110,24 +109,23 @@
[@(d/conn-from-datoms datoms db-schema/schema) assets])) [@(d/conn-from-datoms datoms db-schema/schema) assets]))
(defn filter-only-public-pages-and-blocks (defn filter-only-public-pages-and-blocks
"Prepares a database assuming all pages are private unless a page has a 'public:: true'"
[db] [db]
(let [public-pages (get-public-pages db)] (when-let [public-pages* (seq (get-public-pages db))]
(when (seq public-pages) (let [public-pages (set public-pages*)
(let [public-pages (set public-pages) exported-namespace? #(contains? #{"block" "recent"} %)
exported-namespace? #(contains? #{"block" "me" "recent"} %) filtered-db (d/filter db
filtered-db (d/filter db (fn [db datom]
(fn [db datom] (let [ns (namespace (:a datom))]
(let [ns (namespace (:a datom))] (and
(and (not (contains? #{:block/file} (:a datom)))
(not (contains? #{:block/file} (:a datom))) (not= ns "file")
(not= ns "file") (or
(or (not (exported-namespace? ns))
(not (exported-namespace? ns)) (and (= ns "block")
(and (= ns "block") (or
(or (contains? public-pages (:e datom))
(contains? public-pages (:e datom)) (contains? public-pages (:db/id (:block/page (d/entity db (:e datom))))))))))))
;; TODO: Confirm entity isn't integer datoms (d/datoms filtered-db :eavt)
(contains? public-pages (:db/id (:block/page (d/entity db (:e datom)))))))))))) assets (get-assets db datoms)]
datoms (d/datoms filtered-db :eavt) [@(d/conn-from-datoms datoms db-schema/schema) assets])))
assets (get-assets db datoms)]
[@(d/conn-from-datoms datoms db-schema/schema) assets]))))

View File

@@ -1,4 +1,6 @@
(ns logseq.publish-spa.export (ns logseq.publish-spa.export
"This electron only ns (for the main process) exports files from multiple
locations to provide a complete publishing app"
(:require ["fs-extra" :as fse] (:require ["fs-extra" :as fse]
["path" :as node-path] ["path" :as node-path]
["fs" :as fs] ["fs" :as fs]
@@ -67,10 +69,10 @@
(fse/copy (node-path/join static-dir part) (node-path/join output-static-dir part))) (fse/copy (node-path/join static-dir part) (node-path/join output-static-dir part)))
static-dirs)))]))) static-dirs)))])))
(defn export (defn create-export
"Given a graph's directory, the generated html and the directory containing "Given a graph's directory, the generated html and the directory containing
html/static assets, creates an index.html with supporting assets at the html/static assets, creates the export at the specified output-dir and
specified output directory" includes the index.html with supporting assets"
[html static-dir repo-path output-dir {:keys [notification-fn] [html static-dir repo-path output-dir {:keys [notification-fn]
:or {notification-fn default-notification} :or {notification-fn default-notification}
:as options}] :as options}]

View File

@@ -1,7 +1,11 @@
(ns ^:no-doc logseq.publish-spa.html (ns logseq.publish-spa.html
"This frontend only ns builds the publishing html including doing all the
necessary db filtering"
(:require [clojure.string :as string] (:require [clojure.string :as string]
[goog.string :as gstring] [goog.string :as gstring]
[goog.string.format])) [goog.string.format]
[datascript.transit :as dt]
[logseq.publish-spa.db :as db]))
;; Copied from hiccup but tweaked for publish usage ;; Copied from hiccup but tweaked for publish usage
;; Any changes here should also be made in frontend.publishing/unescape-html ;; Any changes here should also be made in frontend.publishing/unescape-html
@@ -122,3 +126,18 @@
[:script {:src "static/js/interact.min.js"}] [:script {:src "static/js/interact.min.js"}]
[:script {:src "static/js/katex.min.js"}] [:script {:src "static/js/katex.min.js"}]
[:script {:src "static/js/code-editor.js"}]]))))) [:script {:src "static/js/code-editor.js"}]])))))
(defn build-html
"Given the graph's db, filters the db using the given options and returns the
generated index.html string and assets used by the html"
[db* {:keys [app-state repo-config html-options]}]
(let [[db asset-filenames'] (if (:publishing/all-pages-public? repo-config)
(db/clean-export! db*)
(db/filter-only-public-pages-and-blocks db*))
asset-filenames (remove nil? asset-filenames')
db-str (dt/write-transit-str db)
state (assoc app-state
:config {"local" repo-config})
raw-html-str (publishing-html db-str state html-options)]
{:html raw-html-str
:asset-filenames asset-filenames}))

View File

@@ -0,0 +1,62 @@
(ns logseq.publish-spa.db-test
(:require [cljs.test :refer [deftest is]]
[clojure.set :as set]
[logseq.publish-spa.db :as publish-db]
[logseq.graph-parser :as graph-parser]
[datascript.core :as d]
[logseq.db :as ldb]))
(deftest clean-export!
(let [conn (ldb/start-conn)
_ (graph-parser/parse-file conn "page1.md" "public:: false\n- b11\n- b12\n- ![awesome.png](../assets/awesome_1648822509908_0.png)")
_ (graph-parser/parse-file conn "page2.md" "- b21\n- ![thumb-on-fire.PNG](../assets/thumb-on-fire_1648822523866_0.PNG)")
_ (graph-parser/parse-file conn "page3.md" "- b31")
[filtered-db assets] (publish-db/clean-export! @conn)
exported-pages (->> (d/q '[:find (pull ?b [*])
:where [?b :block/name]]
filtered-db)
(map (comp :block/name first))
set)
exported-blocks (->> (d/q '[:find (pull ?p [*])
:where
[?b :block/content]
[?b :block/page ?p]]
filtered-db)
(map (comp :block/name first))
set)]
(is (set/subset? #{"page2" "page3"} exported-pages)
"Contains all pages that haven't been marked private")
(is (not (contains? exported-pages "page1"))
"Doesn't contain private page")
(is (= #{"page2" "page3"} exported-blocks)
"Only exports blocks from public pages")
(is (= ["thumb-on-fire_1648822523866_0.PNG"] assets)
"Only exports assets from public pages")))
(deftest filter-only-public-pages-and-blocks
(let [conn (ldb/start-conn)
_ (graph-parser/parse-file conn "page1.md" "- b11\n- b12\n- ![awesome.png](../assets/awesome_1648822509908_0.png)")
_ (graph-parser/parse-file conn "page2.md" "public:: true\n- b21\n- ![thumb-on-fire.PNG](../assets/thumb-on-fire_1648822523866_0.PNG)")
_ (graph-parser/parse-file conn "page3.md" "public:: true\n- b31")
[filtered-db assets] (publish-db/filter-only-public-pages-and-blocks @conn)
exported-pages (->> (d/q '[:find (pull ?b [*])
:where [?b :block/name]]
filtered-db)
(map (comp :block/name first))
set)
exported-block-pages (->> (d/q '[:find (pull ?p [*])
:where
[?b :block/content]
[?b :block/page ?p]]
filtered-db)
(map (comp :block/name first))
set)]
(is (set/subset? #{"page2" "page3"} exported-pages)
"Contains all pages that have been marked public")
(is (not (contains? exported-pages "page1"))
"Doesn't contain private page")
(is (= #{"page2" "page3"} exported-block-pages)
"Only exports blocks from public pages")
(is (= ["thumb-on-fire_1648822523866_0.PNG"] assets)
"Only exports assets from public pages")))

View File

@@ -1,7 +1,7 @@
(ns logseq.publish-spa.export-test (ns logseq.publish-spa.export-test
(:require [cljs.test :as t :refer [is use-fixtures async]] (:require [cljs.test :as t :refer [is use-fixtures async]]
[logseq.publish-spa.test.helper :as test-helper :include-macros true :refer [deftest-async]] [logseq.publish-spa.test.helper :as test-helper :include-macros true :refer [deftest-async]]
[logseq.publish-spa.export :as export] [logseq.publish-spa.export :as publish-export]
[promesa.core :as p] [promesa.core :as p]
[clojure.set :as set] [clojure.set :as set]
["fs" :as fs] ["fs" :as fs]
@@ -35,11 +35,11 @@
(reduce concat) (reduce concat)
(concat (get-files dir))))) (concat (get-files dir)))))
(defn- export (defn- create-export
[static-dir graph-dir output-dir {:keys [html assets] [static-dir graph-dir output-dir {:keys [html assets]
:or {html "<!DOCTYPE html>" :or {html "<!DOCTYPE html>"
assets []}}] assets []}}]
(export/export (publish-export/create-export
html html
static-dir static-dir
graph-dir graph-dir
@@ -52,10 +52,10 @@
(defn- create-static-dir [dir] (defn- create-static-dir [dir]
(fs/mkdirSync (path/join dir) #js {:recursive true}) (fs/mkdirSync (path/join dir) #js {:recursive true})
(mapv #(fs/mkdirSync (path/join dir %)) export/static-dirs) (mapv #(fs/mkdirSync (path/join dir %)) publish-export/static-dirs)
(fs/mkdirSync (path/join dir "js" "publishing")) (fs/mkdirSync (path/join dir "js" "publishing"))
(mapv #(fs/writeFileSync (path/join dir "js" "publishing" %) %) (mapv #(fs/writeFileSync (path/join dir "js" "publishing" %) %)
(conj export/js-files "manifest.edn")) (conj publish-export/js-files "manifest.edn"))
(fs/writeFileSync (path/join dir "404.html") "")) (fs/writeFileSync (path/join dir "404.html") ""))
(defn- create-logseq-graph (defn- create-logseq-graph
@@ -65,17 +65,14 @@
(fs/writeFileSync (path/join dir "logseq" "config.edn") "{}") (fs/writeFileSync (path/join dir "logseq" "config.edn") "{}")
(fs/mkdirSync (path/join dir "assets"))) (fs/mkdirSync (path/join dir "assets")))
(deftest-async export-with-basic-graph (deftest-async create-export-with-basic-graph
(create-static-dir "tmp/static") (create-static-dir "tmp/static")
(create-logseq-graph "tmp/test-graph") (create-logseq-graph "tmp/test-graph")
(p/let [_ (export "tmp/static" "tmp/test-graph" "tmp/published-graph" {:html "<div>WOOT</div>"})] (p/let [_ (create-export "tmp/static" "tmp/test-graph" "tmp/published-graph" {:html "<div>WOOT</div>"})]
(let [original-paths (map path/basename (get-files-recursively "tmp/static")) (let [original-paths (map path/basename (get-files-recursively "tmp/static"))
copied-paths (map path/basename (get-files-recursively "tmp/published-graph")) copied-paths (map path/basename (get-files-recursively "tmp/published-graph"))
new-files (set/difference (set copied-paths) (set original-paths))] new-files (set/difference (set copied-paths) (set original-paths))]
(prn :ORIGINAL original-paths)
(prn :COPIED copied-paths)
(prn :NEW new-files)
(is (= #{"index.html" "custom.css" "export.css"} (is (= #{"index.html" "custom.css" "export.css"}
new-files) new-files)
"A published graph has the correct new files") "A published graph has the correct new files")
@@ -86,13 +83,13 @@
(str (fs/readFileSync "tmp/published-graph/static/js/main.js"))) (str (fs/readFileSync "tmp/published-graph/static/js/main.js")))
"cljs frontend compiled as main.js is copied correctly")))) "cljs frontend compiled as main.js is copied correctly"))))
(deftest-async export-with-css-files (deftest-async create-export-with-css-files
(create-static-dir "tmp/static") (create-static-dir "tmp/static")
(create-logseq-graph "tmp/test-graph") (create-logseq-graph "tmp/test-graph")
(fs/writeFileSync "tmp/test-graph/logseq/custom.css" ".foo {background-color: blue}") (fs/writeFileSync "tmp/test-graph/logseq/custom.css" ".foo {background-color: blue}")
(fs/writeFileSync "tmp/test-graph/logseq/export.css" ".foo {background-color: red}") (fs/writeFileSync "tmp/test-graph/logseq/export.css" ".foo {background-color: red}")
(p/let [_ (export "tmp/static" "tmp/test-graph" "tmp/published-graph" {})] (p/let [_ (create-export "tmp/static" "tmp/test-graph" "tmp/published-graph" {})]
(is (= ".foo {background-color: blue}" (is (= ".foo {background-color: blue}"
(str (fs/readFileSync "tmp/published-graph/static/css/custom.css"))) (str (fs/readFileSync "tmp/published-graph/static/css/custom.css")))
"custom.css is copied correctly") "custom.css is copied correctly")
@@ -100,16 +97,16 @@
(str (fs/readFileSync "tmp/published-graph/static/css/export.css"))) (str (fs/readFileSync "tmp/published-graph/static/css/export.css")))
"export.css is copied correctly"))) "export.css is copied correctly")))
(deftest-async export-with-assets (deftest-async create-export-with-assets
(create-static-dir "tmp/static") (create-static-dir "tmp/static")
(create-logseq-graph "tmp/test-graph") (create-logseq-graph "tmp/test-graph")
(fs/writeFileSync "tmp/test-graph/assets/foo.jpg" "foo") (fs/writeFileSync "tmp/test-graph/assets/foo.jpg" "foo")
(fs/writeFileSync "tmp/test-graph/assets/bar.png" "bar") (fs/writeFileSync "tmp/test-graph/assets/bar.png" "bar")
(p/let [_ (export "tmp/static" (p/let [_ (create-export "tmp/static"
"tmp/test-graph" "tmp/test-graph"
"tmp/published-graph" "tmp/published-graph"
{:assets ["foo.jpg" "bar.png"]})] {:assets ["foo.jpg" "bar.png"]})]
(is (= "foo" (is (= "foo"
(str (fs/readFileSync "tmp/published-graph/assets/foo.jpg"))) (str (fs/readFileSync "tmp/published-graph/assets/foo.jpg")))
"first asset is copied correctly") "first asset is copied correctly")

View File

@@ -9,83 +9,11 @@
dependencies: dependencies:
import-meta-resolve "^2.1.0" import-meta-resolve "^2.1.0"
ansi-regex@^2.0.0:
version "2.1.1"
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df"
integrity sha512-TIGnTpdo+E3+pCyAluZvtED5p5wCqLdezCyhPZzKPcxvFplEt4i+W7OONCKgeZFT3+y5NZZfOOS/Bdcanm1MYA==
ansi-regex@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-3.0.1.tgz#123d6479e92ad45ad897d4054e3c7ca7db4944e1"
integrity sha512-+O9Jct8wf++lXxxFc4hc8LsjaSq0HFzzL7cVsw8pRDIPdjKD2mT4ytDZlLuSBZ4cLKZFXIrMGO7DbQCtMJJMKw==
at-least-node@^1.0.0: at-least-node@^1.0.0:
version "1.0.0" version "1.0.0"
resolved "https://registry.yarnpkg.com/at-least-node/-/at-least-node-1.0.0.tgz#602cd4b46e844ad4effc92a8011a3c46e0238dc2" resolved "https://registry.yarnpkg.com/at-least-node/-/at-least-node-1.0.0.tgz#602cd4b46e844ad4effc92a8011a3c46e0238dc2"
integrity sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg== integrity sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==
camelcase@^5.0.0:
version "5.3.1"
resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320"
integrity sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==
cliui@^4.0.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/cliui/-/cliui-4.1.0.tgz#348422dbe82d800b3022eef4f6ac10bf2e4d1b49"
integrity sha512-4FG+RSG9DL7uEwRUZXZn3SS34DiDPfzP0VOiEwtUWlE+AR2EIg+hSyvrIgUUfhdgR/UkAeW2QHgeP+hWrXs7jQ==
dependencies:
string-width "^2.1.1"
strip-ansi "^4.0.0"
wrap-ansi "^2.0.0"
code-point-at@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77"
integrity sha512-RpAVKQA5T63xEj6/giIbUEtZwJ4UFIc3ZtvEkiaUERylqe8xb5IvqcgOurZLahv93CLKfxcw5YI+DZcUBRyLXA==
cross-spawn@^6.0.0:
version "6.0.5"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4"
integrity sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==
dependencies:
nice-try "^1.0.4"
path-key "^2.0.1"
semver "^5.5.0"
shebang-command "^1.2.0"
which "^1.2.9"
decamelize@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290"
integrity sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==
end-of-stream@^1.1.0:
version "1.4.4"
resolved "https://registry.yarnpkg.com/end-of-stream/-/end-of-stream-1.4.4.tgz#5ae64a5f45057baf3626ec14da0ca5e4b2431eb0"
integrity sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==
dependencies:
once "^1.4.0"
execa@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/execa/-/execa-1.0.0.tgz#c6236a5bb4df6d6f15e88e7f017798216749ddd8"
integrity sha512-adbxcyWV46qiHyvSp50TKt05tB4tK3HcmF7/nxfAdhnox83seTDbwnaqKO4sXRy7roHAIFqJP/Rw/AuEbX61LA==
dependencies:
cross-spawn "^6.0.0"
get-stream "^4.0.0"
is-stream "^1.1.0"
npm-run-path "^2.0.0"
p-finally "^1.0.0"
signal-exit "^3.0.0"
strip-eof "^1.0.0"
find-up@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/find-up/-/find-up-3.0.0.tgz#49169f1d7993430646da61ecc5ae355c21c97b73"
integrity sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==
dependencies:
locate-path "^3.0.0"
fs-extra@9.1.0: fs-extra@9.1.0:
version "9.1.0" version "9.1.0"
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-9.1.0.tgz#5954460c764a8da2094ba3554bf839e6b9a7c86d" resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-9.1.0.tgz#5954460c764a8da2094ba3554bf839e6b9a7c86d"
@@ -96,18 +24,6 @@ fs-extra@9.1.0:
jsonfile "^6.0.1" jsonfile "^6.0.1"
universalify "^2.0.0" universalify "^2.0.0"
get-caller-file@^1.0.1:
version "1.0.3"
resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-1.0.3.tgz#f978fa4c90d1dfe7ff2d6beda2a515e713bdcf4a"
integrity sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w==
get-stream@^4.0.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-4.1.0.tgz#c1b255575f3dc21d59bfc79cd3d2b46b1c3a54b5"
integrity sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w==
dependencies:
pump "^3.0.0"
graceful-fs@^4.1.6, graceful-fs@^4.2.0: graceful-fs@^4.1.6, graceful-fs@^4.2.0:
version "4.2.11" version "4.2.11"
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.11.tgz#4183e4e8bf08bb6e05bbb2f7d2e0c8f712ca40e3" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.11.tgz#4183e4e8bf08bb6e05bbb2f7d2e0c8f712ca40e3"
@@ -118,33 +34,6 @@ import-meta-resolve@^2.1.0:
resolved "https://registry.yarnpkg.com/import-meta-resolve/-/import-meta-resolve-2.2.2.tgz#75237301e72d1f0fbd74dbc6cca9324b164c2cc9" resolved "https://registry.yarnpkg.com/import-meta-resolve/-/import-meta-resolve-2.2.2.tgz#75237301e72d1f0fbd74dbc6cca9324b164c2cc9"
integrity sha512-f8KcQ1D80V7RnqVm+/lirO9zkOxjGxhaTC1IPrBGd3MEfNgmNG67tSUO9gTi2F3Blr2Az6g1vocaxzkVnWl9MA== integrity sha512-f8KcQ1D80V7RnqVm+/lirO9zkOxjGxhaTC1IPrBGd3MEfNgmNG67tSUO9gTi2F3Blr2Az6g1vocaxzkVnWl9MA==
invert-kv@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/invert-kv/-/invert-kv-2.0.0.tgz#7393f5afa59ec9ff5f67a27620d11c226e3eec02"
integrity sha512-wPVv/y/QQ/Uiirj/vh3oP+1Ww+AWehmi1g5fFWGPF6IpCBCDVrhgHRMvrLfdYcwDh3QJbGXDW4JAuzxElLSqKA==
is-fullwidth-code-point@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz#ef9e31386f031a7f0d643af82fde50c457ef00cb"
integrity sha512-1pqUqRjkhPJ9miNq9SwMfdvi6lBJcd6eFxvfaivQhaH3SgisfiuudvFntdKOmxuee/77l+FPjKrQjWvmPjWrRw==
dependencies:
number-is-nan "^1.0.0"
is-fullwidth-code-point@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz#a3b30a5c4f199183167aaab93beefae3ddfb654f"
integrity sha512-VHskAKYM8RfSFXwee5t5cbN5PZeq1Wrh6qd5bkyiXIf6UQcN6w/A0eXM9r6t8d+GYOh+o6ZhiEnb88LN/Y8m2w==
is-stream@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44"
integrity sha512-uQPm8kcs47jx38atAcWTVxyltQYoPT68y9aWYdV6yWXSyW8mzSat0TL6CiWdZeCdF3KrAvpVtnHbTv4RN+rqdQ==
isexe@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10"
integrity sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==
jsonfile@^6.0.1: jsonfile@^6.0.1:
version "6.1.0" version "6.1.0"
resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-6.1.0.tgz#bc55b2634793c679ec6403094eb13698a6ec0aae" resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-6.1.0.tgz#bc55b2634793c679ec6403094eb13698a6ec0aae"
@@ -154,264 +43,7 @@ jsonfile@^6.0.1:
optionalDependencies: optionalDependencies:
graceful-fs "^4.1.6" graceful-fs "^4.1.6"
lcid@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/lcid/-/lcid-2.0.0.tgz#6ef5d2df60e52f82eb228a4c373e8d1f397253cf"
integrity sha512-avPEb8P8EGnwXKClwsNUgryVjllcRqtMYa49NTsbQagYuT1DcXnl1915oxWjoyGrXR6zH/Y0Zc96xWsPcoDKeA==
dependencies:
invert-kv "^2.0.0"
locate-path@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-3.0.0.tgz#dbec3b3ab759758071b58fe59fc41871af21400e"
integrity sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==
dependencies:
p-locate "^3.0.0"
path-exists "^3.0.0"
map-age-cleaner@^0.1.1:
version "0.1.3"
resolved "https://registry.yarnpkg.com/map-age-cleaner/-/map-age-cleaner-0.1.3.tgz#7d583a7306434c055fe474b0f45078e6e1b4b92a"
integrity sha512-bJzx6nMoP6PDLPBFmg7+xRKeFZvFboMrGlxmNj9ClvX53KrmvM5bXFXEWjbz4cz1AFn+jWJ9z/DJSz7hrs0w3w==
dependencies:
p-defer "^1.0.0"
mem@^4.0.0:
version "4.3.0"
resolved "https://registry.yarnpkg.com/mem/-/mem-4.3.0.tgz#461af497bc4ae09608cdb2e60eefb69bff744178"
integrity sha512-qX2bG48pTqYRVmDB37rn/6PT7LcR8T7oAX3bf99u1Tt1nzxYfxkgqDwUwolPlXweM0XzBOBFzSx4kfp7KP1s/w==
dependencies:
map-age-cleaner "^0.1.1"
mimic-fn "^2.0.0"
p-is-promise "^2.0.0"
mimic-fn@^2.0.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-2.1.0.tgz#7ed2c2ccccaf84d3ffcb7a69b57711fc2083401b"
integrity sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==
mldoc@^1.5.1:
version "1.5.3"
resolved "https://registry.yarnpkg.com/mldoc/-/mldoc-1.5.3.tgz#98d5bb276ac6908d72e1c58c27916e488ef9d395"
integrity sha512-hkI3PtjBHhbZqTr1U5/A8TIrIzg9DGZzCMLrfzePAdM+97GNeZijmPqUQXWEAyEQsDPnkipMoQZsBXxhnwzfJA==
dependencies:
yargs "^12.0.2"
nice-try@^1.0.4:
version "1.0.5"
resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366"
integrity sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==
npm-run-path@^2.0.0:
version "2.0.2"
resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-2.0.2.tgz#35a9232dfa35d7067b4cb2ddf2357b1871536c5f"
integrity sha512-lJxZYlT4DW/bRUtFh1MQIWqmLwQfAxnqWG4HhEdjMlkrJYnJn0Jrr2u3mgxqaWsdiBc76TYkTG/mhrnYTuzfHw==
dependencies:
path-key "^2.0.0"
number-is-nan@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d"
integrity sha512-4jbtZXNAsfZbAHiiqjLPBiCl16dES1zI4Hpzzxw61Tk+loF+sBDBKx1ICKKKwIqQ7M0mFn1TmkN7euSncWgHiQ==
once@^1.3.1, once@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
integrity sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==
dependencies:
wrappy "1"
os-locale@^3.0.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/os-locale/-/os-locale-3.1.0.tgz#a802a6ee17f24c10483ab9935719cef4ed16bf1a"
integrity sha512-Z8l3R4wYWM40/52Z+S265okfFj8Kt2cC2MKY+xNi3kFs+XGI7WXu/I309QQQYbRW4ijiZ+yxs9pqEhJh0DqW3Q==
dependencies:
execa "^1.0.0"
lcid "^2.0.0"
mem "^4.0.0"
p-defer@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/p-defer/-/p-defer-1.0.0.tgz#9f6eb182f6c9aa8cd743004a7d4f96b196b0fb0c"
integrity sha512-wB3wfAxZpk2AzOfUMJNL+d36xothRSyj8EXOa4f6GMqYDN9BJaaSISbsk+wS9abmnebVw95C2Kb5t85UmpCxuw==
p-finally@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/p-finally/-/p-finally-1.0.0.tgz#3fbcfb15b899a44123b34b6dcc18b724336a2cae"
integrity sha512-LICb2p9CB7FS+0eR1oqWnHhp0FljGLZCWBE9aix0Uye9W8LTQPwMTYVGWQWIw9RdQiDg4+epXQODwIYJtSJaow==
p-is-promise@^2.0.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/p-is-promise/-/p-is-promise-2.1.0.tgz#918cebaea248a62cf7ffab8e3bca8c5f882fc42e"
integrity sha512-Y3W0wlRPK8ZMRbNq97l4M5otioeA5lm1z7bkNkxCka8HSPjR0xRWmpCmc9utiaLP9Jb1eD8BgeIxTW4AIF45Pg==
p-limit@^2.0.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.3.0.tgz#3dd33c647a214fdfffd835933eb086da0dc21db1"
integrity sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==
dependencies:
p-try "^2.0.0"
p-locate@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-3.0.0.tgz#322d69a05c0264b25997d9f40cd8a891ab0064a4"
integrity sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==
dependencies:
p-limit "^2.0.0"
p-try@^2.0.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6"
integrity sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==
path-exists@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-3.0.0.tgz#ce0ebeaa5f78cb18925ea7d810d7b59b010fd515"
integrity sha512-bpC7GYwiDYQ4wYLe+FA8lhRjhQCMcQGuSgGGqDkg/QerRWw9CmGRT0iSOVRSZJ29NMLZgIzqaljJ63oaL4NIJQ==
path-key@^2.0.0, path-key@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40"
integrity sha512-fEHGKCSmUSDPv4uoj8AlD+joPlq3peND+HRYyxFz4KPw4z926S/b8rIuFs2FYJg3BwsxJf6A9/3eIdLaYC+9Dw==
pump@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/pump/-/pump-3.0.0.tgz#b4a2116815bde2f4e1ea602354e8c75565107a64"
integrity sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==
dependencies:
end-of-stream "^1.1.0"
once "^1.3.1"
require-directory@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42"
integrity sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==
require-main-filename@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-1.0.1.tgz#97f717b69d48784f5f526a6c5aa8ffdda055a4d1"
integrity sha512-IqSUtOVP4ksd1C/ej5zeEh/BIP2ajqpn8c5x+q99gvcIG/Qf0cud5raVnE/Dwd0ua9TXYDoDc0RE5hBSdz22Ug==
semver@^5.5.0:
version "5.7.1"
resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7"
integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==
set-blocking@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7"
integrity sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==
shebang-command@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea"
integrity sha512-EV3L1+UQWGor21OmnvojK36mhg+TyIKDh3iFBKBohr5xeXIhNBcx8oWdgkTEEQ+BEFFYdLRuqMfd5L84N1V5Vg==
dependencies:
shebang-regex "^1.0.0"
shebang-regex@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3"
integrity sha512-wpoSFAxys6b2a2wHZ1XpDSgD7N9iVjg29Ph9uV/uaP9Ex/KXlkTZTeddxDPSYQpgvzKLGJke2UU0AzoGCjNIvQ==
signal-exit@^3.0.0:
version "3.0.7"
resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.7.tgz#a9a1767f8af84155114eaabd73f99273c8f59ad9"
integrity sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==
string-width@^1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-1.0.2.tgz#118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3"
integrity sha512-0XsVpQLnVCXHJfyEs8tC0zpTVIr5PKKsQtkT29IwupnPTjtPmQ3xT/4yCREF9hYkV/3M3kzcUTSAZT6a6h81tw==
dependencies:
code-point-at "^1.0.0"
is-fullwidth-code-point "^1.0.0"
strip-ansi "^3.0.0"
string-width@^2.0.0, string-width@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e"
integrity sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==
dependencies:
is-fullwidth-code-point "^2.0.0"
strip-ansi "^4.0.0"
strip-ansi@^3.0.0, strip-ansi@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-3.0.1.tgz#6a385fb8853d952d5ff05d0e8aaf94278dc63dcf"
integrity sha512-VhumSSbBqDTP8p2ZLKj40UjBCV4+v8bUSEpUb4KjRgWk9pbqGF4REFj6KEagidb2f/M6AzC0EmFyDNGaw9OCzg==
dependencies:
ansi-regex "^2.0.0"
strip-ansi@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-4.0.0.tgz#a8479022eb1ac368a871389b635262c505ee368f"
integrity sha512-4XaJ2zQdCzROZDivEVIDPkcQn8LMFSa8kj8Gxb/Lnwzv9A8VctNZ+lfivC/sV3ivW8ElJTERXZoPBRrZKkNKow==
dependencies:
ansi-regex "^3.0.0"
strip-eof@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/strip-eof/-/strip-eof-1.0.0.tgz#bb43ff5598a6eb05d89b59fcd129c983313606bf"
integrity sha512-7FCwGGmx8mD5xQd3RPUvnSpUXHM3BWuzjtpD4TXsfcZ9EL4azvVVUscFYwD9nx8Kh+uCBC00XBtAykoMHwTh8Q==
universalify@^2.0.0: universalify@^2.0.0:
version "2.0.0" version "2.0.0"
resolved "https://registry.yarnpkg.com/universalify/-/universalify-2.0.0.tgz#75a4984efedc4b08975c5aeb73f530d02df25717" resolved "https://registry.yarnpkg.com/universalify/-/universalify-2.0.0.tgz#75a4984efedc4b08975c5aeb73f530d02df25717"
integrity sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ== integrity sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==
which-module@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a"
integrity sha512-B+enWhmw6cjfVC7kS8Pj9pCrKSc5txArRyaYGe088shv/FGWH+0Rjx/xPgtsWfsUtS27FkP697E4DDhgrgoc0Q==
which@^1.2.9:
version "1.3.1"
resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a"
integrity sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==
dependencies:
isexe "^2.0.0"
wrap-ansi@^2.0.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-2.1.0.tgz#d8fc3d284dd05794fe84973caecdd1cf824fdd85"
integrity sha512-vAaEaDM946gbNpH5pLVNR+vX2ht6n0Bt3GXwVB1AuAqZosOvHNF3P7wDnh8KLkSqgUh0uh77le7Owgoz+Z9XBw==
dependencies:
string-width "^1.0.1"
strip-ansi "^3.0.1"
wrappy@1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
integrity sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==
"y18n@^3.2.1 || ^4.0.0":
version "4.0.3"
resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.3.tgz#b5f259c82cd6e336921efd7bfd8bf560de9eeedf"
integrity sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==
yargs-parser@^11.1.1:
version "11.1.1"
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-11.1.1.tgz#879a0865973bca9f6bab5cbdf3b1c67ec7d3bcf4"
integrity sha512-C6kB/WJDiaxONLJQnF8ccx9SEeoTTLek8RVbaOIsrAUS8VrBEXfmeSnCZxygc+XC2sNMBIwOOnfcxiynjHsVSQ==
dependencies:
camelcase "^5.0.0"
decamelize "^1.2.0"
yargs@^12.0.2:
version "12.0.5"
resolved "https://registry.yarnpkg.com/yargs/-/yargs-12.0.5.tgz#05f5997b609647b64f66b81e3b4b10a368e7ad13"
integrity sha512-Lhz8TLaYnxq/2ObqHDql8dX8CJi97oHxrjUcYtzKbbykPtVW9WB+poxI+NM2UIzsMgNCZTIf0AQwsjK5yMAqZw==
dependencies:
cliui "^4.0.0"
decamelize "^1.2.0"
find-up "^3.0.0"
get-caller-file "^1.0.1"
os-locale "^3.0.0"
require-directory "^2.1.1"
require-main-filename "^1.0.1"
set-blocking "^2.0.0"
string-width "^2.0.0"
which-module "^2.0.0"
y18n "^3.2.1 || ^4.0.0"
yargs-parser "^11.1.1"

1
scripts/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/.nbb/.cache

7
scripts/nbb.edn Normal file
View File

@@ -0,0 +1,7 @@
{:paths ["src"]
:deps
{logseq/graph-parser
;; Nbb bug. Should just be "../graph-parser"
{:local/root "../../../../deps/graph-parser"}
logseq/publish-spa
{:local/root "../../../../deps/publish-spa"}}}

12
scripts/package.json Normal file
View File

@@ -0,0 +1,12 @@
{
"name": "nbb-dev-scripts",
"version": "1.0.0",
"private": true,
"devDependencies": {
"@logseq/nbb-logseq": "^1.2.168"
},
"dependencies": {
"mldoc": "^1.5.1",
"fs-extra": "9.1.0"
}
}

View File

@@ -38,8 +38,11 @@
(spit config-edn config)))) (spit config-edn config))))
(defn build-publishing (defn build-publishing
[] "Builds release publishing asset when files have changed"
[& _args]
(if-let [_files (seq (set (fs/modified-since (fs/file "static/js/publishing/main.js") (if-let [_files (seq (set (fs/modified-since (fs/file "static/js/publishing/main.js")
(fs/glob "." "src/main/**"))))] (fs/glob "." "{src/main,deps/graph-parser/src}/**"))))]
(shell "clojure -M:cljs release publishing") (do
(println "publishing assets are up to date"))) (println "Building publishing js asset...")
(shell "clojure -M:cljs release publishing"))
(println "Publishing js asset is up to date")))

View File

@@ -0,0 +1,25 @@
(ns logseq.tasks.dev.publishing
(:require [logseq.graph-parser.cli :as gp-cli]
[logseq.publish-spa :as publish-spa]
["fs" :as fs]
["path" :as node-path]
[clojure.edn :as edn]))
(defn- get-db [graph-dir]
(let [{:keys [conn]} (gp-cli/parse-graph graph-dir {:verbose false})] @conn))
(defn -main
[& args]
(when-not (= 3 (count args))
(println "Usage: $0 STATIC-DIR GRAPH-DIR OUT-DIR")
(js/process.exit 1))
(let [[static-dir graph-dir output-path]
;; Offset relative paths since they are run in a different directory than user is in
(map #(if (node-path/isAbsolute %) % (node-path/resolve ".." %)) args)
repo-config (-> (node-path/join graph-dir "logseq" "config.edn") fs/readFileSync str edn/read-string)]
(publish-spa/export (get-db graph-dir)
static-dir
graph-dir
output-path
{:repo-config repo-config})))

417
scripts/yarn.lock Normal file
View File

@@ -0,0 +1,417 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
"@logseq/nbb-logseq@^1.2.168":
version "1.2.168"
resolved "https://registry.yarnpkg.com/@logseq/nbb-logseq/-/nbb-logseq-1.2.168.tgz#e4120c4a7eb6c80737473292c1e20919b4453c91"
integrity sha512-lgZuAhck/74+9mT4vr6jVLkPcyRA/RO8ApBizq3d1L6LsPlPjdRp4nIaC2I1/p/AaIIB5vP89pMpqZfVsIHHQg==
dependencies:
import-meta-resolve "^2.1.0"
ansi-regex@^2.0.0:
version "2.1.1"
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df"
integrity sha512-TIGnTpdo+E3+pCyAluZvtED5p5wCqLdezCyhPZzKPcxvFplEt4i+W7OONCKgeZFT3+y5NZZfOOS/Bdcanm1MYA==
ansi-regex@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-3.0.1.tgz#123d6479e92ad45ad897d4054e3c7ca7db4944e1"
integrity sha512-+O9Jct8wf++lXxxFc4hc8LsjaSq0HFzzL7cVsw8pRDIPdjKD2mT4ytDZlLuSBZ4cLKZFXIrMGO7DbQCtMJJMKw==
at-least-node@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/at-least-node/-/at-least-node-1.0.0.tgz#602cd4b46e844ad4effc92a8011a3c46e0238dc2"
integrity sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==
camelcase@^5.0.0:
version "5.3.1"
resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320"
integrity sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==
cliui@^4.0.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/cliui/-/cliui-4.1.0.tgz#348422dbe82d800b3022eef4f6ac10bf2e4d1b49"
integrity sha512-4FG+RSG9DL7uEwRUZXZn3SS34DiDPfzP0VOiEwtUWlE+AR2EIg+hSyvrIgUUfhdgR/UkAeW2QHgeP+hWrXs7jQ==
dependencies:
string-width "^2.1.1"
strip-ansi "^4.0.0"
wrap-ansi "^2.0.0"
code-point-at@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77"
integrity sha512-RpAVKQA5T63xEj6/giIbUEtZwJ4UFIc3ZtvEkiaUERylqe8xb5IvqcgOurZLahv93CLKfxcw5YI+DZcUBRyLXA==
cross-spawn@^6.0.0:
version "6.0.5"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4"
integrity sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==
dependencies:
nice-try "^1.0.4"
path-key "^2.0.1"
semver "^5.5.0"
shebang-command "^1.2.0"
which "^1.2.9"
decamelize@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290"
integrity sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==
end-of-stream@^1.1.0:
version "1.4.4"
resolved "https://registry.yarnpkg.com/end-of-stream/-/end-of-stream-1.4.4.tgz#5ae64a5f45057baf3626ec14da0ca5e4b2431eb0"
integrity sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==
dependencies:
once "^1.4.0"
execa@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/execa/-/execa-1.0.0.tgz#c6236a5bb4df6d6f15e88e7f017798216749ddd8"
integrity sha512-adbxcyWV46qiHyvSp50TKt05tB4tK3HcmF7/nxfAdhnox83seTDbwnaqKO4sXRy7roHAIFqJP/Rw/AuEbX61LA==
dependencies:
cross-spawn "^6.0.0"
get-stream "^4.0.0"
is-stream "^1.1.0"
npm-run-path "^2.0.0"
p-finally "^1.0.0"
signal-exit "^3.0.0"
strip-eof "^1.0.0"
find-up@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/find-up/-/find-up-3.0.0.tgz#49169f1d7993430646da61ecc5ae355c21c97b73"
integrity sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==
dependencies:
locate-path "^3.0.0"
fs-extra@9.1.0:
version "9.1.0"
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-9.1.0.tgz#5954460c764a8da2094ba3554bf839e6b9a7c86d"
integrity sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==
dependencies:
at-least-node "^1.0.0"
graceful-fs "^4.2.0"
jsonfile "^6.0.1"
universalify "^2.0.0"
get-caller-file@^1.0.1:
version "1.0.3"
resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-1.0.3.tgz#f978fa4c90d1dfe7ff2d6beda2a515e713bdcf4a"
integrity sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w==
get-stream@^4.0.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-4.1.0.tgz#c1b255575f3dc21d59bfc79cd3d2b46b1c3a54b5"
integrity sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w==
dependencies:
pump "^3.0.0"
graceful-fs@^4.1.6, graceful-fs@^4.2.0:
version "4.2.11"
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.11.tgz#4183e4e8bf08bb6e05bbb2f7d2e0c8f712ca40e3"
integrity sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==
import-meta-resolve@^2.1.0:
version "2.2.2"
resolved "https://registry.yarnpkg.com/import-meta-resolve/-/import-meta-resolve-2.2.2.tgz#75237301e72d1f0fbd74dbc6cca9324b164c2cc9"
integrity sha512-f8KcQ1D80V7RnqVm+/lirO9zkOxjGxhaTC1IPrBGd3MEfNgmNG67tSUO9gTi2F3Blr2Az6g1vocaxzkVnWl9MA==
invert-kv@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/invert-kv/-/invert-kv-2.0.0.tgz#7393f5afa59ec9ff5f67a27620d11c226e3eec02"
integrity sha512-wPVv/y/QQ/Uiirj/vh3oP+1Ww+AWehmi1g5fFWGPF6IpCBCDVrhgHRMvrLfdYcwDh3QJbGXDW4JAuzxElLSqKA==
is-fullwidth-code-point@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz#ef9e31386f031a7f0d643af82fde50c457ef00cb"
integrity sha512-1pqUqRjkhPJ9miNq9SwMfdvi6lBJcd6eFxvfaivQhaH3SgisfiuudvFntdKOmxuee/77l+FPjKrQjWvmPjWrRw==
dependencies:
number-is-nan "^1.0.0"
is-fullwidth-code-point@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz#a3b30a5c4f199183167aaab93beefae3ddfb654f"
integrity sha512-VHskAKYM8RfSFXwee5t5cbN5PZeq1Wrh6qd5bkyiXIf6UQcN6w/A0eXM9r6t8d+GYOh+o6ZhiEnb88LN/Y8m2w==
is-stream@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44"
integrity sha512-uQPm8kcs47jx38atAcWTVxyltQYoPT68y9aWYdV6yWXSyW8mzSat0TL6CiWdZeCdF3KrAvpVtnHbTv4RN+rqdQ==
isexe@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10"
integrity sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==
jsonfile@^6.0.1:
version "6.1.0"
resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-6.1.0.tgz#bc55b2634793c679ec6403094eb13698a6ec0aae"
integrity sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==
dependencies:
universalify "^2.0.0"
optionalDependencies:
graceful-fs "^4.1.6"
lcid@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/lcid/-/lcid-2.0.0.tgz#6ef5d2df60e52f82eb228a4c373e8d1f397253cf"
integrity sha512-avPEb8P8EGnwXKClwsNUgryVjllcRqtMYa49NTsbQagYuT1DcXnl1915oxWjoyGrXR6zH/Y0Zc96xWsPcoDKeA==
dependencies:
invert-kv "^2.0.0"
locate-path@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-3.0.0.tgz#dbec3b3ab759758071b58fe59fc41871af21400e"
integrity sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==
dependencies:
p-locate "^3.0.0"
path-exists "^3.0.0"
map-age-cleaner@^0.1.1:
version "0.1.3"
resolved "https://registry.yarnpkg.com/map-age-cleaner/-/map-age-cleaner-0.1.3.tgz#7d583a7306434c055fe474b0f45078e6e1b4b92a"
integrity sha512-bJzx6nMoP6PDLPBFmg7+xRKeFZvFboMrGlxmNj9ClvX53KrmvM5bXFXEWjbz4cz1AFn+jWJ9z/DJSz7hrs0w3w==
dependencies:
p-defer "^1.0.0"
mem@^4.0.0:
version "4.3.0"
resolved "https://registry.yarnpkg.com/mem/-/mem-4.3.0.tgz#461af497bc4ae09608cdb2e60eefb69bff744178"
integrity sha512-qX2bG48pTqYRVmDB37rn/6PT7LcR8T7oAX3bf99u1Tt1nzxYfxkgqDwUwolPlXweM0XzBOBFzSx4kfp7KP1s/w==
dependencies:
map-age-cleaner "^0.1.1"
mimic-fn "^2.0.0"
p-is-promise "^2.0.0"
mimic-fn@^2.0.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-2.1.0.tgz#7ed2c2ccccaf84d3ffcb7a69b57711fc2083401b"
integrity sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==
mldoc@^1.5.1:
version "1.5.3"
resolved "https://registry.yarnpkg.com/mldoc/-/mldoc-1.5.3.tgz#98d5bb276ac6908d72e1c58c27916e488ef9d395"
integrity sha512-hkI3PtjBHhbZqTr1U5/A8TIrIzg9DGZzCMLrfzePAdM+97GNeZijmPqUQXWEAyEQsDPnkipMoQZsBXxhnwzfJA==
dependencies:
yargs "^12.0.2"
nice-try@^1.0.4:
version "1.0.5"
resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366"
integrity sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==
npm-run-path@^2.0.0:
version "2.0.2"
resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-2.0.2.tgz#35a9232dfa35d7067b4cb2ddf2357b1871536c5f"
integrity sha512-lJxZYlT4DW/bRUtFh1MQIWqmLwQfAxnqWG4HhEdjMlkrJYnJn0Jrr2u3mgxqaWsdiBc76TYkTG/mhrnYTuzfHw==
dependencies:
path-key "^2.0.0"
number-is-nan@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d"
integrity sha512-4jbtZXNAsfZbAHiiqjLPBiCl16dES1zI4Hpzzxw61Tk+loF+sBDBKx1ICKKKwIqQ7M0mFn1TmkN7euSncWgHiQ==
once@^1.3.1, once@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
integrity sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==
dependencies:
wrappy "1"
os-locale@^3.0.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/os-locale/-/os-locale-3.1.0.tgz#a802a6ee17f24c10483ab9935719cef4ed16bf1a"
integrity sha512-Z8l3R4wYWM40/52Z+S265okfFj8Kt2cC2MKY+xNi3kFs+XGI7WXu/I309QQQYbRW4ijiZ+yxs9pqEhJh0DqW3Q==
dependencies:
execa "^1.0.0"
lcid "^2.0.0"
mem "^4.0.0"
p-defer@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/p-defer/-/p-defer-1.0.0.tgz#9f6eb182f6c9aa8cd743004a7d4f96b196b0fb0c"
integrity sha512-wB3wfAxZpk2AzOfUMJNL+d36xothRSyj8EXOa4f6GMqYDN9BJaaSISbsk+wS9abmnebVw95C2Kb5t85UmpCxuw==
p-finally@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/p-finally/-/p-finally-1.0.0.tgz#3fbcfb15b899a44123b34b6dcc18b724336a2cae"
integrity sha512-LICb2p9CB7FS+0eR1oqWnHhp0FljGLZCWBE9aix0Uye9W8LTQPwMTYVGWQWIw9RdQiDg4+epXQODwIYJtSJaow==
p-is-promise@^2.0.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/p-is-promise/-/p-is-promise-2.1.0.tgz#918cebaea248a62cf7ffab8e3bca8c5f882fc42e"
integrity sha512-Y3W0wlRPK8ZMRbNq97l4M5otioeA5lm1z7bkNkxCka8HSPjR0xRWmpCmc9utiaLP9Jb1eD8BgeIxTW4AIF45Pg==
p-limit@^2.0.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.3.0.tgz#3dd33c647a214fdfffd835933eb086da0dc21db1"
integrity sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==
dependencies:
p-try "^2.0.0"
p-locate@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-3.0.0.tgz#322d69a05c0264b25997d9f40cd8a891ab0064a4"
integrity sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==
dependencies:
p-limit "^2.0.0"
p-try@^2.0.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6"
integrity sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==
path-exists@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-3.0.0.tgz#ce0ebeaa5f78cb18925ea7d810d7b59b010fd515"
integrity sha512-bpC7GYwiDYQ4wYLe+FA8lhRjhQCMcQGuSgGGqDkg/QerRWw9CmGRT0iSOVRSZJ29NMLZgIzqaljJ63oaL4NIJQ==
path-key@^2.0.0, path-key@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40"
integrity sha512-fEHGKCSmUSDPv4uoj8AlD+joPlq3peND+HRYyxFz4KPw4z926S/b8rIuFs2FYJg3BwsxJf6A9/3eIdLaYC+9Dw==
pump@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/pump/-/pump-3.0.0.tgz#b4a2116815bde2f4e1ea602354e8c75565107a64"
integrity sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==
dependencies:
end-of-stream "^1.1.0"
once "^1.3.1"
require-directory@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42"
integrity sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==
require-main-filename@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-1.0.1.tgz#97f717b69d48784f5f526a6c5aa8ffdda055a4d1"
integrity sha512-IqSUtOVP4ksd1C/ej5zeEh/BIP2ajqpn8c5x+q99gvcIG/Qf0cud5raVnE/Dwd0ua9TXYDoDc0RE5hBSdz22Ug==
semver@^5.5.0:
version "5.7.1"
resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7"
integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==
set-blocking@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7"
integrity sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==
shebang-command@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea"
integrity sha512-EV3L1+UQWGor21OmnvojK36mhg+TyIKDh3iFBKBohr5xeXIhNBcx8oWdgkTEEQ+BEFFYdLRuqMfd5L84N1V5Vg==
dependencies:
shebang-regex "^1.0.0"
shebang-regex@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3"
integrity sha512-wpoSFAxys6b2a2wHZ1XpDSgD7N9iVjg29Ph9uV/uaP9Ex/KXlkTZTeddxDPSYQpgvzKLGJke2UU0AzoGCjNIvQ==
signal-exit@^3.0.0:
version "3.0.7"
resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.7.tgz#a9a1767f8af84155114eaabd73f99273c8f59ad9"
integrity sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==
string-width@^1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-1.0.2.tgz#118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3"
integrity sha512-0XsVpQLnVCXHJfyEs8tC0zpTVIr5PKKsQtkT29IwupnPTjtPmQ3xT/4yCREF9hYkV/3M3kzcUTSAZT6a6h81tw==
dependencies:
code-point-at "^1.0.0"
is-fullwidth-code-point "^1.0.0"
strip-ansi "^3.0.0"
string-width@^2.0.0, string-width@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e"
integrity sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==
dependencies:
is-fullwidth-code-point "^2.0.0"
strip-ansi "^4.0.0"
strip-ansi@^3.0.0, strip-ansi@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-3.0.1.tgz#6a385fb8853d952d5ff05d0e8aaf94278dc63dcf"
integrity sha512-VhumSSbBqDTP8p2ZLKj40UjBCV4+v8bUSEpUb4KjRgWk9pbqGF4REFj6KEagidb2f/M6AzC0EmFyDNGaw9OCzg==
dependencies:
ansi-regex "^2.0.0"
strip-ansi@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-4.0.0.tgz#a8479022eb1ac368a871389b635262c505ee368f"
integrity sha512-4XaJ2zQdCzROZDivEVIDPkcQn8LMFSa8kj8Gxb/Lnwzv9A8VctNZ+lfivC/sV3ivW8ElJTERXZoPBRrZKkNKow==
dependencies:
ansi-regex "^3.0.0"
strip-eof@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/strip-eof/-/strip-eof-1.0.0.tgz#bb43ff5598a6eb05d89b59fcd129c983313606bf"
integrity sha512-7FCwGGmx8mD5xQd3RPUvnSpUXHM3BWuzjtpD4TXsfcZ9EL4azvVVUscFYwD9nx8Kh+uCBC00XBtAykoMHwTh8Q==
universalify@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/universalify/-/universalify-2.0.0.tgz#75a4984efedc4b08975c5aeb73f530d02df25717"
integrity sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==
which-module@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a"
integrity sha512-B+enWhmw6cjfVC7kS8Pj9pCrKSc5txArRyaYGe088shv/FGWH+0Rjx/xPgtsWfsUtS27FkP697E4DDhgrgoc0Q==
which@^1.2.9:
version "1.3.1"
resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a"
integrity sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==
dependencies:
isexe "^2.0.0"
wrap-ansi@^2.0.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-2.1.0.tgz#d8fc3d284dd05794fe84973caecdd1cf824fdd85"
integrity sha512-vAaEaDM946gbNpH5pLVNR+vX2ht6n0Bt3GXwVB1AuAqZosOvHNF3P7wDnh8KLkSqgUh0uh77le7Owgoz+Z9XBw==
dependencies:
string-width "^1.0.1"
strip-ansi "^3.0.1"
wrappy@1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
integrity sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==
"y18n@^3.2.1 || ^4.0.0":
version "4.0.3"
resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.3.tgz#b5f259c82cd6e336921efd7bfd8bf560de9eeedf"
integrity sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==
yargs-parser@^11.1.1:
version "11.1.1"
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-11.1.1.tgz#879a0865973bca9f6bab5cbdf3b1c67ec7d3bcf4"
integrity sha512-C6kB/WJDiaxONLJQnF8ccx9SEeoTTLek8RVbaOIsrAUS8VrBEXfmeSnCZxygc+XC2sNMBIwOOnfcxiynjHsVSQ==
dependencies:
camelcase "^5.0.0"
decamelize "^1.2.0"
yargs@^12.0.2:
version "12.0.5"
resolved "https://registry.yarnpkg.com/yargs/-/yargs-12.0.5.tgz#05f5997b609647b64f66b81e3b4b10a368e7ad13"
integrity sha512-Lhz8TLaYnxq/2ObqHDql8dX8CJi97oHxrjUcYtzKbbykPtVW9WB+poxI+NM2UIzsMgNCZTIf0AQwsjK5yMAqZw==
dependencies:
cliui "^4.0.0"
decamelize "^1.2.0"
find-up "^3.0.0"
get-caller-file "^1.0.1"
os-locale "^3.0.0"
require-directory "^2.1.1"
require-main-filename "^1.0.1"
set-blocking "^2.0.0"
string-width "^2.0.0"
which-module "^2.0.0"
y18n "^3.2.1 || ^4.0.0"
yargs-parser "^11.1.1"

View File

@@ -22,7 +22,7 @@
[electron.window :as win] [electron.window :as win]
[electron.exceptions :as exceptions] [electron.exceptions :as exceptions]
["/electron/utils" :as js-utils] ["/electron/utils" :as js-utils]
[logseq.publish-spa.export :as export])) [logseq.publish-spa.export :as publish-export]))
;; Keep same as main/frontend.util.url ;; Keep same as main/frontend.util.url
(defonce LSP_SCHEME "logseq") (defonce LSP_SCHEME "logseq")
@@ -96,7 +96,7 @@
asset-filenames (->> (js->clj asset-filenames) (remove nil?)) asset-filenames (->> (js->clj asset-filenames) (remove nil?))
root-dir (or output-path (handler/open-dir-dialog))] root-dir (or output-path (handler/open-dir-dialog))]
(when root-dir (when root-dir
(export/export (publish-export/create-export
html html
app-path app-path
repo-path repo-path

View File

@@ -37,9 +37,8 @@
entity pull pull-many transact! get-key-value] entity pull pull-many transact! get-key-value]
[frontend.db.model [frontend.db.model
blocks-count blocks-count-cache clean-export! delete-blocks get-pre-block blocks-count blocks-count-cache delete-blocks get-pre-block
delete-files delete-pages-by-files delete-files delete-pages-by-files get-all-block-contents get-all-tagged-pages
filter-only-public-pages-and-blocks get-all-block-contents get-all-tagged-pages
get-all-templates get-block-and-children get-block-by-uuid get-block-children sort-by-left get-all-templates get-block-and-children get-block-by-uuid get-block-children sort-by-left
get-block-parent get-block-parents parents-collapsed? get-block-referenced-blocks get-all-referenced-blocks-uuid get-block-parent get-block-parents parents-collapsed? get-block-referenced-blocks get-all-referenced-blocks-uuid
get-block-children-ids get-block-immediate-children get-block-page get-block-children-ids get-block-immediate-children get-block-page
@@ -49,7 +48,7 @@
get-latest-journals get-page get-page-alias get-page-alias-names get-paginated-blocks get-latest-journals get-page get-page-alias get-page-alias-names get-paginated-blocks
get-page-blocks-count get-page-blocks-no-cache get-page-file get-page-format get-page-properties get-page-blocks-count get-page-blocks-no-cache get-page-file get-page-format get-page-properties
get-page-referenced-blocks get-page-referenced-blocks-full get-page-referenced-pages get-page-unlinked-references get-page-referenced-blocks get-page-referenced-blocks-full get-page-referenced-pages get-page-unlinked-references
get-all-pages get-pages get-pages-relation get-pages-that-mentioned-page get-public-pages get-tag-pages get-all-pages get-pages get-pages-relation get-pages-that-mentioned-page get-tag-pages
journal-page? page-alias-set pull-block journal-page? page-alias-set pull-block
set-file-last-modified-at! page-empty? page-exists? page-empty-or-dummy? get-alias-source-page set-file-last-modified-at! page-empty? page-exists? page-empty-or-dummy? get-alias-source-page
set-file-content! has-children? get-namespace-pages get-all-namespace-relation get-pages-by-name-partition set-file-content! has-children? get-namespace-pages get-all-namespace-relation get-pages-by-name-partition

View File

@@ -10,13 +10,11 @@
[frontend.db.conn :as conn] [frontend.db.conn :as conn]
[frontend.db.react :as react] [frontend.db.react :as react]
[frontend.db.utils :as db-utils] [frontend.db.utils :as db-utils]
[frontend.extensions.pdf.utils :as pdf-utils]
[frontend.state :as state] [frontend.state :as state]
[frontend.util :as util :refer [react]] [frontend.util :as util :refer [react]]
[frontend.util.drawer :as drawer] [frontend.util.drawer :as drawer]
[logseq.db.default :as default-db] [logseq.db.default :as default-db]
[logseq.db.rules :as rules] [logseq.db.rules :as rules]
[logseq.db.schema :as db-schema]
[logseq.graph-parser.config :as gp-config] [logseq.graph-parser.config :as gp-config]
[logseq.graph-parser.text :as text] [logseq.graph-parser.text :as text]
[logseq.graph-parser.util.page-ref :as page-ref] [logseq.graph-parser.util.page-ref :as page-ref]
@@ -1358,43 +1356,6 @@ independent of format as format specific heading characters are stripped"
[page-name] [page-name]
(:block/journal? (db-utils/entity [:block/name page-name]))) (:block/journal? (db-utils/entity [:block/name page-name])))
(defn get-public-pages
[db]
(-> (d/q
'[:find ?p
:where
[?p :block/name]
[?p :block/properties ?properties]
[(get ?properties :public) ?pub]
[(= true ?pub)]]
db)
(db-utils/seq-flatten)))
(defn get-public-false-pages
[db]
(-> (d/q
'[:find ?p
:where
[?p :block/name]
[?p :block/properties ?properties]
[(get ?properties :public) ?pub]
[(= false ?pub)]]
db)
(db-utils/seq-flatten)))
(defn get-public-false-block-ids
[db]
(-> (d/q
'[:find ?b
:where
[?p :block/name]
[?p :block/properties ?properties]
[(get ?properties :public) ?pub]
[(= false ?pub)]
[?b :block/page ?p]]
db)
(db-utils/seq-flatten)))
(defn get-all-templates (defn get-all-templates
[] []
(let [pred (fn [_db properties] (let [pred (fn [_db properties]
@@ -1517,73 +1478,6 @@ independent of format as format specific heading characters are stripped"
:block/format (:block/format e)})))) :block/format (:block/format e)}))))
(remove nil?)))) (remove nil?))))
(defn get-assets
[datoms]
(let [get-page-by-eid
(memoize #(some->
(db-utils/pull %)
:block/page
:db/id
db-utils/pull))]
(flatten
(keep
(fn [datom]
(cond-> []
(= :block/content (:a datom))
(concat (let [matched (re-seq #"\([./]*/assets/([^)]+)\)" (:v datom))]
(when (seq matched)
(for [[_ path] matched]
(when (and (string? path)
(not (string/ends-with? path ".js")))
path)))))
;; area image assets
(= (:hl-type (:v datom)) "area")
(#(let [path (some-> (db-utils/pull (:e datom))
(pdf-utils/get-area-block-asset-url
(get-page-by-eid (:e datom))))
path (pdf-utils/clean-asset-path-prefix path)]
(conj % path)))))
datoms))))
(defn clean-export!
[db]
(let [remove? #(contains? #{"me" "recent" "file"} %)
non-public-pages (get-public-false-pages db)
non-public-datoms (get-public-false-block-ids db)
non-public-datom-ids (set (concat non-public-pages non-public-datoms))
filtered-db (d/filter db
(fn [_db datom]
(let [ns (namespace (:a datom))]
(and (not (remove? ns))
(not (contains? #{:block/file} (:a datom)))
(not (contains? non-public-datom-ids (:e datom)))))))
datoms (d/datoms filtered-db :eavt)
assets (get-assets datoms)]
[@(d/conn-from-datoms datoms db-schema/schema) assets]))
(defn filter-only-public-pages-and-blocks
[db]
(let [public-pages (get-public-pages db)]
(when (seq public-pages)
(let [public-pages (set public-pages)
exported-namespace? #(contains? #{"block" "me" "recent"} %)
filtered-db (d/filter db
(fn [db datom]
(let [ns (namespace (:a datom))]
(and
(not (contains? #{:block/file} (:a datom)))
(not= ns "file")
(or
(not (exported-namespace? ns))
(and (= ns "block")
(or
(contains? public-pages (:e datom))
(contains? public-pages (:db/id (:block/page (db-utils/entity db (:e datom))))))))))))
datoms (d/datoms filtered-db :eavt)
assets (get-assets datoms)]
[@(d/conn-from-datoms datoms db-schema/schema) assets]))))
;; Deprecated? ;; Deprecated?
(defn delete-blocks (defn delete-blocks
[repo-url files _delete-page?] [repo-url files _delete-page?]

View File

@@ -4,7 +4,7 @@
[frontend.util :as util] [frontend.util :as util]
["/frontend/extensions/pdf/utils" :as js-utils] ["/frontend/extensions/pdf/utils" :as js-utils]
[datascript.core :as d] [datascript.core :as d]
[logseq.graph-parser.config :as gp-config] [logseq.publish-spa.db :as publish-db]
[clojure.string :as string])) [clojure.string :as string]))
(defonce MAX-SCALE 5.0) (defonce MAX-SCALE 5.0)
@@ -15,21 +15,7 @@
[filename] [filename]
(and filename (string? filename) (string/starts-with? filename "hls__"))) (and filename (string? filename) (string/starts-with? filename "hls__")))
(defn clean-asset-path-prefix (def get-area-block-asset-url publish-db/get-area-block-asset-url)
[path]
(when (string? path)
(string/replace-first path #"^[.\/\\]*(assets)[\/\\]+" "")))
(defn get-area-block-asset-url
[block page]
(when-some [props (and block page (:block/properties block))]
(when-some [uuid (:block/uuid block)]
(when-some [stamp (:hl-stamp props)]
(let [group-key (string/replace-first (:block/original-name page) #"^hls__" "")
hl-page (:hl-page props)
encoded-chars? (boolean (re-find #"(?i)%[0-9a-f]{2}" group-key))
group-key (if encoded-chars? (js/encodeURI group-key) group-key)]
(str "./" gp-config/local-assets-dir "/" group-key "/" (str hl-page "_" uuid "_" stamp ".png")))))))
(defn get-bounding-rect (defn get-bounding-rect
[rects] [rects]

View File

@@ -15,7 +15,7 @@
[frontend.mobile.util :as mobile-util] [frontend.mobile.util :as mobile-util]
[frontend.modules.file.core :as outliner-file] [frontend.modules.file.core :as outliner-file]
[frontend.modules.outliner.tree :as outliner-tree] [frontend.modules.outliner.tree :as outliner-tree]
[logseq.publish-spa.html :as html] [logseq.publish-spa.html :as publish-html]
[frontend.state :as state] [frontend.state :as state]
[frontend.util :as util] [frontend.util :as util]
[frontend.util.property :as property] [frontend.util.property :as property]
@@ -77,24 +77,17 @@
"download public pages as html" "download public pages as html"
[repo] [repo]
(when-let [db (db/get-db repo)] (when-let [db (db/get-db repo)]
(let [[db asset-filenames] (if (state/all-pages-public?) (let [{:keys [asset-filenames html]}
(db/clean-export! db) (publish-html/build-html db
(db/filter-only-public-pages-and-blocks db)) {:app-state (select-keys @state/state
asset-filenames (remove nil? asset-filenames) [:ui/theme
db-str (db/db->string db) :ui/sidebar-collapsed-blocks])
state (select-keys @state/state :repo-config (get-in @state/state [:config repo])})
[:ui/theme
:ui/sidebar-collapsed-blocks
:ui/show-recent?
:config])
state (update state :config (fn [config]
{"local" (get config repo)}))
raw-html-str (html/publishing-html db-str state {})
html-str (str "data:text/html;charset=UTF-8," html-str (str "data:text/html;charset=UTF-8,"
(js/encodeURIComponent raw-html-str))] (js/encodeURIComponent html))]
(if (util/electron?) (if (util/electron?)
(js/window.apis.exportPublishAssets (js/window.apis.exportPublishAssets
raw-html-str html
(config/get-repo-dir repo) (config/get-repo-dir repo)
(clj->js asset-filenames) (clj->js asset-filenames)
(util/mocked-open-dir-path)) (util/mocked-open-dir-path))