Permalink
Browse files

Added initial format support to wrmldoc

  • Loading branch information...
markmasse committed Mar 1, 2016
1 parent 4a0f09d commit 67603f12553c8411009d02a6a79c8858fd48e696
Showing with 3,149 additions and 1,325 deletions.
  1. +1 −2 core/src/main/java/org/wrml/model/rest/LinkTemplate.java
  2. +1 −1 core/src/main/java/org/wrml/runtime/format/SystemFormat.java
  3. +42 −1 core/src/main/java/org/wrml/runtime/format/application/vnd/wrml/wrmldoc/WrmldocDataBuilder.java
  4. +19 −2 core/src/main/java/org/wrml/runtime/format/text/html/WrmldocFormatter.java
  5. +1 −9 core/src/main/java/org/wrml/runtime/rest/DefaultApiLoader.java
  6. +10 −1 core/src/main/resources/org/wrml/runtime/format/text/html/index.html
  7. +11 −0 wrmldoc/ace/ace.js
  8. +1 −0 wrmldoc/ace/mode-html.js
  9. +1 −0 wrmldoc/ace/mode-java.js
  10. +1 −0 wrmldoc/ace/mode-json.js
  11. +1 −0 wrmldoc/ace/mode-xml.js
  12. +1 −0 wrmldoc/ace/mode-yaml.js
  13. +2 −1 wrmldoc/css/app/_variables.scss
  14. +72 −6 wrmldoc/css/app/apps/api.scss
  15. +40 −0 wrmldoc/css/app/apps/apiBrowser.scss
  16. +20 −5 wrmldoc/css/app/apps/header.scss
  17. +12 −2 wrmldoc/css/app/components/_base.scss
  18. +117 −30 wrmldoc/css/wrmldoc.css
  19. +1 −1 wrmldoc/css/wrmldoc.min.css
  20. +146 −16 wrmldoc/css/wrmldoc.scss
  21. +117 −30 wrmldoc/css/wrmldoc.tmp.css
  22. +56 −16 wrmldoc/js/app/Wrmldoc.coffee
  23. +225 −14 wrmldoc/js/app/apps/api/show/ApiShowView.coffee
  24. +62 −363 wrmldoc/js/app/apps/api/show/templates/api_show.eco
  25. +390 −0 wrmldoc/js/app/apps/api/show/templates/resource_show.eco
  26. +34 −0 wrmldoc/js/app/apps/apiBrowser/ApiBrowserApp.coffee
  27. +33 −0 wrmldoc/js/app/apps/apiBrowser/show/ApiBrowserShowView.coffee
  28. +63 −0 wrmldoc/js/app/apps/apiBrowser/show/templates/api_browser_show.eco
  29. +82 −0 wrmldoc/js/app/apps/header/show/HeaderShowView.coffee
  30. +62 −33 wrmldoc/js/app/apps/header/show/templates/header.eco
  31. +16 −38 wrmldoc/js/app/apps/model/show/ModelShowView.coffee
  32. +51 −58 wrmldoc/js/app/apps/model/show/templates/model_show.eco
  33. +20 −2 wrmldoc/js/app/apps/relation/show/RelationShowView.coffee
  34. +22 −26 wrmldoc/js/app/apps/relation/show/templates/relation_show.eco
  35. +15 −0 wrmldoc/js/app/apps/schema/show/SchemaShowView.coffee
  36. +115 −37 wrmldoc/js/app/apps/schema/show/templates/schema_show.eco
  37. +6 −0 wrmldoc/js/app/config/marionette/renderer.coffee
  38. +34 −34 wrmldoc/js/app/entities/_base/Model.coffee
  39. +970 −362 wrmldoc/js/wrmldoc.js
  40. +276 −235 wrmldoc/js/wrmldoc.min.js
@@ -61,7 +61,7 @@
* <p/>
* <p>
* A link ends with its pointy-end pointing to the end point. This end point is the resource that the referrer resource
* was referencing with its link.
* is referencing with its link.
* </p>
*
* @see Api
@@ -70,7 +70,6 @@
* @see URI
* @see Link
* @see LinkRelation
* @see org.wrml.runtime.schema.LinkSlot
* @see LinkValue
* @see Schema
* @see Document
@@ -82,7 +82,7 @@
vnd_wrml_swagger_api(new UniqueName("application/vnd.wrml.swagger.api+json"),
"The WRML System Format representing the \"application/vnd.wrml.swagger.api\" media type.",
URI.create("http://wrml.org"),
URI.create(""), "txt"),
URI.create(""), "json"),
vnd_wrml_wrmldoc(new UniqueName("application/vnd.wrml.wrmldoc+json"),
"The WRML System Format representing the \"application/vnd.wrml.wrmldoc\" media type.",
@@ -25,9 +25,11 @@
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.format.Format;
import org.wrml.model.rest.Api;
import org.wrml.model.rest.Document;
import org.wrml.model.rest.LinkRelation;
@@ -38,12 +40,16 @@
import org.wrml.model.schema.Schema;
import org.wrml.runtime.Context;
import org.wrml.runtime.Keys;
import org.wrml.runtime.format.FormatLoader;
import org.wrml.runtime.format.Formatter;
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.schema.SchemaLoader;
import java.io.IOException;
import java.net.URI;
import java.util.SortedSet;
public class WrmldocDataBuilder {
@@ -166,10 +172,44 @@ else if (model instanceof DocumentNotFoundErrorReport) {
final ObjectNode jstreeDataNode = _JstreeDataBuilder.buildJstreeData(objectMapper, context);
wrmlDataNode.put(PropertyName.jstree.name(), jstreeDataNode);
final ObjectNode formatsDataNode = buildFormatsData(objectMapper, model);
wrmlDataNode.put(PropertyName.formats.name(), formatsDataNode);
return wrmlDataNode;
}
public ObjectNode buildFormatsData(final ObjectMapper objectMapper, final Model model) {
final ObjectNode formatsNode = objectMapper.createObjectNode();
final Context context = model.getContext();
final FormatLoader formatLoader = context.getFormatLoader();
final SortedSet<URI> formatUris = formatLoader.getLoadedFormatUris();
final URI defaultFormatUri = formatLoader.getDefaultFormatUri();
for (final URI formatUri : formatUris) {
final Formatter formatter = formatLoader.getFormatter(formatUri);
if (formatter.isApplicableTo(model.getSchemaUri())) {
final Format format = formatLoader.loadFormat(formatUri);
final String mediaTypeString = String.valueOf(format.getMediaType());
final ObjectNode formatNode = objectMapper.createObjectNode();
formatsNode.put(mediaTypeString, formatNode);
formatNode.put("uri", String.valueOf(formatUri));
formatNode.put("title", format.getTitle());
formatNode.put("mediaType", mediaTypeString);
formatNode.put("fileExtension", format.getFileExtension());
formatNode.put("isDefault", formatUri.equals(defaultFormatUri));
}
}
return formatsNode;
}
public enum PropertyName {
docroot,
documentTitle,
@@ -179,7 +219,8 @@ else if (model instanceof DocumentNotFoundErrorReport) {
schema,
api,
relation,
jstree;
jstree,
formats;
}
}
@@ -79,6 +79,8 @@ public void writeModel(final OutputStream out, final Model model, final ModelWri
try {
final MessageFormat pageTemplate = getTemplate(SHELL_PAGE_TEMPLATE_RESOURCE);
final ObjectNode wrmldocData = _WrmldocDataBuilder.buildWrmldocData(objectMapper, model);
final String documentTitle = wrmldocData.get(WrmldocDataBuilder.PropertyName.documentTitle.name()).asText();
@@ -100,8 +102,23 @@ public void writeModel(final OutputStream out, final Model model, final ModelWri
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, jstreeValue);
final JsonNode formatsDataNode = wrmldocData.get(WrmldocDataBuilder.PropertyName.formats.name());
final String formatsValue = objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(formatsDataNode);
final String renderedPage =
renderPage(
pageTemplate,
_WrmldocDataBuilder.getDocroot(),
dotMin,
documentTitle,
documentIcon,
schemaUriString,
modelValue,
schemaValue,
apiValue,
relationValue,
jstreeValue,
formatsValue);
IOUtils.write(renderedPage, out);
@@ -518,18 +518,10 @@ private void loadSystemApis() {
apiBuilder.uri(apiUri).title(systemApi.getTitle()).description(systemApi.getDescription());
// NOTE: This call to docroot will automatically *Api* as a default response schema at the root
apiBuilder.docroot(systemApi.getDocrootId());
apiBuilder.resource(SYSTEM_API_PRIMARY_ENDPOINT_FULL_PATH, systemApi.getPrimaryEndpointId(), systemApi.getDefaultSchemaInterface(), true);
// TODO: Rework the SchemaNamespace
/*
* if (systemApi == SystemApi.Schema) { apiBuilder.link(SYSTEM_API_DOCROOT_FULL_PATH, SystemLinkRelation.self.getUri(), SYSTEM_API_DOCROOT_FULL_PATH,
* SchemaNamespace.class); apiBuilder.link(SYSTEM_API_DOCROOT_FULL_PATH, SystemLinkRelation.element.getUri(), SYSTEM_API_PRIMARY_ENDPOINT_FULL_PATH, Schema.class);
* apiBuilder.link(SYSTEM_API_DOCROOT_FULL_PATH, SystemLinkRelation.child.getUri(), SYSTEM_API_PRIMARY_ENDPOINT_FULL_PATH, SchemaNamespace.class);
* apiBuilder.link(SYSTEM_API_PRIMARY_ENDPOINT_FULL_PATH, SystemLinkRelation.element.getUri(), SYSTEM_API_PRIMARY_ENDPOINT_FULL_PATH, Schema.class);
* apiBuilder.link(SYSTEM_API_PRIMARY_ENDPOINT_FULL_PATH, SystemLinkRelation.child.getUri(), SYSTEM_API_PRIMARY_ENDPOINT_FULL_PATH, SchemaNamespace.class); }
*/
final Api api = apiBuilder.toApi();
loadApi(api);
}
@@ -55,7 +55,9 @@
"relation" : {8},
"jstree" : {9}
"jstree" : {9},
"formats" : {10}
'}';
@@ -66,6 +68,13 @@
<script type="text/javascript" src="{0}jstree/jstree{1}.js"></script>
<script type="text/javascript" src="{0}ace/ace.js"></script>
<script type="text/javascript" src="{0}ace/mode-html.js"></script>
<script type="text/javascript" src="{0}ace/mode-java.js"></script>
<script type="text/javascript" src="{0}ace/mode-json.js"></script>
<script type="text/javascript" src="{0}ace/mode-xml.js"></script>
<script type="text/javascript" src="{0}ace/mode-yaml.js"></script>
<!-- Uses wrmldoc for app logic -->
<script type="text/javascript" src="{0}js/wrmldoc{1}.js"></script>
View

Large diffs are not rendered by default.

Oops, something went wrong.
View

Large diffs are not rendered by default.

Oops, something went wrong.
View

Large diffs are not rendered by default.

Oops, something went wrong.
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit 67603f1

Please sign in to comment.