Skip to content

Commit

Permalink
Update lib to run with feat/db branch and ensure file graph still runs
Browse files Browse the repository at this point in the history
  • Loading branch information
logseq-cldwalker committed Oct 8, 2024
1 parent 0cb0063 commit f9a30b4
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 24 deletions.
3 changes: 1 addition & 2 deletions nbb.edn
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
{org.babashka/cli {:mvn/version "0.6.46"}
logseq/graph-parser
{:git/url "https://github.com/logseq/logseq"
:git/sha "82cf4d3c65acbf230a3170640fe271dd74095067"
:git/tag "0.9.8"
:git/sha "eed5c8bce43d5235dd1936e72d60fae2b0cd03bb"
:deps/root "deps/graph-parser"}
#_{:local/root "../logseq/deps/graph-parser"}}}
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
"url": "https://github.com/logseq/rdf-export/issues"
},
"homepage": "https://github.com/logseq/rdf-export#readme",
"devDependencies": {
"@logseq/nbb-logseq": "logseq/nbb-logseq#feat-db-v16"
},
"dependencies": {
"@logseq/nbb-logseq": "^1.2.168",
"mldoc": "^1.5.0",
"n3": "^1.16.3",
"turtle-validator": "^1.1.1"
Expand Down
24 changes: 12 additions & 12 deletions src/logseq/rdf_export.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ All of the above pages can be customized with query config options."
[clojure.edn :as edn]
[clojure.set :as set]
[datascript.core :as d]
[logseq.db.rules :as rules]
[logseq.db.frontend.rules :as rules]
[babashka.cli :as cli]
[logseq.graph-parser.cli :as gp-cli]
[logseq.rdf-export.config :as config]
Expand All @@ -23,18 +23,18 @@ All of the above pages can be customized with query config options."
(map
(fn [block]
(let [block-name (or (get-in block [:block/properties :title])
(:block/original-name block)
(:block/title block)
;; Use page name for non-journal pre-blocks
(when-not (get-in block [:block/page :block/journal?])
(get-in block [:block/page :block/original-name])))]
(get-in block [:block/page :block/title])))]
(cond->
(-> (:block/properties block)
;; TODO: Add proper tags support
(dissoc :title :tags)
((fn [x] (apply dissoc x exclude-properties)))
expand-entity-fn)
(some? block-name)
(assoc :block/original-name block-name))))
(assoc :block/title block-name))))
result))

(defn- page-url [page-name config]
Expand All @@ -49,8 +49,8 @@ All of the above pages can be customized with query config options."
[m
{:keys [url-property type-property classes-without-ids unique-id-properties] :as config}
property-map]
(if-let [subject (if (:block/original-name m)
(page-url (:block/original-name m) config)
(if-let [subject (if (:block/title m)
(page-url (:block/title m) config)
(some #(when-let [v (m %)]
(if (url? v) v (page-url v config)))
unique-id-properties))]
Expand All @@ -75,7 +75,7 @@ All of the above pages can be customized with query config options."
(defn- block->label-triple [block]
[(:url block)
"http://www.w3.org/2000/01/rdf-schema#label"
(:block/original-name block)])
(:block/title block)])

(defn- build-alias-triples
[ents config]
Expand All @@ -84,7 +84,7 @@ All of the above pages can be customized with query config options."
(mapcat #(map (fn [alias]
(block->label-triple
{:url (page-url alias config)
:block/original-name (:block/original-name %)}))
:block/title (:block/title %)}))
(:alias %)))))

(defn- add-class-instances [db config property-map {:keys [add-labels]}]
Expand Down Expand Up @@ -115,7 +115,7 @@ All of the above pages can be customized with query config options."
(vals rules/query-dsl-rules))
(map first)
(create-entities config))
built-in-properties {:block/original-name
built-in-properties {:block/title
{:url (if add-labels
"http://www.w3.org/2000/01/rdf-schema#label"
"https://schema.org/name")}
Expand All @@ -124,7 +124,7 @@ All of the above pages can be customized with query config options."
"http://www.w3.org/2002/07/owl#sameAs"
"https://schema.org/sameAs")}}
property-map (into built-in-properties
(map (juxt (comp keyword :block/original-name) identity)
(map (juxt (comp keyword :block/title) identity)
properties))]
(set
(concat
Expand All @@ -134,8 +134,8 @@ All of the above pages can be customized with query config options."
(when add-labels
(map (fn [[k v]]
(block->label-triple
{:url (:url v) :block/original-name (name k)}))
(dissoc built-in-properties :block/original-name)))))))
{:url (:url v) :block/title (name k)}))
(dissoc built-in-properties :block/title)))))))

(defn- add-quads [writer quads]
(doseq [[q1 q2 q3]
Expand Down
2 changes: 1 addition & 1 deletion src/logseq/rdf_export/config.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
:in $ %
:where
(page-property ?b :type "Class")
[?b :block/original-name ?n]
[?b :block/title ?n]
(page-property ?b2 :type ?n)]
;; Query to fetch additional instances.
;; Useful for instances that aren't fetched by :class-instances-query
Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/docs-with-labels.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,6 @@ d:Rectangle <http://www.w3.org/2000/01/rdf-schema#label> "Whiteboard/Tool/Shape/
d:Search a d:Feature;
<http://www.w3.org/2000/01/rdf-schema#label> "Search";
d:platforms <https://docs.logseq.com/#/page/All%20Platforms>.
d:Settings a <https://docs.logseq.com/#/page/UI%20Element>;
<http://www.w3.org/2000/01/rdf-schema#label> "Settings".
d:Shape <http://www.w3.org/2000/01/rdf-schema#label> "Whiteboard/Tool/Shape".
d:Shapes <http://www.w3.org/2000/01/rdf-schema#label> "Whiteboard/Tool/Shape".
<https://docs.logseq.com/#/page/Snap%20to%20grid> a d:Feature;
Expand Down Expand Up @@ -436,6 +434,8 @@ d:sameAs a d:Property;
<http://www.w3.org/2000/01/rdf-schema#label> "sameAs";
d:rangeIncludes d:Uri;
s:url <https://www.w3.org/2002/07/owl#sameAs>.
d:settings a <https://docs.logseq.com/#/page/UI%20Element>;
<http://www.w3.org/2000/01/rdf-schema#label> "settings".
d:slide a d:Feature;
<http://www.w3.org/2000/01/rdf-schema#label> "slide";
<http://www.w3.org/2002/07/owl#sameAs> d:Presentation;
Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/docs.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,6 @@ d:Query a d:Command;
d:Search a d:Feature;
d:platforms <https://docs.logseq.com/#/page/All%20Platforms>;
s:name "Search".
d:Settings a <https://docs.logseq.com/#/page/UI%20Element>;
s:name "Settings".
<https://docs.logseq.com/#/page/Snap%20to%20grid> a d:Feature;
d:initial-version "0.9.10";
d:platforms <https://docs.logseq.com/#/page/All%20Platforms>;
Expand Down Expand Up @@ -501,6 +499,8 @@ d:sameAs a d:Property;
s:description "Indicates that two URIs are equivalent";
s:name "sameAs";
s:url <https://www.w3.org/2002/07/owl#sameAs>.
d:settings a <https://docs.logseq.com/#/page/UI%20Element>;
s:name "settings".
d:slide a d:Feature;
d:platforms <https://docs.logseq.com/#/page/All%20Platforms>;
s:name "slide";
Expand Down
7 changes: 3 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
# yarn lockfile v1


"@logseq/nbb-logseq@^1.2.168":
version "1.2.168"
resolved "https://registry.yarnpkg.com/@logseq/nbb-logseq/-/nbb-logseq-1.2.168.tgz#e4120c4a7eb6c80737473292c1e20919b4453c91"
integrity sha512-lgZuAhck/74+9mT4vr6jVLkPcyRA/RO8ApBizq3d1L6LsPlPjdRp4nIaC2I1/p/AaIIB5vP89pMpqZfVsIHHQg==
"@logseq/nbb-logseq@logseq/nbb-logseq#feat-db-v16":
version "1.2.173-feat-db-v16"
resolved "https://codeload.github.com/logseq/nbb-logseq/tar.gz/5c52c2869da240283db96cd13366e45e532c5d29"
dependencies:
import-meta-resolve "^2.1.0"

Expand Down

0 comments on commit f9a30b4

Please sign in to comment.