// Small HTML pieces of the plugin's server-rendered admin pages. const { escapeHtml } = require("./htmlEscape"); // The hidden CSRF input for a form POST (Saltcorn's csurf token). const csrfField = (req) => { const token = req.csrfToken ? req.csrfToken() : ""; return ``; }; // Bootstrap nav-pills (links = [[href, label], ...]) with the current page marked // active. The active link is the one whose href is the LONGEST boundary-safe // prefix of the request path, so a sub-page still highlights its parent tab. const navPills = (req, links) => { const cur = String((req && (req.originalUrl || req.path)) || "").split("?")[0].replace(/\/+$/, ""); let activeHref = ""; for (const [href] of links) { const h = href.replace(/\/+$/, ""); if ((cur === h || cur.startsWith(h + "/")) && h.length > activeHref.length) { activeHref = h; } } const items = links.map(([href, label]) => { const on = href.replace(/\/+$/, "") === activeHref; return `