#lang racket/base
(require scribble/doclang
scribble/base
scribble/core
scribble/decode
scriblib/render-cond
scribble/html-properties
racket/runtime-path
racket/path
(for-syntax racket/base)
"bootstrap.rkt")
(provide (except-out (all-from-out scribble/doclang) #%module-begin)
(all-from-out "bootstrap.rkt")
(all-from-out scribble/base)
(rename-out [module-begin #%module-begin]))
(define-syntax (module-begin stx)
(syntax-case stx ()
[(_ id . body)
#`(#%module-begin id change-defaults ()
(inject-javascript-url "http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js")
(splice (map inject-javascript-path js-paths))
. body)]))
(define-runtime-path bootstrap-prefix.html (build-path "bootstrap-prefix.html"))
(define-runtime-path bootstrap.css (build-path "bootstrap.css"))
(define-runtime-path-list js-paths
(list (build-path "easyXDM.min.js")
(build-path "json2.min.js")
(build-path "wescheme-embedded.js")
(build-path "bootstrap-helpers.js")))
(define (change-defaults doc)
(struct-copy part doc
[style (make-style (style-name (part-style doc))
(list* (html-defaults bootstrap-prefix.html bootstrap.css js-paths)
(style-properties (part-style doc))))]))
(define (inject-javascript-url a-url)
(cond-element
[latex ""]
[html (make-element (make-style #f (list (make-script-property "text/javascript"
a-url)))
'())]
[text ""]))
(define (inject-javascript-path a-path)
(cond-element
[latex ""]
[html (make-element (make-style #f
(list (make-script-property "text/javascript"
(path->string (file-name-from-path a-path)))))
'())]
[text ""]))