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"))
|
(setv (get hy-env "PATH") (+ (get hy-env "PATH") ":./www/site/scripts"))
|
||||||
|
|
||||||
(defn execute-bash [data]
|
(defn execute-bash [data]
|
||||||
(sub r"\$\[(.*?)\]" (fn [sequence]
|
(sub r"\$\[(.*?)\]" (fn [sequence]
|
||||||
(. (check-output (.group sequence 1) :shell True :executable "/bin/bash" :env hy-env) (decode) (strip)))
|
(. (check-output (.group sequence 1) :shell True :executable "bash" :env hy-env) (decode) (strip)))
|
||||||
data))
|
data))
|
||||||
|
|
||||||
(defn parse-html-file [path #** kwargs]
|
(defn parse-html-file [path #** kwargs]
|
||||||
(with [f (open path "r")]
|
(with [f (open path "r")]
|
||||||
(setv data (.read f)))
|
(setv data (.read f)))
|
||||||
|
|
||||||
(for [[k v] (.items kwargs)]
|
(for [[k v] (.items kwargs)]
|
||||||
(setv data (.replace data f"{"{"}{k}{"}"}" (str v))))
|
(setv data (.replace data f"{"{"}{k}{"}"}" (str v))))
|
||||||
|
|
||||||
(execute-bash data))
|
(execute-bash data))
|
||||||
|
|
||||||
(defn send-raw-file [path]
|
(defn send-raw-file [path]
|
||||||
(setv [mime-type _] (guess-type path))
|
(setv [mime-type _] (guess-type path))
|
||||||
|
|
||||||
(when (not mime-type)
|
(when (not mime-type)
|
||||||
(setv mime-type "text/plain"))
|
(setv mime-type "text/plain"))
|
||||||
|
|
||||||
(with [f (open path "rb")]
|
(with [f (open path "rb")]
|
||||||
(setv data (.read f)))
|
(setv data (.read f)))
|
||||||
|
|
||||||
(return #({"Content-Type" mime-type "Cache-Control" "max-age=300, stale-while-revalidate=3600"} data)))
|
(return #({"Content-Type" mime-type "Cache-Control" "max-age=300, stale-while-revalidate=3600"} data)))
|
||||||
|
@ -8,4 +8,4 @@
|
|||||||
(setv env hy-env)
|
(setv env hy-env)
|
||||||
(setv (get env "PATH") (+ (get hy-env "PATH") ":./scripts"))
|
(setv (get env "PATH") (+ (get hy-env "PATH") ":./scripts"))
|
||||||
|
|
||||||
(print (sub r"\$\[(.*?)\]" (fn [sequence] (. (check-output (.group sequence 1) :shell True :executable "/bin/bash" :env env) (decode) (strip))) (with [fp (open (get argv 1) "r")] (.read fp))))
|
(print (sub r"\$\[(.*?)\]" (fn [sequence] (. (check-output (.group sequence 1) :shell True :executable "bash" :env env) (decode) (strip))) (with [fp (open (get argv 1) "r")] (.read fp))))
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
path=$1
|
path=$1
|
||||||
caption=$2
|
caption=$2
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
tmpfile=$(mktemp)
|
tmpfile=$(mktemp)
|
||||||
|
|
||||||
timeout 0.6s nvim "$1" -c "set nonu | set nornu" -c "autocmd LspAttach * execute 'TOhtml | w! ${tmpfile} | qa!'" >/dev/null || nvim "$1" -c "set nonu | set nornu" -c "TOhtml | w! ${tmpfile} | qa!" >/dev/null
|
timeout 0.6s nvim "$1" -c "set nonu | set nornu" -c "autocmd LspAttach * execute 'TOhtml | w! ${tmpfile} | qa!'" >/dev/null || nvim "$1" -c "set nonu | set nornu" -c "TOhtml | w! ${tmpfile} | qa!" >/dev/null
|
||||||
|
Reference in New Issue
Block a user