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 : show-help ( topic -- )
12 [ help ] with-html-stream
13 ] simple-html-document ;
15 : string>topic ( string -- topic )
16 " " split dup length 1 = [ first ] when ;
19 { "topic" "handbook" v-default string>topic }
22 M: link browser-link-href
24 dup word? over f eq? or [
27 dup array? [ " " join ] when
28 [ show-help ] curry quot-link
31 : show-word ( word vocab -- )
35 { "word" "call" v-default }
36 { "vocab" "kernel" v-default }
39 M: f browser-link-href
40 drop \ f browser-link-href ;
42 M: word browser-link-href
43 dup word-name swap word-vocabulary
44 [ show-word ] 2curry quot-link ;
46 : show-vocab ( vocab -- )
47 f >vocab-link show-help ;
50 { "vocab" "kernel" v-default }
53 M: vocab-spec browser-link-href
54 vocab-name [ show-vocab ] curry quot-link ;
56 : show-vocabs-tagged ( tag -- )
57 <vocab-tag> show-help ;
59 \ show-vocabs-tagged {
63 M: vocab-tag browser-link-href
64 vocab-tag-name [ show-vocabs-tagged ] curry quot-link ;
66 : show-vocabs-by ( author -- )
67 <vocab-author> show-help ;
73 M: vocab-author browser-link-href
74 vocab-author-name [ show-vocabs-by ] curry quot-link ;
76 "help" "show-help" "extra/webapps/help" web-app
78 ! Hard-coding for factorcode.org
79 PREDICATE: pathname resource-pathname
80 pathname-string "resource:" head? ;
82 M: resource-pathname browser-link-href
84 "resource:" ?head drop
85 "/responder/resources/" swap append ;