Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added config variations #82

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default value should be mentioned/kept though.

Also typos, "usually" and "have" instead of "has".


## 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*)))