This commit is contained in:
@@ -11,8 +11,7 @@
|
|||||||
::doerg-parser]))
|
::doerg-parser]))
|
||||||
|
|
||||||
(s/def ::file
|
(s/def ::file
|
||||||
#(or (instance? java.io.File %)
|
(s/conformer (comp fs/file fs/absolutize fs/expand-home)))
|
||||||
(string? %)))
|
|
||||||
|
|
||||||
(s/def ::executable #(or (fs/executable? %)
|
(s/def ::executable #(or (fs/executable? %)
|
||||||
(and (fs/relative? %)
|
(and (fs/relative? %)
|
||||||
|
|||||||
@@ -4,11 +4,14 @@
|
|||||||
[net.deertopia.doerg.config :as doerg]))
|
[net.deertopia.doerg.config :as doerg]))
|
||||||
|
|
||||||
(s/def ::config
|
(s/def ::config
|
||||||
(s/keys :req [::state-directory]))
|
(s/keys :req [::state-directory
|
||||||
|
::org-roam-db-path]))
|
||||||
|
|
||||||
(def default
|
(def default
|
||||||
{::state-directory (fs/xdg-state-home "doerg-publisher")})
|
{::state-directory (fs/xdg-state-home "doerg-publisher")
|
||||||
|
::org-roam-db-path (fs/file (fs/home) ".cache" "emacs" "org-roam.db")})
|
||||||
|
|
||||||
(def ^:dynamic *cfg* default)
|
(def ^:dynamic *cfg* default)
|
||||||
|
|
||||||
(s/def ::state-directory ::doerg/file)
|
(s/def ::state-directory ::doerg/file)
|
||||||
|
(s/def ::org-roam-db-path ::doerg/file)
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
(ns net.deertopia.publisher.node
|
(ns net.deertopia.publisher.roam
|
||||||
(:require [next.jdbc :as sql]
|
(:require [next.jdbc :as sql]
|
||||||
[net.deertopia.publisher.config :as cfg]
|
[net.deertopia.publisher.config :as cfg]
|
||||||
[net.deertopia.publisher.slug :as slug]
|
[net.deertopia.publisher.slug :as slug]
|
||||||
[babashka.fs :as fs]
|
[babashka.fs :as fs]
|
||||||
[elisp.instaparse :as elisp])
|
[net.deertopia.publisher.elisp :as elisp])
|
||||||
(:import (java.util UUID)))
|
(:import (java.util UUID)))
|
||||||
|
|
||||||
;;; Global database
|
;;; Global database
|
||||||
|
|
||||||
(defonce ^:dynamic *use-db-cache?* true)
|
(defonce ^:dynamic *use-db-cache?* true)
|
||||||
|
|
||||||
(def db-path (-> (cfg/get :org-roam :database)
|
(def db-path (-> cfg/*cfg* ::cfg/org-roam-db-path
|
||||||
fs/expand-home str))
|
fs/expand-home str))
|
||||||
|
|
||||||
(def db {:dbtype "sqlite"
|
(def db {:dbtype "sqlite"
|
||||||
@@ -69,20 +69,24 @@
|
|||||||
"Return the node associated with `this` or nil."))
|
"Return the node associated with `this` or nil."))
|
||||||
|
|
||||||
(extend-protocol GetNode
|
(extend-protocol GetNode
|
||||||
|
String
|
||||||
|
(get-node [this]
|
||||||
|
(or (some-> this slug/from-string get-node)
|
||||||
|
(some-> this parse-uuid get-node)))
|
||||||
java.util.UUID
|
java.util.UUID
|
||||||
(get-node [this]
|
(get-node [this]
|
||||||
(make-node this))
|
(make-node this))
|
||||||
net.deertopia.publish.slug.Slug
|
net.deertopia.publisher.slug.Slug
|
||||||
(get-node [this]
|
(get-node [this]
|
||||||
(-> this slug/to-uuid make-node)))
|
(-> this slug/to-uuid make-node)))
|
||||||
|
|
||||||
(comment
|
(comment
|
||||||
(let [n (make-node (slug/to-uuid (slug/->Slug "68XqhHerTWCbE--RYLEdHw")))]
|
(def node (get-node "68XqhHerTWCbE--RYLEdHw"))
|
||||||
(fetch-with-cache
|
(fetch-with-cache
|
||||||
n :title
|
node :title
|
||||||
#(do (println "fetch")
|
#(do (println "fetch")
|
||||||
(sql/execute-one! ds ["select title from nodes where id = ?"
|
(sql/execute-one! ds ["select title from nodes where id = ?"
|
||||||
(print-elisp-string (:id %))])))))
|
(print-elisp-string (:id %))]))))
|
||||||
|
|
||||||
|
|
||||||
;;; Node operations
|
;;; Node operations
|
||||||
Reference in New Issue
Block a user