Improve env
This commit is contained in:
parent
fff8929b0e
commit
bf914c8451
7 changed files with 32 additions and 5 deletions
1
.env.example
Normal file
1
.env.example
Normal file
|
@ -0,0 +1 @@
|
||||||
|
HP_ENV=
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,3 +1,4 @@
|
||||||
.qlot
|
.qlot
|
||||||
bin/tailwindcss
|
bin/tailwindcss
|
||||||
public/style/dist.css
|
public/style/dist.css
|
||||||
|
.env
|
||||||
|
|
3
qlfile
3
qlfile
|
@ -8,4 +8,5 @@ ql clack
|
||||||
git hsx https://github.com/skyizwhite/hsx.git
|
git hsx https://github.com/skyizwhite/hsx.git
|
||||||
git ningle-fbr https://github.com/skyizwhite/ningle-fbr.git
|
git ningle-fbr https://github.com/skyizwhite/ningle-fbr.git
|
||||||
git lack-mw https://github.com/skyizwhite/lack-mw.git
|
git lack-mw https://github.com/skyizwhite/lack-mw.git
|
||||||
git trivial-backtrace https://github.com/hraban/trivial-backtrace.git
|
git trivial-backtrace https://github.com/hraban/trivial-backtrace.git
|
||||||
|
ql cl-dotenv
|
||||||
|
|
|
@ -46,3 +46,7 @@
|
||||||
(:class qlot/source/git:source-git
|
(:class qlot/source/git:source-git
|
||||||
:initargs (:remote-url "https://github.com/hraban/trivial-backtrace.git")
|
:initargs (:remote-url "https://github.com/hraban/trivial-backtrace.git")
|
||||||
:version "git-7f90b4a4144775cca0728791e4b92ac2557b07a1"))
|
:version "git-7f90b4a4144775cca0728791e4b92ac2557b07a1"))
|
||||||
|
("cl-dotenv" .
|
||||||
|
(:class qlot/source/ql:source-ql
|
||||||
|
:initargs (:%version :latest)
|
||||||
|
:version "ql-2018-10-18"))
|
||||||
|
|
14
src/env.lisp
Normal file
14
src/env.lisp
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
(defpackage #:hp/env
|
||||||
|
(:use #:cl)
|
||||||
|
(:import-from #:cl-dotenv
|
||||||
|
#:load-env)
|
||||||
|
(:export #:hp-env))
|
||||||
|
(in-package #:hp/env)
|
||||||
|
|
||||||
|
(load-env (merge-pathnames "./.env"))
|
||||||
|
|
||||||
|
(defmacro env-var (name var)
|
||||||
|
`(defun ,name ()
|
||||||
|
(or (uiop:getenv ,var) "")))
|
||||||
|
|
||||||
|
(env-var hp-env "HP_ENV")
|
|
@ -3,6 +3,8 @@
|
||||||
#:hsx)
|
#:hsx)
|
||||||
(:import-from #:trivial-backtrace
|
(:import-from #:trivial-backtrace
|
||||||
#:print-backtrace)
|
#:print-backtrace)
|
||||||
|
(:import-from #:hp/env
|
||||||
|
#:hp-env)
|
||||||
(:export #:*recoverer*))
|
(:export #:*recoverer*))
|
||||||
(in-package #:hp/middlewares/recoverer)
|
(in-package #:hp/middlewares/recoverer)
|
||||||
|
|
||||||
|
@ -14,7 +16,7 @@
|
||||||
(body
|
(body
|
||||||
(main
|
(main
|
||||||
(h1 "500 Internal Server Error")
|
(h1 "500 Internal Server Error")
|
||||||
(when (string= (uiop:getenv "HP_ENV") "dev")
|
(when (string= (hp-env) "dev")
|
||||||
(hsx
|
(hsx
|
||||||
(pre
|
(pre
|
||||||
(code (print-backtrace condition :output nil))))))))))
|
(code (print-backtrace condition :output nil))))))))))
|
||||||
|
|
|
@ -4,11 +4,15 @@
|
||||||
#:trivia)
|
#:trivia)
|
||||||
(:import-from :jingle)
|
(:import-from :jingle)
|
||||||
(:import-from #:hsx/element
|
(:import-from #:hsx/element
|
||||||
#:element))
|
#:element)
|
||||||
|
(:import-from #:hp/env
|
||||||
|
#:hp-env))
|
||||||
(in-package #:hp/renderer)
|
(in-package #:hp/renderer)
|
||||||
|
|
||||||
(defun bust-cache (url)
|
(defun bust-cache (url)
|
||||||
(format nil "~a?v=~a" url (get-universal-time)))
|
(format nil "~a?v=~a" url (if (string= (hp-env) "dev")
|
||||||
|
(get-universal-time)
|
||||||
|
#.(get-universal-time))))
|
||||||
|
|
||||||
(defparameter *metadata-template*
|
(defparameter *metadata-template*
|
||||||
(list :title (lambda (title)
|
(list :title (lambda (title)
|
||||||
|
@ -70,7 +74,7 @@
|
||||||
|
|
||||||
(defmethod jingle:process-response ((app jingle:app) result)
|
(defmethod jingle:process-response ((app jingle:app) result)
|
||||||
(jingle:set-response-header :content-type "text/html; charset=utf-8")
|
(jingle:set-response-header :content-type "text/html; charset=utf-8")
|
||||||
(when (string= (uiop:getenv "HP_ENV") "dev")
|
(when (string= (hp-env) "dev")
|
||||||
(jingle:set-response-header :cache-control "no-store, no-cache, must-revalidate")
|
(jingle:set-response-header :cache-control "no-store, no-cache, must-revalidate")
|
||||||
(jingle:set-response-header :pragma "no-cache")
|
(jingle:set-response-header :pragma "no-cache")
|
||||||
(jingle:set-response-header :expires "0"))
|
(jingle:set-response-header :expires "0"))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue