webapps.utils: new vocab with common code used in most webapps
parent
cc4bb991b2
commit
0f387e750d
|
@ -1,15 +1,13 @@
|
||||||
! Copyright (C) 2009 Doug Coleman.
|
! Copyright (C) 2009 Doug Coleman.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: db.tuples locals site-watcher site-watcher.db
|
USING: continuations db db.tuples io.directories io.files.temp kernel
|
||||||
site-watcher.private kernel db io.directories io.files.temp
|
locals sequences site-watcher.db tools.test webapps.utils ;
|
||||||
continuations db.sqlite
|
|
||||||
sequences tools.test ;
|
|
||||||
IN: site-watcher.tests
|
IN: site-watcher.tests
|
||||||
|
|
||||||
[ "site-watcher.db" temp-file delete-file ] ignore-errors
|
[ "site-watcher.db" temp-file delete-file ] ignore-errors
|
||||||
|
|
||||||
:: fake-sites ( -- seq )
|
:: fake-sites ( -- seq )
|
||||||
"site-watcher.db" temp-file <sqlite-db> [
|
"site-watcher.db" <temp-sqlite-db> [
|
||||||
account ensure-table
|
account ensure-table
|
||||||
site ensure-table
|
site ensure-table
|
||||||
watching-site ensure-table
|
watching-site ensure-table
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
USING: continuations db db.sqlite io.directories io.files.temp
|
USING: continuations db io.directories io.files.temp tools.test
|
||||||
webapps.mason.backend tools.test ;
|
webapps.mason.backend webapps.utils ;
|
||||||
IN: webapps.mason.backend.tests
|
IN: webapps.mason.backend.tests
|
||||||
|
|
||||||
[ "mason-test.db" temp-file delete-file ] ignore-errors
|
[ "mason-test.db" temp-file delete-file ] ignore-errors
|
||||||
|
@ -7,7 +7,7 @@ IN: webapps.mason.backend.tests
|
||||||
{ 0 1 2 } [
|
{ 0 1 2 } [
|
||||||
! Do it in a with-transaction to simulate semantics of
|
! Do it in a with-transaction to simulate semantics of
|
||||||
! with-mason-db
|
! with-mason-db
|
||||||
"mason-test.db" temp-file <sqlite-db> [
|
"mason-test.db" <temp-sqlite-db> [
|
||||||
[
|
[
|
||||||
init-mason-db
|
init-mason-db
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,15 @@
|
||||||
! Copyright (C) 2009 Slava Pestov.
|
! Copyright (C) 2009 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! 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.alloy furnace.auth furnace.auth.features.deactivate-user
|
||||||
furnace.auth.features.edit-profile
|
furnace.auth.features.edit-profile
|
||||||
furnace.auth.features.recover-password
|
furnace.auth.features.recover-password
|
||||||
furnace.auth.features.registration furnace.auth.login
|
furnace.auth.features.registration furnace.auth.login
|
||||||
furnace.boilerplate furnace.redirection html.forms http.server
|
furnace.boilerplate furnace.redirection html.forms http.server
|
||||||
http.server.dispatchers kernel namespaces site-watcher site-watcher.db
|
http.server.dispatchers kernel namespaces site-watcher site-watcher.db
|
||||||
site-watcher.private urls validators io.sockets.secure.debug
|
site-watcher.private urls sequences validators
|
||||||
io.servers io.files.temp db db.tuples sequences
|
|
||||||
webapps.site-watcher.common webapps.site-watcher.watching
|
webapps.site-watcher.common webapps.site-watcher.watching
|
||||||
webapps.site-watcher.spidering ;
|
webapps.site-watcher.spidering webapps.utils ;
|
||||||
QUALIFIED: assocs
|
QUALIFIED: assocs
|
||||||
IN: webapps.site-watcher
|
IN: webapps.site-watcher
|
||||||
|
|
||||||
|
@ -62,14 +61,8 @@ IN: webapps.site-watcher
|
||||||
allow-edit-profile
|
allow-edit-profile
|
||||||
allow-deactivation ;
|
allow-deactivation ;
|
||||||
|
|
||||||
: <site-watcher-server> ( -- threaded-server )
|
|
||||||
<http-server>
|
|
||||||
<test-secure-config> >>secure-config
|
|
||||||
8081 >>insecure
|
|
||||||
8431 >>secure ;
|
|
||||||
|
|
||||||
: site-watcher-db ( -- db )
|
: site-watcher-db ( -- db )
|
||||||
"test.db" temp-file <sqlite-db> ;
|
"test.db" <temp-sqlite-db> ;
|
||||||
|
|
||||||
<site-watcher-app>
|
<site-watcher-app>
|
||||||
<login-config>
|
<login-config>
|
||||||
|
@ -89,4 +82,4 @@ M: site-watcher-app init-user-profile
|
||||||
: start-site-watcher ( -- )
|
: start-site-watcher ( -- )
|
||||||
init-db
|
init-db
|
||||||
site-watcher-db run-site-watcher
|
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
|
hashtables urls html.forms html.components html.templates.chloe http.server
|
||||||
http.server.dispatchers furnace furnace.boilerplate furnace.auth
|
http.server.dispatchers furnace furnace.boilerplate furnace.auth
|
||||||
furnace.actions furnace.redirection furnace.db furnace.auth.login
|
furnace.actions furnace.redirection furnace.db furnace.auth.login
|
||||||
io.sockets.secure.debug ;
|
webapps.utils ;
|
||||||
IN: webapps.todo
|
IN: webapps.todo
|
||||||
|
|
||||||
TUPLE: todo-list < dispatcher ;
|
TUPLE: todo-list < dispatcher ;
|
||||||
|
@ -111,10 +111,7 @@ todo "TODO"
|
||||||
USING: furnace.auth.features.registration
|
USING: furnace.auth.features.registration
|
||||||
furnace.auth.features.edit-profile
|
furnace.auth.features.edit-profile
|
||||||
furnace.auth.features.deactivate-user
|
furnace.auth.features.deactivate-user
|
||||||
db.sqlite
|
furnace.alloy ;
|
||||||
furnace.alloy
|
|
||||||
io.servers
|
|
||||||
io.sockets.secure ;
|
|
||||||
|
|
||||||
: <login-config> ( responder -- responder' )
|
: <login-config> ( responder -- responder' )
|
||||||
"Todo list" <login-realm>
|
"Todo list" <login-realm>
|
||||||
|
@ -122,7 +119,8 @@ io.sockets.secure ;
|
||||||
allow-edit-profile
|
allow-edit-profile
|
||||||
allow-deactivation ;
|
allow-deactivation ;
|
||||||
|
|
||||||
: todo-db ( -- db ) "resource:todo.db" <sqlite-db> ;
|
: todo-db ( -- db )
|
||||||
|
"todo.db" <temp-sqlite-db> ;
|
||||||
|
|
||||||
: init-todo-db ( -- )
|
: init-todo-db ( -- )
|
||||||
todo-db [
|
todo-db [
|
||||||
|
@ -136,15 +134,9 @@ io.sockets.secure ;
|
||||||
<login-config>
|
<login-config>
|
||||||
todo-db <alloy> ;
|
todo-db <alloy> ;
|
||||||
|
|
||||||
: <todo-website-server> ( -- threaded-server )
|
|
||||||
<http-server>
|
|
||||||
<test-secure-config> >>secure-config
|
|
||||||
8080 >>insecure
|
|
||||||
8431 >>secure ;
|
|
||||||
|
|
||||||
: run-todo ( -- )
|
: run-todo ( -- )
|
||||||
<todo-app> main-responder set-global
|
<todo-app> main-responder set-global
|
||||||
todo-db start-expiring
|
todo-db start-expiring
|
||||||
<todo-website-server> start-server drop ;
|
run-test-httpd ;
|
||||||
|
|
||||||
MAIN: run-todo
|
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
|
furnace.recaptcha.example http.server io.directories
|
||||||
io.encodings.ascii io.files io.files.temp io.servers
|
io.encodings.ascii io.files io.servers kernel namespaces sequences
|
||||||
io.sockets.secure.debug kernel namespaces sequences splitting
|
splitting webapps.utils webapps.wiki websites.concatenative ;
|
||||||
webapps.wiki websites.concatenative ;
|
|
||||||
IN: webapps.wiki.example
|
IN: webapps.wiki.example
|
||||||
|
|
||||||
: wiki-db ( -- db )
|
: wiki-db ( -- db )
|
||||||
"wiki.db" temp-file <sqlite-db> ;
|
"wiki.db" <temp-sqlite-db> ;
|
||||||
|
|
||||||
: insert-page ( file-name -- )
|
: insert-page ( file-name -- )
|
||||||
dup ".txt" ?tail [
|
dup ".txt" ?tail [
|
||||||
|
@ -39,16 +38,10 @@ IN: webapps.wiki.example
|
||||||
<factor-boilerplate>
|
<factor-boilerplate>
|
||||||
wiki-db <alloy> ;
|
wiki-db <alloy> ;
|
||||||
|
|
||||||
: <wiki-website-server> ( -- threaded-server )
|
|
||||||
<http-server>
|
|
||||||
<test-secure-config> >>secure-config
|
|
||||||
8080 >>insecure
|
|
||||||
8431 >>secure ;
|
|
||||||
|
|
||||||
: run-wiki ( -- )
|
: run-wiki ( -- )
|
||||||
init-wiki-db
|
init-wiki-db
|
||||||
<wiki-app> main-responder set-global
|
<wiki-app> main-responder set-global
|
||||||
wiki-db start-expiring
|
wiki-db start-expiring
|
||||||
<wiki-website-server> start-server drop ;
|
run-test-httpd ;
|
||||||
|
|
||||||
MAIN: run-wiki
|
MAIN: run-wiki
|
||||||
|
|
Loading…
Reference in New Issue