summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2012-07-05 22:31:17 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2012-07-05 22:31:17 +0200
commit0ba8317f8b725f2048b0ddbf5beec5681afab293 (patch)
tree2e3ef377a4026b133fe80871e4dcb361528c809b
parent6bd3d074947f9a12d5f6ab2f42bdaa7f0b036bd7 (diff)
downloadcollection-json-explorer-0ba8317f8b725f2048b0ddbf5beec5681afab293.tar.gz
collection-json-explorer-0ba8317f8b725f2048b0ddbf5beec5681afab293.tar.bz2
collection-json-explorer-0ba8317f8b725f2048b0ddbf5beec5681afab293.tar.xz
collection-json-explorer-0ba8317f8b725f2048b0ddbf5beec5681afab293.zip
o Automatically showing next/prev links if the collection has next/prev links.
-rw-r--r--routes/index.js3
-rw-r--r--views/data.jade20
2 files changed, 20 insertions, 3 deletions
diff --git a/routes/index.js b/routes/index.js
index 73f82ab..fb81a41 100644
--- a/routes/index.js
+++ b/routes/index.js
@@ -86,12 +86,11 @@ exports.render = function(req, res) {
sendErr(req, res, 'Unable to parse JSON: ' + e, httpResponse);
return;
}
- var collection = collection_json.fromObject(parsedBody).collection;
res.render('data', {
urlgenerator: urlgenerator(req),
url: req.query.url, referer: req.query.referer,
params: params,
- collection: collection,
+ root: collection_json.fromObject(parsedBody),
httpResponse: httpResponse,
formattedBody: JSON.stringify(parsedBody, null, ' ')
});
diff --git a/views/data.jade b/views/data.jade
index b2910b2..bf22302 100644
--- a/views/data.jade
+++ b/views/data.jade
@@ -74,6 +74,18 @@ block meta
h3(id='link-#{i + 1}') Collection Link ##{i}#{title}
block link
+block next_prev
+ - var next = root.findLinkByRel('next');
+ - var prev = root.findLinkByRel('prev');
+ if next || prev
+ div(class='fluid-row')
+ div(class='span12')
+ if prev
+ a(class='btn btn-primary btn-mini', href=urlgenerator.render(next.href) + '#items') Previous
+ |
+ if next
+ a(class='btn btn-primary btn-mini', href=urlgenerator.render(next.href) + '#items') Next
+
// TODO: If the collection has prev/next links, add buttons to
// automaticaly navigate those.
// TODO: Add ability to show the raw part of the collection.
@@ -81,7 +93,8 @@ block items
if collection.items.length == 0
p Collection has no items.
else
- // p The feed has #{collection.items.length} items.
+ block next_prev
+
each item, i in collection.items
- var href=item.href
h2(id='item-#{i+1}') Item ##{i+1}
@@ -111,6 +124,8 @@ block items
dt #{data.name}
dd #{data.value}
+ block next_prev
+
block queries
if collection.queries.length == 0
p Collection has no queries.
@@ -247,6 +262,8 @@ block inner_content
h1 Items
if collection.items.length > 1
span(class='badge') #{collection.items.length}
+ if root.findLinkByRel('next')
+ |+
block items
section(id='queries')
div(class='page-header')
@@ -270,6 +287,7 @@ block inner_content
block httpResponse
block content
+ - var collection = root.collection
div(class='row-fluid')
div(class='span3')
block sidebar