miniblog

Miniblog: A command-line static blog system in Common Lisp
Log | Files | Refs | README | LICENSE

commit 128941562d9ed8c2e1a5c2fa838c3c62b95e7cb9
parent 3e1502d61ae7869727961a63279142386e122877
Author: Decay <decay@todayiwilllaunchmyinfantsonintoorbit.com>
Date:   Sat, 12 Sep 2020 23:35:56 -0700

Less mysterious refactoring of DB handling

Gradually starting to decouple the DB initialization and eventually
make it configurable.

Diffstat:
Msrc/db.lisp | 7++++++-
Msrc/miniblog.lisp | 4++--
Msrc/packages.lisp | 3++-
3 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/db.lisp b/src/db.lisp @@ -11,11 +11,16 @@ :accessor entry-content)) (:metaclass mito:dao-table-class)) +(defun init-tables () + "Initialize the DB schema. Currently just does the mito + yakshaving to create the BLOG-ENTRIES table." + (ensure-table-exists 'blog-entries)) + (defun init (&rest params) "Initialize the DB DAO. Consumes parameters identical to mito:connect-toplevel or sxql:connect" (apply #'connect-toplevel params) - (ensure-table-exists 'blog-entries)) + (init-tables)) (defun xform (entry) "Transform a blog-entries object into an idiomatic property list" diff --git a/src/miniblog.lisp b/src/miniblog.lisp @@ -263,11 +263,11 @@ (defun initialize () (init-tz) (set-config-and-defaults) - (make-generators) - (miniblog.db:init :sqlite3 :database-name (get-db-filename))) + (make-generators)) (defun miniblog (&key add get edit delete list start n regen-all help) (initialize) + (miniblog.db:init :sqlite3 :database-name (get-db-filename)) (cond (add (add-new regen-all)) (get (get-post get)) (edit (edit-post edit regen-all)) diff --git a/src/packages.lisp b/src/packages.lisp @@ -13,7 +13,8 @@ (defpackage :miniblog.db (:use :cl :mito :sxql) - (:export #:init #:add-entry #:get-entry #:with-entry-id + (:export #:init #:init-tables #:add-entry #:get-entry + #:with-entry-id #:get-entries #:update-entry #:delete-entry)) (defpackage :miniblog.content