GC needs to be ran explicitly

master
not manx 4 years ago
parent 554f30858c
commit f0441780af
Signed by: C-xC-c
GPG Key ID: F52ED472284EF2F4

@ -1,14 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
</head>
<body style="text-align:center;max-width:75em;margin:auto;">
<h1>plum.moe/loli</h1>
<p>Gets a random loli from lolibooru, converts it to base64 and displays it in the browser.</p>
<p>By default it only searches for images tagged as safe. You can pass <code>rating=q</code> or <code>rating=e</code> if you're feeling lewd.<br /> Passing <code>rating=-e</code> will randomly choose a non-explicit image and so fourth.</p>
<p>Tring to query lolibooru via the URL otherwise will not work.</p>
<p>Made by <a href="mailto:boku@plum.moe">Manx</a>, source available on <a href="https://github.com/C-xC-c/lolisp">github</a>.</p>
</body>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
</head>
<body style="text-align:center;max-width:75em;margin:auto;">
<h1>plum.moe/loli</h1>
<p>Gets a random loli from lolibooru, converts it to base64 and displays it in the browser.</p>
<p>By default it only searches for images tagged as safe. You can pass <code>rating=q</code> or <code>rating=e</code> if you're feeling lewd.<br /> Passing <code>rating=-e</code> will randomly choose a non-explicit image and so fourth.</p>
<p>Tring to query lolibooru via the URL otherwise will not work.</p>
<p>Made by <a href="mailto:boku@plum.moe">Manx</a>, source available on <a href="https://github.com/C-xC-c/lolisp">github</a>.</p>
</body>
</html>

@ -1,12 +1,10 @@
(mapc
(lambda (x) (ql:quickload x))
'(:cl-rng
:manx-utils
:cl-ppcre
:aserve
:dexador
:jsown
:qbase64))
(ql:quickload :aserve)
(ql:quickload :dexador)
(ql:quickload :jsown)
(ql:quickload :qbase64)
(ql:quickload :cl-ppcre)
(ql:quickload :cl-rng)
(ql:quickload :manx-utils)
(load #p"config.lisp")
@ -38,27 +36,27 @@
(loop (sleep 10000)))
(defun loli-rating (req)
(let ((rating (net.aserve:request-query-value "rating" req)))
(or (cl-ppcre:scan-to-strings "-?(s|q|e)" rating)
"s")))
(defun loli-rating (rating)
(or (cl-ppcre:scan-to-strings "-?(s|q|e)" rating)
"s"))
(defun based-loli (req)
(manx-utils:to-string
"data:image/jpg;base64,"
(qbase64:encode-bytes
(dex:get (get-loli (loli-rating req))))))
(dex:get (get-loli
(loli-rating (net.aserve:request-query-value "rating" req)))))))
(defun this-is-bad-code (req ent)
(net.aserve:with-http-response (req ent)
(net.aserve:with-http-body (req ent)
(net.html.generator:html
(:html
(:head
((:meta name "viewport" content "width=device-width, initial-scale=1")))
((:body :style "position:relative")
((:img :style "object-fit: contain; width: 100%; height:100%"
:src (based-loli req)))
((:a :style "position:absolute;top:8px;right:16px;" href "/loli/about") "about")))))))
(:html
(:head
((:meta name "viewport" content "width=device-width, initial-scale=1")))
((:body :style "position:relative")
((:img :style "object-fit: contain; width: 100%; height:100%"
:src (based-loli req)))
((:a :style "position:absolute;top:8px;right:16px;" href "/loli/about") "about"))))))
(gc :full t)) ;; Removes downloaded files from memory
(main)

@ -4,13 +4,13 @@ it on a web page.
This code is terrible because I am too.
** Setup
*** dependencies
*** Dependencies
I use SBCL.
Most systems will be downloaded by quicklisp. You wll need to git
clone [[git@github.com:C-xC-c/manx-utils][manx-utils]] and [[public@flanchan.moe:cl-rng.git][cl-rng]] manually and add them to your
clone [[https://github.com/C-xC-c/manx-utils][manx-utils]] and [[https://github.com/notflan/cl-rng][cl-rng]] manually and add them to your
~local-projects~.
***
*** Hosting
- Clone the repo
- Move ~loli.example.service~ to ~/etc/systemd/system/loli.service~
- Change ~workingdirectory~ in ~loli.service~ to wherever your lolisp

Loading…
Cancel
Save