Skip to content

Instantly share code, notes, and snippets.

@mamund
Last active August 29, 2015 14:07
Show Gist options
  • Save mamund/8bd6ca62856d58a34760 to your computer and use it in GitHub Desktop.
Save mamund/8bd6ca62856d58a34760 to your computer and use it in GitHub Desktop.
InfoQ API Design Methodology Examples. To-Do List and Item representations for HTML, ALPS profile for To-Do Service
<html>
<head>
<!-- for test display only -->
<title>To Do List</title>
<style>
.name, .scheduledTime, .status, .item {display:block}
</style>
</head>
<body>
<!-- for test display only -->
<h1>To-Do List</h1>
<!-- to-do list collection -->
<ul>
<li>
<a href="/list/1" rel="item" class="item">
<span class="identifier">1</span>
</a>
<span class="name">First item in the list</span>
<span class="scheduledTime">2014-12-01</span>
<span class="status">pending</span>
</li>
<li>
<a href="/list/2" rel="item" class="item">
<span class="identifier">2</span>
</a>
<span class="name">Second item in the list</span>
<span class="scheduledTime">2014-12-01</span>
<span class="status">pending</span>
</li>
<li>
<a href="/list/3" rel="item" class="item">
<span class="identifier">3</span>
</a>
<span class="name">Third item in the list</span>
<span class="scheduledTime">2014-12-01</span>
<span class="status">complete</span>
</li>
</ul>
<!-- search transition -->
<form method="get" action="/list/" class="search">
<legend>Search</legend>
<input name="name" class="identifier" />
<input type="submit" value="Name Search" />
</form>
<!-- create-item transition -->
<form method="post" action="/list/" class="http://mamund.com/rel/create-item">
<legend>Create Item</legend>
<input name="name" class="name" />
<input name="scheduledTime" class="scheduledTime" />
<input type="submit" value="Create Item" />
</form>
</body>
</html>
<html>
<head>
<!-- for test display only -->
<title>To Do List</title>
<style>
.name, .scheduledTime, .status, .item, .collection {display:block}
</style>
</head>
<body>
<!-- for test display only -->
<h1>To-Do Item</h1>
<a href="/list/" rel="collection" class="collection">Back to List</a>
<!-- to-do list collection -->
<ul>
<li>
<a href="/list/1" rel="item" class="item">
<span class="identifier">1</span>
</a>
<span class="name">First item in the list</span>
<span class="scheduledTime">2014-12-01</span>
<span class="status">pending</span>
</li>
</ul>
<!-- edit transition -->
<form method="post" action="/list/1" class="edit">
<legend>Update Status</legend>
<input type="hidden" name="etag" value="q1w2e3r4t5y6" class="etag" />
<input type="text" name="status" value="pending" class="status" />
<input type="submit" value="Update" />
</form>
</body>
</html>
<alps version="1.0">
<doc>
ALPS profile for InfoQ article on "API Design Methodology"
</doc>
<!-- data descriptors -->
<descriptor id="identifier" type="semantic" ref="http://purl.org/dc/elements/1.1/identifier" />
<descriptor id="name" type="semantic" ref="https://schema.org/name" />
<descriptor id="scheduledTime" type="semantic" ref="https://schema.org/scheduledTime" />
<descriptor id="status" type="semantic" ref="https://schema.org/status" />
<!-- action descriptors -->
<descriptor id="collection" type="safe" ref="http://www.iana.org/assignments/link-relations/link-relations.xhtml" />
<descriptor id="item" type="safe" ref="http://www.iana.org/assignments/link-relations/link-relations.xhtml">
<descriptor href="#identifier" />
</descriptor>
<descriptor id="search" type="safe" ref="http://www.iana.org/assignments/link-relations/link-relations.xhtml">
<descriptor href="#name" />
</descriptor>
<descriptor id="create-item" type="unsafe" ref="http://mamund.com/rels/create-item">
<descriptor href="#name" />
<descriptor href="scheduledTime" />
</descriptor>
<descriptor id="edit" type="idempotent" ref="http://www.iana.org/assignments/link-relations/link-relations.xhtml">
<descriptor href="#identifier" />
<descriptor href="#status" />
</descriptor>
</alps>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment