Skip to content

Commit

Permalink
Now the user can choose directly the configuration file.
Browse files Browse the repository at this point in the history
  • Loading branch information
herdigiorgi committed Jun 14, 2015
1 parent c45d7be commit 30ff8f1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 18 deletions.
4 changes: 2 additions & 2 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 4 additions & 3 deletions src/coleslaw.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -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*))
Expand Down
17 changes: 4 additions & 13 deletions src/config.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -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*)))

0 comments on commit 30ff8f1

Please sign in to comment.