1 ! Copyright (C) 2008 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: math kernel accessors http.server http.server.dispatchers
4 furnace furnace.actions furnace.sessions furnace.redirection
5 html.components html.forms fry urls ;
10 TUPLE: counter-app < dispatcher ;
12 M: counter-app init-session* drop 0 count sset ;
14 : <counter-action> ( quot -- action )
18 URL" $counter-app" <redirect>
21 : <display-action> ( -- action )
23 [ count sget "counter" set-value ] >>init
24 { counter-app "counter" } >>template ;
26 : <counter-app> ( -- responder )
27 counter-app new-dispatcher
28 [ 1+ ] <counter-action> "inc" add-responder
29 [ 1- ] <counter-action> "dec" add-responder
30 <display-action> "" add-responder ;
33 USING: db.sqlite furnace.alloy namespaces ;
35 : counter-db ( -- db ) "counter.db" <sqlite-db> ;
40 main-responder set-global