MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / WebApps

Class WebApps

src/main/java/fielded/boxbrowser/WebApps.java:32–281  ·  view source on GitHub ↗

Plugin for making web apps in Field

Source from the content-addressed store, hash-verified

30 * Plugin for making web apps in Field
31 */
32public class WebApps extends Box implements IO.Loaded {
33 static public final String EXECUTE = "/execute/";
34 static public final String CONTINUE = "/continue/";
35 static public final String FILESYSTEM = "/filesystem/";
36
37 static public Dict.Prop<BiFunctionOfBoxAnd<String, String>> newStaticHTML = new Dict.Prop<>("newStaticHTML").type()
38 .toCanon()
39 .doc("`_.newStaticHTML(\"mypage\")` adds an `_.html` property to this box that is served up by the WebApps plugin at http://localhost:8082/mypage");
40
41 static public Dict.Prop<BiConsumer<String, String>> newStaticFile = new Dict.Prop<>("newStaticFile").type()
42 .toCanon()
43 .doc("`_.newStaticFile(\"myjpeg.jpg\", \"/path/to/a/jpeg\")` adds a file to the webserver resolvable at http://localhost:8082/myjpeg.jpg");
44
45 static public Dict.Prop<String> html = new Dict.Prop<>("html").type()
46 .toCanon()
47 .doc(" a static html resource served by the WebApps plugin, creatable using `_.newStaticHTML(...)`");
48
49 static {
50 FieldBox.fieldBox.io.addFilespec("html", ".html", "htmlmixed");
51 }
52
53 static public final String preambleA = "<html xmlns='http://www.w3.org/1999/xhtml'> <meta charset='UTF-8'><head>" +
54 "<script src='/field/filesystem/codemirror-5.25.2/lib/codemirror.js'></script>" +
55 "<link rel='stylesheet' href='/field/filesystem/codemirror-5.25.2/lib/codemirror.css'>" +
56 "<link rel='stylesheet' href='/field/filesystem/codemirror-5.25.2/theme/default.css'>" +
57 "<link rel='stylesheet' href='/field/filesystem/field-boxbrowser.css' type='text/css'>" +
58 "<script src='/field/filesystem/codemirror-5.25.2/mode/javascript/javascript.js'></script>" +
59 "<script src='/field/filesystem/jquery-2.1.0.min.js'></script>" +
60 "<script src='/field/filesystem/field-boxbrowser.js'></script>" +
61 "</head><body><div class='all'>";
62 static public final String postambleA = "</div></body>";
63
64 static public String preambleB;
65
66 static {
67 try {
68// preambleB = Files.toString(new File(fieldagent.Main.app + "modules/fieldcore/resources/init_webapps.html_fragment"), Charset.defaultCharset());
69 preambleB = Files.toString(new File(fieldagent.Main.app + "lib/web/init_webapps.html_fragment"), Charset.defaultCharset());
70 preambleB += "<body><div class='all'>";
71 } catch (IOException e) {
72 e.printStackTrace();
73 }
74 }
75
76 static public final String postambleB = "</div></body>";
77
78 private final Box root;
79 private Server s;
80
81 HashBiMap<String, Box> lookup = HashBiMap.create();
82 HashBiMap<String, String> resources = HashBiMap.create();
83
84 public WebApps(Box root) {
85 this.root = root;
86
87 properties.put(Commands.commands, () -> {
88 Map<Pair<String, String>, Runnable> m = new LinkedHashMap<>();
89 RemoteEditor ed = this.find(RemoteEditor.editor, both())

Callers

nothing calls this directly

Calls 6

docMethod · 0.80
toCanonMethod · 0.80
typeMethod · 0.80
addFilespecMethod · 0.80
toStringMethod · 0.45
createMethod · 0.45

Tested by

no test coverage detected