diff options
author | colin <colin@cicadas.surf> | 2023-05-26 08:41:30 -0700 |
---|---|---|
committer | colin <colin@cicadas.surf> | 2023-05-26 08:41:30 -0700 |
commit | 372e5d1691452d467239bcec39f1441f0204b244 (patch) | |
tree | 26153c66f9bfeeb4e317f7a40973ed2432b97d55 | |
parent | 9c6799f688d39058e75978acf66a11c69f26e546 (diff) |
support for robots.txt
-rw-r--r-- | fussy.lisp | 25 |
1 files changed, 21 insertions, 4 deletions
@@ -238,6 +238,7 @@ returns a list of those names." fussy-el :std "" :documentation "These paths are by default equal to the config directory.") + (robots.txt :std "robots.txt") (logfile :std "fussy.log") (port :std 8888) (domain :std "localhost") @@ -252,8 +253,18 @@ directory is used as a default directory for all relative paths mentioned in the config file. Any Absolute paths in the config file are treated as such.") +(defun config-directory () + (or *config-directory* + (uiop:merge-pathnames* (user-homedir-pathname) ".fussy/"))) + +(defun robots-path-name (&optional (config *config*)) + (uiop:merge-pathnames* (config-directory) (robots.txt config))) + +(defun logfile-path-name (&optional (config *config*)) + (uiop:merge-pathnames* (config-directory) (logfile config))) + (defun fussy-log (msg &rest args) - (with-open-file (out (logfile *config*) + (with-open-file (out (logfile-path-name) :direction :output :if-exists :append :if-does-not-exist :create) @@ -270,10 +281,10 @@ are treated as such.") (read-from-string (a:read-file-into-string file)))) (defun full-store-directory (&optional (config *config*)) - (uiop:merge-pathnames* (store-directory config) *config-directory*)) + (uiop:merge-pathnames* (store-directory config) (config-directory))) (defun full-theme-image-directory (&optional (config *config*)) - (uiop:merge-pathnames* (theme-image-directory config) *config-directory*)) + (uiop:merge-pathnames* (theme-image-directory config) (config-directory))) (defun emacs-dot-d-directory (&optional (config *config*)) (uiop:merge-pathnames* ".emacs.d/" (full-theme-image-directory config))) @@ -304,7 +315,7 @@ that they are not loaded during image gen.") (mapcar downcaser +standard-themes+)))) (defun fussy-elisp-script-location (&optional (config *config*)) - (uiop:merge-pathnames* *config-directory* (fussy-el config))) + (uiop:merge-pathnames* (config-directory) (fussy-el config))) (defun format-emacs-evocation-script (package-names) (format @@ -534,6 +545,12 @@ h1 { (setf (lzb:response-header :content-type) "text/css") +style-css+) +(lzb:defendpoint* :get "/robots.txt" () () + "Endpoint for serving robots.txt" + (setf (lzb:response-header :content-type) "text/plain") + (or (uiop:file-exists-p (robots-path-name)) + "")) + (lzb:defendpoint* :get "/images/:pkg:/:theme:/:image:" () () "Endpoint for serving theme preview images" (let ((file-path |