html := import("html").Renderer() paths := import("paths") log := import("log") text := import("text") os := import("os") print_header := func(c) { header := html.nav({ id: "main-nav" }) nav_file_links := [] if c.is_index { nav_file_links += [] if c.http.request.url.path != "/" { nav_file_links += [ html.a({ href: ".." }).body( "<<<" ) ] } dir := os.open(paths.dir(c.pp.fpath)) names := dir.readdirnames(0) for _, name in names { if text.has_suffix(name, c.pp_ext) { name = name[:len(name)-len(c.pp_ext)] } if name == c.index_suffix { continue } ext := paths.ext(name) href := "./" + name if !ext { href += "/" } nav_file_links += [html.a({ href: href }).body( name )] } } else { nav_file_links += [html.a({ href: "." }).body( "<<<" )] } header.body( html.div({ class: "files" }).body( nav_file_links... ) ) header.add(html.button({ id: "create-heading-nav-btn" }).body( "Содержание" )) c.pp.print(html.button({ id: "top-btn" }).body( "TOP" )) c.pp.print(header) } export { print_header : print_header }