]> gitweb.factorcode.org Git - factor.git/commitdiff
FUEL: breadcrumb system on vocabs/tag and vocabs/author pages
authorBjörn Lindqvist <bjourne@gmail.com>
Fri, 7 Jul 2017 13:01:26 +0000 (15:01 +0200)
committerBjörn Lindqvist <bjourne@gmail.com>
Fri, 7 Jul 2017 13:26:03 +0000 (15:26 +0200)
extra/fuel/help/help-docs.factor
extra/fuel/help/help-tests.factor
extra/fuel/help/help.factor

index 4f8772083fd313a60024e0634de8631dccb68e91..6cbdcc27cc10915b5afa94f8ad3de92e027e0f50 100644 (file)
@@ -12,3 +12,12 @@ HELP:  get-article
 HELP: find-word
 { $values { "name" string } { "word/f" "word or f" } }
 { $description "Prefer to use search which takes the execution context into account. If that fails, fall back on a search of all words." } ;
+
+HELP: vocab-element
+{ $values { "name" string } { "element" sequence } }
+{ $description "Creates help markup for a vocab suitable for rendering with FUEL." }
+{ $see-also article-element word-element } ;
+
+HELP: get-vocabs/tag
+{ $values { "tag" string } { "element" sequence } }
+{ $description "Creates help markup for a page listing all vocabs with a given tag." } ;
index f0db961334225dc889f4a82a3221756d6005c194..d8a75e21a4fd19aab74ab4a7f4ee8834578263de 100644 (file)
@@ -34,3 +34,12 @@ IN: fuel.help.tests
 } [
     "server-config" article-parents
 ] unit-test
+
+{
+    {
+        { "handbook" "Factor handbook" article }
+        { "first-program" "Your first program" article }
+    }
+} [
+    "first-program-test" article-crumbs
+] unit-test
index 7031b66cc85a957cf8fef961b8566ba9cccb5bf2..48500f5777ccc24d368d71e8751ee3b21e2e4fcd 100644 (file)
@@ -9,7 +9,10 @@ IN: fuel.help
 
 SYMBOLS: $doc-path $next-link $prev-link $fuel-nav-crumbs ;
 
-: common-crumbs ( -- crumbs )
+: articles-crumbs ( seq -- crumbs )
+    [ dup article-title \ article 3array ] map ;
+
+: base-crumbs ( -- crumbs )
     { "handbook" "vocab-index" } [ dup article-title \ article 3array ] map ;
 
 : vocab-own-crumbs ( vocab-name -- crumbs )
@@ -19,7 +22,7 @@ SYMBOLS: $doc-path $next-link $prev-link $fuel-nav-crumbs ;
     [ dup "." split last \ vocab 3array ] map ;
 
 : vocab-crumbs ( vocab-name -- crumbs )
-    vocab-own-crumbs common-crumbs prepend ;
+    vocab-own-crumbs base-crumbs prepend ;
 
 : article-parents ( article-name -- parents )
     [ article-parent ] follow
@@ -131,13 +134,19 @@ PRIVATE>
 : vocab-help ( name -- str )
     dup empty? [ vocab-children-help ] [ vocab-element ] if ;
 
+: add-crumb ( crumbs article -- crumbs' )
+    dup article-name 2array suffix ;
+
+: simple-element ( title content crumbs -- element )
+    \ $fuel-nav-crumbs prefix prefix \ article -rot 3array ;
+
 : get-vocabs/author ( author -- element )
-    [ "Vocabularies by " prepend \ $heading swap 2array ]
-    [ authored do-vocab-list ] bi 2array ;
+    [ "Vocabularies by " prepend ] [ authored do-vocab-list ] bi
+    base-crumbs "vocab-authors" add-crumb simple-element ;
 
 : get-vocabs/tag ( tag -- element )
-    [ "Vocabularies tagged " prepend \ $heading swap 2array ]
-    [ tagged do-vocab-list ] bi 2array ;
+    [ "Vocabularies tagged " prepend ] [ tagged do-vocab-list ] bi
+    base-crumbs "vocab-tags" add-crumb simple-element ;
 
 : format-index ( seq -- seq )
     [ [ >link name>> ] [ article-title ] bi 2array \ $subsection prefix ] map ;
@@ -153,5 +162,5 @@ PRIVATE>
 : vocab-help-article?  ( name -- ? )
     dup lookup-vocab [ help>> = ] [ drop f ] if* ;
 
-: get-article ( name -- str )
+: get-article ( name -- element )
     dup vocab-help-article? [ vocab-help ] [ article-element ] if ;