--- /dev/null
+package jrw.resp;
+
+import jrw.*;
+import jrw.sp.*;
+import java.util.*;
+import java.util.function.*;
+import static jrw.sp.cons.*;
+import static jrw.sp.xhtml.cons.*;
+
+public class Skeleton {
+ public static Environment.Variable<Supplier<? extends Skeleton>> defskel = new Environment.Variable<>(() -> Skeleton::new);
+ public List<String> styles = new ArrayList<>();
+ public Element body = xhtml.cons.body();
+ public String title;
+
+ public Skeleton(String title, Object... contents) {
+ this.title = title;
+ populate(body, contents);
+ }
+
+ public Skeleton() {
+ this("");
+ }
+
+ public Skeleton title(String title) {this.title = title; return(this);}
+ public Skeleton style(String... styles) {this.styles.addAll(Arrays.asList(styles)); return(this);}
+ public Skeleton body(Object... data) {populate(body, data); return(this);}
+
+ public Element head(Request req) {
+ Element head = xhtml.cons.head(xhtml.cons.title(title));
+ for(String style : styles)
+ populate(head, link($("rel", "stylesheet"), $("type", "text/css"), $("href", style)));
+ return(head);
+ }
+
+ public Element body(Request req) {
+ return(body);
+ }
+
+ public Element message(Request req) {
+ return(html(head(req), body(req)));
+ }
+
+ public Element error(Request req) {
+ return(message(req));
+ }
+}