Skip to content

Instantly share code, notes, and snippets.

View mikekelly's full-sized avatar

Mike Kelly mikekelly

View GitHub Profile
@mikekelly
mikekelly / gist:669660
Created November 9, 2010 19:33
invoice.xml
# GET /invoice/1203897
<resource rel="self" href="/invoice/1203897">
<link rel="client" href="http://evilinc.com" />
<resource rel="line-item" href="/invoice/1203897/line-item/1">
<resource rel="item" href="/invetory/9821732">
<sku>WHMK5662</sku>
<description>Interesting Widget</description>
</resource>
<quantity>5</quantity>
@mikekelly
mikekelly / gist:669662
Created November 9, 2010 19:35
invoice.hal.xml
#GET /invoice/1203897
<resource rel="self" href="/invoice/1203897">
<link rel="client" href="http://evilinc.com" />
<resource rel="line-item" href="/invoice/1203897/line-item/1">
<resource rel="item" href="/invetory/9821732">
<sku>WHMK5662</sku>
<description>Interesting Widget</description>
</resource>
<quantity>5</quantity>
@mikekelly
mikekelly / halv3.xml
Created January 17, 2011 14:50
Example use of hal
<resource rel="self" href="/my_collection">
<link rel="next" href="/another_collection" />
<link rel="search" templated="true" href="/my_collection/search={searchterm}" />
<control activity="createItem" target="/my_collection" template="/my_collection/new" method="PUT" content-type="application/vnd.ericjbowman+xml"/>
<resource rel="info" href="/my_collection/info" etag="ZOMGSCIENCE1337" cache-control="public, max-age=600">
<items>12</items>
<foo>bar</foo>
</resource>
</resource>
var x = foo.bar["func"](param);
$(document).ready(function () {
$('#gco_slider_01').cycle({
fx: 'scrollHorz',
speed: 450,
timeout: 0,
after: function (curr, next, opts) {
var index = opts.currSlide;
$('#gco_slider_01_prev')[index == 0 ? 'hide' : 'show']();
$('#gco_slider_01_next')[index == opts.slideCount - 1 ? 'hide' : 'show']();
@mikekelly
mikekelly / 0_README.txt
Created March 29, 2011 23:19
a sketch of application/halo+json & application/halo+xml
I've added a control element with these properties/attributes:
method ; method to use for generated request e.g. POST/PUT/DELETE
content-type ; (optional) content-type of the request body generated by the template (defaults to application/hal+xml)
schema ; contains schema for data submitted to template
template ; (optional) A string or object representing the template or form for the request.
template-href ; (optional) Contains a URI which links to a resource where the template or form can be fetched.
template-type ; (optional) URI used to identify the template format in use (defaults to mustache).
@mikekelly
mikekelly / example.lisp
Created April 21, 2011 11:12
Example resource definition
(defresource "example"
(GET (lambda (req)
'(200
(:content-type "text/plain")
("This is the example resource"))))
(POST (lambda (req)
'(200
(:content-type "text/plain")
("Thanks for posting something")))))
@mikekelly
mikekelly / hal-example.xml
Created May 27, 2011 09:36
Example usage of the media type application/hal+xml
<resource rel="self" href="/" xmlns:ex="http://example.org/rels/">
<link rel="ex:look" href="/bleh" />
<link rel="ex:search" href="/search?term={searchTerm}" />
<resource rel="ex:member" name="1" href="/foo">
<link rel="ex:created_by" href="/some_dude" />
<example>bar</example>
<resource rel="ex:status" href="/foo;status">
<some_property>disabled</some_property>
</resource>
</resource>
@mikekelly
mikekelly / min_hal.xml
Created June 14, 2011 21:25
minimum valid hal representation
<resource href="http://example.com/" />
@mikekelly
mikekelly / hal_example.json
Created June 15, 2011 13:47
Example use of HAL's JSON variant
{
"_links": {
"self": { "href": "/orders" },
"next": { "href": "/orders?page=2" },
"search": { "href": "/orders?id={order_id}" }
},
"_embedded": {
"order": [
{
"_links": {