(module hwiki mzscheme
(require (planet "hwikireq.scm" ("oesterholt" "hwiki.plt" 1 0)))
(require (planet "hwiki-internal.scm" ("oesterholt" "hwiki.plt" 1 0)))
(provide interface-version instance-expiration-handler manager start)
(require (planet "hwiki-manager.scm" ("oesterholt" "hwiki.plt" 1 0)))
(define interface-version 'v2-transitional)
(define (instance-expiration-handler failed-request)
(display (format "~s~%" failed-request))
)
(define manager (hwiki-current-manager (create-hwiki-manager instance-expiration-handler)))
(define (set-timeout context)
(debug (format "set-timout: logged-in=~a, ~s" (-> context logged-in?) adjust-timeout!))
(if (-> context logged-in?)
(let ((seconds (* 3 3600.0)))
(debug (format "set-timeout:adjusting timeout for the current continuation to ~a seconds" seconds))
)))
(define (start request)
(hwiki-start request set-timeout))
(if (not (getenv "HWIKI_TINYMCE"))
(error "The location of the 'tinymce' directory must be given through environment variable HWIKI_TINYMCE"))
(if (not (getenv "HWIKI_PLUGINS"))
(error "The location of 'hwiki-plugins.scm' must be given through environment variable HWIKI_PLUGINS"))
(if (not (getenv "HWIKI_DATA"))
(error "The hwiki data directory must be given through environment variable HWIKI_DATA"))
(if (not (getenv "HWIKI_HTDOCS"))
(error "The htdocs directory must be given through environment variable HWIKI_HTDOCS"))
(if (not (getenv "HWIKI_LOGS"))
(error "The hwiki logs directory must be given through environment variable HWIKI_LOGS"))
(if (not (getenv "HWIKI_SRCDIR"))
(error "The hwiki source directory must be given through environment variable HWIKI_SRCDIR"))
(let ((src (getenv "HWIKI_TINYMCE"))
(dst (build-path (getenv "HWIKI_HTDOCS") "tinymce")))
(if (not (directory-exists? dst))
(copy-directory/files src dst)))
(let ((src (getenv "HWIKI_PLUGINS"))
(dst (build-path (current-directory) "hwiki-plugins.scm")))
(if (not (file-exists? dst))
(copy-to src dst)))
(let ((src (getenv "HWIKI_REWRITES"))
(dst (build-path (current-directory) "rewrite-rules.scm")))
(if (file-exists? src)
(if (not (file-exists? dst))
(copy-to src dst))))
(let ((srcdir (build-path (getenv "HWIKI_SRCDIR") "examples"))
(dstdir (build-path (getenv "HWIKI_DATA") "css"))
(htdocd (build-path (getenv "HWIKI_HTDOCS"))))
(if (not (directory-exists? dstdir))
(make-directory* dstdir))
(if (not (directory-exists? htdocd))
(make-directory* htdocd))
(if (not (file-exists? (build-path dstdir "admin")))
(begin
(copy-to (build-path srcdir "admin") (build-path dstdir "admin"))
(copy-to (build-path srcdir "admin") (build-path htdocd "admin.css"))))
(if (not (file-exists? (build-path dstdir "default")))
(begin
(copy-to (build-path srcdir "default") (build-path dstdir "default"))
(copy-to (build-path srcdir "default") (build-path htdocd "default.css"))))
)
)