Now the user can choose directly the configuration file.

This commit is contained in:
digiorgi 2015-06-14 13:48:57 -04:00
parent c45d7be575
commit 30ff8f17df
3 changed files with 10 additions and 18 deletions

View file

@ -2,8 +2,8 @@
## Where ## Where
Coleslaw needs a `.coleslawrc` file to operate properly. That file is usually located at Coleslaw needs a configuration file to operate properly. It can has any name and
$HOME/.coleslawrc but may also be placed in the blog repo itself. is usally placed in the blog repo itself.
## What ## What

View file

@ -3,10 +3,11 @@
(defvar *last-revision* nil (defvar *last-revision* nil
"The git revision prior to the last push. For use with GET-UPDATED-FILES.") "The git revision prior to the last push. For use with GET-UPDATED-FILES.")
(defun main (repo-dir &optional oldrev) (defun main (&optional (config-file #p"~/.coleslawrc") oldrev)
"Load the user's config file, then compile and deploy the blog stored "Load the user's config file, then compile and deploy the blog stored
in REPO-DIR. Optionally, OLDREV is the revision prior to the last push." where the CONF-FILE is stored. Optionally, OLDREV is the revision prior to
(load-config repo-dir) the last push."
(load-config config-file)
(setf *last-revision* oldrev) (setf *last-revision* oldrev)
(load-content) (load-content)
(compile-theme (theme *config*)) (compile-theme (theme *config*))

View file

@ -69,19 +69,10 @@ are in the plugins folder in coleslaw's source directory."
(destructuring-bind (name &rest args) plugin (destructuring-bind (name &rest args) plugin
(enable-plugin name args)))) (enable-plugin name args))))
(defun discover-config-path (repo-path) (defun load-config (config-file)
"Check the supplied REPO-PATH for a .coleslawrc and if one "Load CONFIG-FILE, the coleslaw configuration file."
doesn't exist, use the .coleslawrc in the home directory." (with-open-file (in config-file :external-format :utf-8)
(let ((repo-config (rel-path repo-path ".coleslawrc")))
(if (file-exists-p repo-config)
repo-config
(rel-path (user-homedir-pathname) ".coleslawrc"))))
(defun load-config (&optional (repo-dir ""))
"Find and load the coleslaw configuration from .coleslawrc. REPO-DIR will be
preferred over the home directory if provided."
(with-open-file (in (discover-config-path repo-dir) :external-format :utf-8)
(let ((config-form (read in))) (let ((config-form (read in)))
(setf *config* (construct 'blog config-form) (setf *config* (construct 'blog config-form)
(repo-dir *config*) repo-dir))) (repo-dir *config*) (directory-namestring config-file))))
(load-plugins (plugins *config*))) (load-plugins (plugins *config*)))