kevinswiber / siren

Structured Interface for Representing Entities, super-rad hypermedia
MIT License
1.3k stars 71 forks source link

Mapping Siren to HTML / Jade #21

Open ericelliott opened 11 years ago

ericelliott commented 11 years ago

I've been frustrated by the limitations of JSON for expressing hypermedia, so I'm experimenting with mapping Siren semantics to HTML (via Jade).

I'd love to get some feedback on this effort. I'm calling it Jiron.

apsoto commented 11 years ago

Might want to also check out [kiva/backbone.siren]

kevinswiber commented 11 years ago

Addressing your concerns:

Code on demand

I'm very interested in Code on Demand. I didn't see an example in Jiron. Do you see this as a script tag?

Style support

What does this mean to you? I have a plan to add class attributes to just about every element of Siren. I find I can use them everywhere. For me, personally, they're becoming one of the strongest features of the format. Clients would be able to key "style" off of class values.

ericelliott commented 11 years ago

I'm very interested in Code on Demand. I didn't see an example in Jiron. Do you see this as a script tag?

Yes. Just a script that would load on the client and provide additional behaviors. Obviously, we'd need to come up with some restrictions and semantics to make it easy to hook up those behaviors to whatever UI the client choses to express. It should not just try to interact with and manipulate the host document directly.

Style support

To me, it means that it would be nice to provide a default view for browsing the API directly.

apsoto commented 11 years ago

I've been thinking of doing this as well to make a very simple api browser. If you make an api request, and hit it with a typical browser's Accepts, it will spit out a simple html doc with the json in a <script> and another helper js lib referenced via <script> that will dynamically render a human friendly interface.

Is that what you're trying to get at?

ericelliott commented 11 years ago

Something like that, yes. =)

apsoto commented 11 years ago

Cool idea. I think (making assumptions here) that your Jiron project require's node? I think it would be most useful as a stand-alone javascript lib so any platform could use it since all you need to do is spit out some html and reference the lib, which any server platform can do.

ericelliott commented 11 years ago

Jiron doesn't require Node, but I'm already working on a Jiron serializer for the Node siren-resource module -- which is also a cool project.

ericelliott commented 11 years ago

I just checked - there are Ruby gems that wrap Jade for the client. A Jiron client could easily use those for the client compiler.

Also, It's easy to get Jade working stand-alone in the browser using Browserify V2's standalone mode.

apsoto commented 11 years ago

sounds cool. Keep pulling on that string...maybe a super simple but complete example (psuedo-api server, that spits out siren/json and jiron)

ericelliott commented 11 years ago

Yeah, siron-resource will do that, soon. Jiron support is the next feature I want to add to it.

pke commented 6 years ago

@ericelliott Any more work done on your jiron? It looks like a tempting solution to create responses, we might try it out in a Rails backend.