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