diff --git a/basis/furnace/recaptcha/example/authors.txt b/basis/furnace/recaptcha/example/authors.txt new file mode 100644 index 0000000000..b4bd0e7b35 --- /dev/null +++ b/basis/furnace/recaptcha/example/authors.txt @@ -0,0 +1 @@ +Doug Coleman \ No newline at end of file diff --git a/basis/furnace/recaptcha/example/example.factor b/basis/furnace/recaptcha/example/example.factor new file mode 100644 index 0000000000..264be678ae --- /dev/null +++ b/basis/furnace/recaptcha/example/example.factor @@ -0,0 +1,31 @@ +! Copyright (C) 2009 Doug Coleman. +! See http://factorcode.org/license.txt for BSD license. +USING: accessors db.sqlite furnace.actions furnace.alloy +furnace.conversations furnace.recaptcha furnace.redirection +html.templates.chloe.compiler http.server +http.server.dispatchers http.server.responses io.streams.string +kernel urls xml.syntax ; +IN: furnace.recaptcha.example + +TUPLE: recaptcha-app < dispatcher recaptcha ; + +: recaptcha-db ( -- obj ) "recaptcha-example" ; + +: ( -- obj ) + + [ + begin-conversation + validate-recaptcha + recaptcha-valid? cget + "?good" "?bad" ? >url + ] >>submit + { recaptcha-app "example" } >>template ; + +: ( -- obj ) + \ recaptcha-app new-dispatcher + "" add-responder + + "concatenative.org" >>domain + "6LeJWQgAAAAAAFlYV7SuBClE9uSpGtV_ZS-qVON7" >>public-key + "6LeJWQgAAAAAALh-XJgSSQ6xKygRgJ8-029Ip2Xv" >>private-key + recaptcha-db ; diff --git a/basis/furnace/recaptcha/example/example.xml b/basis/furnace/recaptcha/example/example.xml new file mode 100644 index 0000000000..e59f441f7f --- /dev/null +++ b/basis/furnace/recaptcha/example/example.xml @@ -0,0 +1,4 @@ + + +
+
diff --git a/basis/furnace/recaptcha/recaptcha-docs.factor b/basis/furnace/recaptcha/recaptcha-docs.factor index 90d4a8195c..d416dd9474 100644 --- a/basis/furnace/recaptcha/recaptcha-docs.factor +++ b/basis/furnace/recaptcha/recaptcha-docs.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2009 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. USING: help.markup help.syntax http.server.filters kernel -multiline furnace.actions furnace.alloy ; +multiline furnace.actions furnace.alloy furnace.conversations ; IN: furnace.recaptcha HELP: @@ -24,49 +24,19 @@ ARTICLE: "recaptcha-example" "Recaptcha example" "There are several steps to using the Recaptcha library." { $list { "Wrap the responder in a " { $link } } + { "Wrap the responder in a " { $link } " if it is not already" } + { "Ensure that there is a database connected, with the " { $link } " word" } + { "Start a conversation to move values between requests" } { "Add a handler calling " { $link validate-recaptcha } " in the " { $slot "submit" } " of the " { $link page-action } } - { "Put the chloe tag " { $snippet "" } " in the template for your " { $link action } } + { "Pass the conversation from your submit action using " { $link } } + { "Put the chloe tag " { $snippet "" } " inside a form tag in the template for your " { $link page-action } } } -"An example follows:" +$nl +"Run this example vocabulary:" { $code -HEREDOC: RECAPTCHA-TUTORIAL -USING: db.sqlite kernel http.server.dispatchers db.sqlite -furnace.actions furnace.recaptcha furnace.conversations -furnace.redirection xml.syntax html.templates.chloe.compiler -io.streams.string http.server.responses furnace.alloy http.server ; -TUPLE: recaptcha-app < dispatcher recaptcha ; - -: recaptcha-db ( -- obj ) - "recaptcha-example" ; - -: ( -- obj ) - - [ - begin-conversation - validate-recaptcha - recaptcha-valid? cget "?good" "?bad" ? >url - ] >>submit - [ - -
- XML> - compile-template [ call( -- ) ] with-string-writer "text/html" - ] >>display ; - -: ( -- obj ) - \ recaptcha-app new-dispatcher - "" add-responder - - "concatenative.org" >>domain - "6LeJWQgAAAAAAFlYV7SuBClE9uSpGtV_ZS-qVON7" >>public-key - "6LeJWQgAAAAAALh-XJgSSQ6xKygRgJ8-029Ip2Xv" >>private-key - recaptcha-db ; - - main-responder set-global -RECAPTCHA-TUTORIAL -} - -; + "USE: furnace.recaptcha.example" + " main-responder set-global" +} ; ARTICLE: "furnace.recaptcha" "Recaptcha" "The " { $vocab-link "furnace.chloe-tags.recaptcha" } " vocabulary implements support for the Recaptcha. Recaptcha is a web service that provides the user with a captcha, a test that is easy to solve by visual inspection, but hard to solve by writing a computer program. Use a captcha to protect forms from abusive users." $nl