X-Git-Url: https://gitweb.factorcode.org/gitweb.cgi?p=factor.git;a=blobdiff_plain;f=extra%2Fwebapps%2Fhelp%2Fhelp.factor;h=faa1b11a5a511488b4e58ddcea7e9f836fc8c3fe;hp=faac2d4fd46da7304b6d48b66006c09b535179a2;hb=3db5f47bade7e2b8eb36c0c77398e6c1e10a6e55;hpb=a17da74181fc87938aee868e6e6f097b2119edc6 diff --git a/extra/webapps/help/help.factor b/extra/webapps/help/help.factor index faac2d4fd4..faa1b11a5a 100644 --- a/extra/webapps/help/help.factor +++ b/extra/webapps/help/help.factor @@ -4,15 +4,16 @@ 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 unicode urls ; +kernel namespaces sequences simple-tokenizer splitting unicode +urls ; IN: webapps.help TUPLE: help-webapp < dispatcher ; : fixup-words ( title href -- title' href' ) dup "word-" head? [ - dup ".html" ?tail drop "," split1-last nip - '[ " (" _ 3append ")" append ] dip + dup ".html" ?tail drop "," split1-last nip dup ":" append + '[ " (" _ 3append ")" append _ ?head drop ] dip ] when ; : links ( apropos -- seq ) @@ -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 ; + :: ( help-dir -- action ) { help-webapp "search" } >>template @@ -28,12 +32,13 @@ 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 ] with-directory ] unless-empty not "empty" set-value - help-navbar "navbar" set-value + help-nav "nav" set-value { help-webapp "search" } ] >>display