(symbol make-wiki (==>) (args rest first build-sitemap-for)) ::
(symbol build-sitemap-for
(str :dir ==>) (get-wiki-pages make-list-of-links write-wiki)
) ::
(symbol get-wiki-pages
(==>) (
get-files get-filenames ("index.html" ==) reject '> sort
)
) ::
(symbol make-list-of-links
(quot :filenames ==> dict:xml-element :document) (
html"
"
("children" 0 "children") (stack.pop make-list-items) update
@document
)
) ::
(symbol write-wiki
(==>) (xml.to-xml dir ("index.html") prepend fs.join-path fs.write)
) ::
(symbol get-files (==>) (dir sys.ls)) ::
(symbol get-filenames (quot :files ==>) (files (fs.filename) map)) ::
(symbol make-list-items (==>) (filenames (a-tag li-tag) map)) ::
(symbol a-tag
(str :destination ==> dict:xml-element :tag) (
html""
("children") (destination xml.text stack.swap append) update
("attributes") (destination "href" dict.set) update
@tag
)
) ::
(symbol li-tag
(dict:xml-element :content ==> dict:xml-element :tag) (
html""
("children") (content stack.swap append) update
@tag
)
) ::
(sigil html
(str :html ==> dict:xml-element :result)
(html xml.from-html @result)
) ::
(symbol update
(quot|dict :structure quot :path quot :operation ==> quot|dict :updated) (
path first :index
(
((path size 1 == structure "quot" type? and) (
structure structure index get operation ->
index set @updated
))
((path size 1 == structure "dict" type? and) (
structure structure index dict.get operation ->
index dict.set @updated
))
((structure "quot" type?) (
structure index get path rest operation update :value
structure value index set @updated
))
((structure "dict" type?) (
structure index dict.get path rest operation update :value
structure value index dict.set @updated
))
) case
)
) ::
make-wiki