sclass HTMLFramer1 { S title; bool titleIsHTML; new L navItems; new LS contents; new LinkedHashSet headElements; // automatically avoid duplication bool navBeforeTitle; new L willRender; srecord NavItem(S link, S html) { bool targetBlank; } swappable S render() { callFAll(willRender); ret hhtml(hhead(htitle(titleIsHTML ? hTitleClean(title) : title) + lines(headElements)) + hbody( (navBeforeTitle ? renderNav() + renderTitle() : renderTitle() + renderNav()) + lines(contents))); } swappable S renderTitle() { ret h1(encodedTitle()); } S encodedTitle() { //printVars_str encodedTitle(+title, +titleIsHTML); ret titleIsHTML ? title : htmlEncode2(title); } swappable S renderNav() { if (empty(navItems)) ret ""; ret div_vbar(map renderNavItem(navItems), style := "margin-bottom: 0.5em"); } S renderNavItem(NavItem ni) { ret ahref_possiblyTargetBlank(ni.link, ni.html, ni.targetBlank); } void addNavItem(S html) { navItems.add(new NavItem(null, html)); } void addNavItem(S link, S html, O... _) { navItems.add(setAll(new NavItem(link, html), filterParams(_, 'targetBlank))); } void addInHead(O html) { headElements.add(str(html)); } // add contents: TODO move things to head automatically void add(O html) { addIfNempty(contents, strOrEmpty(html)); } void clearNavItems { navItems.clear(); } }