summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--routes/index.js10
-rw-r--r--views/data.jade52
2 files changed, 33 insertions, 29 deletions
diff --git a/routes/index.js b/routes/index.js
index ce0d6aa..fca41dd 100644
--- a/routes/index.js
+++ b/routes/index.js
@@ -18,10 +18,11 @@ exports.index = function(req, res){
};
exports.render = function(req, res) {
- function sendErr(err) {
+ function sendErr(err, rawBody) {
res.render('data', {
url: req.query.url,
- err: err
+ err: err,
+ rawBody: rawBody
});
}
var u = url.parse(req.query.url, true);
@@ -35,17 +36,18 @@ exports.render = function(req, res) {
u.query = _.extend({}, u.query, params);
fetchCollection(url.format(u), function(err, headers, body) {
if(err) {
- sendErr(err);
+ sendErr(err, body);
}
else {
var parsedBody;
try {
parsedBody = JSON.parse(body);
} catch(e) {
- sendErr('Unable to parse JSON: ' + e);
+ sendErr('Unable to parse JSON: ' + e, body);
return;
}
var collection = collection_json.fromObject(parsedBody).collection;
+ console.log(collection);
var isUrl = function(u) {
try {
var x = url.parse(u);
diff --git a/views/data.jade b/views/data.jade
index 5c93aef..9f64ddf 100644
--- a/views/data.jade
+++ b/views/data.jade
@@ -127,7 +127,6 @@ block queries
div(class='control-group')
div(class='controls')
input(type='submit') Execute
- // button(class='execute-query') Execute
block headers
pre
@@ -137,12 +136,6 @@ block headers
td #{key}:
td #{value}
-block formatted_body
- pre= formattedBody
-
-block raw_body
- pre= rawBody
-
block navbar
div(class='navbar navbar-fixed-top')
div(class='navbar-inner')
@@ -169,29 +162,37 @@ block navbar
block sidebar
div(id='navbar', class='sidebar-nav sidebar-nav-fixed')
ul(class='nav nav-list')
- li(class='nav-header'): a(href='#meta') Meta
- each link, i in collection.links
- li: a(href='#link-' + (i + 1))
- mixin get_name(link, 'Link', i)
- li(class='nav-header'): a(href='#items') Items
- each item, i in collection.items
- li: a(href='#item-' + (i + 1)) ##{i + 1}
- li(class='nav-header'): a(href='#queries') Queries
- each query, i in collection.queries
- li: a(href='#query-' + (i + 1))
- mixin get_name(query, 'Query', i)
- li(class='nav-header'): a(href='#headers') Headers
- li(class='nav-header'): a(href='#formatted-body') Formatted Body
- li(class='nav-header'): a(href='#raw-body') Raw Body
+ if typeof err != 'undefined'
+ li(class='nav-header'): a(href='#error') Error
+ li(class='nav-header'): a(href='#raw-body') Raw Body
+ else
+ li(class='nav-header'): a(href='#meta') Meta
+ each link, i in collection.links
+ li: a(href='#link-' + (i + 1))
+ mixin get_name(link, 'Link', i)
+ li(class='nav-header'): a(href='#items') Items
+ each item, i in collection.items
+ li: a(href='#item-' + (i + 1)) ##{i + 1}
+ li(class='nav-header'): a(href='#queries') Queries
+ each query, i in collection.queries
+ li: a(href='#query-' + (i + 1))
+ mixin get_name(query, 'Query', i)
+ li(class='nav-header'): a(href='#headers') Headers
+ li(class='nav-header'): a(href='#formatted-body') Formatted Body
+ li(class='nav-header'): a(href='#raw-body') Raw Body
block inner_content
if typeof err != 'undefined'
section(id='error')
div(class='page-error')
h1 Error
- p Error rendering #{url}
+ p Error rendering #{url}
- p= err
+ p= err
+ section(id='raw-body')
+ div(class='page-header')
+ h1 Raw Body
+ pre= rawBody
else
section(id='meta')
div(class='page-header')
@@ -214,15 +215,16 @@ block inner_content
section(id='formatted-body')
div(class='page-header')
h1 Formatted Body
- block formatted_body
+ pre= formattedBody
section(id='raw-body')
div(class='page-header')
h1 Raw Body
- block raw_body
+ pre= rawBody
block content
div(class='row-fluid')
div(class='span3')
block sidebar
div(class='span9')
+ - console.log('fuck')
block inner_content