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

View File

@@ -4,7 +4,7 @@
[frontend.util :as util]
["/frontend/extensions/pdf/utils" :as js-utils]
[datascript.core :as d]
[logseq.graph-parser.config :as gp-config]
[logseq.publish-spa.db :as publish-db]
[clojure.string :as string]))
(defonce MAX-SCALE 5.0)
@@ -15,21 +15,7 @@
[filename]
(and filename (string? filename) (string/starts-with? filename "hls__")))
(defn clean-asset-path-prefix
[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")))))))
(def get-area-block-asset-url publish-db/get-area-block-asset-url)
(defn get-bounding-rect
[rects]