FUEL: breadcrumb system on vocabs/tag and vocabs/author pages

modern-harvey2
Björn Lindqvist 2017-07-07 15:01:26 +02:00
parent ba9a1ca5ef
commit 71b92c4e28
3 changed files with 34 additions and 7 deletions

View 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." } ;

View 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

View 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 ;