(module hwiki-internal mzscheme
        (require "hwikireq.scm")
        (require "context.scm")
        (require "config.scm")
        (require "page.scm")
        (require "plugins.scm")

        ;;; Special pages
        (require "special-login.scm")
        (require "special-logout.scm")
        (require "special-template.scm")
        (require "special-edit.scm")
        (require "special-upload.scm")
        (require "special-admin.scm")
        (require "special-prefs.scm")
        (require "special-cell-usage.scm")
        ;;; plugins
        (define INSTALL-PLUGINS #t)
        (provide hwiki-start)
        ; hwiki is a wiki with which you can edit pages using a wysiwyg
        ; editor. It is possible to create pages using templates. Templates
        ; can be created. They're using css. There are several things
        ; users can do with hwiki.
        ; Three roles: Readers, editors and administrators.
        ; An administrator can make editor users.
        ; Editor users can create and edit templates.
        ; Templates are lists of page parts. And a CSS.
        ; Page parts have standard names or have page names.
        (define (hwiki-start request set-timeout)
          (if INSTALL-PLUGINS
                (debug "Installing plugins")
                (let ((f (dynamic-require "hwiki-plugins.scm" 'install-plugins)))
                  (debug (format "dynamic require of 'hwiki-plugins.scm' results in ~a" f))
                  (set! INSTALL-PLUGINS #f)
                  (debug (enumerate-plugins)))))
          (debug "START" (url->string (request-uri request)))
          (let ((context (get-context request)))
            (set-timeout context)
            (let ((P (page context)))
              (let ((function (if (or (-> P special?) (-> context logged-in?))
                (if (not (-> P special?))
                    (-> context from-where (-> context page-name)))
                (debug "special?" (-> P special?) " function: " function " context:" (-> context context))
                ;(adjust-timeout! (form-timeout))
                (let ((R (-> P create-html)))
                  (debug "calling " R)
                  (let ((B (function R)))
                  (debug "RESTART" R function B)
                    (hwiki-start B set-timeout)))))))

        );; end-module