forked from nat/natalieee.net
make scripts and script execution nix compatible
This commit is contained in:
@ -6,27 +6,27 @@
|
||||
|
||||
(setv (get hy-env "PATH") (+ (get hy-env "PATH") ":./www/site/scripts"))
|
||||
|
||||
(defn execute-bash [data]
|
||||
(sub r"\$\[(.*?)\]" (fn [sequence]
|
||||
(. (check-output (.group sequence 1) :shell True :executable "/bin/bash" :env hy-env) (decode) (strip)))
|
||||
(defn execute-bash [data]
|
||||
(sub r"\$\[(.*?)\]" (fn [sequence]
|
||||
(. (check-output (.group sequence 1) :shell True :executable "bash" :env hy-env) (decode) (strip)))
|
||||
data))
|
||||
|
||||
(defn parse-html-file [path #** kwargs]
|
||||
(with [f (open path "r")]
|
||||
(setv data (.read f)))
|
||||
|
||||
|
||||
(for [[k v] (.items kwargs)]
|
||||
(setv data (.replace data f"{"{"}{k}{"}"}" (str v))))
|
||||
|
||||
|
||||
(execute-bash data))
|
||||
|
||||
(defn send-raw-file [path]
|
||||
(setv [mime-type _] (guess-type path))
|
||||
|
||||
|
||||
(when (not mime-type)
|
||||
(setv mime-type "text/plain"))
|
||||
|
||||
|
||||
(with [f (open path "rb")]
|
||||
(setv data (.read f)))
|
||||
|
||||
|
||||
(return #({"Content-Type" mime-type "Cache-Control" "max-age=300, stale-while-revalidate=3600"} data)))
|
||||
|
Reference in New Issue
Block a user