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
27 dup array? [ " " join ] when
28 [ show-help ] curry quot-link
31 : show-word ( word vocab -- )
35 { "vocab" "kernel" v-default }
36 { "word" "call" v-default }
39 M: word browser-link-href
40 dup word-name swap word-vocabulary
41 [ show-word ] 2curry quot-link ;
43 : show-vocab ( vocab -- )
44 f >vocab-link show-help ;
47 { "vocab" "kernel" v-default }
50 M: vocab-spec browser-link-href
51 vocab-name [ show-vocab ] curry quot-link ;
53 : show-vocabs-tagged ( tag -- )
54 <vocab-tag> show-help ;
56 \ show-vocabs-tagged {
60 M: vocab-tag browser-link-href
61 vocab-tag-name [ show-vocabs-tagged ] curry quot-link ;
63 : show-vocabs-by ( author -- )
64 <vocab-author> show-help ;
70 M: vocab-author browser-link-href
71 vocab-author-name [ show-vocabs-by ] curry quot-link ;
73 "help" "show-help" "extra/webapps/help" web-app
75 ! Hard-coding for factorcode.org
76 PREDICATE: pathname resource-pathname
77 pathname-string "resource:" head? ;
79 M: resource-pathname browser-link-href
81 "resource:" ?head drop
82 "/responder/resources/" swap append ;