Skip to content

Instantly share code, notes, and snippets.

@HadrienGardeur
Last active December 10, 2015 00:49
Show Gist options
  • Save HadrienGardeur/4354170 to your computer and use it in GitHub Desktop.
Save HadrienGardeur/4354170 to your computer and use it in GitHub Desktop.
Attempt to bring OPDS to JSON. Kinda, sorta HAL based but staying away from the use of _embedded and generic collections for now.
{
"_type": "application/vnd.opds.acquisition+json",
"title": "Best Sellers",
"_links": {
"self": { "href": "/top", "type": "application/vnd.opds.acquisition+json" },
"next": { "href": "/top?page=2", "type": "application/vnd.opds.acquisition+json" },
"search": { "name": "Search in catalog", "href": "/search?q={query}", "type": "application/vnd.opds.acquisition+json", "templated": true },
"namespace": { "name": "opensearch", "href": "http://a9.com/-/spec/opensearch/1.1/" },
"curie": { "name": "opds", "href": "http://opds-spec.org/{rel}", "templated": "true" }
},
"opensearch:totalResults": "20",
"opensearch:itemsPerPage": "2",
"publications": [{
"title": "Pride and Prejudice",
"contributor": { "name": "Jane Austen", "role": "aut" },
"summary": "Mr and Mrs Bennet have five unmarried daughters. When the amiable Mr Bingly moves into the neighbourhood, Mrs Bennet therefore feels entirely sure that he is meant for one of her girls. Her eldest Miss Bennet captures his attention, but Mr Bingley's proud friend Mr Darcy does not approve the match and takes his friend away to London. Though not before losing his own heart to the second eldest, Lizzie. With an indolent father on one side and a nervous, ignorant mother on the other, the girls soon find themselves in the middle of a disaster which throws them back in with the two gentlemen. All parties must re-think their pride and the prejudice of first impressions.",
"_links": {
"alternate": { "href": "/book/1", "type": "application/vnd.opds.publication+json" },
"opds:acquisition": { "href": "/book/1.epub", "type": "application/epub+xml" },
"opds:image": { "href": "/book/1.jpg", "type": "image/jpg" }
}
}, {
"title": "Crime and Punishment",
"contributor": [{
"name": "Fyodor Dostoyevsky", "role": "aut"
}, {
"name": "Constance Garnett", "role": "trl"
}],
"summary": "The poverty-stricken Raskolnikov, believing he is exempt from moral law, murders a man only to face the consequences not only from society but from his conscience, in this seminal story of justice, morality, and redemption from one of Russia's greatest novelists.",
"_links": {
"alternate": { "href": "/book/2", "type": "application/vnd.opds.publication+json" },
"opds:acquisition": { "href": "/book/2.epub", "type": "application/epub+xml" },
"opds:image": { "href": "/book/2.jpg", "type": "image/jpg" }
}
}]
}
{
"_type": "application/vnd.opds.navigation+json",
"title": "eBook Store",
"_links": {
"self": { "href": "/catalog", "type": "application/vnd.opds.navigation+json" },
"search": { "name": "Search in catalog", "href": "/search?q={query}", "type": "application/vnd.opds.acquisition+json", "templated": true }
},
"navigation": [{
"title": "Best Sellers",
"_links": {"opds:top": { "href": "/top", "profile": "http://opds-spec.org/navigation", "type": "application/vnd.opds.acquisition+json"}}
},{
"title": "New Releases",
"_links": {"opds:new": { "href": "/new", "profile": "http://opds-spec.org/navigation", "type": "application/vnd.opds.acquisition+json" }}
}]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment