You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
76 lines
2.8 KiB
76 lines
2.8 KiB
(in-package #:cl-user) |
|
(defpackage rails-to-caveman.config |
|
(:use #:cl) |
|
(:import-from #:envy |
|
#:config-env-var |
|
#:defconfig) |
|
(:export #:config |
|
#:*application-root* |
|
#:*static-directory* |
|
#:*template-directory* |
|
#:appenv |
|
#:developmentp |
|
#:productionp)) |
|
(in-package #:rails-to-caveman.config) |
|
|
|
(setf (config-env-var) "APP_ENV") |
|
|
|
(defparameter *application-root* (asdf:system-source-directory :rails-to-caveman)) |
|
(defparameter *static-directory* (merge-pathnames #P"static/" *application-root*)) |
|
(defparameter *template-directory* (merge-pathnames #P"templates/" *application-root*)) |
|
|
|
(defconfig :common |
|
#| CHANGED DATABASE FROM IN-MEMORY(CHAPTER 4) |
|
============================================== |
|
Changed the database name from ':memory:' to 'rails-to-caveman' |
|
in Chapter 4. Be default, Caveman sets the database to |
|
'in-memory'. You need to override this everytime you want to |
|
your a persistent database in your app. |
|
|
|
You can name your database whatever you want. I have just went |
|
with 'rails-to-caveman' because the tutorial said so. |
|
|# |
|
|
|
#| EXCERPT TAKEN FROM TUTORIAL (CHAPTER 4): |
|
============================================ |
|
Initially: I set the database-name to “your-app”, but later when I |
|
tried to access the database, I got angry with CAN'T OPEN. So I |
|
changed the name to “your_app” and it worked fine. Apparently, words |
|
separated by . Dashes Are Capitalized At The Beginning . The Name |
|
Specified In The Code Here Is "Your-App", But The Registered File |
|
Name Is "Your-App" However MITO:CONNECT-TOPLEVEL, If You |
|
Specify "Your-App": Database-Name, The Case conversion of the |
|
implicit reason is not performed and the file "your-app" is searched |
|
for in a case-sensitive manner, resulting in an error. Here, for |
|
safety, the database name is defined in camel case without symbols. |
|
|
|
The database file is created in the current directory. If you don't |
|
like this, you can specify the absolute path for: |
|
DATABASE-NAME. *APPLICATION-ROOT* The variable is created DEFCONFIG, |
|
the argument to is :DATABASE-NAME(DATABASE-PATH), and there is |
|
also a "db "directory in the project directory, so I don't wonder if |
|
it will do it well. I think it's unfriendly to have no documentation. |
|
|# |
|
`(:databases ((:maindb :sqlite3 :database-name ,(merge-pathnames #P"db/rails_to_caveman.db" |
|
*application-root*))))) |
|
|
|
(defconfig |development| |
|
'()) |
|
|
|
(defconfig |production| |
|
'()) |
|
|
|
(defconfig |test| |
|
'()) |
|
|
|
(defun config (&optional key) |
|
(envy:config #.(package-name *package*) key)) |
|
|
|
(defun appenv () |
|
(uiop:getenv (config-env-var #.(package-name *package*)))) |
|
|
|
(defun developmentp () |
|
(string= (appenv) "development")) |
|
|
|
(defun productionp () |
|
(string= (appenv) "production"))
|
|
|