Yu-Gi-Oh! Deck Building and Card Inventory Management web interface written in Common Lisp, utilizing HTMX.
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

44 lines
1.6KB

  1. ;;;; src/web/hermetic.lisp
  2. ;;;;
  3. ;;;; demo quick reference
  4. ;;;;
  5. (in-package #:cl-deck-builder2.web)
  6. (defroute ("/hermetic" :method :GET) ()
  7. (if (hermetic:logged-in-p)
  8. (progn
  9. (flash :messages (format nil "Welcome, ~A!" (hermetic:user-name)))
  10. (render-with-env #P"/user/index.html"))
  11. (render-with-env #P"/user/login.html")))
  12. (defroute ("/hermetic/login" :method :POST) (&key _parsed)
  13. (let ((username (query-param "username" _parsed))
  14. (password (query-param "password" _parsed)))
  15. (handler-case
  16. (ratify:with-parsed-forms
  17. ((:string username)
  18. (:string password))
  19. (let ((params (list :|username| username :|password| password)))
  20. (login params
  21. (cl-markup:html5 (:h1 "You are logged in"))
  22. (cl-markup:html5 (:h1 "Wrong password :c"))
  23. (cl-markup:html5 (:h1 "No such username " params)))))
  24. (ratify:combined-error (e)
  25. (flash :errors e)
  26. (redirect "/hermetic")))))
  27. (defroute ("/hermetic/logout" :method :GET) ()
  28. (logout
  29. (cl-markup:html5 (:h1 "You are logged out"))
  30. (cl-markup:html5 (:h1 "You are not logged in."))))
  31. (defroute ("/hermetic/users-only" :method :GET) ()
  32. (auth (:user)
  33. (cl-markup:html5 (:h1 "If you are seeing this, you are a user."))))
  34. (defroute ("/hermetic/admins-only" :method :GET) ()
  35. (hermetic:auth (:admin)
  36. (cl-markup:html5 (:h1 "If you are seeing this, you are an admin."))
  37. (cl-markup:html5 (:h1 "Custom auth denied page. You are not authorized!"))))