Mercurial > core / lisp/lib/web/index.lisp
changeset 664: |
4d8451fe5423 |
parent: |
lisp/web/index.lisp@e912dc076208
|
author: |
Richard Westhaver <ellis@rwest.io> |
date: |
Sun, 22 Sep 2024 01:02:49 -0400 |
permissions: |
-rw-r--r-- |
description: |
moved web to lib/web, added dat/css |
1 ;;; web/index.lisp --- local user index 4 (uiop:define-package :web/index 5 (:use :cl :std :hunchentoot :lass :spinneret) 10 (in-package :web/index) 12 (defparameter *last-update* (get-universal-time)) 14 (defun current-time () (setq *last-update* (get-universal-time))) 16 (defparameter *web-index-port* 8888) 18 (defparameter *server* 19 (make-instance 'easy-acceptor 23 (define-easy-handler (b :uri "/b") (user) 24 (setf (content-type*) "text/plain") 25 (format nil "showing buffers for ~@[ ~A~]." user)) 27 (define-easy-handler (i :uri "/i") (user) 28 (setf (content-type*) "text/plain") 29 (format nil "showing inbox for ~@[ ~A~]." user)) 31 (define-easy-handler (a :uri "/a") (user) 32 (setf (content-type*) "text/plain") 33 (format nil "showing agenda for ~@[ ~A~]." user)) 35 (define-easy-handler (org :uri "/org") (user) 36 (setf (content-type*) "text/plain") 37 (format nil "showing org-files for ~@[ ~A~]." user)) 39 (deftag link (link body) 40 `(:a :href ,@link ,@body)) 42 (defmacro with-index-page (&optional (title "local index") &body body) 51 (link "https://compiler.company" "~") 52 (link "https://compiler.company/blog" "blog") 53 (link "https://compiler.company/docs" "docs") 54 (link "https://compiler.company/code" "code") 57 (:footer ("Last update: ~A" (current-time)))))))) 59 (defun tabulate (&rest rows) 62 (loop for row in rows do 63 (:tr (loop for cell in row do 65 (if (find :table (get-html-path)) 67 (:table (:tbody (tabulate))))))) 69 (defun inner-section () 70 "Binds *HTML-PATH* to replicate the depth the output is used in." 72 (let ((*html-path* (append *html-path* '(:section :section)))) 73 (:h* "Heading three levels deep")))) 75 (defun outer-section (html) 76 "Uses HTML from elsewhere and embed it into a section" 79 (:h* "Heading two levels deep") 83 (defun main (&key (output *standard-output*) (port *web-index-port*)) 84 (let ((*standard-output* output)) 85 (print "starting index server on ~A" port) 88 (defun shutdown (&optional (target *server*))