json-ld/json-ld.org — pull request #336 by bollwyvl (2014-03-18 16:53:49+00:00)
Title: Using JSON schema in playground

This uses @madskristensen's JSON schema from #334. The schema is loaded once asynchronously.

I am making some assumptions about how it is structured, such that any change to the structure of the schema will likely result in some degraded performance of the playground.

## Autocomplete
The hints make the most use of the schema information, with a new bootstrap popover that shows basically all of the leaves of the schema except for `additionalProperties` and `additionalItems`. However, it only shows information: for example, even though `@id` is presented as an option for `@type`, there is no way to automatically select it, closing the current string, appending a `:` and the string `@id`. We can explore adding a `customKeys` to allow for, perhaps, actually completing these things.

@lanthaler asked whether we could do better with the current context, i.e. only show `@list` as a value of `@container` for example. I think we can, but we may have to go back to drawing board on the codemirror javascript mode, and make use of `pushContext` and some other things that I don't understand so that we have this data. Right now, I can only I've done what I could to do "interesting" things with what is in a simple context, but there's obviously a bit further to go.

## Validation
The schema is also used at validation time (as opposed to the previous well-formedness check), but as the schema is not normative, this provides no additional feedback at this time (aside from complaining about documents like `""` and `1`). However, it is probably worth leaving in place, as this might develop further.

For example, it would be great if jsonld.js errors included JSON Patch-style paths to errors, i.e. `@context/homepage/@id`, rather than/in addition to a copy of the `localContext`. The instrumented `jsonlint,parse` now keeps around a `lineIndex` for each of the input fields. From this information, we could figure out where the problem occurs and show this along with the rest of the validation results.

## CDN
I also took this opportunity to increase the amount of CDN usage for commodity libraries to combat the increasing size of the (useful) loaded scripts and styles. At some point, we should probably consider setting up a build/testing automation setup and use something like bower, as this would have the potential to reduce the number of requests to its absolute minimum.