mirror of https://github.com/logseq/logseq
fix: open db graph urls
Also introduced var for logseq_db_ in depsfeat/datascript-storage-test
parent
c468d05845
commit
5e547a1663
|
@ -3,7 +3,8 @@
|
|||
(:require ["path" :as node-path]
|
||||
["better-sqlite3" :as sqlite3]
|
||||
[clojure.string :as string]
|
||||
[cljs-bean.core :as bean]))
|
||||
[cljs-bean.core :as bean]
|
||||
[logseq.db.sqlite.util :as sqlite-util]))
|
||||
|
||||
;; use built-in blocks to represent db schema, config, custom css, custom js, etc.
|
||||
|
||||
|
@ -22,7 +23,7 @@
|
|||
(defn sanitize-db-name
|
||||
[db-name]
|
||||
(-> db-name
|
||||
(string/replace "logseq_db_" "")
|
||||
(string/replace sqlite-util/db-version-prefix "")
|
||||
(string/replace "/" "_")
|
||||
(string/replace "\\" "_")
|
||||
(string/replace ":" "_"))) ;; windows
|
||||
|
|
|
@ -31,6 +31,8 @@
|
|||
(contains? (set (:block/type block)) "macro") 7
|
||||
:else 5))
|
||||
|
||||
(defonce db-version-prefix "logseq_db_")
|
||||
|
||||
(defn time-ms
|
||||
"Copy of util/time-ms. Too basic to couple this to main app"
|
||||
[]
|
||||
|
|
|
@ -5,7 +5,8 @@ necessary db filtering"
|
|||
[goog.string :as gstring]
|
||||
[goog.string.format]
|
||||
[datascript.transit :as dt]
|
||||
[logseq.publishing.db :as db]))
|
||||
[logseq.publishing.db :as db]
|
||||
[logseq.db.sqlite.util :as sqlite-util]))
|
||||
|
||||
;; Copied from hiccup but tweaked for publish usage
|
||||
;; Any changes here should also be made in frontend.publishing/unescape-html
|
||||
|
@ -142,7 +143,7 @@ generated index.html string and assets used by the html"
|
|||
asset-filenames (remove nil? asset-filenames')
|
||||
|
||||
db-str (dt/write-transit-str db)
|
||||
repo-name (if db-graph? "logseq_db_local" "local")
|
||||
repo-name (if db-graph? (str sqlite-util/db-version-prefix "local") "local")
|
||||
;; The repo-name is used by the client and thus determines whether
|
||||
;; it's a db graph or not
|
||||
state (assoc app-state
|
||||
|
|
|
@ -245,7 +245,7 @@
|
|||
(->> (common-graph/read-directories dir)
|
||||
(remove (fn [s] (= s db/unlinked-graphs-dir)))
|
||||
(map graph-name->path)
|
||||
(map (fn [s] (str "logseq_db_" s))))))
|
||||
(map (fn [s] (str sqlite-util/db-version-prefix s))))))
|
||||
|
||||
(defn- get-graphs
|
||||
[]
|
||||
|
@ -255,13 +255,15 @@
|
|||
|
||||
;; TODO support alias mechanism
|
||||
(defn get-graph-name
|
||||
"Given a graph's name of string, returns the graph's fullname.
|
||||
E.g., given `cat`, returns `logseq_local_<path_to_directory>/cat`
|
||||
Returns `nil` if no such graph exists."
|
||||
"Given a graph's name of string, returns the graph's fullname. For example, given
|
||||
`cat`, returns `logseq_local_<path_to_directory>/cat` for a file graph and
|
||||
`logseq_db_cat` for a db graph. Returns `nil` if no such graph exists."
|
||||
[graph-identifier]
|
||||
(->> (get-graphs)
|
||||
(some #(when (string/ends-with? (utils/normalize-lc %)
|
||||
(str "/" (utils/normalize-lc graph-identifier)))
|
||||
(some #(when (or
|
||||
(= (utils/normalize-lc %) (utils/normalize-lc (str sqlite-util/db-version-prefix graph-identifier)))
|
||||
(string/ends-with? (utils/normalize-lc %)
|
||||
(str "/" (utils/normalize-lc graph-identifier))))
|
||||
%))))
|
||||
|
||||
(defmethod handle :getGraphs [_window [_]]
|
||||
|
|
|
@ -229,9 +229,7 @@
|
|||
(let [remote? (:remote? (first (filter #(= current-repo (:url %)) repos)))
|
||||
repo-name (db/get-repo-name current-repo)
|
||||
short-repo-name (if repo-name
|
||||
(if (config/db-based-graph? repo-name)
|
||||
(string/replace-first repo-name config/db-version-prefix "")
|
||||
(db/get-short-repo-name repo-name))
|
||||
(db/get-short-repo-name repo-name)
|
||||
"Select a Graph")]
|
||||
[:a.item.group.flex.items-center.p-2.text-sm.font-medium.rounded-md
|
||||
|
||||
|
|
|
@ -36,15 +36,18 @@
|
|||
(defn get-short-repo-name
|
||||
"repo-name: from get-repo-name. Dir/Name => Name"
|
||||
[repo-name]
|
||||
(cond
|
||||
(util/electron?)
|
||||
(text/get-file-basename repo-name)
|
||||
(let [repo-name' (cond
|
||||
(util/electron?)
|
||||
(text/get-file-basename repo-name)
|
||||
|
||||
(mobile-util/native-platform?)
|
||||
(gp-util/safe-decode-uri-component (text/get-file-basename repo-name))
|
||||
(mobile-util/native-platform?)
|
||||
(gp-util/safe-decode-uri-component (text/get-file-basename repo-name))
|
||||
|
||||
:else
|
||||
repo-name))
|
||||
:else
|
||||
repo-name)]
|
||||
(if (config/db-based-graph? repo-name')
|
||||
(string/replace-first repo-name' config/db-version-prefix "")
|
||||
repo-name')))
|
||||
|
||||
(defn datascript-db
|
||||
[repo]
|
||||
|
|
Loading…
Reference in New Issue