Initial import
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
#lang racket/base
|
||||
|
||||
(require racket/path
|
||||
racket/runtime-path)
|
||||
|
||||
(provide (struct-out wiki-config)
|
||||
make-wiki-config
|
||||
default-wiki-config
|
||||
static-directory
|
||||
uploads-directory
|
||||
deleted-directory
|
||||
data-static-directory
|
||||
vendor-directory
|
||||
database-config-path
|
||||
language-config-path)
|
||||
|
||||
(struct wiki-config (data-dir
|
||||
port
|
||||
listen-ip
|
||||
secure-cookie?
|
||||
site-title
|
||||
session-seconds
|
||||
language)
|
||||
#:transparent)
|
||||
|
||||
(define-runtime-path static-directory "../static")
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; goal : Create a wiki configuration.
|
||||
; pre : data-dir is a path string, port is a port number and listen-ip is
|
||||
; an IP address string, "*" or #f.
|
||||
; post : No files or settings have been changed.
|
||||
; result : A wiki-config value with a complete data directory path.
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
(define (make-wiki-config #:data-dir [data-dir "wiki-data"]
|
||||
#:port [port 8080]
|
||||
#:listen-ip [listen-ip "127.0.0.1"]
|
||||
#:secure-cookie? [secure-cookie? #f]
|
||||
#:site-title [site-title "Racket Wiki"]
|
||||
#:session-seconds [session-seconds (* 12 60 60)]
|
||||
#:language [language "en"])
|
||||
(define normalized-listen-ip
|
||||
(if (equal? listen-ip "*")
|
||||
#f
|
||||
listen-ip))
|
||||
(wiki-config (path->complete-path data-dir)
|
||||
port
|
||||
normalized-listen-ip
|
||||
secure-cookie?
|
||||
site-title
|
||||
session-seconds
|
||||
language))
|
||||
|
||||
(define (default-wiki-config)
|
||||
(make-wiki-config))
|
||||
|
||||
(define (uploads-directory config)
|
||||
(build-path (wiki-config-data-dir config) "uploads"))
|
||||
|
||||
(define (deleted-directory config)
|
||||
(build-path (wiki-config-data-dir config) "deleted"))
|
||||
|
||||
(define (data-static-directory config)
|
||||
(build-path (wiki-config-data-dir config) "static"))
|
||||
|
||||
(define (vendor-directory config)
|
||||
(build-path (data-static-directory config) "vendor"))
|
||||
|
||||
(define (database-config-path config)
|
||||
(build-path (wiki-config-data-dir config) "database.rktd"))
|
||||
|
||||
(define (language-config-path config)
|
||||
(build-path (wiki-config-data-dir config) "language.rktd"))
|
||||
Reference in New Issue
Block a user