FUEL: breadcrumb system on vocabs/tag and vocabs/author pages
parent
ba9a1ca5ef
commit
71b92c4e28
|
@ -12,3 +12,12 @@ HELP: get-article
|
||||||
HELP: find-word
|
HELP: find-word
|
||||||
{ $values { "name" string } { "word/f" "word or f" } }
|
{ $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." } ;
|
{ $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." } ;
|
||||||
|
|
|
@ -34,3 +34,12 @@ IN: fuel.help.tests
|
||||||
} [
|
} [
|
||||||
"server-config" article-parents
|
"server-config" article-parents
|
||||||
] unit-test
|
] unit-test
|
||||||
|
|
||||||
|
{
|
||||||
|
{
|
||||||
|
{ "handbook" "Factor handbook" article }
|
||||||
|
{ "first-program" "Your first program" article }
|
||||||
|
}
|
||||||
|
} [
|
||||||
|
"first-program-test" article-crumbs
|
||||||
|
] unit-test
|
||||||
|
|
|
@ -9,7 +9,10 @@ IN: fuel.help
|
||||||
|
|
||||||
SYMBOLS: $doc-path $next-link $prev-link $fuel-nav-crumbs ;
|
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 ;
|
{ "handbook" "vocab-index" } [ dup article-title \ article 3array ] map ;
|
||||||
|
|
||||||
: vocab-own-crumbs ( vocab-name -- crumbs )
|
: 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 ;
|
[ dup "." split last \ vocab 3array ] map ;
|
||||||
|
|
||||||
: vocab-crumbs ( vocab-name -- crumbs )
|
: vocab-crumbs ( vocab-name -- crumbs )
|
||||||
vocab-own-crumbs common-crumbs prepend ;
|
vocab-own-crumbs base-crumbs prepend ;
|
||||||
|
|
||||||
: article-parents ( article-name -- parents )
|
: article-parents ( article-name -- parents )
|
||||||
[ article-parent ] follow
|
[ article-parent ] follow
|
||||||
|
@ -131,13 +134,19 @@ PRIVATE>
|
||||||
: vocab-help ( name -- str )
|
: vocab-help ( name -- str )
|
||||||
dup empty? [ vocab-children-help ] [ vocab-element ] if ;
|
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 )
|
: get-vocabs/author ( author -- element )
|
||||||
[ "Vocabularies by " prepend \ $heading swap 2array ]
|
[ "Vocabularies by " prepend ] [ authored do-vocab-list ] bi
|
||||||
[ authored do-vocab-list ] bi 2array ;
|
base-crumbs "vocab-authors" add-crumb simple-element ;
|
||||||
|
|
||||||
: get-vocabs/tag ( tag -- element )
|
: get-vocabs/tag ( tag -- element )
|
||||||
[ "Vocabularies tagged " prepend \ $heading swap 2array ]
|
[ "Vocabularies tagged " prepend ] [ tagged do-vocab-list ] bi
|
||||||
[ tagged do-vocab-list ] bi 2array ;
|
base-crumbs "vocab-tags" add-crumb simple-element ;
|
||||||
|
|
||||||
: format-index ( seq -- seq )
|
: format-index ( seq -- seq )
|
||||||
[ [ >link name>> ] [ article-title ] bi 2array \ $subsection prefix ] map ;
|
[ [ >link name>> ] [ article-title ] bi 2array \ $subsection prefix ] map ;
|
||||||
|
@ -153,5 +162,5 @@ PRIVATE>
|
||||||
: vocab-help-article? ( name -- ? )
|
: vocab-help-article? ( name -- ? )
|
||||||
dup lookup-vocab [ help>> = ] [ drop f ] if* ;
|
dup lookup-vocab [ help>> = ] [ drop f ] if* ;
|
||||||
|
|
||||||
: get-article ( name -- str )
|
: get-article ( name -- element )
|
||||||
dup vocab-help-article? [ vocab-help ] [ article-element ] if ;
|
dup vocab-help-article? [ vocab-help ] [ article-element ] if ;
|
||||||
|
|
Loading…
Reference in New Issue