1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
(define-module (settings) #:use-module (plugin captcha-plaintext) #:use-module (plugin captcha-booru) #:use-module (utils) ;; #:use-module (dbi dbi) #:use-module (database postgres) #:export (get-setting set-setting! connect-to-db *site-base-url* *test-run* *ignore-invalid-hmac*)) (define-once settings `((max-notice-length . 280) (protocol . "http://") (domain . "gutter.local") (port . "") (base-path . "") (download-path . "/var/www/html/social/file") (avatar-path . "/var/www/html/social/avatar") ;; database-connection (database-user . "postgres") (database-password . "sql") (database-name . "social_test") (database-host . "127.0.0.1") (database-port . "5432") ;; (captcha . ,captcha-plaintext-with-wordlist) (captcha . ,captcha-touhou-no-sample) (min-password-length . 8))) (define *site-base-url* #f) (define (update-base-url) (set! *site-base-url* (string-append (get-setting 'protocol) (get-setting 'domain) (get-setting 'port) (get-setting 'base-path)))) (define (get-setting key) (assoc-value key settings)) (define (set-setting! key value) (set! settings (cons (cons key value) settings)) (when (or (eq? key 'protocol) (eq? key 'domain) (eq? key 'port) (eq? key 'base-path)) (update-base-url))) (define (connect-to-db) (pg-connectdb (string-append "user=" (get-setting 'database-user) " password=" (get-setting 'database-password) " dbname=" (get-setting 'database-name) " authtype=password" " host=" (get-setting 'database-host) " port=" (get-setting 'database-port)))) ;; (define (connect-to-db) (dbi-open "postgresql" (string-append user ;; ":" password ;; ":" database-name ;; ":tcp:" host ;; ":" port))) (define *test-run* #f) (define *ignore-invalid-hmac* #t) ;useful when often dropping the test-db (update-base-url)