]> gitweb.factorcode.org Git - factor.git/blob - extra/webapps/help/help.factor
Merge branch 'master' of git://factorcode.org/git/factor
[factor.git] / extra / webapps / help / help.factor
1 ! Copyright (C) 2008 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: kernel accessors http.server.dispatchers
4 http.server.static furnace.actions furnace.redirection urls
5 validators locals io.files html.forms html.components help.html ;
6 IN: webapps.help
7
8 TUPLE: help-webapp < dispatcher ;
9
10 M: result link-title title>> ;
11
12 M: result link-href href>> ;
13
14 :: <search-action> ( help-dir -- action )
15     <page-action>
16         { help-webapp "search" } >>template
17
18         [
19             {
20                 { "search" [ 1 v-min-length 50 v-max-length v-one-line ] }
21             } validate-params
22
23             help-dir [
24                 "search" value article-apropos "articles" set-value
25                 "search" value word-apropos "words" set-value
26                 "search" value vocab-apropos "vocabs" set-value
27             ] with-directory
28
29             { help-webapp "search" } <chloe-content>
30         ] >>submit ;
31
32 : <main-action> ( -- action )
33     <page-action>
34         { help-webapp "help" } >>template ;
35
36 : <help-webapp> ( help-dir -- webapp )
37     help-webapp new-dispatcher
38         <main-action> "" add-responder
39         over <search-action> "search" add-responder
40         swap <static> "content" add-responder ;
41
42