1 ! Copyright (C) 2005, 2007 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: kernel furnace furnace.validator http.server.responders
4 help help.topics html splitting sequences words strings
5 quotations macros vocabs tools.browser combinators
9 ! : string>topic ( string -- topic )
10 ! " " split dup length 1 = [ first ] when ;
12 : show-help ( topic -- )
15 [ help ] with-html-stream
16 ] simple-html-document ;
21 \ show-help { { "topic" "handbook" } } default-values
23 M: link browser-link-href
25 dup word? over f eq? or [
28 dup array? [ " " join ] when
29 [ show-help ] curry quot-link
32 : show-word ( word vocab -- )
39 \ show-word { { "word" "call" } { "vocab" "kernel" } } default-values
41 M: f browser-link-href
42 drop \ f browser-link-href ;
44 M: word browser-link-href
45 dup word-name swap word-vocabulary
46 [ show-word ] 2curry quot-link ;
48 : show-vocab ( vocab -- )
49 f >vocab-link show-help ;
55 \ show-vocab { { "vocab" "kernel" } } default-values
57 M: vocab-spec browser-link-href
58 vocab-name [ show-vocab ] curry quot-link ;
60 : show-vocabs-tagged ( tag -- )
61 <vocab-tag> show-help ;
63 \ show-vocabs-tagged {
67 M: vocab-tag browser-link-href
68 vocab-tag-name [ show-vocabs-tagged ] curry quot-link ;
70 : show-vocabs-by ( author -- )
71 <vocab-author> show-help ;
77 M: vocab-author browser-link-href
78 vocab-author-name [ show-vocabs-by ] curry quot-link ;
80 "help" "show-help" "extra/webapps/help" web-app
82 ! Hard-coding for factorcode.org
83 PREDICATE: pathname resource-pathname
84 pathname-string "resource:" head? ;
86 M: resource-pathname browser-link-href
88 "resource:" ?head drop
89 "/responder/source/" swap append ;