From c04cb305f45e39b71a7bdd51f91e8076eae86481 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Fri, 29 Jun 2012 09:27:22 +0200 Subject: o Showing doc.uri and doc.version. --- routes/index.js | 9 ++++----- views/data.jade | 33 +++++++++++++++++++++++++++++---- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/routes/index.js b/routes/index.js index 6910dfa..1a05e39 100644 --- a/routes/index.js +++ b/routes/index.js @@ -13,21 +13,20 @@ exports.render = function(req, res){ accept: 'application/vnd.collection+json' }; var clientReq = http.request(options, function(clientRes) { - console.log('STATUS: ' + clientRes.statusCode); - console.log('HEADERS: ' + JSON.stringify(clientRes.headers)); clientRes.setEncoding('utf8'); - var body = ""; + var body = ''; clientRes.on('data', function (chunk) { body += chunk; }); clientRes.on('end', function (chunk) { - var doc = collection_json.fromObject(JSON.parse(body)); + var parsedBody = JSON.parse(body); + var doc = collection_json.fromObject(parsedBody); res.render('data', { url: req.query.url, doc: doc, headers: clientRes.headers, raw: body, - formattedRaw: JSON.stringify(JSON.parse(body), null, ' ') }); + formattedRaw: JSON.stringify(parsedBody, null, ' ') }); }); }); clientReq.on('error', function() { diff --git a/views/data.jade b/views/data.jade index cb181f3..8fbd05e 100644 --- a/views/data.jade +++ b/views/data.jade @@ -7,10 +7,17 @@ block content form(action="/render") p label URL: - input(name="url", value="http://p2k12.bitraf.no/checkins-trygvis.php") + input(name="url", value="#{url}") input(type="submit", value="Render") + form(action="http://redbot.org/?") + p + input(name="uri", value="#{url}", type="hidden") + input(type="submit", value="Check with redbot.org") + ul + li + a(href="#meta") Meta li a(href="#items") Items li @@ -20,6 +27,22 @@ block content li a(href="#formatted-body") Formatted body + a(id="meta") + h1 + a(href="#meta") Meta + + table + tr + td Version + td #{doc.version} + tr + td URI + td + if typeof doc.uri == 'string' + a(href="#{doc.uri}") #{doc.uri} + else + span No URI + a(id="items") h1 a(href="#items") Items @@ -36,9 +59,11 @@ block content h1 a(href="#headers") Headers pre - each value, key in headers - span #{key}: #{value} - br + table + each value, key in headers + tr + td #{key}: + td #{value} a(id="body") h1 -- cgit v1.2.3