Now the user can choose directly the configuration file.
This commit is contained in:
parent
c45d7be575
commit
30ff8f17df
3 changed files with 10 additions and 18 deletions
|
@ -2,8 +2,8 @@
|
|||
|
||||
## Where
|
||||
|
||||
Coleslaw needs a `.coleslawrc` file to operate properly. That file is usually located at
|
||||
$HOME/.coleslawrc but may also be placed in the blog repo itself.
|
||||
Coleslaw needs a configuration file to operate properly. It can has any name and
|
||||
is usally placed in the blog repo itself.
|
||||
|
||||
## What
|
||||
|
||||
|
|
|
@ -3,10 +3,11 @@
|
|||
(defvar *last-revision* nil
|
||||
"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
|
||||
in REPO-DIR. Optionally, OLDREV is the revision prior to the last push."
|
||||
(load-config repo-dir)
|
||||
where the CONF-FILE is stored. Optionally, OLDREV is the revision prior to
|
||||
the last push."
|
||||
(load-config config-file)
|
||||
(setf *last-revision* oldrev)
|
||||
(load-content)
|
||||
(compile-theme (theme *config*))
|
||||
|
|
|
@ -69,19 +69,10 @@ are in the plugins folder in coleslaw's source directory."
|
|||
(destructuring-bind (name &rest args) plugin
|
||||
(enable-plugin name args))))
|
||||
|
||||
(defun discover-config-path (repo-path)
|
||||
"Check the supplied REPO-PATH for a .coleslawrc and if one
|
||||
doesn't exist, use the .coleslawrc in the home directory."
|
||||
(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)
|
||||
(defun load-config (config-file)
|
||||
"Load CONFIG-FILE, the coleslaw configuration file."
|
||||
(with-open-file (in config-file :external-format :utf-8)
|
||||
(let ((config-form (read in)))
|
||||
(setf *config* (construct 'blog config-form)
|
||||
(repo-dir *config*) repo-dir)))
|
||||
(repo-dir *config*) (directory-namestring config-file))))
|
||||
(load-plugins (plugins *config*)))
|
||||
|
|
Loading…
Add table
Reference in a new issue