1 ! Copyright (C) 2008 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors db.sqlite furnace.actions furnace.alloy
4 furnace.redirection help.html help.topics html.components
5 html.forms html.templates.chloe http.server
6 http.server.dispatchers http.server.static io.directories
7 io.files kernel locals namespaces sequences unicode.categories
11 TUPLE: help-webapp < dispatcher ;
13 M: result link-title title>> ;
15 M: result link-href href>> ;
17 :: <search-action> ( help-dir -- action )
19 { help-webapp "search" } >>template
21 "search" param [ blank? ] trim [
23 [ article-apropos "articles" set-value ]
24 [ word-apropos "words" set-value ]
25 [ vocab-apropos "vocabs" set-value ] tri
28 help-navbar "navbar" set-value
30 { help-webapp "search" } <chloe-content>
33 : help-url ( topic -- url )
34 topic>filename "$help-webapp/content/" prepend >url ;
36 : <main-action> ( -- action )
38 [ "handbook" >link help-url <redirect> ] >>display ;
40 :: <help-webapp> ( help-dir -- webapp )
41 help-webapp new-dispatcher
42 <main-action> "" add-responder
43 help-dir <search-action> "search" add-responder
44 help-dir <static> "content" add-responder
45 "resource:basis/definitions/icons/" <static> "icons" add-responder ;
47 : run-help-webapp ( -- )
48 "resource:temp/docs" <help-webapp>
49 main-responder set-global