5 Commits

12 changed files with 44 additions and 100 deletions

27
flake.lock generated
View File

@ -1,27 +0,0 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1747542820,
"narHash": "sha256-GaOZntlJ6gPPbbkTLjbd8BMWaDYafhuuYRNrxCGnPJw=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "292fa7d4f6519c074f0a50394dbbe69859bb6043",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

View File

@ -1,39 +0,0 @@
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
};
outputs =
{ self, nixpkgs }:
let
pkgs = nixpkgs.legacyPackages.x86_64-linux;
in
with pkgs;
{
devShells.x86_64-linux.default = mkShell {
buildInputs = with python312Packages; [
hy
(buildPythonPackage rec {
pname = "hyrule";
version = "1.0.0";
src = fetchPypi {
inherit pname version;
hash = "sha256-SZyFjXNs6thVWhKbajYelY0DoRYqrcCQcdKMNC5t6Og=";
};
propagatedBuildInputs = [
pip
wheel
hy
];
})
bleach
pyaml
requests
requests_toolbelt
validators
];
};
};
}

View File

@ -1,7 +0,0 @@
hy>=1
hyrule>=1
bleach>=6.2.0
pyaml>=25.1.0
requests>=2.32.3
requests-toolbelt>=1
validators>=0.34.0

View File

@ -8,7 +8,7 @@
(defn execute-bash [data] (defn execute-bash [data]
(sub r"\$\[(.*?)\]" (fn [sequence] (sub r"\$\[(.*?)\]" (fn [sequence]
(. (check-output (.group sequence 1) :shell True :executable "bash" :env hy-env) (decode) (strip))) (. (check-output (.group sequence 1) :shell True :executable "/bin/bash" :env hy-env) (decode) (strip)))
data)) data))
(defn parse-html-file [path #** kwargs] (defn parse-html-file [path #** kwargs]

View File

@ -1,26 +1,38 @@
(import hyrule.collections [assoc]) (import isal.igzip [compress :as gzip])
(import isal.isal_zlib [compress :as zstd])
(defn send-code [code] (import hyrule.collections [assoc])
(require hyrule.control [branch])
(defn pack-code [code]
(.encode f"HTTP/1.1 {code}\r\n" "utf-8")) (.encode f"HTTP/1.1 {code}\r\n" "utf-8"))
(defn send-headers [headers] (defn pack-headers [headers]
(.encode (+ (.join "\r\n" (lfor [k v] (.items headers) f"{k}: {v}")) "\r\n\r\n") "utf-8")) (.encode (+ (.join "\r\n" (lfor [k v] (.items headers) f"{k}: {v}")) "\r\n\r\n") "utf-8"))
(defn send-body [body] (defn send [[code 200] [headers None] [body ""] [request-headers None]]
(cond (when (is headers None)
(setv headers {}))
(setv body (cond
(isinstance body bytes) body (isinstance body bytes) body
(isinstance body str) (.encode body "utf-8"))) (isinstance body str) (.encode body "utf-8")))
(defn send [[code 200] [headers None] [body ""]] (when request-headers
(when (is headers None) (when (.get request-headers "Accept-Encoding")
(setv headers {})) (branch (in it (.get request-headers "Accept-Encoding"))
"zstd" (do
(setv (get headers "Accept-Encoding") "gzip")
(setv body (zstd body)))
"gzip" (do
(setv (get headers "Accept-Encoding") "gzip")
(setv body (gzip body))))))
(assoc headers "WHAT...-your-trans-gener..." "that is so cool...") (assoc headers "WHAT...-your-trans-gener..." "that is so cool...")
(when (not-in "Content-Type" headers) (when (not-in "Content-Type" headers)
(assoc headers "Content-Type" "text/html")) (assoc headers "Content-Type" "text/html"))
(+ (+
(send-code code) (pack-code code)
(send-headers headers) (pack-headers headers)
(send-body body))) body))

View File

@ -39,7 +39,7 @@
True (get address 0))) f": {(. parsed-request (get "method"))} {(. parsed-request (get "route") (get "path"))}")) True (get address 0))) f": {(. parsed-request (get "method"))} {(. parsed-request (get "route") (get "path"))}"))
(setv response (match-request parsed-request)) (setv response (match-request parsed-request))
(.sendall client-socket (http.response.send #** response)) (.sendall client-socket (http.response.send :request-headers (.get parsed-request "headers") #** response))
(except [e Exception] (except [e Exception]
(.warn log (format-exc)) (.warn log (format-exc))

View File

@ -1,4 +1,4 @@
#!/usr/bin/env bash #!/bin/bash
mkdir data mkdir data
(cd src; hy build.hy) (cd src; hy build.hy)
rm -rf site/html rm -rf site/html

View File

@ -64,10 +64,15 @@ specific:
src: //tasiaiso.vulpecula.zone/images/badges/tasiaiso.png src: //tasiaiso.vulpecula.zone/images/badges/tasiaiso.png
alt: tasia's 88x31 alt: tasia's 88x31
# does not 301 to https if requested with http
- host: //www.31a05b.net/ - host: //www.31a05b.net/
src: https://www.31a05b.net/a/8831/31a05b.png src: https://www.31a05b.net/a/8831/31a05b.png
alt: 31A05B9C's random site alt: 31A05B9C's random site
- host: //bunbun.dev/
src: //bunbun.dev/assets/88x31s/bunbun.dev.gif
alt: bunbun.dev
general: general:
- src: assets/88x31/e2vial-88x31.gif - src: assets/88x31/e2vial-88x31.gif
alt: an estrogen vial spinning next to the text "powered by estrogen" alt: an estrogen vial spinning next to the text "powered by estrogen"

View File

@ -15,7 +15,7 @@
(h2 "site info" ~(run "make-footnote \"as of last build\"")) (h2 "site info" ~(run "make-footnote \"as of last build\""))
(details (details
(summary "git changelog") (summary "git changelog")
(pre ~(run "git log --pretty=format:'%ad %s' --date=short"))) (pre ~(run #[[git log --pretty=format:'%ad %s' --date=short | sed 's/</\&lt;/g; s/>/\&gt;/g']])))
(details (details
(summary "file tree of the site on the server") (summary "file tree of the site on the server")

View File

@ -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 "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 "/bin/bash" :env env) (decode) (strip))) (with [fp (open (get argv 1) "r")] (.read fp))))

View File

@ -1,4 +1,4 @@
#!/usr/bin/env bash #!/bin/bash
path=$1 path=$1
caption=$2 caption=$2

View File

@ -1,7 +1,7 @@
#!/usr/bin/env bash #!/bin/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 noswapfile" -c "%s/^$/ /g" -c "set conceallevel=0" -c "set nonu | set nornu" -c "autocmd LspAttach * execute 'TOhtml | w! ${tmpfile} | qa!'" >/dev/null || nvim "$1" -c "set noswapfile" -c "%s/^$/ /" -c "set conceallevel=0" -c "set nonu | set nornu" -c "TOhtml | w! ${tmpfile} | qa!" >/dev/null
cat "${tmpfile}" | pup --pre 'style, pre' | sed '/^$/d' cat "${tmpfile}" | pup --pre 'style, pre' | sed '/^$/d'