commit a1dddc02f4f698c6595637dd55883d12ab7374a2
parent 902f0b869105c6a2ff900bc3a6f3385761cd68d0
Author: Decay <decay@todayiwilllaunchmyinfantsonintoorbit.com>
Date: Tue, 6 Oct 2020 18:04:26 -0700
Make DB configuration configuration in .miniblogrc
Diffstat:
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/src/miniblog.lisp b/src/miniblog.lisp
@@ -13,6 +13,7 @@
; If it's set to a string in .miniblogrc, will be
; translated with uiop:parse-native-namestring
(defvar *root-uri*) ; Absolute or relative root uri, defaults to "~username"
+(defvar *db-config*) ; Database configuration, defaults to sqlite3 ~/.miniblog.db
(defvar *generator*) ; Function to generate post pages, see content.lisp
(defvar *page-generator*) ; Function to generate hierarchical pages, see content.lisp
(defvar *rss-generator*) ; Function to generate RSS feed, see content.lisp
@@ -458,12 +459,18 @@
(defun init-tz ()
(reread-timezone-repository))
+(defun get-db-filename ()
+ (namestring (merge-pathnames
+ (user-homedir-pathname)
+ (make-pathname :name ".miniblog" :type "db"))))
+
(defun set-config-and-defaults ()
(setf *root-uri* (format nil "/~~~a/" (get-username)))
(setf *public-html*
(merge-pathnames
(make-pathname :directory '(:relative "public_html"))
(user-homedir-pathname)))
+ (setf *db-config* (list :sqlite3 :database-name (get-db-filename)))
(with-open-file (config
(merge-pathnames
(make-pathname :name ".miniblogrc")
@@ -474,11 +481,6 @@
(if (stringp *public-html*)
(setf *public-html* (uiop:parse-native-namestring (uiop:native-namestring *public-html*)))))
-(defun get-db-filename ()
- (namestring (merge-pathnames
- (user-homedir-pathname)
- (make-pathname :name ".miniblog" :type "db"))))
-
(defun initialize ()
(init-tz)
(set-config-and-defaults)
@@ -487,7 +489,7 @@
(defun miniblog (&key add get edit delete list start n page move uri children-to-root regen-all help)
(declare (ignore help))
(initialize)
- (miniblog.db:init :sqlite3 :database-name (get-db-filename))
+ (apply #'miniblog.db:init *db-config*)
(let ((entry-type (if page :page :post)))
(cond (add (add-entry entry-type uri regen-all))
(get (get-entry entry-type get))