Skip to content

Instantly share code, notes, and snippets.

View mamund's full-sized avatar

Mike Amundsen mamund

View GitHub Profile
@mamund
mamund / task-client-code2.js
Last active January 1, 2016 11:59
sample client-side code for hypermedia client
var thisPage = function() {
var g = {};
g.msg = {};
g.listUrl = '/tasks/';
function init() {}
function showResponse() {}
function showControls() {}
@mamund
mamund / list.js
Last active January 3, 2016 02:09
Representing unique (non-item) POST templates in compliant Collection+JSON. 1) list.js shows a list of sheduled meetings 2) each item has a "patch" link that points to another representation 3) patch.js shows a response from the "patch" link showing only a template to fill out. client apps SHOULD use POST to send this payload.
{
"collection" : {
"version" : "1.0",
"href" : "http://example.org/schedules",
"links" : [
{"link" : {"rel" : "profile", "href" : "http://example.org/profiles/schedules"},
{"link" : {"rel" : "http://example.org/rels/rssfeed", "href" : "http://example.org/schedules/index.rss"}
],
@mamund
mamund / menu.js
Created January 14, 2014 06:57
Expressing a nested menu in Cj
{ "collection" : {
"version" : "1.0",
"href" : "http://example.org/nav",
"links" : [
{"link" : {"rel" : "profile", "href": "http://example.org/profiles/nav"}
],
"items" : [
@mamund
mamund / qbe-ext-with-method.js
Last active January 4, 2016 10:38
mapping out a QBE extension for Cj
{
"collection": {
"qbe": [
{
"href": "http://example.org/Customers",
"method" : "POST",
"data": [
{"name": "fname", "prompt": "First Name:", "operators": ["Eq", "substringof"]},
{"name": "lname", "prompt": "Last Name:", "operators": ["Eq", "substringof"]},
{"name": "age", "prompt": "Age:", "operators": []},
@mamund
mamund / attach-template.js
Created February 6, 2014 01:21
possible cj extension to support uploads. if "file" property appears in the "template" object then client SHOULD use multipart/form-data for sending the request body.
// cj write template
{
"template" : {
"data" : [
{"name" : "qwe", "value" : ""},
{"name" : "rty", "file" : ""}
]
}
}
@mamund
mamund / uber.js
Created February 9, 2014 02:10
sample Uber in JSON and XML
{
"uber" :
{
"version" : " 1.0",
"data" :
[
{"rel" : "self", "url" : "http://example.org/"},
{"rel" : "profile", "url" : "http://example.org/profiles/people-and-places"},
"data" :
[
@mamund
mamund / metadata-cj.js
Created February 12, 2014 16:48
top-level metadata object for Cj
{
"collection" : {
"links" : [],
"metadata" : {
"data" :[
{"name" : "pagecount", "value" : "257", "prompt" : "Pages:"}
]
},
@mamund
mamund / template-v-item.js
Last active August 29, 2015 13:56
item and template don't need to coincide
{
"collection" : {
"version" : "1.0",
"href" : "http://example.org/template-v-items/",
"links" : [
{"rel" : "help", "href" : "http://example.org/template-v-item/publications.html"},
{"rel" : "profile", "href" : "http://example.org/template-v-item/profiles/publications.alps"}
],
@mamund
mamund / shared-prompts.js
Created February 27, 2014 22:03
shared prompts for Cj items
{
"collection" : {
"version" : "1.0",
"href" : "http://example.org/shared-prompts/",
"prompts" : [
{"name" : "givenName", "prompt" : "First Name"}.
{"name" : "familyName", "prompt" : "Last Name"},
{"name" : "avatar", "prompt" : "Mug Shot"},
{"name" : "blog", "prompt" : "Home Page"}
<alps version="1.0">
<link rel="help" href="http://example.org/documentation/products.html" />
<doc>
This is a prototype product API.
</doc>
<!-- transitions -->
<descriptor id="item" type="safe" rt="#product">
<doc>Retrieve A Single Product</doc>
</descriptor>