2008-09-29 05:10:20 -04:00
|
|
|
! Copyright (C) 2008 Slava Pestov.
|
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
2011-10-14 01:09:30 -04:00
|
|
|
USING: accessors db.sqlite furnace.actions furnace.alloy
|
|
|
|
furnace.redirection help.html help.topics html.components
|
|
|
|
html.forms html.templates.chloe http.server
|
|
|
|
http.server.dispatchers http.server.static io.directories
|
|
|
|
io.files kernel locals namespaces sequences unicode.categories
|
|
|
|
urls ;
|
2008-09-29 05:10:20 -04:00
|
|
|
IN: webapps.help
|
|
|
|
|
|
|
|
TUPLE: help-webapp < dispatcher ;
|
|
|
|
|
2008-11-23 04:55:43 -05:00
|
|
|
M: result link-title title>> ;
|
|
|
|
|
|
|
|
M: result link-href href>> ;
|
|
|
|
|
2008-09-29 05:10:20 -04:00
|
|
|
:: <search-action> ( help-dir -- action )
|
|
|
|
<page-action>
|
|
|
|
{ help-webapp "search" } >>template
|
|
|
|
[
|
2011-10-14 01:09:30 -04:00
|
|
|
"search" param [ blank? ] trim [
|
|
|
|
help-dir [
|
|
|
|
[ article-apropos "articles" set-value ]
|
|
|
|
[ word-apropos "words" set-value ]
|
|
|
|
[ vocab-apropos "vocabs" set-value ] tri
|
|
|
|
] with-directory
|
|
|
|
] unless-empty
|
2008-09-29 05:10:20 -04:00
|
|
|
|
|
|
|
{ help-webapp "search" } <chloe-content>
|
|
|
|
] >>submit ;
|
|
|
|
|
2011-10-14 01:09:30 -04:00
|
|
|
: help-url ( topic -- url )
|
|
|
|
topic>filename "$help-webapp/content/" prepend >url ;
|
|
|
|
|
2008-09-29 05:10:20 -04:00
|
|
|
: <main-action> ( -- action )
|
2011-10-14 01:09:30 -04:00
|
|
|
<action>
|
|
|
|
[ "handbook" >link help-url <redirect> ] >>display ;
|
2008-09-29 05:10:20 -04:00
|
|
|
|
2011-10-14 01:09:30 -04:00
|
|
|
:: <help-webapp> ( help-dir -- webapp )
|
2008-09-29 05:10:20 -04:00
|
|
|
help-webapp new-dispatcher
|
|
|
|
<main-action> "" add-responder
|
2011-10-14 01:09:30 -04:00
|
|
|
help-dir <search-action> "search" add-responder
|
2011-10-03 14:09:12 -04:00
|
|
|
help-dir <static> "content" add-responder
|
2009-09-23 21:56:47 -04:00
|
|
|
"resource:basis/definitions/icons/" <static> "icons" add-responder ;
|
2008-09-29 05:10:20 -04:00
|
|
|
|
2011-09-27 13:20:15 -04:00
|
|
|
: run-help-webapp ( -- )
|
2011-10-14 01:09:30 -04:00
|
|
|
"resource:temp/docs" <help-webapp>
|
2011-09-27 13:20:15 -04:00
|
|
|
main-responder set-global
|
|
|
|
8080 httpd drop ;
|
2008-09-29 05:10:20 -04:00
|
|
|
|
2011-09-27 13:20:15 -04:00
|
|
|
MAIN: run-help-webapp
|