#lang racket/base ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Small runtime configuration and data-path helpers. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (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"]) (let ((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))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; goal : Create the default wiki configuration. ; pre : none. ; post : No files or settings have been changed. ; result : A wiki-config using the documented default values. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define (default-wiki-config) (make-wiki-config)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; goal : Resolve the directory containing uploaded files. ; pre : config is a wiki-config value. ; post : No directory is created. ; result : The uploads path below the configured data directory. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define (uploads-directory config) (build-path (wiki-config-data-dir config) "uploads")) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; goal : Resolve the directory reserved for deleted data. ; pre : config is a wiki-config value. ; post : No directory is created. ; result : The deleted-data path below the configured data directory. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define (deleted-directory config) (build-path (wiki-config-data-dir config) "deleted")) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; goal : Resolve the writable static-data directory. ; pre : config is a wiki-config value. ; post : No directory is created. ; result : The static path below the configured data directory. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define (data-static-directory config) (build-path (wiki-config-data-dir config) "static")) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; goal : Resolve the downloaded browser-library directory. ; pre : config is a wiki-config value. ; post : No directory is created. ; result : The vendor path below the writable static-data directory. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define (vendor-directory config) (build-path (data-static-directory config) "vendor")) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; goal : Resolve the PostgreSQL settings file. ; pre : config is a wiki-config value. ; post : No file is created or read. ; result : The database.rktd path below the configured data directory. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define (database-config-path config) (build-path (wiki-config-data-dir config) "database.rktd")) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; goal : Resolve the selected-language settings file. ; pre : config is a wiki-config value. ; post : No file is created or read. ; result : The language.rktd path below the configured data directory. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define (language-config-path config) (build-path (wiki-config-data-dir config) "language.rktd"))