]> gitweb.factorcode.org Git - factor.git/blob - extra/webapps/wiki/example/example.factor
mason: made build targets into a table and added timestamp on report
[factor.git] / extra / webapps / wiki / example / example.factor
1 USING: accessors calendar db db.tuples furnace.alloy
2 furnace.recaptcha.example http.server io.directories
3 io.encodings.ascii io.files io.servers kernel namespaces sequences
4 splitting webapps.utils webapps.wiki websites.concatenative ;
5 IN: webapps.wiki.example
6
7 : wiki-db ( -- db )
8     "wiki.db" <temp-sqlite-db> ;
9
10 : insert-page ( file-name -- )
11     dup ".txt" ?tail [
12         swap ascii file-contents
13         f <revision>
14             swap >>content
15             swap >>title
16             "slava" >>author
17             now >>date
18         add-revision
19     ] [ 2drop ] if ;
20
21 : insert-pages ( -- )
22     "resource:extra/webapps/wiki/initial-content" [
23         [ insert-page ] each
24     ] with-directory-files ;
25
26 : init-wiki-db ( -- )
27     wiki-db [
28         init-furnace-tables
29         article ensure-table
30         revision ensure-table
31         insert-pages
32     ] with-db ;
33
34 : <wiki-app> ( -- dispatcher )
35     <wiki>
36     <test-recaptcha>
37     <login-config>
38     <factor-boilerplate>
39     wiki-db <alloy> ;
40
41 : run-wiki ( -- )
42     init-wiki-db
43     <wiki-app> main-responder set-global
44     wiki-db start-expiring
45     run-test-httpd ;
46
47 MAIN: run-wiki