Yu-Gi-Oh! Deck Building and Card Inventory Management web interface written in Common Lisp, utilizing HTMX.
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

122 行
3.7KB

  1. #|
  2. src/config.lisp
  3. Configuration skeleton generated by Caveman.
  4. Additional changes:
  5. *public-directory* :: This is where YGOProDeck images and things generated *by the "public" are stored.
  6. Database Configuration:
  7. We use :MEMORY for SQLite in-memory,currently :MAINDB is the default
  8. database which is an SQLite3 file in this directory, and :MYSQL is our
  9. MariaDB testbed server we're planning on migrating to.
  10. |#
  11. (in-package :cl-user)
  12. (defpackage #:cl-deck-builder2.config
  13. (:use #:cl)
  14. (:import-from #:envy
  15. #:config-env-var
  16. #:defconfig)
  17. (:export #:config
  18. #:*application-root*
  19. #:*public-directory*
  20. #:*static-directory*
  21. #:*template-directory*
  22. #:*app-log-file*
  23. #:appenv
  24. #:developmentp
  25. #:productionp)
  26. (:documentation "Configuration package. Using Envy configuration switcher. Mostly default from Caveman2 skeleton generator. I added a bunch of documentation."))
  27. (in-package :cl-deck-builder2.config)
  28. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  29. (setf (config-env-var) "APP_ENV")
  30. (defparameter *application-root*
  31. (asdf:system-source-directory :cl-deck-builder2)
  32. "The source directory of this web application.")
  33. (defparameter *public-directory*
  34. (probe-file #P"~/public/")
  35. "The absolute path to the directory where we serve public files from.")
  36. (defparameter *static-directory*
  37. (merge-pathnames #P"static/" *application-root*)
  38. "The absolute path to the directory where we serve static files from.")
  39. (defparameter *template-directory*
  40. (merge-pathnames #P"templates/" *application-root*)
  41. "The absolute path to the directory where we find and compile templates from.")
  42. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  43. (defparameter *app-log-file*
  44. (merge-pathnames
  45. (make-pathname
  46. :name (local-time:format-timestring
  47. nil (local-time:now)
  48. :format local-time:+rfc3339-format/date-only+)
  49. :type "log")
  50. (merge-pathnames
  51. *public-directory*
  52. (user-homedir-pathname)))
  53. "The log file for this instance of the app to use. We don't really care about conflicts at this point, as we :APPEND.
  54. Possibly in the future use the git commit id.")
  55. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  56. ;; Configurations
  57. (defconfig :common
  58. `(:databases
  59. ((:memory :sqlite3 :database-name ":memory:")
  60. (:maindb :sqlite3 :database-name
  61. ,(asdf:system-relative-pathname
  62. :cl-deck-builder2 "deck_builder" :type "sqlite3"))
  63. (:mysql :mysql
  64. :host "127.0.0.1"
  65. :port 3306
  66. :database-name "deck_builder"
  67. :username "deck_builder"
  68. :password "deck_builder"))
  69. :server (:address "0.0.0.0" :port 5005 :server :woo)
  70. :slynk (:interface "0.0.0.0"
  71. :port 4005
  72. :style :spawn
  73. :dont-close t)
  74. :websocket (:address "0.0.0.0" :port 5001)))
  75. (defconfig |development|
  76. '())
  77. (defconfig |production|
  78. '())
  79. (defconfig |test|
  80. '())
  81. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  82. (defun config (&optional key)
  83. "Query the configuration environment information.
  84. ARGUMENTS
  85. KEY The key to query from the configuration."
  86. (envy:config #.(package-name *package*) key))
  87. (defun appenv ()
  88. "Get the current environment variable value. Default is ~APP_ENV~."
  89. (uiop:getenv (config-env-var #.(package-name *package*))))
  90. (defun developmentp ()
  91. "Return T if the application is in \"development\" mode."
  92. (string= (appenv) "development"))
  93. (defun productionp ()
  94. "Return T if the application is in \"production\" mode."
  95. (string= (appenv) "production"))