1 ! Copyright (C) 2006 Chris Double. All Rights Reserved.
2 ! See http://factorcode.org/license.txt for BSD license.
4 USING: kernel furnace fjsc peg namespaces
5 lazy-lists io io.files furnace.validator sequences
6 http.client http.server http.server.responders
11 #! Compile the factor code as a string, outputting the http
12 #! response containing the javascript.
14 'expression' parse parse-result-ast fjsc-compile
17 ! The 'compile' action results in an URL that looks like
18 ! 'responder/fjsc/compile'. It takes one query or post
19 ! parameter called 'code'. It calls the 'compile' word
20 ! passing the parameter to it on the stack.
25 : compile-url ( url -- )
26 #! Compile the factor code at the given url, return the javascript.
27 dup "http:" head? [ "Unable to access remote sites." throw ] when
28 "http://" "host" header-param rot 3append http-get compile "();" write flush ;
34 : render-page* ( model body-template head-template -- )
36 [ render-component ] [ f rot render-component ] html-document
40 #! The main 'repl' page.
41 f "repl" "head" render-page* ;
43 ! An action called 'repl'
44 \ repl { } define-action
47 ! Create the web app, providing access
48 ! under '/responder/fjsc' which calls the
50 "fjsc" "repl" "extra/webapps/fjsc" web-app
52 ! An URL to the javascript resource files used by
53 ! the 'fjsc' responder.
56 "extra/fjsc/resources/" resource-path doc-root set
59 ] add-simple-responder
61 ! An URL to the resource files used by
63 "fjsc-repl-resources" [
65 "extra/webapps/fjsc/resources/" resource-path doc-root set
68 ] add-simple-responder ;