From: slava Date: Thu, 19 Oct 2006 22:09:43 +0000 (+0000) Subject: More web framework work X-Git-Tag: 0.85~5 X-Git-Url: https://gitweb.factorcode.org/gitweb.cgi?p=factor.git;a=commitdiff_plain;h=21e4d08362e8831e7982f2e8066c1f3217c10e12 More web framework work --- diff --git a/TODO.FACTOR.txt b/TODO.FACTOR.txt index 27ddc07d50..81439e4519 100644 --- a/TODO.FACTOR.txt +++ b/TODO.FACTOR.txt @@ -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 ] . diff --git a/contrib/furnace-pastebin/pastebin.factor b/contrib/furnace-pastebin/pastebin.factor index c1501d5e4d..2378487321 100644 --- a/contrib/furnace-pastebin/pastebin.factor +++ b/contrib/furnace-pastebin/pastebin.factor @@ -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 diff --git a/contrib/furnace/responder.factor b/contrib/furnace/responder.factor index a434aacf35..17c9ee9474 100644 --- a/contrib/furnace/responder.factor +++ b/contrib/furnace/responder.factor @@ -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 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 ; diff --git a/contrib/furnace/tools/browser.factor b/contrib/furnace/tools/browser.factor index 01fe1e1e6d..d388093186 100644 --- a/contrib/furnace/tools/browser.factor +++ b/contrib/furnace/tools/browser.factor @@ -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" render-page ; +: browse ( word vocab apropos -- ) + pick pick browser-title >r "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 f \ browse + 4array >quotation quot-link ; diff --git a/contrib/furnace/tools/browser.fhtml b/contrib/furnace/tools/browser.fhtml index d9e269b34e..52508c6b01 100644 --- a/contrib/furnace/tools/browser.fhtml +++ b/contrib/furnace/tools/browser.fhtml @@ -1,11 +1,12 @@ -<% USING: namespaces furnace:browser words help kernel ; %> +<% USING: namespaces furnace:browser words help kernel tools sequences io +html ; %>
- - - + + +
VocabulariesWordsDocumentationVocabulariesWordsDocumentation
@@ -19,4 +20,14 @@
+

Apropos

+
+ <% + "apropos" get dup empty? [ + drop + ] [ + "Results for " write dup write ":" write
+ apropos + ] if + %>
diff --git a/contrib/furnace/tools/help.factor b/contrib/furnace/tools/help.factor index 7257cc3f4b..fe178b5a5d 100644 --- a/contrib/furnace/tools/help.factor +++ b/contrib/furnace/tools/help.factor @@ -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 +
+ "Search" write ] 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" 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 index 0000000000..28718d3311 --- /dev/null +++ b/contrib/furnace/tools/search.fhtml @@ -0,0 +1,15 @@ +<% USING: help kernel sequences html namespaces io ; %> + +
+

Search help

+ + <% + "terms" get dup empty? [ + drop + ] [ + "Results for " write dup write ":" write
+ search-help. + ] if + %> + +