1 ! Copyright (C) 2004 Chris Double.
2 ! See http://factorcode.org/license.txt for BSD license.
4 USING: definitions hashtables help html httpd io kernel memory
5 namespaces prettyprint sequences words xml ;
7 : option ( current text -- )
8 #! Output the HTML option tag for the given text. If
9 #! it is equal to the current string, make the option selected.
10 <option tuck = [ "yes" =selected ] when option>
14 : options ( current seq -- ) [ option ] each-with ;
16 : list ( current seq name -- )
17 <select =name "width: 200px;" =style "20" =size "document.forms.main.submit()" =onchange select>
21 : current-vocab ( -- string )
22 "vocab" query-param [ "kernel" ] unless* ;
24 : current-word ( -- word )
25 "word" query-param "vocab" query-param lookup ;
28 current-vocab vocabs "vocab" list ;
31 current-word [ word-name ] [ f ] if*
32 current-vocab vocab hash-keys natural-sort "word" list ;
35 #! Write the source for the given word from the vocab as HTML.
36 current-word [ [ see-help ] with-html-stream ] when* ;
39 #! Write out the HTML for the body of the main browser page.
40 <table "100%" =width table>
42 <th> "Vocabularies" write </th>
43 <th> "Words" write </th>
44 <th> "Documentation" write </th>
47 <td "top" =valign "width: 200px;" =style td>
50 <td "top" =valign "width: 200px;" =style td>
53 <td "top" =valign td> word-source </td>
57 : browser-title ( -- str )
59 [ summary ] [ "IN: " current-vocab append ] if* ;
61 : browser-responder ( -- )
62 #! Display a Smalltalk like browser for exploring words.
63 serving-html browser-title [
64 <form "main" =name "" =action "get" =method form>