2022-08-23 09:57:42 +00:00
|
|
|
#lang racket/base
|
|
|
|
(require racket/path
|
2022-08-24 01:23:46 +00:00
|
|
|
racket/runtime-path
|
2022-08-23 09:57:42 +00:00
|
|
|
net/url
|
|
|
|
web-server/servlet-dispatch
|
|
|
|
web-server/dispatchers/filesystem-map
|
|
|
|
(prefix-in pathprocedure: web-server/dispatchers/dispatch-pathprocedure)
|
|
|
|
(prefix-in sequencer: web-server/dispatchers/dispatch-sequencer)
|
|
|
|
(prefix-in lift: web-server/dispatchers/dispatch-lift)
|
|
|
|
(prefix-in filter: web-server/dispatchers/dispatch-filter)
|
|
|
|
(prefix-in files: web-server/dispatchers/dispatch-files)
|
2022-08-23 10:43:44 +00:00
|
|
|
"src/config.rkt"
|
2022-08-30 09:33:28 +00:00
|
|
|
"src/reloadable.rkt"
|
|
|
|
"src/server-utils.rkt")
|
2022-08-23 09:57:42 +00:00
|
|
|
|
2022-08-30 09:33:28 +00:00
|
|
|
(define-syntax-rule (require-reloadable filename varname)
|
|
|
|
(define varname
|
|
|
|
(reloadable-entry-point->procedure
|
|
|
|
(make-reloadable-entry-point (quote varname) filename))))
|
|
|
|
|
|
|
|
(require-reloadable "src/page-category.rkt" page-category)
|
|
|
|
(require-reloadable "src/page-home.rkt" page-home)
|
|
|
|
(require-reloadable "src/page-not-found.rkt" page-not-found)
|
|
|
|
(require-reloadable "src/page-proxy.rkt" page-proxy)
|
|
|
|
(require-reloadable "src/page-search.rkt" page-search)
|
|
|
|
(require-reloadable "src/page-wiki.rkt" page-wiki)
|
2022-08-24 01:23:46 +00:00
|
|
|
|
2022-08-30 09:33:28 +00:00
|
|
|
(when (not (config-true? 'debug))
|
|
|
|
(set-reload-poll-interval! #f))
|
|
|
|
(reload!)
|
|
|
|
|
|
|
|
(define-runtime-path path-static "static")
|
2022-08-23 09:57:42 +00:00
|
|
|
|
|
|
|
(serve/launch/wait
|
2022-08-24 08:59:11 +00:00
|
|
|
#:listen-ip (if (config-true? 'debug) "127.0.0.1" #f)
|
|
|
|
#:port (string->number (config-get 'port))
|
2022-08-23 09:57:42 +00:00
|
|
|
(λ (quit)
|
|
|
|
(sequencer:make
|
2022-08-30 09:33:28 +00:00
|
|
|
(pathprocedure:make "/" page-home)
|
2022-08-23 09:57:42 +00:00
|
|
|
(pathprocedure:make "/proxy" page-proxy)
|
|
|
|
(filter:make #rx"^/[a-z-]+/wiki/Category:.+$" (lift:make page-category))
|
|
|
|
(filter:make #rx"^/[a-z-]+/wiki/.+$" (lift:make page-wiki))
|
|
|
|
(filter:make #rx"^/[a-z-]+/search$" (lift:make page-search))
|
|
|
|
(filter:make #rx"^/static/" (files:make
|
|
|
|
#:url->path
|
|
|
|
(lambda (u)
|
2022-08-24 01:23:46 +00:00
|
|
|
((make-url->path path-static)
|
2022-08-23 09:57:42 +00:00
|
|
|
(struct-copy url u [path (cdr (url-path u))])))
|
|
|
|
#:path->mime-type
|
|
|
|
(lambda (u)
|
2022-08-30 09:33:28 +00:00
|
|
|
(ext->mime-type (path-get-extension u)))
|
2022-08-24 08:59:11 +00:00
|
|
|
#:cache-no-cache (config-true? 'debug) #;"browser applies heuristics if unset"))
|
2022-08-23 09:57:42 +00:00
|
|
|
(lift:make page-not-found))))
|