diff --git a/extra/fjsc/fjsc.factor b/extra/fjsc/fjsc.factor index b6b5ff3b08..1a2c486ddd 100755 --- a/extra/fjsc/fjsc.factor +++ b/extra/fjsc/fjsc.factor @@ -336,7 +336,7 @@ M: wrapper (parse-factor-quotation) ( object -- ast ) GENERIC: fjsc-parse ( object -- ast ) M: string fjsc-parse ( object -- ast ) - 'expression' parse ast>> ; + 'expression' parse ; M: quotation fjsc-parse ( object -- ast ) [ @@ -353,11 +353,11 @@ M: quotation fjsc-parse ( object -- ast ) ] with-string-writer ; : fjsc-compile* ( string -- string ) - 'statement' parse ast>> fjsc-compile ; + 'statement' parse fjsc-compile ; : fc* ( string -- ) [ - 'statement' parse ast>> values>> do-expressions + 'statement' parse values>> do-expressions ] { } make [ write ] each ; diff --git a/extra/fjsc/resources/bootstrap.js b/extra/fjsc/resources/bootstrap.js index 032829c363..795ab7496e 100644 --- a/extra/fjsc/resources/bootstrap.js +++ b/extra/fjsc/resources/bootstrap.js @@ -188,7 +188,7 @@ Factor.prototype.make_quotation = function(source, func) { Factor.prototype.server_eval = function(text, handler, next) { var self = this; - $.post("/responder/fjsc/compile", { code: text }, function(result) { + $.post("compile", { code: text }, function(result) { factor.run_eval = function(func) { factor.cont.next = function() { handler(text,result); } try { diff --git a/unmaintained/webapps/fjsc/authors.txt b/extra/webapps/fjsc/authors.txt similarity index 100% rename from unmaintained/webapps/fjsc/authors.txt rename to extra/webapps/fjsc/authors.txt diff --git a/extra/webapps/fjsc/fjsc.factor b/extra/webapps/fjsc/fjsc.factor new file mode 100644 index 0000000000..01d6935bee --- /dev/null +++ b/extra/webapps/fjsc/fjsc.factor @@ -0,0 +1,90 @@ +! Copyright (C) 2008 Chris Double. All Rights Reserved. +USING: + accessors + fjsc + furnace + furnace.actions + furnace.boilerplate + furnace.redirection + furnace.utilities + html.forms + http + http.client + http.server + http.server.dispatchers + http.server.responses + http.server.static + io + io.pathnames + io.streams.string + kernel + namespaces + peg + sequences + urls + validators +; +IN: webapps.fjsc + +TUPLE: fjsc < dispatcher ; + +: absolute-url ( url -- url ) + "http://" request get "host" header append + over "/" head? [ "/" append ] unless + swap append ; + +: do-compile-url ( url -- response ) + [ + absolute-url http-get nip 'expression' parse fjsc-compile write "();" write + ] with-string-writer + "application/javascript" ; + +: v-local ( string -- string ) + dup "http:" head? [ "Unable to compile code from remote sites" throw ] when ; + +: validate-compile-url ( -- ) + { + { "url" [ v-required v-local ] } + } validate-params ; + +: ( -- action ) + + [ validate-compile-url ] >>validate + [ "url" value do-compile-url ] >>submit + [ validate-compile-url "url" value do-compile-url ] >>display ; + +: do-compile ( code -- response ) + [ + 'expression' parse fjsc-compile write + ] with-string-writer + "application/javascript" ; + +: validate-compile ( -- ) + { + { "code" [ v-required ] } + } validate-params ; + +: ( -- action ) + + [ validate-compile ] >>validate + [ "code" value do-compile ] >>submit + [ validate-compile "code" value do-compile ] >>display ; + +: ( -- action ) + + { fjsc "main" } >>template ; + +: ( -- fjsc ) + dispatcher new-dispatcher + "extra/webapps/fjsc/www" resource-path "static" add-responder + "extra/fjsc/resources" resource-path "fjsc" add-responder + fjsc new-dispatcher + "" add-responder + "compile" add-responder + "compile-url" add-responder + + { fjsc "fjsc" } >>template + >>default ; + +: activate-fjsc ( -- ) + main-responder set-global ; diff --git a/extra/webapps/fjsc/fjsc.xml b/extra/webapps/fjsc/fjsc.xml new file mode 100644 index 0000000000..ef00149028 --- /dev/null +++ b/extra/webapps/fjsc/fjsc.xml @@ -0,0 +1,17 @@ + + + + + <t:write-title/> + + + + + + + + +
+ + +
diff --git a/extra/webapps/fjsc/main.xml b/extra/webapps/fjsc/main.xml new file mode 100644 index 0000000000..185ee22f6d --- /dev/null +++ b/extra/webapps/fjsc/main.xml @@ -0,0 +1,45 @@ + + + Factor to JavaScript REPL + + + + + +
+
+

More information on the Factor to Javascript compiler can be found at these blog posts:

+ +

The terminal emulation code for the Factor REPL is provided by the awesome termlib library by Norbert Landsteiner. Documentation for termlib is available here. Please note the license of 'termlib':

+
This JavaScript-library is free for private and academic use. Please include a readable copyright statement and a backlink to http://www.masswerk.at in the web page. The library should always be accompanied by the "readme.txt" and the sample HTML-documents. + + The term "private use" includes any personal or non-commercial use, which is not related to commercial activites, but excludes intranet, extranet and/or public net applications that are related to any kind of commercial or profit oriented activity. + + For commercial use see http://www.masswerk.at for contact information.
+
+

Stack

+
+
+

Playground

+
+

Compiled Code

+ +

Some useful words:

+
+
vocabs ( -- seq )
+
Return a sequence of available vocabularies
+
words ( string -- seq )
+
Return a sequence of words in the given vocabulary
+
all-words ( -- seq )
+
Return a sequence of all words
+
+

The contents of bootstrap.factor have been loaded on startup.

+
+
diff --git a/unmaintained/webapps/fjsc/summary.txt b/extra/webapps/fjsc/summary.txt similarity index 100% rename from unmaintained/webapps/fjsc/summary.txt rename to extra/webapps/fjsc/summary.txt diff --git a/unmaintained/webapps/fjsc/tags.txt b/extra/webapps/fjsc/tags.txt similarity index 100% rename from unmaintained/webapps/fjsc/tags.txt rename to extra/webapps/fjsc/tags.txt diff --git a/unmaintained/webapps/fjsc/resources/repl.js b/extra/webapps/fjsc/www/repl.js similarity index 100% rename from unmaintained/webapps/fjsc/resources/repl.js rename to extra/webapps/fjsc/www/repl.js diff --git a/unmaintained/webapps/fjsc/resources/termlib/faq.html b/extra/webapps/fjsc/www/termlib/faq.html similarity index 100% rename from unmaintained/webapps/fjsc/resources/termlib/faq.html rename to extra/webapps/fjsc/www/termlib/faq.html diff --git a/unmaintained/webapps/fjsc/resources/termlib/index.html b/extra/webapps/fjsc/www/termlib/index.html similarity index 100% rename from unmaintained/webapps/fjsc/resources/termlib/index.html rename to extra/webapps/fjsc/www/termlib/index.html diff --git a/unmaintained/webapps/fjsc/resources/termlib/multiterm_test.html b/extra/webapps/fjsc/www/termlib/multiterm_test.html similarity index 100% rename from unmaintained/webapps/fjsc/resources/termlib/multiterm_test.html rename to extra/webapps/fjsc/www/termlib/multiterm_test.html diff --git a/unmaintained/webapps/fjsc/resources/termlib/parser_sample.html b/extra/webapps/fjsc/www/termlib/parser_sample.html similarity index 100% rename from unmaintained/webapps/fjsc/resources/termlib/parser_sample.html rename to extra/webapps/fjsc/www/termlib/parser_sample.html diff --git a/unmaintained/webapps/fjsc/resources/termlib/readme.txt b/extra/webapps/fjsc/www/termlib/readme.txt similarity index 100% rename from unmaintained/webapps/fjsc/resources/termlib/readme.txt rename to extra/webapps/fjsc/www/termlib/readme.txt diff --git a/unmaintained/webapps/fjsc/resources/termlib/term_styles.css b/extra/webapps/fjsc/www/termlib/term_styles.css similarity index 100% rename from unmaintained/webapps/fjsc/resources/termlib/term_styles.css rename to extra/webapps/fjsc/www/termlib/term_styles.css diff --git a/unmaintained/webapps/fjsc/resources/termlib/termlib.js b/extra/webapps/fjsc/www/termlib/termlib.js similarity index 100% rename from unmaintained/webapps/fjsc/resources/termlib/termlib.js rename to extra/webapps/fjsc/www/termlib/termlib.js diff --git a/unmaintained/webapps/fjsc/resources/termlib/termlib_parser.js b/extra/webapps/fjsc/www/termlib/termlib_parser.js similarity index 100% rename from unmaintained/webapps/fjsc/resources/termlib/termlib_parser.js rename to extra/webapps/fjsc/www/termlib/termlib_parser.js diff --git a/unmaintained/webapps/fjsc/fjsc.factor b/unmaintained/webapps/fjsc/fjsc.factor deleted file mode 100755 index cf01bf63db..0000000000 --- a/unmaintained/webapps/fjsc/fjsc.factor +++ /dev/null @@ -1,70 +0,0 @@ -! Copyright (C) 2006 Chris Double. All Rights Reserved. -! See http://factorcode.org/license.txt for BSD license. -! -USING: kernel furnace fjsc peg namespaces - lazy-lists io io.files furnace.validator sequences - http.client http.server http.server.responders - webapps.file html ; -IN: webapps.fjsc - -: compile ( code -- ) - #! Compile the factor code as a string, outputting the http - #! response containing the javascript. - serving-text - 'expression' parse parse-result-ast fjsc-compile - write flush ; - -! The 'compile' action results in an URL that looks like -! 'responder/fjsc/compile'. It takes one query or post -! parameter called 'code'. It calls the 'compile' word -! passing the parameter to it on the stack. -\ compile { - { "code" v-required } -} define-action - -: compile-url ( url -- ) - #! Compile the factor code at the given url, return the javascript. - dup "http:" head? [ "Unable to access remote sites." throw ] when - "http://" "host" header-param rot 3append http-get compile "();" write flush ; - -\ compile-url { - { "url" v-required } -} define-action - -: render-page* ( model body-template head-template -- ) - [ - [ render-component ] [ f rot render-component ] html-document - ] serve-html ; - -: repl ( -- ) - #! The main 'repl' page. - f "repl" "head" render-page* ; - -! An action called 'repl' -\ repl { } define-action - -: fjsc-web-app ( -- ) - ! Create the web app, providing access - ! under '/responder/fjsc' which calls the - ! 'repl' action. - "fjsc" "repl" "extra/webapps/fjsc" web-app - - ! An URL to the javascript resource files used by - ! the 'fjsc' responder. - "fjsc-resources" [ - [ - "extra/fjsc/resources/" resource-path doc-root set - file-responder - ] with-scope - ] add-simple-responder - - ! An URL to the resource files used by - ! 'termlib'. - "fjsc-repl-resources" [ - [ - "extra/webapps/fjsc/resources/" resource-path doc-root set - file-responder - ] with-scope - ] add-simple-responder ; - -MAIN: fjsc-web-app diff --git a/unmaintained/webapps/fjsc/head.furnace b/unmaintained/webapps/fjsc/head.furnace deleted file mode 100644 index 97a3645479..0000000000 --- a/unmaintained/webapps/fjsc/head.furnace +++ /dev/null @@ -1,7 +0,0 @@ -Factor to Javascript REPL - - - - - - diff --git a/unmaintained/webapps/fjsc/repl.furnace b/unmaintained/webapps/fjsc/repl.furnace deleted file mode 100644 index c67e9d4d2e..0000000000 --- a/unmaintained/webapps/fjsc/repl.furnace +++ /dev/null @@ -1,43 +0,0 @@ - - - - -
-
-

More information on the Factor to Javascript compiler can be found at these blog posts: -

-

-

The terminal emulation code for the Factor REPL is provided by the awesome termlib library by Norbert Landsteiner. Documentation for termlib is available here. Please note the license of 'termlib':

-
This JavaScript-library is free for private and academic use. Please include a readable copyright statement and a backlink to in the web page. The library should always be accompanied by the "readme.txt" and the sample HTML-documents. - -The term "private use" includes any personal or non-commercial use, which is not related to commercial activites, but excludes intranet, extranet and/or public net applications that are related to any kind of commercial or profit oriented activity. - -For commercial use see http://www.masswerk.at for contact information.
-
-

Stack

-
-
-

Playground

-
-
-

Compiled Code

- -

Some useful words: -

-
vocabs ( -- seq )
-
Return a sequence of available vocabularies
-
words ( string -- seq )
-
Return a sequence of words in the given vocabulary
-
all-words ( -- seq )
-
Return a sequence of all words
-
-

-

The contents of bootstrap.factor have been loaded on startup.

-