webapps.utils: new vocab with common code used in most webapps
parent
cc4bb991b2
commit
0f387e750d
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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 ;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 ;
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue