Use updated hunchenhelpers

master
not manx 4 years ago
parent 0053b38eb3
commit 58b3c80e8a
Signed by: C-xC-c
GPG Key ID: F52ED472284EF2F4

@ -1,14 +0,0 @@
<!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.</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,6 +1,5 @@
(in-package :lolisp) (in-package #:lolisp)
(defvar @html "text/html")
(defparameter *serb* nil (defparameter *serb* nil
"The hunchentoot acceptor (server) that will serve our handlers and "The hunchentoot acceptor (server) that will serve our handlers and
files.") files.")
@ -32,7 +31,7 @@ Use cl-rng to pick a random page from the lolibooru API"
(defun based-loli (url) (defun based-loli (url)
(str "data:image/jpeg;base64," (qbase64:encode-bytes (dex:get url)))) (str "data:image/jpeg;base64," (qbase64:encode-bytes (dex:get url))))
(henh:handle :get (loli :uri "/loli/") @html (henh:handle (get-loli :get "/loli/")
(rating) (rating)
(cl-who:with-html-output-to-string (x) (cl-who:with-html-output-to-string (x)
(:html (:html
@ -43,19 +42,13 @@ Use cl-rng to pick a random page from the lolibooru API"
(:style "body{position:relative;}img{object-fit:contain;width:100%;height:100%;}#about{position:absolute;top:8px;right:16px}")) (:style "body{position:relative;}img{object-fit:contain;width:100%;height:100%;}#about{position:absolute;top:8px;right:16px}"))
(:body (:body
(:img :src (based-loli (loli-link rating))) (:img :src (based-loli (loli-link rating)))
(:a :id "about" :href "/loli/about" "about"))) (:a :id "about" :href "/loli/about.html" "about")))
x)) x))
(defun configure () (defun configure ()
(setf *serb* (make-instance 'hunchentoot:easy-acceptor (setf *serb* (make-instance 'henh:acceptor
:port (config-item :port) :port (config-item :port)
:address (config-item :host) :document-root (config-item :document-root))))
:document-root (config-item :document-root)
:error-template-directory (config-item :error-root)
;; We (eval) these because quoting streams is werid.
;; '*standard-ouput* is not of type stream why?
:access-log-destination (eval (config-item :access-log))
:message-log-destination (eval (config-item :error-log)))))
(defun start () (defun start ()
(handler-case (configure) (handler-case (configure)
@ -65,7 +58,7 @@ Use cl-rng to pick a random page from the lolibooru API"
(hunchentoot:start *serb*)) (hunchentoot:start *serb*))
(defun stop () (defun stop ()
(hunchentoot:stop *serb*)) (hunchentoot:stop *serb* :soft t))
(export '(configure (export '(configure
start start

@ -1,4 +1,4 @@
(asdf:defsystem :lolisp (asdf:defsystem #:lolisp
:description "The worst lolibooru scraper you've ever seen" :description "The worst lolibooru scraper you've ever seen"
:author "Manx (boku@plum.moe)" :author "Manx (boku@plum.moe)"
:license "X11/MIT" :license "X11/MIT"

@ -1,2 +1,2 @@
(defpackage :lolisp (defpackage #:lolisp
(:use :cl)) (:use :cl))

Loading…
Cancel
Save