fix: remove file graph :block/file and dependent code

Also remove all file graph references in publishing and
add back publishing.db tests with db graph.
Also remove file graph behavior for cmd-k and files
This commit is contained in:
Gabriel Horner
2026-01-09 12:14:24 -05:00
parent c89d415e93
commit 6312f8236a
44 changed files with 132 additions and 336 deletions

View File

@@ -11,6 +11,6 @@
"fs-extra": "9.1.0"
},
"scripts": {
"test": "yarn nbb-logseq -cp test:../graph-parser/src -m nextjournal.test-runner"
"test": "yarn nbb-logseq -cp test -m nextjournal.test-runner"
}
}

View File

@@ -22,7 +22,6 @@
output-path
(merge opts {:repo (str sqlite-util/db-version-prefix db-name)
:repo-config repo-config
:db-graph? true
:ui/theme "dark"
:ui/radix-color :cyan}))))

View File

@@ -18,7 +18,6 @@ can be passed:
can be icon, name, alias, title, description and url
* :repo - Name of repo
* :repo-config - A graph's configuration
* :db-graph? - Boolean which indicates if graph is db based
* :default-notification-fn - Configure how errors are reported when creating the export.
Default is to throw an exception when it occurs."
[db static-dir graph-dir output-dir {:keys [notification-fn dev?]

View File

@@ -1,47 +1,10 @@
(ns logseq.publishing.db
"Provides db fns and associated util fns for publishing"
(:require [clojure.set :as set]
[clojure.string :as string]
[datascript.core :as d]
[logseq.db.common.entity-plus :as entity-plus]
[logseq.db.frontend.malli-schema :as db-malli-schema]
[logseq.db.frontend.rules :as rules]))
(defn ^:api 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 independent from the frontend app"
[db block page]
(let [db-based? (entity-plus/db-based-graph? db)]
(when-some [uuid' (:block/uuid block)]
(if db-based?
(when-let [image (:logseq.property.pdf/hl-image block)]
(str "./assets/" (:block/uuid image) ".png"))
(let [props (and block page (:block/properties block))
prop-lookup-fn #(get %1 (keyword (name %2)))]
(when-some [stamp (:hl-stamp props)]
(let [group-key (string/replace-first (:block/title page) #"^hls__" "")
hl-page (prop-lookup-fn props :logseq.property.pdf/hl-page)
encoded-chars? (boolean (re-find #"(?i)%[0-9a-f]{2}" group-key))
group-key (if encoded-chars? (js/encodeURI group-key) group-key)]
(str "./assets/" group-key "/" (str hl-page "_" uuid' "_" stamp ".png")))))))))
(defn- clean-asset-path-prefix
[path]
(when (string? path)
(string/replace-first path #"^[.\/\\]*(assets)[\/\\]+" "")))
(defn- get-public-pages
[db]
(->> (d/q
'[:find ?p
:where
[?p :block/name]
[?p :block/properties ?properties]
[(get ?properties :public) ?pub]
[(= true ?pub)]]
db)
(map first)))
(defn- get-db-public-pages
"Returns public pages and anything they are directly related to: their tags,
their properties and any property values that are pages. Anything on the
@@ -78,76 +41,6 @@
(map first)
set))
(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)
(map first)))
(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)
(map first)))
(defn- hl-type-area-fn
[db]
(if (entity-plus/db-based-graph? db)
(fn [datom]
(and (= :logseq.property.pdf/hl-type (:a datom))
(= (keyword (:v datom)) :area)))
(fn [datom]
(and
(= :block/properties (:a datom))
(= (keyword (get (:v datom) :hl-type)) :area)))))
(defn- get-file-assets
[db datoms]
(let [pull (fn [eid db]
(d/pull db '[*] eid))
get-page-by-eid
(memoize #(some->
(pull % db)
:block/page
:db/id
(pull db)))
hl-type-area? (hl-type-area-fn db)]
(->>
(keep
(fn [datom]
(cond-> []
(= :block/title (: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-area? datom)
(#(let [path (some-> (pull (:e datom) db)
(get-area-block-asset-url
db
(get-page-by-eid (:e datom))))
path (clean-asset-path-prefix path)]
(conj % path)))))
datoms)
flatten
distinct)))
(defn- get-aliases-for-page-ids
[db page-ids]
(->> (d/q '[:find ?e
@@ -170,36 +63,22 @@
(map #(str (:block/uuid %) "." (:logseq.property.asset/type %)))))
(defn clean-export!
"Prepares a database assuming all pages are public unless a page has a 'public:: false'"
[db {:keys [db-graph?]}]
(let [remove? #(contains? #{"recent" "file"} %)
non-public-datom-ids (if db-graph?
(get-db-public-false-pages db)
(set (concat (get-public-false-pages db) (get-public-false-block-ids db))))
"Prepares a database assuming all pages are public unless a page has a publishing-public? property set to false"
[db]
(let [remove? #(contains? #{"file"} %)
non-public-datom-ids (get-db-public-false-pages db)
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)))))))
(not (contains? non-public-datom-ids (:e datom)))
(not (and (contains? non-public-datom-ids (:v datom))
(= :block/page (:a datom))))))))
datoms (d/datoms filtered-db :eavt)
assets (if db-graph? (get-db-assets filtered-db) (get-file-assets db datoms))]
assets (get-db-assets filtered-db)]
;; (prn :public-counts :datoms (count datoms) :assets (count assets))
[@(d/conn-from-datoms datoms (:schema db)) assets]))
(defn- file-filter-only-public
[public-pages db datom]
(let [ns' (namespace (:a datom))]
(and
(not (contains? #{:block/file} (:a datom)))
(not= ns' "file")
(or
(not (contains? #{"block" "recent"} ns'))
(and (= ns' "block")
(or
(contains? public-pages (:e datom))
(contains? public-pages (:db/id (:block/page (d/entity db (:e datom)))))))))))
(defn- db-filter-only-public
[public-ents _db datom]
(contains? public-ents (:e datom)))
@@ -263,17 +142,15 @@
ents))
(defn filter-only-public-pages-and-blocks
"Prepares a database assuming all pages are private unless a page has a 'public:: true'"
[db {:keys [db-graph?]}]
"Prepares a database assuming all pages are private unless a page has a publishing-public? property set to true"
[db]
{:post [(some? %) (sequential? %)]}
(let [public-pages* (seq (if db-graph? (get-db-public-pages db) (get-public-pages db)))
(let [public-pages* (seq (get-db-public-pages db))
public-pages (set/union (set public-pages*)
(get-aliases-for-page-ids db public-pages*))
filter-fn (if db-graph?
(partial db-filter-only-public (get-db-public-ents db public-pages))
(partial file-filter-only-public public-pages))
filter-fn (partial db-filter-only-public (get-db-public-ents db public-pages))
filtered-db (d/filter db filter-fn)
datoms (d/datoms filtered-db :eavt)
assets (if db-graph? (get-db-assets filtered-db) (get-file-assets db datoms))]
assets (get-db-assets filtered-db)]
;; (prn :private-counts :internal (count internal-ents) :datoms (count datoms) :assets (count assets))
[@(d/conn-from-datoms datoms (:schema db)) assets]))

View File

@@ -138,13 +138,13 @@ necessary db filtering"
(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 [repo app-state repo-config html-options db-graph? dev?]}]
[db* {:keys [repo app-state repo-config html-options dev?]}]
(let [all-pages-public? (if-let [value (:publishing/all-pages-public? repo-config)]
value
(:all-pages-public? repo-config))
[db asset-filenames'] (if all-pages-public?
(db/clean-export! db* {:db-graph? db-graph?})
(db/filter-only-public-pages-and-blocks db* {:db-graph? db-graph?}))
(db/clean-export! db*)
(db/filter-only-public-pages-and-blocks db*))
_ (when dev?
(println "Exporting" (count (d/datoms db :eavt)) "of" (count (d/datoms db* :eavt)) "datoms and"
(count asset-filenames') "asset(s)..."))

View File

@@ -0,0 +1,85 @@
(ns logseq.publishing.db-test
(:require [cljs.test :refer [deftest is]]
[clojure.set :as set]
[datascript.core :as d]
[logseq.db :as ldb]
[logseq.publishing.db :as publish-db]
[logseq.db.test.helper :as db-test]))
(deftest clean-export!
(let [conn (db-test/create-conn-with-blocks
[{:page {:block/title "page1"
:build/properties {:logseq.property/publishing-public? false}}
:blocks [{:block/title "b11"}
{:block/title "b12"}
{:block/title "![awesome.png](../assets/awesome_1648822509908_0.png"}]}
{:page {:block/title "page2"}
:blocks [{:block/title "b21"}
{:block/title "![thumb-on-fire.PNG](../assets/thumb-on-fire_1648822523866_0.PNG)"}]}
{:page {:block/title "page3"}
:blocks [{:block/title "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/title]
[?b :block/page ?p]
[(missing? $ ?p :logseq.property/built-in?)]]
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")
;; TODO: Create assets to test this
#_(is (= ["thumb-on-fire_1648822523866_0.PNG"] assets)
"Only exports assets from public pages")))
(deftest filter-only-public-pages-and-blocks
(let [conn (db-test/create-conn-with-blocks
[{:page {:block/title "page1"
:build/properties {:logseq.property/publishing-public? false}}
:blocks [{:block/title "b11"}
{:block/title "b12"}
{:block/title "![awesome.png](../assets/awesome_1648822509908_0.png"}]}
{:page {:block/title "page2"
:build/properties {:logseq.property/publishing-public? true
:block/alias #{[:build/page {:block/title "page2-alias"}]}}}
:blocks [{:block/title "b21"}
{:block/title "![thumb-on-fire.PNG](../assets/thumb-on-fire_1648822523866_0.PNG)"}]}
{:page {:block/title "page3"
:build/properties {:logseq.property/publishing-public? true}}
:blocks [{:block/title "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/title]
[?b :block/page ?p]
[(missing? $ ?p :logseq.property/built-in?)]]
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 (seq (ldb/get-page filtered-db "page2-alias"))
"Alias of public page is exported")
(is (= #{"page2" "page3"} exported-block-pages)
"Only exports blocks from public pages")
;; TODO: Create assets to test this
#_(is (= ["thumb-on-fire_1648822523866_0.PNG"] assets)
"Only exports assets from public pages")))

View File

@@ -24,7 +24,7 @@
(defn kondo-git-changes
"Run clj-kondo across dirs and only for files that git diff detects as unstaged changes"
[]
(let [kondo-dirs ["src" "deps/common" "deps/db" "deps/graph-parser" "deps/outliner" "deps/publish" "deps/publishing" "deps/cli"]
(let [kondo-dirs ["src" "deps/common" "deps/db" "deps/graph-parser" "deps/outliner" "deps/publishing" "deps/publish" "deps/cli"]
dir-regex (re-pattern (str "^(" (string/join "|" kondo-dirs) ")"))
dir-to-files (->> (shell {:out :string} "git diff --name-only")
:out

View File

@@ -1,7 +1,6 @@
(ns frontend.components.cmdk.core
(:require [cljs-bean.core :as bean]
[clojure.string :as string]
[electron.ipc :as ipc]
[frontend.components.block :as block]
[frontend.components.cmdk.list-item :as list-item]
[frontend.components.icon :as icon-component]
@@ -30,7 +29,6 @@
[goog.functions :as gfun]
[goog.object :as gobj]
[goog.userAgent]
[logseq.common.path :as path]
[logseq.common.util :as common-util]
[logseq.common.util.block-ref :as block-ref]
[logseq.db :as ldb]
@@ -498,15 +496,8 @@
(defn- open-file
[file-path]
(if (or (string/ends-with? file-path ".edn")
(string/ends-with? file-path ".js")
(string/ends-with? file-path ".css"))
(route-handler/redirect! {:to :file
:path-params {:path file-path}})
;; open this file in directory
(when (util/electron?)
(let [file-fpath (path/path-join (config/get-repo-dir (state/get-current-repo)) file-path)]
(ipc/ipc "openFileInFolder" file-fpath)))))
(route-handler/redirect! {:to :file
:path-params {:path file-path}}))
(defn- page-item?
[item]

View File

@@ -3,18 +3,15 @@
[cljs-time.core :as t]
[clojure.string :as string]
[frontend.components.lazy-editor :as lazy-editor]
[frontend.components.svg :as svg]
[frontend.config :as config]
[frontend.context.i18n :refer [t]]
[frontend.date :as date]
[frontend.db :as db]
[frontend.db.async :as db-async]
[frontend.db.model :as db-model]
[frontend.fs :as fs]
[frontend.state :as state]
[frontend.ui :as ui]
[frontend.util :as util]
[goog.object :as gobj]
[goog.string :as gstring]
[logseq.common.config :as common-config]
[logseq.common.path :as path]
@@ -101,33 +98,14 @@
(let [repo-dir (config/get-repo-dir (state/get-current-repo))
rel-path (when (string/starts-with? path repo-dir)
(path/trim-dir-prefix repo-dir path))
title (db-model/get-file-page (or path rel-path))
file-path path
random-id (str (common-uuid/gen-uuid))
content (rum/react (::file-content state))]
[:div.file {:id (str "file-edit-wrapper-" random-id)
:key path}
[:h1.title
[:bdi (or title rel-path path)]]
(when title
[:div.text-sm.mb-4.ml-1 "Page: "
[:a.bg-base-2.p-1.ml-1 {:style {:border-radius 4}
:href (rfe/href :page {:name title})
:on-click (fn [e]
(when (gobj/get e "shiftKey")
(when-let [page (db/get-page title)]
(state/sidebar-add-block!
(state/get-current-repo)
(:db/id page)
:page))
(util/stop e)))}
title]])
[:bdi (or rel-path path)]]
(when (and title (not (string/starts-with? title "logseq/")))
[:p.text-sm.ml-1.mb-4
(svg/warning {:style {:width "1em"
:display "inline-block"}})
[:span.ml-1 "Please don't remove the page's title property (you can still modify it)."]])
(cond
;; image type

View File

@@ -1,7 +1,6 @@
(ns frontend.components.left-sidebar
"App left sidebar"
(:require [clojure.string :as string]
[electron.ipc :as ipc]
[frontend.components.block :as block]
[frontend.components.dnd :as dnd-component]
[frontend.components.icon :as icon]
@@ -22,7 +21,6 @@
[frontend.storage :as storage]
[frontend.ui :as ui]
[frontend.util :as util]
[frontend.util.page :as page-util]
[goog.object :as gobj]
[logseq.db :as ldb]
[logseq.shui.hooks :as hooks]
@@ -49,8 +47,6 @@
icon (icon/get-node-icon-cp page {:size 16})
title (:block/title page)
untitled? (db-model/untitled-page? title)
name (:block/name page)
file-rpath (when (util/electron?) (page-util/get-page-file-rpath name))
ctx-icon #(shui/tabler-icon %1 {:class "scale-90 pr-1 opacity-80"})
open-in-sidebar #(state/sidebar-add-block!
(state/get-current-repo)
@@ -70,20 +66,6 @@
(some-> binding
(first)
(shortcut-utils/decorate-binding))))))
(when-let [page-fpath (and (util/electron?) file-rpath
(config/get-repo-fpath (state/get-current-repo) file-rpath))]
[:<>
(x-menu-item
{:key "open-in-folder"
:on-click #(ipc/ipc :openFileInFolder page-fpath)}
(ctx-icon "folder")
(t :page/open-in-finder))
(x-menu-item
{:key "open with default app"
:on-click #(js/window.apis.openPath page-fpath)}
(ctx-icon "file")
(t :page/open-with-default-app))])
(x-menu-item
{:key "open in sidebar"
:on-click open-in-sidebar}

View File

@@ -1,6 +1,5 @@
(ns frontend.components.page-menu
(:require [electron.ipc :as ipc]
[frontend.commands :as commands]
(:require [frontend.commands :as commands]
[frontend.components.export :as export]
[frontend.config :as config]
[frontend.context.i18n :refer [t]]
@@ -13,8 +12,6 @@
[frontend.mobile.util :as mobile-util]
[frontend.state :as state]
[frontend.util :as util]
[frontend.util.page :as page-util]
[logseq.common.path :as path]
[logseq.db :as ldb]
[logseq.shui.hooks :as hooks]
[logseq.shui.ui :as shui]
@@ -83,8 +80,7 @@
(defn ^:large-vars/cleanup-todo page-menu
[page]
(when-let [page-name (and page (db/page? page) (:block/name page))]
(let [repo (state/sub :git/current-repo)
page-title (str (:block/uuid page))
(let [page-title (str (:block/uuid page))
whiteboard? (ldb/whiteboard? page)
block? (and page (util/uuid-string? page-name) (not whiteboard?))
contents? (= page-name "contents")
@@ -92,7 +88,6 @@
_favorites-updated? (state/sub :favorites/updated?)
favorited? (page-handler/favorited? page-title)
developer-mode? (state/sub [:ui/developer-mode?])
file-rpath (when (util/electron?) (page-util/get-page-file-rpath page-name))
_ (state/sub :auth/id-token)]
(when (not block?)
(->>
@@ -117,18 +112,6 @@
{:title (t :page/delete)
:options {:on-click #(delete-page-confirm! page)}})
;; TODO: In the future, we'd like to extract file-related actions
;; (such as open-in-finder & open-with-default-app) into a sub-menu of
;; this one. However this component doesn't yet exist. PRs are welcome!
;; Details: https://github.com/logseq/logseq/pull/3003#issuecomment-952820676
(when file-rpath
(let [repo-dir (config/get-repo-dir repo)
file-fpath (path/path-join repo-dir file-rpath)]
[{:title (t :page/open-in-finder)
:options {:on-click #(ipc/ipc "openFileInFolder" file-fpath)}}
{:title (t :page/open-with-default-app)
:options {:on-click #(js/window.apis.openPath file-fpath)}}]))
(when page
{:title (t :export-page)
:options {:on-click #(shui/dialog-open!

View File

@@ -338,10 +338,6 @@
(str "memory:///"
(string/replace-first repo-url db-version-prefix "")))))
(defn get-repo-fpath
[repo-url path]
(path/path-join (get-repo-dir repo-url) path))
(defn get-repo-config-path
[]
(path/path-join app-name config-file))

View File

@@ -466,31 +466,6 @@ independent of format as format specific heading characters are stripped"
(:block/_tags class))
(remove ldb/hidden?))))
(defn get-file-page
([file-path]
(get-file-page file-path true))
([file-path title?]
(when-let [repo (state/get-current-repo)]
(when-let [db (conn/get-db repo)]
(some->
(d/q
(if title?
'[:find ?page-name
:in $ ?path
:where
[?file :file/path ?path]
[?page :block/file ?file]
[?page :block/title ?page-name]]
'[:find ?page-name
:in $ ?path
:where
[?file :file/path ?path]
[?page :block/file ?file]
[?page :block/name ?page-name]])
db file-path)
db-utils/seq-flatten
first)))))
(comment
;; For debugging
(defn get-all-blocks

View File

@@ -4,9 +4,7 @@
[frontend.context.i18n :refer [t]]
[frontend.db :as db]
[frontend.db.async :as db-async]
[frontend.db.conn :as conn]
[frontend.db.model :as db-model]
[frontend.db.utils :as db-utils]
[frontend.extensions.lightbox :as lightbox]
[frontend.extensions.pdf.windows :as pdf-windows]
[frontend.fs :as fs]
@@ -22,7 +20,6 @@
[frontend.util.ref :as ref]
[logseq.common.config :as common-config]
[logseq.graph-parser.exporter :as gp-exporter]
[logseq.publishing.db :as publish-db]
[promesa.core :as p]
[reitit.frontend.easy :as rfe]
[rum.core :as rum]))
@@ -260,10 +257,7 @@
(rum/local nil ::src)
[state block]
(let [*src (::src state)]
(when-let [asset-path' (and block (publish-db/get-area-block-asset-url
(conn/get-db (state/get-current-repo))
block
(db-utils/pull (:db/id (:block/page block)))))]
(when-let [asset-path' (and block (assets-handler/get-area-block-asset-url block))]
(when (nil? @*src)
(p/let [asset-path (assets-handler/<make-asset-url asset-path')]
(reset! *src asset-path)))

View File

@@ -4,9 +4,7 @@
[frontend.components.svg :as svg]
[frontend.context.i18n :refer [t]]
[frontend.db.async :as db-async]
[frontend.db.conn :as conn]
[frontend.db.model :as db-model]
[frontend.db.utils :as db-utils]
[frontend.extensions.pdf.assets :as pdf-assets]
[frontend.extensions.pdf.utils :as pdf-utils]
[frontend.extensions.pdf.windows :refer [resolve-own-container] :as pdf-windows]
@@ -17,7 +15,6 @@
[frontend.storage :as storage]
[frontend.ui :as ui]
[frontend.util :as util]
[logseq.publishing.db :as publish-db]
[logseq.shui.hooks :as hooks]
[logseq.shui.ui :as shui]
[promesa.core :as p]
@@ -384,10 +381,7 @@
(fn []
(p/let [_ (db-async/<get-block repo id {:children? false})
block (db-model/get-block-by-uuid id)]
(when-let [asset-path' (and block (publish-db/get-area-block-asset-url
(conn/get-db (state/get-current-repo))
block
(db-utils/pull (:db/id (:block/page block)))))]
(when-let [asset-path' (and block (assets-handler/get-area-block-asset-url block))]
(-> asset-path' (assets-handler/<make-asset-url)
(p/then #(set-src! %))))))
[])

View File

@@ -57,6 +57,13 @@
(medley/find-first #(= name (:name (second %1)))
(medley/indexed alias-dirs))))
(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 independent from the frontend app"
[block]
(when-let [image (:logseq.property.pdf/hl-image block)]
(str "./assets/" (:block/uuid image) ".png")))
(defn resolve-asset-real-path-url
[repo rpath]
(when-let [rpath (and (string? rpath)

View File

@@ -6,10 +6,8 @@
[clojure.string :as string]
[datascript.core :as d]
[dommy.core :as dom]
[frontend.config :as config]
[frontend.db :as db]
[frontend.db.conn :as conn]
[frontend.fs :as fs]
[frontend.handler.config :as config-handler]
[frontend.handler.db-based.editor :as db-editor-handler]
[frontend.handler.notification :as notification]
@@ -156,24 +154,18 @@
;; =========
(defn after-page-deleted!
[repo page-name file-path tx-meta]
(let [repo-dir (config/get-repo-dir repo)]
[page-name tx-meta]
;; TODO: move favorite && unfavorite to worker too
(when-let [page-block-uuid (:block/uuid (db/get-page page-name))]
(<db-unfavorite-page! page-block-uuid))
(when-let [page-block-uuid (:block/uuid (db/get-page page-name))]
(<db-unfavorite-page! page-block-uuid))
(when (and (not= :rename-page (:real-outliner-op tx-meta))
(= (some-> (state/get-current-page) common-util/page-name-sanity-lc)
(common-util/page-name-sanity-lc page-name)))
(route-handler/redirect-to-home!))
(when (and (not= :rename-page (:real-outliner-op tx-meta))
(= (some-> (state/get-current-page) common-util/page-name-sanity-lc)
(common-util/page-name-sanity-lc page-name)))
(route-handler/redirect-to-home!))
;; TODO: why need this?
(ui-handler/re-render-root!)
(when file-path
(-> (p/let [exists? (fs/file-exists? repo-dir file-path)]
(when exists? (fs/unlink! repo (config/get-repo-fpath repo file-path) nil)))
(p/catch (fn [error] (js/console.error error)))))))
(ui-handler/re-render-root!))
(defn after-page-renamed!
[repo {:keys [page-id old-name new-name]}]

View File

@@ -1232,7 +1232,7 @@
(when (and (:db/id entity) (not (ldb/built-in? entity)))
(let [value (string/trim value)]
;; FIXME: somehow frontend.components.editor's will-unmount event will loop forever
;; maybe we shouldn't save the block/file in "will-unmount" event?
;; maybe we shouldn't save in "will-unmount" event?
(save-block-if-changed! block value opts)))))
(defn save-block!

View File

@@ -108,9 +108,9 @@
(page-handler/create-today-journal!)
(page-handler/<create! page-name opts)))
(defmethod handle :page/deleted [[_ repo page-name file-path tx-meta]]
(defmethod handle :page/deleted [[_ page-name tx-meta]]
(when-not (util/mobile?)
(page-common-handler/after-page-deleted! repo page-name file-path tx-meta)))
(page-common-handler/after-page-deleted! page-name tx-meta)))
(defmethod handle :page/renamed [[_ repo data]]
(when-not (util/mobile?)

View File

@@ -28,8 +28,7 @@
:app-state (select-keys @state/state
[:ui/theme
:ui/sidebar-collapsed-blocks])
:repo-config (get-in @state/state [:config repo])
:db-graph? true})
:repo-config (get-in @state/state [:config repo])})
html-str (str "data:text/html;charset=UTF-8,"
(js/encodeURIComponent html))]
(if (util/electron?)

View File

@@ -102,7 +102,7 @@
:tx-meta (:tx-meta tx-report)}])))))))
(when (= (:outliner-op tx-meta) :delete-page)
(state/pub-event! [:page/deleted repo (:deleted-page tx-meta) (:file-path tx-meta) tx-meta]))
(state/pub-event! [:page/deleted (:deleted-page tx-meta) tx-meta]))
(when (= (:outliner-op tx-meta) :rename-page)
(state/pub-event! [:page/renamed repo (:data tx-meta)]))))

View File

@@ -1,8 +1,7 @@
(ns frontend.util.page
"Provides util fns for page blocks"
(:require [frontend.db :as db]
[frontend.state :as state]
[frontend.util :as util]))
[frontend.state :as state]))
(defn get-current-page-uuid
"Fetch the current page's uuid with same approach as get-current-page-id"
@@ -15,14 +14,4 @@
nothing is found, gets page of last edited block"
[]
(let [page-name (state/get-current-page)]
(:db/id (db/get-page page-name))))
(defn get-page-file-rpath
"Gets the file path of a page. If no page is given, detects the current page.
Returns nil if no file path is found or no page is detected or given"
([]
(when-let [page-id (get-current-page-id)]
(get-in (db/entity page-id) [:block/file :file/path])))
([page-name]
(when-let [page-name' (some-> page-name util/page-name-sanity-lc)]
(get-in (db/get-page page-name') [:block/file :file/path]))))
(:db/id (db/get-page page-name))))

View File

@@ -305,8 +305,6 @@
:page/logseq-is-having-a-problem "Logseq està tenint un problema. Per intentar tornar a un estat de treball, intenti el següent procediment en ordre:"
:page/make-private "Fer privada"
:page/make-public "Fer pública al publicar"
:page/open-in-finder "Obrir ubicació del arxiu"
:page/open-with-default-app "Obrir amb la aplicació preestablerta"
:page/something-went-wrong "Alguna cosa ha sortit malament"
:page/step "Pas {1}"
:page/try "Intentar"

View File

@@ -95,8 +95,6 @@
:page/logseq-is-having-a-problem "Logseq má problém. Chcete-li se pokusit uvést jej zpět do funkčního stavu, vyzkoušejte prosím následující bezpečné kroky v uvedeném pořadí:"
:page/step "Krok {1}"
:page/try "Zkusit"
:page/open-in-finder "Otevřít v adresáři"
:page/open-with-default-app "Otevřít pomocí výchozí aplikace"
:page/make-public "Označit stránku jjako veřejnou"
:page/make-private "Označit stránku jjako soukromou"
:page/delete "Smazat stránku"

View File

@@ -208,8 +208,6 @@
:page/logseq-is-having-a-problem "Logseq hat ein Problem festgestellt. Versuche zurückzukehren ..."
:page/make-private "Privat machen"
:page/make-public "Beim Export in HTML veröffentlichen"
:page/open-in-finder "Im Verzeichnis öffnen"
:page/open-with-default-app "Mit Standard-Anwendung öffnen"
:page/something-went-wrong "Es ist etwas schief gelaufen."
:page/step "Schritt {1}"
:page/try "Versuch"

View File

@@ -105,8 +105,6 @@
:page/try "Try"
:page/delete-confirmation "Are you sure you want to delete this page?"
:page/db-delete-confirmation "Are you sure you want to delete this page?"
:page/open-in-finder "Open in directory"
:page/open-with-default-app "Open with default app"
:page/make-public "Make it public for publishing"
:page/make-private "Make it private"
:page/delete "Delete page"

View File

@@ -304,8 +304,6 @@
:page/logseq-is-having-a-problem "Logseq está teniendo un problema. Para intentar volver a un estado de trabajo, intenta los siguientes pasos seguros en orden:"
:page/make-private "Hacer privada"
:page/make-public "Hacer pública al publicar"
:page/open-in-finder "Abrir ubicación del archivo"
:page/open-with-default-app "Abrir con la aplicación predeterminada"
:page/something-went-wrong "Algo malió sal"
:page/step "Paso {1}"
:page/try "Intentar"

View File

@@ -73,8 +73,6 @@
:page/logseq-is-having-a-problem "لاگ‌سیک دچار مشکلی شده است. برای بازگرداندن آن به حالت قابل استفاده لطفا گام‌های زیر را به ترتیب انجام دهید:"
:page/step "گام {1}"
:page/try "امتحان کنید"
:page/open-in-finder "باز کردن در پوشه"
:page/open-with-default-app "باز کردن با برنامه پیش‌فرض"
:page/make-public "عمومی ساختن برای انتشار"
:page/make-private "تبدیل به خصوصی"
:page/delete "حذف برگه"

View File

@@ -111,8 +111,6 @@
:page/backlinks "Rétro-lien"
:page/copy-page-url "Copier l'URL de la page"
:page/created-at "Créée le"
:page/open-in-finder "Ouvrir dans l'explorateur de fichiers"
:page/open-with-default-app "Ouvrir avec l'application par défaut"
:page/unfavorite "Retirer la page des favoris"
:page/updated-at "Mise à jour le"
:pdf/copy-ref "Copier la référence"

View File

@@ -90,8 +90,6 @@
:page/logseq-is-having-a-problem "Logseq mengalami masalah. Untuk mencoba mengembalikannya ke keadaan yang berfungsi, silakan coba langkah-langkah aman berikut ini secara berurutan:"
:page/step "Langkah {1}"
:page/try "Coba"
:page/open-in-finder "Buka dalam direktori"
:page/open-with-default-app "Buka dengan aplikasi default"
:page/make-public "Buat publik untuk dipublikasikan"
:page/make-private "Buat pribadi"
:page/delete "Hapus halaman"

View File

@@ -32,8 +32,6 @@
:left-side-bar/journals "Diario"
:left-side-bar/nav-favorites "Preferiti"
:left-side-bar/nav-recent-pages "Recenti"
:page/open-in-finder "Apri nella cartella"
:page/open-with-default-app "Apri con l'app predefinita"
:page/make-public "Segna come pubblico per la pubblicazione"
:page/make-private "Segna come privato"
:page/delete "Elimina pagina"

View File

@@ -99,8 +99,6 @@
:page/logseq-is-having-a-problem "Logseqになにか問題があります。きちんと動く状態に戻すため、以下の項目を上から順番に実行してください"
:page/step "ステップ{1}"
:page/try "試す"
:page/open-in-finder "ディレクトリで開く"
:page/open-with-default-app "既定のアプリで開く"
:page/make-public "パブリッシュのため公開する"
:page/make-private "非公開にする"
:page/delete "ページを削除"

View File

@@ -33,8 +33,6 @@
:left-side-bar/journals "일지"
:left-side-bar/nav-favorites "즐겨찾기"
:left-side-bar/nav-recent-pages "최근 페이지"
:page/open-in-finder "디렉토리에서 열기"
:page/open-with-default-app "기본 앱으로 열기"
:page/make-public "출판 전 공개 상태로 만들기"
:page/make-private "비공개 상태로 만들기"
:page/delete "페이지 삭제"

View File

@@ -36,8 +36,6 @@
:left-side-bar/journals "Dagbøker"
:left-side-bar/nav-favorites "Favoritter"
:left-side-bar/nav-recent-pages "Nylig"
:page/open-in-finder "Åpne i mappe"
:page/open-with-default-app "Åpne med forhåndsvalgt app"
:page/make-public "Gjør den offentlig for publisering"
:page/make-private "Gjør den privat"
:page/delete "Slett side"

View File

@@ -78,8 +78,6 @@
:page/delete "Verwijder pagina"
:page/make-private "Maak prive"
:page/make-public "Maak publiek"
:page/open-in-finder "Open in map"
:page/open-with-default-app "Open met standaard app"
:page/unfavorite "Pagina uit favorieten verwijderen"
:page/updated-at "Bijgewerkt op"
:pdf/copy-ref "Kopieer ref"

View File

@@ -35,8 +35,6 @@
:left-side-bar/journals "Dzienniki"
:left-side-bar/nav-favorites "Ulubione"
:left-side-bar/nav-recent-pages "Ostatnio odwiedzane"
:page/open-in-finder "Otwórz w przeglądarce plików"
:page/open-with-default-app "Otwórz w domyślnej aplikacji"
:page/make-public "Oznacz jako publiczną"
:page/make-private "Oznacz jako prywatną"
:page/delete "Usuń stronę"

View File

@@ -104,8 +104,6 @@
:page/try "Tentar"
:page/delete-confirmation "Você tem certeza que quer deletar essa página?"
:page/db-delete-confirmation "Você tem certeza que quer deletar essa página?"
:page/open-in-finder "Abrir no diretório"
:page/open-with-default-app "Abrir com o aplicativo padrão"
:page/make-public "Torná-la pública para publicação"
:page/make-private "Tornar privado"
:page/delete "Excluir página"

View File

@@ -43,8 +43,6 @@
:page/logseq-is-having-a-problem "Logseq está tendo um problema. Para tentar colocá-lo de volta em um estado de funcionamento, por favor tente os seguintes passos seguros em ordem:"
:page/step "Passo {1}"
:page/try "Tentar"
:page/open-in-finder "Abrir em pasta"
:page/open-with-default-app "Abrir com a aplicação predefinida"
:page/make-public "Tornar pública para publicação"
:page/make-private "Tornar privada"
:page/delete "Apagar página"

View File

@@ -50,8 +50,6 @@
:page/logseq-is-having-a-problem "У Logseq возникла проблема. Чтобы попытаться вернуть его в рабочее состояние, пожалуйста, попробуйте выполнить следующие безопасные шаги по порядку:"
:page/step "Шаг {1}"
:page/try "Попробовать"
:page/open-in-finder "Открыть в каталоге"
:page/open-with-default-app "Открыть в приложении по умолчанию"
:page/make-public "Сделать доступной для публикации"
:page/make-private "Сделать приватной"
:page/delete "Удалить страницу"

View File

@@ -95,8 +95,6 @@
:page/logseq-is-having-a-problem "Logseq má problém. Skúste tieto bezpečné kroky, aby ste ho dostali do funkčného stavu:"
:page/step "Krok {1}"
:page/try "Vyskúšať"
:page/open-in-finder "Otvoriť v adresári"
:page/open-with-default-app "Otvoriť v predvolenej aplikácii"
:page/make-public "Označiť stránku ako verejnú"
:page/make-private "Označiť stránku ako súkromnú"
:page/delete "Odstrániť stránku"

View File

@@ -99,8 +99,6 @@
:page/logseq-is-having-a-problem "Logseq'te bir sorun var. Tekrar çalışır duruma getirmek için lütfen aşağıdaki güvenli adımları sırayla deneyin:"
:page/step "{1}. Adım"
:page/try "Deneyin"
:page/open-in-finder "Dizini aç"
:page/open-with-default-app "Varsayılan uygulamayla aç"
:page/make-public "Yayımlamak için herkese açık hale getir"
:page/make-private "Özel yap"
:page/delete "Sayfayı sil"

View File

@@ -44,8 +44,6 @@
:page/logseq-is-having-a-problem "У Logseq виникла проблема. Щоб спробувати повернути його до робочого стану, виконайте такі безпечні кроки по порядку:"
:page/step "Крок {1}"
:page/try "Спробувати"
:page/open-in-finder "Відкрити у директорії"
:page/open-with-default-app "Відкрити за допомогою програми за умовчанням"
:page/make-public "Зробіти загальнодоступним для публікації"
:page/make-private "Зробити приватним"
:page/delete "Видалити сторінку"

View File

@@ -94,8 +94,6 @@
:left-side-bar/journals "日志"
:left-side-bar/nav-favorites "收藏页面"
:left-side-bar/nav-recent-pages "最近使用"
:page/open-in-finder "打开文件对应目录"
:page/open-with-default-app "用默认应用打开文件"
:page/make-public "导出 HTML 时发布本页面"
:page/make-private "导出 HTML 时取消发布本页面"
:page/delete "删除本页"

View File

@@ -44,8 +44,6 @@
:page/logseq-is-having-a-problem "Logseq 出了些問題。請按照以下安全步驟將其恢復到正常狀態:"
:page/step "步驟 {1}"
:page/try "嘗試"
:page/open-in-finder "開啟資料夾"
:page/open-with-default-app "使用預設應用程式開啟"
:page/make-public "將其公開讓所有人均可檢視"
:page/make-private "將其轉為私人"
:page/delete "刪除頁面"