Ver Fonte

chore: mv sanitize-filename into exporter

should fix outliner CI as it never loads exporter
Gabriel Horner há 3 meses atrás
pai
commit
6ef1c62e95

+ 12 - 4
deps/graph-parser/src/logseq/graph_parser/exporter.cljs

@@ -2,6 +2,7 @@
   "Exports a file graph to DB graph. Used by the File to DB graph importer and
   by nbb-logseq CLIs"
   (:require ["path" :as node-path]
+            ["sanitize-filename" :as sanitizeFilename]
             [borkdude.rewrite-edn :as rewrite]
             [cljs-time.coerce :as tc]
             [cljs.pprint]
@@ -36,8 +37,7 @@
             [logseq.graph-parser.extract :as extract]
             [logseq.graph-parser.property :as gp-property]
             [logseq.graph-parser.utf8 :as utf8]
-            [promesa.core :as p]
-            [logseq.graph-parser.text :as text]))
+            [promesa.core :as p]))
 
 (defn- add-missing-timestamps
   "Add updated-at or created-at timestamps if they doesn't exist"
@@ -1112,13 +1112,21 @@
                  [(node-path/basename image-path) (:block/uuid tx)]) image-paths txs)
           (into {}))}))
 
+;; Reference same default class in cljs + nbb without needing .cljc
+(def sanitizeFilename' (if (find-ns 'nbb.core) (aget sanitizeFilename "default") sanitizeFilename))
+
+(defn safe-sanitize-file-name
+  "Sanitizes filenames for pdf assets"
+  [s]
+  (sanitizeFilename' (str s)))
+
 (defn- build-pdf-annotations-tx
   "Builds tx for pdf annotations when a pdf has an annotations EDN file under assets/"
   [parent-asset-path assets parent-asset pdf-annotation-pages opts]
   (let [asset-edn-path (node-path/join common-config/local-assets-dir
-                                       (text/safe-sanitize-file-name
+                                       (safe-sanitize-file-name
                                         (node-path/basename (string/replace-first parent-asset-path #"(?i)\.pdf$" ".edn"))))
-        asset-md-name (str "hls__" (text/safe-sanitize-file-name
+        asset-md-name (str "hls__" (safe-sanitize-file-name
                                     (node-path/basename (string/replace-first parent-asset-path #"(?i)\.pdf$" ".md"))))]
     (when-let [asset-edn-map (get @assets asset-edn-path)]
       ;; Mark edn asset so it isn't treated like a normal asset later

+ 2 - 11
deps/graph-parser/src/logseq/graph_parser/text.cljs

@@ -1,7 +1,6 @@
 (ns logseq.graph-parser.text
   "Miscellaneous text util fns for the parser. Used by file and DB graphs"
-  (:require ["sanitize-filename" :as sanitizeFilename]
-            [clojure.set :as set]
+  (:require [clojure.set :as set]
             [clojure.string :as string]
             [goog.string :as gstring]
             [logseq.common.util :as common-util]
@@ -152,12 +151,4 @@
             v'))))))
 
 (def namespace-page? ns-util/namespace-page?)
-(def get-namespace-last-part ns-util/get-last-part)
-
-;; Reference same default class in cljs + nbb without needing .cljc
-(def sanitizeFilename' (if (find-ns 'nbb.core) (aget sanitizeFilename "default") sanitizeFilename))
-
-(defn safe-sanitize-file-name
-  "Sanitizes filenames for pdf assets"
-  [s]
-  (sanitizeFilename' (str s)))
+(def get-namespace-last-part ns-util/get-last-part)

+ 3 - 3
src/main/frontend/extensions/pdf/assets.cljs

@@ -25,12 +25,12 @@
             [frontend.util.ref :as ref]
             [logseq.common.config :as common-config]
             [logseq.common.path :as path]
+            [logseq.graph-parser.exporter :as gp-exporter]
             [logseq.publishing.db :as publish-db]
             [medley.core :as medley]
             [promesa.core :as p]
             [reitit.frontend.easy :as rfe]
-            [rum.core :as rum]
-            [logseq.graph-parser.text :as text]))
+            [rum.core :as rum]))
 
 (defn get-in-repo-assets-full-filename
   [url]
@@ -53,7 +53,7 @@
                       (some-> url (js/decodeURIComponent)
                               (get-in-repo-assets-full-filename)
                               (string/replace '"/" "_")))
-        filekey   (text/safe-sanitize-file-name
+        filekey   (gp-exporter/safe-sanitize-file-name
                    (subs filename' 0 (- (count filename') (inc (count ext-name)))))]
     (when-let [key (and (not (string/blank? filekey))
                         (if web-link?