diff --git a/extra/site-watcher/site-watcher-tests.factor b/extra/site-watcher/site-watcher-tests.factor index c19fa08ac0..77ae155f4a 100644 --- a/extra/site-watcher/site-watcher-tests.factor +++ b/extra/site-watcher/site-watcher-tests.factor @@ -1,15 +1,13 @@ ! Copyright (C) 2009 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: db.tuples locals site-watcher site-watcher.db -site-watcher.private kernel db io.directories io.files.temp -continuations db.sqlite -sequences tools.test ; +USING: continuations db db.tuples io.directories io.files.temp kernel +locals sequences site-watcher.db tools.test webapps.utils ; IN: site-watcher.tests [ "site-watcher.db" temp-file delete-file ] ignore-errors :: fake-sites ( -- seq ) - "site-watcher.db" temp-file <sqlite-db> [ + "site-watcher.db" <temp-sqlite-db> [ account ensure-table site ensure-table watching-site ensure-table diff --git a/extra/webapps/mason/backend/backend-tests.factor b/extra/webapps/mason/backend/backend-tests.factor index f6870993fd..9f4b09df4d 100644 --- a/extra/webapps/mason/backend/backend-tests.factor +++ b/extra/webapps/mason/backend/backend-tests.factor @@ -1,5 +1,5 @@ -USING: continuations db db.sqlite io.directories io.files.temp -webapps.mason.backend tools.test ; +USING: continuations db io.directories io.files.temp tools.test +webapps.mason.backend webapps.utils ; IN: webapps.mason.backend.tests [ "mason-test.db" temp-file delete-file ] ignore-errors @@ -7,7 +7,7 @@ IN: webapps.mason.backend.tests { 0 1 2 } [ ! Do it in a with-transaction to simulate semantics of ! with-mason-db - "mason-test.db" temp-file <sqlite-db> [ + "mason-test.db" <temp-sqlite-db> [ [ init-mason-db diff --git a/extra/webapps/site-watcher/site-watcher.factor b/extra/webapps/site-watcher/site-watcher.factor index 80ec7363b9..a41dbdba8f 100644 --- a/extra/webapps/site-watcher/site-watcher.factor +++ b/extra/webapps/site-watcher/site-watcher.factor @@ -1,16 +1,15 @@ ! Copyright (C) 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors assocs db.sqlite furnace furnace.actions +USING: accessors assocs db db.sqlite db.tuples furnace furnace.actions furnace.alloy furnace.auth furnace.auth.features.deactivate-user furnace.auth.features.edit-profile furnace.auth.features.recover-password furnace.auth.features.registration furnace.auth.login furnace.boilerplate furnace.redirection html.forms http.server http.server.dispatchers kernel namespaces site-watcher site-watcher.db -site-watcher.private urls validators io.sockets.secure.debug -io.servers io.files.temp db db.tuples sequences +site-watcher.private urls sequences validators webapps.site-watcher.common webapps.site-watcher.watching -webapps.site-watcher.spidering ; +webapps.site-watcher.spidering webapps.utils ; QUALIFIED: assocs IN: webapps.site-watcher @@ -62,14 +61,8 @@ IN: webapps.site-watcher allow-edit-profile allow-deactivation ; -: <site-watcher-server> ( -- threaded-server ) - <http-server> - <test-secure-config> >>secure-config - 8081 >>insecure - 8431 >>secure ; - : site-watcher-db ( -- db ) - "test.db" temp-file <sqlite-db> ; + "test.db" <temp-sqlite-db> ; <site-watcher-app> <login-config> @@ -89,4 +82,4 @@ M: site-watcher-app init-user-profile : start-site-watcher ( -- ) init-db site-watcher-db run-site-watcher - <site-watcher-server> start-server drop ; + run-test-httpd ; diff --git a/extra/webapps/todo/todo.factor b/extra/webapps/todo/todo.factor index 103bb1bdab..0fd46994e0 100644 --- a/extra/webapps/todo/todo.factor +++ b/extra/webapps/todo/todo.factor @@ -4,7 +4,7 @@ USING: accessors kernel sequences namespaces db db.types db.tuples validators hashtables urls html.forms html.components html.templates.chloe http.server http.server.dispatchers furnace furnace.boilerplate furnace.auth furnace.actions furnace.redirection furnace.db furnace.auth.login -io.sockets.secure.debug ; +webapps.utils ; IN: webapps.todo TUPLE: todo-list < dispatcher ; @@ -111,10 +111,7 @@ todo "TODO" USING: furnace.auth.features.registration furnace.auth.features.edit-profile furnace.auth.features.deactivate-user -db.sqlite -furnace.alloy -io.servers -io.sockets.secure ; +furnace.alloy ; : <login-config> ( responder -- responder' ) "Todo list" <login-realm> @@ -122,7 +119,8 @@ io.sockets.secure ; allow-edit-profile allow-deactivation ; -: todo-db ( -- db ) "resource:todo.db" <sqlite-db> ; +: todo-db ( -- db ) + "todo.db" <temp-sqlite-db> ; : init-todo-db ( -- ) todo-db [ @@ -136,15 +134,9 @@ io.sockets.secure ; <login-config> todo-db <alloy> ; -: <todo-website-server> ( -- threaded-server ) - <http-server> - <test-secure-config> >>secure-config - 8080 >>insecure - 8431 >>secure ; - : run-todo ( -- ) <todo-app> main-responder set-global todo-db start-expiring - <todo-website-server> start-server drop ; + run-test-httpd ; MAIN: run-todo diff --git a/extra/webapps/utils/utils.factor b/extra/webapps/utils/utils.factor new file mode 100644 index 0000000000..9d6195e198 --- /dev/null +++ b/extra/webapps/utils/utils.factor @@ -0,0 +1,15 @@ +USING: accessors db.sqlite http.server io.files.temp io.servers +io.sockets.secure.debug kernel ; +IN: webapps.utils + +: <temp-sqlite-db> ( name -- db ) + temp-file <sqlite-db> ; + +: <test-http-server> ( -- threaded-server ) + <http-server> + <test-secure-config> >>secure-config + 8081 >>insecure + 8431 >>secure ; + +: run-test-httpd ( -- ) + <test-http-server> start-server drop ; diff --git a/extra/webapps/wiki/example/example.factor b/extra/webapps/wiki/example/example.factor index 99c005f96e..3b419e9a9c 100644 --- a/extra/webapps/wiki/example/example.factor +++ b/extra/webapps/wiki/example/example.factor @@ -1,12 +1,11 @@ -USING: accessors calendar db db.sqlite db.tuples furnace.alloy +USING: accessors calendar db db.tuples furnace.alloy furnace.recaptcha.example http.server io.directories -io.encodings.ascii io.files io.files.temp io.servers -io.sockets.secure.debug kernel namespaces sequences splitting -webapps.wiki websites.concatenative ; +io.encodings.ascii io.files io.servers kernel namespaces sequences +splitting webapps.utils webapps.wiki websites.concatenative ; IN: webapps.wiki.example : wiki-db ( -- db ) - "wiki.db" temp-file <sqlite-db> ; + "wiki.db" <temp-sqlite-db> ; : insert-page ( file-name -- ) dup ".txt" ?tail [ @@ -39,16 +38,10 @@ IN: webapps.wiki.example <factor-boilerplate> wiki-db <alloy> ; -: <wiki-website-server> ( -- threaded-server ) - <http-server> - <test-secure-config> >>secure-config - 8080 >>insecure - 8431 >>secure ; - : run-wiki ( -- ) init-wiki-db <wiki-app> main-responder set-global wiki-db start-expiring - <wiki-website-server> start-server drop ; + run-test-httpd ; MAIN: run-wiki