mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-19 05:45:01 +00:00
a0058869c9
Moved resources to correct folder Fixed and improved build information, no longer tracking build.properties
75 lines
2.1 KiB
Java
75 lines
2.1 KiB
Java
package me.totalfreedom.totalfreedommod.httpd;
|
|
|
|
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD.Response;
|
|
|
|
public class HTTPDPageBuilder
|
|
{
|
|
|
|
private static final String TEMPLATE = "<!DOCTYPE html>\r\n"
|
|
+ "<html>\r\n"
|
|
+ "<head>\r\n"
|
|
+ "<title>{$TITLE}</title>\r\n"
|
|
+ "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\r\n"
|
|
+ "{$STYLE}"
|
|
+ "{$SCRIPT}"
|
|
+ "</head>\r\n"
|
|
+ "<body>\r\n{$BODY}</body>\r\n"
|
|
+ "</html>\r\n";
|
|
private static final String STYLE = "<style type=\"text/css\">{$STYLE}</style>\r\n";
|
|
private static final String SCRIPT = "<script src=\"//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js\"></script>\r\n"
|
|
+ "<script src=\"//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js\"></script>\r\n"
|
|
+ "<script>\r\n{$SCRIPT}\r\n</script>\r\n";
|
|
//
|
|
private String body = null;
|
|
private String title = null;
|
|
private String style = null;
|
|
private String script = null;
|
|
|
|
public HTTPDPageBuilder()
|
|
{
|
|
}
|
|
|
|
public HTTPDPageBuilder(String body, String title, String style, String script)
|
|
{
|
|
this.body = body;
|
|
this.title = title;
|
|
this.style = style;
|
|
this.script = script;
|
|
}
|
|
|
|
public void setBody(String body)
|
|
{
|
|
this.body = body;
|
|
}
|
|
|
|
public void setTitle(String title)
|
|
{
|
|
this.title = title;
|
|
}
|
|
|
|
public void setStyle(String style)
|
|
{
|
|
this.style = style;
|
|
}
|
|
|
|
public void setScript(String script)
|
|
{
|
|
this.script = script;
|
|
}
|
|
|
|
public Response getResponse()
|
|
{
|
|
return new Response(this.toString());
|
|
}
|
|
|
|
@Override
|
|
public String toString()
|
|
{
|
|
return TEMPLATE
|
|
.replace("{$BODY}", this.body == null ? "" : this.body)
|
|
.replace("{$TITLE}", this.title == null ? "" : this.title)
|
|
.replace("{$STYLE}", this.style == null ? "" : STYLE.replace("{$STYLE}", this.style))
|
|
.replace("{$SCRIPT}", this.script == null ? "" : SCRIPT.replace("{$SCRIPT}", this.script));
|
|
}
|
|
}
|