! Copyright (C) 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: accessors assocs furnace.actions furnace.boilerplate furnace.redirection help.html help.topics html.components html.forms http.server http.server.dispatchers http.server.static io.directories io.files.temp io.servers kernel namespaces sequences unicode urls ; IN: webapps.help TUPLE: help-webapp < dispatcher ; : links ( apropos -- seq ) [ swap ] { } assoc>map ; : ?links ( has-links? apropos -- has-links? seq ) links [ empty? not or ] keep ; :: ( help-dir -- action ) { help-webapp "search" } >>template [ "search" param [ unicode:blank? ] trim [ f swap help-dir [ [ article-apropos ?links "articles" set-value ] [ word-apropos ?links "words" set-value ] [ vocab-apropos ?links "vocabs" set-value ] tri ] with-directory not "empty" set-value ] unless-empty help-navbar "navbar" set-value { help-webapp "search" } ] >>display { help-webapp "help" } >>template ; : help-url ( topic -- url ) topic>filename "$help-webapp/content/" prepend >url ; : ( -- action ) [ "handbook" >link help-url ] >>display ; :: ( help-dir -- webapp ) help-webapp new-dispatcher "" add-responder help-dir "search" add-responder help-dir "content" add-responder ; : run-help-webapp ( -- ) "docs" cache-file main-responder set-global 8080 httpd wait-for-server ; MAIN: run-help-webapp