Browse Source

Squashed commit of the following:

commit aa45b3fa6cddedadd95b1a7b2a585ed29c8f2c61
Author: Gabriel Horner <[email protected]>
Date:   Fri Apr 18 14:31:00 2025 -0400

    fix(regression): paths of file graph exports

    markdown + opml exports had zipped files several
    directories deep because they used the full path of the graph

commit 63403bd8c59cac39e8306d470a2b8a1297552323
Author: Gabriel Horner <[email protected]>
Date:   Fri Apr 18 12:32:51 2025 -0400

    fix: remove unused workarounds from #11774

    Previous commit fixed these issues

commit 4ad4944b4e53c782fa9073aa73c1a03ab063a678
Author: Gabriel Horner <[email protected]>
Date:   Fri Apr 18 12:29:06 2025 -0400

    fix: for file graphs, tags with blank space in the namespace parent

    creates entities with nil :block/title to be created. This
    created unexpected bugs in the UI e.g. all pages and
    caused duplicate content to appear.
    Example from test graph: 'tags:: [[Some / Namespace ]]'
    Fixes
    https://test.logseq.com/#/page/68017fb5-7b9c-448a-9f64-6bb8d8669396
rcmerci 6 months ago
parent
commit
501b5f0fe4

+ 1 - 3
deps/db/src/logseq/db.cljs

@@ -499,9 +499,7 @@
    (d/datoms db :avet :block/name)
    (keep (fn [d]
            (let [e (d/entity db (:e d))]
-             (when-not (or (hidden-or-internal-tag? e)
-                           ;; Why this happened?
-                           (nil? (:block/title e)))
+             (when-not (hidden-or-internal-tag? e)
                e))))))
 
 (def built-in? entity-util/built-in?)

+ 1 - 2
deps/db/src/logseq/db/common/view.cljs

@@ -362,8 +362,7 @@
                           (exclude-ids (:db/id e))
                           (or (ldb/hidden-or-internal-tag? e)
                               (entity-util/property? e)
-                              (entity-util/built-in? e)
-                              (nil? (:block/title e))))
+                              (entity-util/built-in? e)))
                 (cond-> e
                   refs-count?
                   (assoc :block.temp/refs-count (count (:block/_refs e)))))))

+ 1 - 1
deps/graph-parser/src/logseq/graph_parser/block.cljs

@@ -345,7 +345,7 @@
               (when namespace?
                 (let [namespace' (first (common-util/split-last "/" original-page-name))]
                   (when-not (string/blank? namespace')
-                    {:block/namespace {:block/name (common-util/page-name-sanity-lc namespace')}})))
+                    {:block/namespace {:block/name (string/trim (common-util/page-name-sanity-lc namespace'))}})))
               (when (and with-timestamp? (or skip-existing-page-check? (not page-entity))) ;; Only assign timestamp on creating new entity
                 (let [current-ms (common-util/time-ms)]
                   {:block/created-at current-ms

+ 6 - 5
src/main/frontend/handler/export/opml.cljs

@@ -15,6 +15,7 @@
             [frontend.util :as util :refer [concatv mapcatv removev]]
             [goog.dom :as gdom]
             [hiccups.runtime :as h]
+            [logseq.common.path :as path]
             [promesa.core :as p]))
 
 ;;; *opml-state*
@@ -462,13 +463,13 @@
   [repo]
   (p/let [files (common/<get-file-contents repo "opml")]
     (when (seq files)
-      (let [repo (-> repo
-                     (string/replace config/db-version-prefix "")
-                     (string/replace config/local-db-prefix ""))
+      (let [repo' (if (config/db-based-graph? repo)
+                    (string/replace repo config/db-version-prefix "")
+                    (path/basename repo))
             files (->> (export-files-as-opml files nil)
                        (clojure.core/remove nil?))
-            zip-file-name (str repo "_opml_" (quot (util/time-ms) 1000))]
-        (p/let [zipfile (zip/make-zip zip-file-name files repo)]
+            zip-file-name (str repo' "_opml_" (quot (util/time-ms) 1000))]
+        (p/let [zipfile (zip/make-zip zip-file-name files repo')]
           (when-let [anchor (gdom/getElement "export-as-opml")]
             (.setAttribute anchor "href" (js/window.URL.createObjectURL zipfile))
             (.setAttribute anchor "download" (.-name zipfile))

+ 6 - 5
src/main/frontend/handler/export/text.cljs

@@ -11,6 +11,7 @@
               simple-asts->string space]]
             [frontend.util :as util :refer [concatv mapcatv removev]]
             [goog.dom :as gdom]
+            [logseq.common.path :as path]
             [logseq.db :as ldb]
             [logseq.graph-parser.schema.mldoc :as mldoc-schema]
             [malli.core :as m]
@@ -547,11 +548,11 @@
   (p/let [files (util/profile :get-file-content (common/<get-file-contents repo "md"))]
     (when (seq files)
       (let [files (export-files-as-markdown files nil)
-            repo (-> repo
-                     (string/replace config/db-version-prefix "")
-                     (string/replace config/local-db-prefix ""))
-            zip-file-name (str repo "_markdown_" (quot (util/time-ms) 1000))]
-        (p/let [zipfile (zip/make-zip zip-file-name files repo)]
+            repo' (if (config/db-based-graph? repo)
+                    (string/replace repo config/db-version-prefix "")
+                    (path/basename repo))
+            zip-file-name (str repo' "_markdown_" (quot (util/time-ms) 1000))]
+        (p/let [zipfile (zip/make-zip zip-file-name files repo')]
           (when-let [anchor (gdom/getElement "export-as-markdown")]
             (.setAttribute anchor "href" (js/window.URL.createObjectURL zipfile))
             (.setAttribute anchor "download" (.-name zipfile))