improve JSON rendering
Ticket
+issues
In addition to rendering in Html, we want to format cards and their included cards as structured objects presented in JSON.
Key use cases:
- jsTree
- JsTreeGrid
- simple import/export
(above tools recommended here)
+solution
The first major chunk of work (creating the object_renderer) is largely done.
The biggest design needs:
- what does the data look like?
- how do we handle custom formatting?
We're putting ideas for the data in +examples below.
As for custom formatting, there are at least three options:
- Client side
- Server side 1: custom views
- Server side 2: custom actions
For client side, I think we should have very strong default options so that folks can get all the data that they need for cases where the client will be able to do significant data manipulation.
That said, there will also be cases where it really should come out cleanly right from Wagn, and I would think that option #2 is the right way to go. Views are for all different ways to see the same data. Actions are for data events that trigger some internal or external state change. There may be some such triggers that involve JSON, but I would think that any server-side arrangement of data should happen in the views.
+example
Sample output:
{ "url": "http://cutch:3000/rules_to_export.json?pretty=true", "timestamp": "2013-09-23 15:37:11 -0600", "card": { "name": "rules_to_export", "type": "Search", "content": "{\r\n\"left\":{\"type\":\"Set\"},\r\n\"right\":{\r\n \"type\":\"Setting\",\r\n \"not\":{\"name\":[\"in\",\"*create\",\"*read\",\"*update\",\"*delete\"]}\r\n},\r\n\"edited_by\":{\"not\":\"WagnBot\"},\r\n\"return\":\"name\"\r\n}", "value": [ { "name": "item type+*right+*option label", "type": "Phrase", "content": "" }, { "name": "item type+*right+*default", "type": "Pointer", "content": "Image" },....
In this proposal, "content" is the raw content, where "value" involves processed content. The above example shows search results. Typical inclusions might be handled as follows:
...
:content => "I include {{whatever else}}",
:value=> [
'I include:',
{
:name => 'whatever else',
:type => 'Phrase'
},
'!'
]
note that there really isn't much need to keep labeling things as a "card". Every hash is a card.
Preliminary Notes from a Demo/Example with Jquery Widgets
These widgets are somewhat rigid about how they they will take the json data, but you can re-arrange things in the success callback. All the same, we can produce something closer if needed:
{data:"TheCardname":attr:{field1:value1,field2,value2...},children:{data:'PlusName',attr:...}}