]> gitweb.factorcode.org Git - factor.git/commitdiff
More web framework work
authorslava <slava@factorcode.org>
Thu, 19 Oct 2006 22:09:43 +0000 (22:09 +0000)
committerslava <slava@factorcode.org>
Thu, 19 Oct 2006 22:09:43 +0000 (22:09 +0000)
TODO.FACTOR.txt
contrib/furnace-pastebin/pastebin.factor
contrib/furnace/responder.factor
contrib/furnace/tools/browser.factor
contrib/furnace/tools/browser.fhtml
contrib/furnace/tools/help.factor
contrib/furnace/tools/search.fhtml [new file with mode: 0644]

index 27ddc07d50471f46377a5215ec6813a05234b279..81439e4519473f6f5d28d42b30c81fbb33d32f4f 100644 (file)
@@ -1,5 +1,4 @@
 - live search: timer delay would be nice
-- httpd search tools
 - hashed generic method dispatch
 - fix this:
   [ 1 2 3 4 5 6 7 8 9 10 10 10 10 10 10 10 10 10 10 11 11 11 113 ] .
index c1501d5e4dc3b0f32af7b27ded00895793e442d3..23784873213d2a02e4174441abbd9e8940a2a099 100644 (file)
@@ -29,14 +29,12 @@ C: pastebin ( -- pastebin )
     pastebin get pastebin-pastes nth ;
 
 : show-paste ( n -- )
-    "Paste"
-    swap get-paste
-    "show-paste" render-page ;
+    get-paste "show-paste" "Paste" render-page ;
 
 \ show-paste { { "n" v-number } } define-action
 
 : new-paste ( -- )
-    "New paste" f "new-paste" render-page ;
+    f "new-paste" "New paste" render-page ;
 
 \ new-paste { } define-action
 
@@ -55,9 +53,7 @@ C: pastebin ( -- pastebin )
         [ show-paste ] "show-paste-quot" set
         [ new-paste ] "new-paste-quot" set
 
-        "Pastebin"
-        pastebin get
-        "paste-list" render-page
+        pastebin get "paste-list" "Pastebin" render-page
     ] with-scope ;
 
 \ paste-list { } define-action
index a434aacf3597ad330d79c1c2f3b98b8fda7607fd..17c9ee94749139cc130c2a86a61913ea7abe952d 100644 (file)
@@ -98,20 +98,12 @@ SYMBOL: model
         ".fhtml" append resource-path run-embedded-file
     ] with-scope ;
 
-TUPLE: component model template ;
-
-TUPLE: page title root ;
-
-C: page ( title model template -- page )
-    [ >r <component> r> set-page-root ] keep
-    [ set-page-title ] keep ;
-
 : render-template ( model template -- )
     template-path get swap path+ call-template ;
 
-: render-page ( title model template -- )
+: render-page ( model template title -- )
     [
-        rot [
+        [
             render-template
         ] html-document
     ] with-html-stream ;
index 01fe1e1e6dbb6bab08e8c0353298f874c46bfb7c..d388093186b2f2038fe573011818fafc943ed71c 100644 (file)
@@ -20,20 +20,19 @@ TUPLE: list current options name ;
     2dup lookup dup
     [ 2nip summary ] [ drop nip "IN: " swap append ] if ;
 
-TUPLE: browser word vocab ;
+TUPLE: browser word vocab apropos ;
 
-: browse ( word vocab -- )
-    2dup browser-title
-    -rot <browser>
-    "browser" render-page ;
+: browse ( word vocab apropos -- )
+    pick pick browser-title >r <browser> "browser" r> render-page ;
 
 \ browse {
     { "word" }
     { "vocab" "kernel" v-default }
+    { "apropos" }
 } define-action
 
 "browser" "browse" "contrib/furnace/tools" web-app
 
 M: word browser-link-href
-    dup word-name swap word-vocabulary \ browse
-    3array >quotation quot-link ;
+    dup word-name swap word-vocabulary \ browse
+    4array >quotation quot-link ;
index d9e269b34e94fbc2b53459fba40f0812740d5eca..52508c6b01489dc847dbba7ab4139bb03b55e57c 100644 (file)
@@ -1,11 +1,12 @@
-<% USING: namespaces furnace:browser words help kernel ; %>
+<% USING: namespaces furnace:browser words help kernel tools sequences io
+html ; %>
 
 <form id="main" action="browse" method="get">
     <table width="100%">
         <tr>
-            <th>Vocabularies</th>
-            <th>Words</th>
-            <th>Documentation</th>
+            <th align="left">Vocabularies</th>
+            <th align="left">Words</th>
+            <th align="left">Documentation</th>
         </tr>
         <tr>
             <td valign="top" style="width: 200px;">
             </td>
         </tr>
     </table>
+    <h2>Apropos</h2>
+    <input type="field" name="apropos" /><br/>
+    <%
+        "apropos" get dup empty? [
+            drop
+        ] [
+            <b> "Results for " write dup write ":" write </b> <br/>
+            apropos
+        ] if
+    %>
 </form>
index 7257cc3f4b7bac022eed1f757404276272d53b4e..fe178b5a5d277202c0d113705f938858dc9caa94 100644 (file)
@@ -1,22 +1,19 @@
 ! Copyright (C) 2005, 2006 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 IN: furnace:help
-USING: furnace help html kernel sequences words strings ;
-
-: string>topic ( string -- topic )
-    " " split dup length 1 = [ first ] when ;
+USING: furnace help html kernel sequences words strings io ;
 
 : show-help ( topic -- )
     dup article-title [
         [ help ] with-html-stream
+        <br/>
+        <a "search" =href a> "Search" write </a>
     ] html-document ;
 
 \ show-help {
     { "topic" "handbook" v-default string>topic }
 } define-action
 
-"help" "show-help" "contrib/furnace/tools" web-app
-
 M: link browser-link-href
     link-name [ \ f ] unless* dup word? [
         browser-link-href
@@ -24,3 +21,14 @@ M: link browser-link-href
         dup [ string? ] all? [ " " join ] when
         [ show-help ] curry quot-link
     ] if ;
+
+TUPLE: search terms ;
+
+: search ( terms -- )
+    <search> "search" "Search" render-page ;
+
+\ search {
+    { "terms" }
+} define-action
+
+"help" "show-help" "contrib/furnace/tools" web-app
diff --git a/contrib/furnace/tools/search.fhtml b/contrib/furnace/tools/search.fhtml
new file mode 100644 (file)
index 0000000..28718d3
--- /dev/null
@@ -0,0 +1,15 @@
+<% USING: help kernel sequences html namespaces io ; %>
+
+<form action="search" method="get">
+    <h1>Search help</h1>
+    <input type="field" name="terms" />
+    <%
+        "terms" get dup empty? [
+            drop
+        ] [
+            <b> "Results for " write dup write ":" write </b> <br/>
+            search-help.
+        ] if
+    %>
+    <input type="submit" />
+</form>