(module hwiki-upload mzscheme
(require (planet "mzrpc.scm" ("oesterholt" "mzrpc.plt" 1 0)))
(require (planet "spod-html.scm" ("oesterholt" "roos.plt" 1 0)))
(provide hwiki-set-page!
hwiki-set-spod!
hwiki-env-set-page!
hwiki-env-set-spod!)
(define (env function var)
(let ((R (getenv (format "~a" var))))
(if (eq? R #f)
(error (format "~a:expected environment variable: ~a" function var))
R)))
(rpc-local-define (hwiki-put-page! _context _page-name _html))
(define (hwiki-set-page! _host _user _pass _context _page-name _html _toc)
(let ((handle (rpc-connect _host 7713 (format "~a::~a" _context _user) _pass #f)))
(if (not (rpc-valid? handle))
(error
(format "hwiki-rpc-client:Cannot connect to host '~a:7713' with user '~a' and the given password"
_host
_user)))
(let ((R (hwiki-put-page! handle _context _page-name _html)))
(rpc-disconnect handle)
R)))
(define (hwiki-set-spod! _host _user _pass _context _page-name _spod _toc)
(let ((provider (spod-provider)))
(spod-install-html-provider)
(hwiki-set-page! _host _user _pass _context _page-name (->spod _spod) _toc)
(spod-install-provider provider)))
(define (hwiki-env-set-spod! _context _page-name _spod _toc)
(hwiki-set-spod! (env 'hwiki-env-set-spod! "HOST")
(env 'hwiki-env-set-spod! "USER")
(env 'hwiki-env-set-spod! "PASS")
_context _page-name _spod _toc))
(define (hwiki-env-set-page! _context _page-name _spod _toc)
(hwiki-set-page! (env 'hwiki-env-set-page! "HOST")
(env 'hwiki-env-set-page! "USER")
(env 'hwiki-env-set-page! "PASS")
_context _page-name _spod _toc))
)