webapps.wiki.example: new vocab to show how the wiki webapp should be

run

it's a little tricky to figure out so a vocab demonstrating it is useful
db4
Björn Lindqvist 2015-10-04 03:07:29 +02:00
parent 28c179cf59
commit cc4bb991b2
3 changed files with 61 additions and 19 deletions

View File

@ -17,11 +17,14 @@ TUPLE: recaptcha-app < dispatcher recaptcha ;
[ "?good" >url <redirect> ] >>submit [ "?good" >url <redirect> ] >>submit
{ recaptcha-app "example" } >>template ; { recaptcha-app "example" } >>template ;
: <test-recaptcha> ( responder -- recaptcha )
<recaptcha>
"concatenative.org" >>domain
"6LeJWQgAAAAAAFlYV7SuBClE9uSpGtV_ZS-qVON7" >>public-key
"6LeJWQgAAAAAALh-XJgSSQ6xKygRgJ8-029Ip2Xv" >>private-key ;
: <recaptcha-app> ( -- obj ) : <recaptcha-app> ( -- obj )
\ recaptcha-app new-dispatcher \ recaptcha-app new-dispatcher
<recaptcha-challenge> "" add-responder <recaptcha-challenge> "" add-responder
<recaptcha> <test-recaptcha>
"concatenative.org" >>domain
"6LeJWQgAAAAAAFlYV7SuBClE9uSpGtV_ZS-qVON7" >>public-key
"6LeJWQgAAAAAALh-XJgSSQ6xKygRgJ8-029Ip2Xv" >>private-key
recaptcha-db <alloy> ; recaptcha-db <alloy> ;

View File

@ -0,0 +1,54 @@
USING: accessors calendar db db.sqlite 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 ;
IN: webapps.wiki.example
: wiki-db ( -- db )
"wiki.db" temp-file <sqlite-db> ;
: insert-page ( file-name -- )
dup ".txt" ?tail [
swap ascii file-contents
f <revision>
swap >>content
swap >>title
"slava" >>author
now >>date
add-revision
] [ 2drop ] if ;
: insert-pages ( -- )
"resource:extra/webapps/wiki/initial-content" [
[ insert-page ] each
] with-directory-files ;
: init-wiki-db ( -- )
wiki-db [
init-furnace-tables
article ensure-table
revision ensure-table
insert-pages
] with-db ;
: <wiki-app> ( -- dispatcher )
<wiki>
<test-recaptcha>
<login-config>
<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 ;
MAIN: run-wiki

View File

@ -370,18 +370,3 @@ M: revision feed-entry-url id>> revision-url ;
<boilerplate> <boilerplate>
[ init-sidebars init-relative-link-prefix ] >>init [ init-sidebars init-relative-link-prefix ] >>init
{ wiki "wiki-common" } >>template ; { wiki "wiki-common" } >>template ;
: init-wiki ( -- )
"resource:extra/webapps/wiki/initial-content" [
[
dup ".txt" ?tail [
swap ascii file-contents
f <revision>
swap >>content
swap >>title
"slava" >>author
now >>date
add-revision
] [ 2drop ] if
] each
] with-directory-files ;