]> gitweb.factorcode.org Git - factor.git/commitdiff
webapps.help: tokenize and collapse search terms
authorJohn Benediktsson <mrjbq7@gmail.com>
Fri, 26 Aug 2022 21:25:26 +0000 (14:25 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Fri, 26 Aug 2022 21:28:03 +0000 (14:28 -0700)
extra/webapps/help/help.factor

index 79c789ed02218eb891d3de54bbb78ee629f6397c..faa1b11a5a511488b4e58ddcea7e9f836fc8c3fe 100644 (file)
@@ -4,7 +4,8 @@ USING: accessors assocs furnace.actions furnace.boilerplate
 furnace.redirection help.html help.topics html.components
 html.forms http.server http.server.dispatchers
 http.server.static io.directories io.files.temp io.servers
-kernel namespaces sequences splitting unicode urls ;
+kernel namespaces sequences simple-tokenizer splitting unicode
+urls ;
 IN: webapps.help
 
 TUPLE: help-webapp < dispatcher ;
@@ -21,6 +22,9 @@ TUPLE: help-webapp < dispatcher ;
 : ?links ( has-links? apropos -- has-links? seq/f )
     links [ f ] [ nip t swap ] if-empty ;
 
+: ?tokenize ( str -- str' )
+    [ tokenize ] [ drop 1array ] recover ;
+
 :: <search-action> ( help-dir -- action )
     <page-action>
         { help-webapp "search" } >>template
@@ -28,6 +32,7 @@ TUPLE: help-webapp < dispatcher ;
             f "search" param [ unicode:blank? ] trim
             dup "search" set-value [
                 help-dir [
+                    ?tokenize concat
                     [ article-apropos ?links "articles" set-value ]
                     [ word-apropos ?links "words" set-value ]
                     [ vocab-apropos ?links "vocabs" set-value ] tri