Permalink
Browse files

Updated wrmldoc to start supporting Open and New Document

  • Loading branch information...
1 parent dbc0fae commit de7903efe428c7ec48fd3dbabfc735f1f90bb142 @markmasse markmasse committed Oct 26, 2015
Showing with 12,501 additions and 425 deletions.
  1. +1 −1 cli/src/main/java/org/wrml/werminal/dialog/OpenModelDialog.java
  2. +258 −0 core/src/main/java/org/wrml/runtime/format/application/vnd/wrml/wrmldoc/JstreeDataBuilder.java
  3. +7 −1 core/src/main/java/org/wrml/runtime/format/application/vnd/wrml/wrmldoc/WrmldocDataBuilder.java
  4. +4 −1 core/src/main/java/org/wrml/runtime/format/text/html/WrmldocFormatter.java
  5. +7 −6 core/src/main/resources/org/wrml/runtime/format/text/html/index.html
  6. +7 −1 server/server-core/src/main/java/org/wrml/server/WrmlServlet.java
  7. +3 −0 wrmldoc/build.sh
  8. +15 −1 wrmldoc/css/app/apps/header.scss
  9. +59 −1 wrmldoc/css/app/components/_base.scss
  10. +55 −0 wrmldoc/css/wrmldoc.css
  11. +1 −1 wrmldoc/css/wrmldoc.min.css
  12. +75 −2 wrmldoc/css/wrmldoc.scss
  13. +55 −0 wrmldoc/css/wrmldoc.tmp.css
  14. +52 −13 wrmldoc/js/app/Wrmldoc.coffee
  15. +4 −4 wrmldoc/js/app/apps/api/ApiApp.coffee
  16. +4 −4 wrmldoc/js/app/apps/api/show/ApiShowController.coffee
  17. +5 −5 wrmldoc/js/app/apps/api/show/templates/api_show.eco
  18. +4 −4 wrmldoc/js/app/apps/apiNotFound/ApiNotFoundApp.coffee
  19. +4 −4 wrmldoc/js/app/apps/apiNotFound/show/ApiNotFoundShowController.coffee
  20. +1 −1 wrmldoc/js/app/apps/apiNotFound/show/templates/apiNotFound_show.eco
  21. +4 −4 wrmldoc/js/app/apps/documentNotFound/DocumentNotFoundApp.coffee
  22. +4 −4 wrmldoc/js/app/apps/documentNotFound/show/DocumentNotFoundShowController.coffee
  23. +6 −14 wrmldoc/js/app/apps/documentNotFound/show/DocumentNotFoundShowView.coffee
  24. +2 −2 wrmldoc/js/app/apps/documentNotFound/show/templates/documentNotFound_show.eco
  25. +5 −5 wrmldoc/js/app/apps/footer/FooterApp.coffee
  26. +6 −5 wrmldoc/js/app/apps/footer/show/FooterShowController.coffee
  27. +4 −3 wrmldoc/js/app/apps/footer/show/templates/footer.eco
  28. +4 −6 wrmldoc/js/app/apps/header/HeaderApp.coffee
  29. +6 −5 wrmldoc/js/app/apps/header/show/HeaderShowController.coffee
  30. +194 −1 wrmldoc/js/app/apps/header/show/HeaderShowView.coffee
  31. +79 −8 wrmldoc/js/app/apps/header/show/templates/header.eco
  32. +4 −4 wrmldoc/js/app/apps/home/HomeApp.coffee
  33. +4 −4 wrmldoc/js/app/apps/home/show/HomeShowController.coffee
  34. +6 −6 wrmldoc/js/app/apps/model/ModelApp.coffee
  35. +5 −6 wrmldoc/js/app/apps/model/show/ModelShowController.coffee
  36. +4 −4 wrmldoc/js/app/apps/registration/RegistrationApp.coffee
  37. +4 −4 wrmldoc/js/app/apps/registration/show/RegistrationShowController.coffee
  38. +4 −4 wrmldoc/js/app/apps/relation/RelationApp.coffee
  39. +4 −4 wrmldoc/js/app/apps/relation/show/RelationShowController.coffee
  40. +4 −4 wrmldoc/js/app/apps/resourceNotFound/ResourceNotFoundApp.coffee
  41. +4 −4 wrmldoc/js/app/apps/resourceNotFound/show/ResourceNotFoundShowController.coffee
  42. +4 −4 wrmldoc/js/app/apps/schema/SchemaApp.coffee
  43. +4 −4 wrmldoc/js/app/apps/schema/show/SchemaShowController.coffee
  44. +2 −2 wrmldoc/js/app/components/form/FormController.coffee
  45. +359 −140 wrmldoc/js/wrmldoc.js
  46. +134 −124 wrmldoc/js/wrmldoc.min.js
  47. +5 −0 wrmldoc/jstree/.gitignore
  48. +7,781 −0 wrmldoc/jstree/jstree.js
  49. +5 −0 wrmldoc/jstree/jstree.min.js
  50. BIN wrmldoc/jstree/themes/default-dark/32px.png
  51. BIN wrmldoc/jstree/themes/default-dark/40px.png
  52. +1,105 −0 wrmldoc/jstree/themes/default-dark/style.css
  53. +1 −0 wrmldoc/jstree/themes/default-dark/style.min.css
  54. BIN wrmldoc/jstree/themes/default-dark/throbber.gif
  55. BIN wrmldoc/jstree/themes/default/32px.png
  56. BIN wrmldoc/jstree/themes/default/40px.png
  57. +1,061 −0 wrmldoc/jstree/themes/default/style.css
  58. +1 −0 wrmldoc/jstree/themes/default/style.min.css
  59. BIN wrmldoc/jstree/themes/default/throbber.gif
  60. BIN wrmldoc/jstree/themes/wrml/32px.png
  61. BIN wrmldoc/jstree/themes/wrml/40px.png
  62. BIN wrmldoc/jstree/themes/wrml/api.png
  63. BIN wrmldoc/jstree/themes/wrml/resource.png
  64. BIN wrmldoc/jstree/themes/wrml/schema.png
  65. +1,061 −0 wrmldoc/jstree/themes/wrml/style.css
  66. BIN wrmldoc/jstree/themes/wrml/throbber.gif
@@ -427,7 +427,7 @@ public void onComponentInvalidated(final Component component) {
private void addKeyMessageLabel() {
- addMessageLabel("Enter a Schema.id and *click* the \"" + ENTER_KEYS_BUTTON_LABEL + "\" button.",
+ addMessageLabel("Enter a Schema URI and *click* the \"" + ENTER_KEYS_BUTTON_LABEL + "\" button.",
Alignment.LEFT_CENTER);
}
@@ -0,0 +1,258 @@
+/**
+ * WRML - Web Resource Modeling Language
+ * __ __ ______ __ __ __
+ * /\ \ _ \ \ /\ == \ /\ "-./ \ /\ \
+ * \ \ \/ ".\ \\ \ __< \ \ \-./\ \\ \ \____
+ * \ \__/".~\_\\ \_\ \_\\ \_\ \ \_\\ \_____\
+ * \/_/ \/_/ \/_/ /_/ \/_/ \/_/ \/_____/
+ *
+ * http://www.wrml.org
+ *
+ * Copyright (C) 2011 - 2013 Mark Masse <mark@wrml.org> (OSS project WRML.org)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.wrml.runtime.format.application.vnd.wrml.wrmldoc;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import org.apache.commons.lang3.StringUtils;
+import org.wrml.model.Model;
+import org.wrml.model.rest.*;
+import org.wrml.model.rest.status.ApiNotFoundErrorReport;
+import org.wrml.model.rest.status.DocumentNotFoundErrorReport;
+import org.wrml.model.rest.status.ErrorReport;
+import org.wrml.model.rest.status.ResourceNotFoundErrorReport;
+import org.wrml.model.schema.Schema;
+import org.wrml.runtime.Context;
+import org.wrml.runtime.Keys;
+import org.wrml.runtime.format.application.vnd.wrml.complete.api.CompleteApiBuilder;
+import org.wrml.runtime.format.application.vnd.wrml.complete.schema.CompleteSchemaBuilder;
+import org.wrml.runtime.rest.ApiLoader;
+import org.wrml.runtime.rest.ApiNavigator;
+import org.wrml.runtime.rest.Resource;
+import org.wrml.runtime.schema.ProtoSlot;
+import org.wrml.runtime.schema.Prototype;
+import org.wrml.runtime.schema.SchemaLoader;
+import org.wrml.util.UniqueName;
+
+import java.io.IOException;
+import java.net.URI;
+import java.util.*;
+
+public class JstreeDataBuilder {
+
+ public static final String JSTREE_WRML_THEME_PATH = "jstree/themes/wrml/";
+
+ private final String _ThemeDocroot;
+
+ public JstreeDataBuilder(final String docroot) {
+ _ThemeDocroot = docroot + JSTREE_WRML_THEME_PATH;
+ }
+
+ public String getThemeDocroot() {
+ return _ThemeDocroot;
+ }
+
+ public ObjectNode buildJstreeData(final ObjectMapper objectMapper, final Context context) throws IOException {
+ final ObjectNode jstreeDataNode = objectMapper.createObjectNode();
+
+ final ObjectNode openDocumentDialogNode = buildOpenDocumentDialogData(objectMapper, context);
+ jstreeDataNode.put(PropertyName.openDocumentDialog.name(), openDocumentDialogNode);
+
+ return jstreeDataNode;
+ }
+
+ private ObjectNode buildOpenDocumentDialogData(final ObjectMapper objectMapper, final Context context) {
+
+ final ObjectNode openDocumentDialogNode = objectMapper.createObjectNode();
+
+ final ObjectNode coreNode = objectMapper.createObjectNode();
+ openDocumentDialogNode.put(PropertyName.core.name(), coreNode);
+
+ final ArrayNode dataArrayNode = objectMapper.createArrayNode();
+ coreNode.put(PropertyName.data.name(), dataArrayNode);
+
+ final ApiLoader apiLoader = context.getApiLoader();
+ final SortedSet<URI> loadedApiUris = apiLoader.getLoadedApiUris();
+ for (URI apiUri : loadedApiUris) {
+
+ final ApiNavigator apiNavigator = apiLoader.getLoadedApiNavigator(apiUri);
+ final Map<UUID, Resource> allResources = apiNavigator.getAllResources();
+ if (allResources.isEmpty()) {
+ continue;
+ }
+
+ final Resource docrootResource = apiNavigator.getDocroot();
+ final ObjectNode docrootResourceDataNode = buildResourceDataNode(objectMapper, context, docrootResource);
+
+ if (docrootResourceDataNode.size() > 0) {
+
+ final ObjectNode apiDataNode = objectMapper.createObjectNode();
+ dataArrayNode.add(apiDataNode);
+
+ final Api api = apiNavigator.getApi();
+ final String apiTitle = api.getTitle();
+
+ apiDataNode.put(PropertyName.text.name(), apiTitle);
+ apiDataNode.put(PropertyName.icon.name(), _ThemeDocroot + "api.png");
+
+ final ObjectNode dataNode = objectMapper.createObjectNode();
+ apiDataNode.put(PropertyName.data.name(), dataNode);
+
+ dataNode.put(PropertyName.type.name(), "api");
+
+ final ObjectNode apiNode = objectMapper.createObjectNode();
+ dataNode.put(PropertyName.api.name(), apiNode);
+
+ apiNode.put(PropertyName.title.name(), api.getTitle());
+ apiNode.put(PropertyName.uri.name(), apiUri.toString());
+
+ final ArrayNode resourceArrayNode = objectMapper.createArrayNode();
+ resourceArrayNode.add(docrootResourceDataNode);
+ apiDataNode.put(PropertyName.children.name(), resourceArrayNode);
+ }
+
+ }
+
+ return openDocumentDialogNode;
+ }
+
+ private ObjectNode buildResourceDataNode(final ObjectMapper objectMapper, final Context context, final Resource resource) {
+
+ final ObjectNode resourceDataNode = objectMapper.createObjectNode();
+ boolean addDataProperties = false;
+
+ final ArrayNode childrenArrayNode = objectMapper.createArrayNode();
+
+ final Set<URI> responseSchemaUris = resource.getResponseSchemaUris(Method.Get);
+ if (responseSchemaUris != null && !responseSchemaUris.isEmpty()) {
+
+ addDataProperties = true;
+
+ final SchemaLoader schemaLoader = context.getSchemaLoader();
+ for (URI schemaUri : responseSchemaUris) {
+
+ final Prototype prototype = schemaLoader.getPrototype(schemaUri);
+ final UniqueName schemaName = prototype.getUniqueName();
+ final ObjectNode childSchemaDataNode = objectMapper.createObjectNode();
+ childSchemaDataNode.put(PropertyName.text.name(), schemaName.getLocalName());
+ childSchemaDataNode.put(PropertyName.icon.name(), _ThemeDocroot + "schema.png");
+
+ final ObjectNode dataNode = objectMapper.createObjectNode();
+ childSchemaDataNode.put(PropertyName.data.name(), dataNode);
+
+ dataNode.put(PropertyName.type.name(), "schema");
+
+ final ObjectNode schemaNode = objectMapper.createObjectNode();
+ dataNode.put(PropertyName.schema.name(), schemaNode);
+
+ schemaNode.put(PropertyName.title.name(), schemaName.getLocalName());
+ schemaNode.put(PropertyName.uri.name(), schemaUri.toString());
+
+ final ArrayNode keysArrayNode = objectMapper.createArrayNode();
+ schemaNode.put(PropertyName.keys.name(), keysArrayNode);
+
+ final String[] uriParameterNames = resource.getUriTemplate().getParameterNames();
+ final Set<String> allKeySlotNames = prototype.getAllKeySlotNames();
+
+ for (String parameterName : uriParameterNames) {
+ final String keySlotName = parameterName;
+ if (allKeySlotNames.contains(keySlotName)) {
+ final ProtoSlot keyProtoSlot = prototype.getProtoSlot(keySlotName);
+ final ObjectNode keyNode = objectMapper.createObjectNode();
+ keysArrayNode.add(keyNode);
+
+ keyNode.put(PropertyName.title.name(), keyProtoSlot.getTitle());
+ keyNode.put(PropertyName.name.name(), keyProtoSlot.getName());
+ keyNode.put(PropertyName.type.name(), keyProtoSlot.getValueType().name());
+ }
+ }
+
+ childrenArrayNode.add(childSchemaDataNode);
+ }
+
+ }
+
+ final ResourceTemplate resourceTemplate = resource.getResourceTemplate();
+ final List<ResourceTemplate> childResourceTemplates = resourceTemplate.getChildren();
+ for (ResourceTemplate childResourceTemplate : childResourceTemplates) {
+ final UUID childResourceTemplateId = childResourceTemplate.getUniqueId();
+ final Resource childResource = resource.getApiNavigator().getResource(childResourceTemplateId);
+ final ObjectNode childResouceDataNode = buildResourceDataNode(objectMapper, context, childResource);
+
+ if (childResouceDataNode.size() > 0) {
+ childrenArrayNode.add(childResouceDataNode);
+ }
+ }
+
+ if (childrenArrayNode.size() > 0) {
+ addDataProperties = true;
+ resourceDataNode.put(PropertyName.children.name(), childrenArrayNode);
+ }
+
+ if (addDataProperties) {
+ resourceDataNode.put(PropertyName.text.name(), resource.getPathSegment());
+ resourceDataNode.put(PropertyName.icon.name(), _ThemeDocroot + "resource.png");
+ final ObjectNode stateNode = objectMapper.createObjectNode();
+ resourceDataNode.put(PropertyName.state.name(), stateNode);
+ stateNode.put(PropertyName.opened.name(), true);
+
+ final ObjectNode dataNode = objectMapper.createObjectNode();
+ resourceDataNode.put(PropertyName.data.name(), dataNode);
+
+ dataNode.put(PropertyName.type.name(), "resource");
+
+ final ObjectNode resourceNode = objectMapper.createObjectNode();
+ dataNode.put(PropertyName.resource.name(), resourceNode);
+
+ final String pathText = resource.getPathText();
+ resourceNode.put(PropertyName.title.name(), pathText);
+ resourceNode.put(PropertyName.path.name(), pathText);
+
+ }
+
+ return resourceDataNode;
+ }
+
+
+ public enum PropertyName {
+ openDocumentDialog,
+ core,
+ data,
+ id,
+ text,
+ icon,
+ state,
+ opened,
+ disabled,
+ selected,
+ children,
+ li_attr,
+ a_attr,
+ type,
+ title,
+ name,
+ uri,
+ path,
+ keys,
+ api,
+ resource,
+ schema;
+ }
+
+}
+
+
+
@@ -50,6 +50,7 @@
public static final String DEFAULT_DOCROOT = "/_wrml/wrmldoc/";
private final CompleteApiBuilder _CompleteApiBuilder;
+ private final JstreeDataBuilder _JstreeDataBuilder;
private final String _Docroot;
public WrmldocDataBuilder(final CompleteApiBuilder completeApiBuilder) {
@@ -66,6 +67,7 @@ public WrmldocDataBuilder(final CompleteApiBuilder completeApiBuilder, final Str
_Docroot = DEFAULT_DOCROOT;
}
+ _JstreeDataBuilder = new JstreeDataBuilder(_Docroot);
}
public CompleteApiBuilder getCompleteApiBuilder() {
@@ -161,6 +163,9 @@ else if (model instanceof DocumentNotFoundErrorReport) {
wrmlDataNode.put(PropertyName.api.name(), apiNode);
wrmlDataNode.put(PropertyName.relation.name(), relationNode);
+ final ObjectNode jstreeDataNode = _JstreeDataBuilder.buildJstreeData(objectMapper, context);
+ wrmlDataNode.put(PropertyName.jstree.name(), jstreeDataNode);
+
return wrmlDataNode;
}
@@ -173,7 +178,8 @@ else if (model instanceof DocumentNotFoundErrorReport) {
model,
schema,
api,
- relation;
+ relation,
+ jstree;
}
}
@@ -97,8 +97,11 @@ public void writeModel(final OutputStream out, final Model model, final ModelWri
final JsonNode relationNode = wrmldocData.get(WrmldocDataBuilder.PropertyName.relation.name());
final String relationValue = objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(relationNode);
+ final JsonNode jstreeDataNode = wrmldocData.get(WrmldocDataBuilder.PropertyName.jstree.name());
+ final String jstreeValue = objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(jstreeDataNode);
+
final MessageFormat pageTemplate = getTemplate(SHELL_PAGE_TEMPLATE_RESOURCE);
- final String renderedPage = renderPage(pageTemplate, _WrmldocDataBuilder.getDocroot(), dotMin, documentTitle, documentIcon, schemaUriString, modelValue, schemaValue, apiValue, relationValue);
+ final String renderedPage = renderPage(pageTemplate, _WrmldocDataBuilder.getDocroot(), dotMin, documentTitle, documentIcon, schemaUriString, modelValue, schemaValue, apiValue, relationValue, jstreeValue);
IOUtils.write(renderedPage, out);
@@ -53,7 +53,9 @@
"api" : {7},
- "relation" : {8}
+ "relation" : {8},
+
+ "jstree" : {9}
'}';
@@ -62,6 +64,8 @@
<script type="text/javascript" src="{0}js/lib{1}.js"></script>
+ <script type="text/javascript" src="{0}jstree/jstree{1}.js"></script>
+
<!-- Uses wrmldoc for app logic -->
<script type="text/javascript" src="{0}js/wrmldoc{1}.js"></script>
@@ -72,6 +76,8 @@
<!-- The favicon -->
<link rel="shortcut icon" href="{3}" />
+ <link rel="stylesheet" media="all" href="{0}jstree/themes/wrml/style.css" />
+
<link rel="stylesheet" media="all" href="{0}css/wrmldoc{1}.css" />
<title>{2} - wrmldoc</title>
@@ -80,18 +86,13 @@
<body>
-
-
<div id="wrap">
<div id="header-region"></div>
<div id="main-region" class="container"></div>
<div id="push"></div>
</div>
<div id="footer-region"></div>
-
-
-
<script type="text/javascript">
// Start App
@@ -505,7 +505,13 @@ else if (path == null) {
host = host.substring(0, portSeparatorIndex);
}
- int port = Integer.parseInt(portString);
+ int port = 80;
+ try {
+ port = Integer.parseInt(portString);
+ }
+ catch (NumberFormatException e) {
+ LOGGER.debug("Cannot parse request URI port string value as int: {}", portString);
+ }
if (port == 80) {
port = -1;
View
@@ -153,6 +153,9 @@ cat ${JS_LIB_PATH}/marionette.js >> ${COMPILED_LIB_JS}
cat ${JS_LIB_PATH}/syphon.js >> ${COMPILED_LIB_JS}
+# TODO: This produces errors for some reason
+#cat ${JS_LIB_PATH}/jstree.js >> ${COMPILED_LIB_JS}
+
#######################
# Bootstrap
#######################
Oops, something went wrong.

0 comments on commit de7903e

Please sign in to comment.