Yu-Gi-Oh! Deck Building and Card Inventory Management web interface written in Common Lisp, utilizing HTMX.
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

42 linhas
1.4KB

  1. #|
  2. src/web/qr.lisp
  3. QR Generator
  4. New style web page with DEFCLASS brings some challenges: APPLY
  5. #'FN e.g. MAKE-INSTANCE usually expects a PLIST e.g. :SLOT VALUE,
  6. however, rendering with HTMX/HTML will require (SYMBOL-VALUE
  7. :SLOT) e.g. "8-BIT-BYTE" which makes matching them up
  8. tricky. Perhaps this is a solved problem.
  9. |#
  10. (in-package #:cl-deck-builder2.web)
  11. (defparameter *qr-settings* (make-instance 'qr-settings)
  12. "The saved settings for the QR module.")
  13. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  14. (defroute ("/qr" :method :GET) ()
  15. "QR Generator Main Route. Display the index page. Login Required."
  16. (v:info :qr "GET /qr")
  17. (with-logged-in-user
  18. (setf (getf (response-headers *response*) :cache-control) "no-cache, must-revalidate")
  19. (render-with-env #P"qr.html"
  20. (append
  21. (list :active "/qr")
  22. (qr-to-plist *qr-settings* t)))))
  23. (defroute ("/qr" :method :POST) (&key _parsed)
  24. "QR Generator Main Route. Update the *QR-SETTINGS* and display the result. Login Required."
  25. (v:info :qr "POST /qr => ~a" _parsed)
  26. (with-logged-in-user
  27. (alexandria:if-let ((settings (reinitialize-instance *qr-settings* :content _parsed)))
  28. (alexandria:if-let ((html (qr-generate settings)))
  29. html
  30. (_ "Something went wrong. Try again?"))
  31. (setf *qr-settings* (make-instance 'qr-settings)))))