M README.md => README.md +4 -4
@@ 14,10 14,10 @@ Common Lisp web development.
# Run the Software
-The web app runs on [Clack](https://github.com/fukamachi/clack). I recommend
-using Roswell and `clackup`. to start the server:
+The web app uses [Roswell](https://roswell.github.io/) to launch. After you
+have that install, run:
- $ clackup clackup.lisp
+ $ ./roswell/ur-game
Alternatively, with your CL impl of choice (I use SBCL):
@@ 27,7 27,7 @@ Alternatively, with your CL impl of choice (I use SBCL):
* You win the game by getting all your seven pieces from one end of
the board to the other.
-* You roll marked four dice, and the sum of all dice with marks up is
+* You roll four marked dice, and the sum of all dice with marks up is
how much you can move a single piece on your turn.
* If your piece lands on a rosette, you gain an extra turn.
* You can jump over or capture enemy pieces, but you cannot capture
D clackup.lisp => clackup.lisp +0 -4
@@ 1,4 0,0 @@
-;; Launch the app via `clackup clackup.lisp`
-(load "ur-game.asd")
-(ql:quickload :ur-game)
-ur-game:*app*
A roswell/ur-game.ros => roswell/ur-game.ros +20 -0
@@ 0,0 1,20 @@
+#!/bin/sh
+#|-*- mode:lisp -*-|#
+#|
+exec ros -Q -- $0 "$@"
+|#
+(progn ;;init forms
+ (ros:ensure-asdf)
+ #+quicklisp(ql:quickload '() :silent t))
+
+(defpackage :ros.script.ur-game.3834464264
+ (:use :cl))
+(in-package :ros.script.ur-game.3834464264)
+
+(load "ur-game.asd")
+(ql:quickload :ur-game)
+
+(defun main (&rest argv)
+ (declare (ignorable argv))
+ (ur-game:start :app-root #P"." :use-thread nil))
+;;; vim: set ft=lisp lisp:
M src/ur-game.lisp => src/ur-game.lisp +17 -14
@@ 13,8 13,7 @@
(:import-from :json
:encode-json-plist-to-string
:decode-json-from-string)
- (:export :start
- :*app*))
+ (:export :start))
(in-package #:ur-game)
@@ 24,12 23,11 @@
;; File Paths
-(defparameter +app-root+
- (asdf:system-source-directory :ur-game))
-(defparameter +static-path+
- (merge-pathnames #P"static/" +app-root+))
-(defparameter +index-path+
- (merge-pathnames #P"index.html" +app-root+))
+(defun static-directory (app-root)
+ (merge-pathnames #P"static/" app-root))
+
+(defun index-filepath (app-root)
+ (merge-pathnames #P"index.html" app-root))
;; Websocket close codes
@@ 268,7 266,7 @@
(funcall peeking-app env)
(funcall app env))))
-(defparameter *app*
+(defun app (app-root)
(lack:builder
;; === Middlewares ===
(peek-request
@@ 290,16 288,21 @@
`(302 (:location ,(concatenate 'string "/#/" token)))))
;; Serve "index.html" for "/".
(route "/"
- (constantly `(200 (:content-type "text/html") ,+index-path+)))
+ (constantly `(200 (:content-type "text/html") ,(index-filepath app-root))))
;; Static Path
- (:static :path "/static/" :root +static-path+)
+ (:static :path "/static/" :root (static-directory app-root))
;; All other routes are invalid.
(constantly '(404 (:content-type "text/plain") ("Not Found")))))
(defvar *website-handler* nil)
-(defun start ()
+(defun start (&key (app-root (asdf:system-source-directory :ur-game))
+ (port 5000)
+ (use-thread t))
(when *website-handler* (clack:stop *website-handler*))
- (setf *website-handler* (clack:clackup *app*
- :server :hunchentoot))
+ (setf *website-handler*
+ (clack:clackup (app app-root)
+ :server :hunchentoot
+ :port port
+ :use-thread use-thread))
(values))
M ur-game.asd => ur-game.asd +3 -0
@@ 9,6 9,9 @@
#:cl-json
#:cl-ppcre
#:clack
+ #:clack-handler-hunchentoot
+ #:lack
+ #:lack-middleware-static
#:session-token
#:uiop
#:vom