|
|
@ -5,8 +5,8 @@ var fs = require('fs'), |
|
|
|
glob = require('glob'), |
|
|
|
glob = require('glob'), |
|
|
|
statusProcessor = require('../lib/status-processor'); |
|
|
|
statusProcessor = require('../lib/status-processor'); |
|
|
|
|
|
|
|
|
|
|
|
var parseOptionsFromReferer = function (req, callback) { |
|
|
|
var parseOptionsFromReferer = function (path, callback) { |
|
|
|
var pathParts = (url.parse(req.headers.referer || "").pathname || "").split("/"); |
|
|
|
var pathParts = path.split("/"); |
|
|
|
var result = {}; |
|
|
|
var result = {}; |
|
|
|
if (pathParts.length < 3) { |
|
|
|
if (pathParts.length < 3) { |
|
|
|
return callback("BadRequest", result); |
|
|
|
return callback("BadRequest", result); |
|
|
@ -19,8 +19,15 @@ var parseOptionsFromReferer = function (req, callback) { |
|
|
|
return callback(null, result); |
|
|
|
return callback(null, result); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var createShowReport = function (res) { |
|
|
|
|
|
|
|
return function (err, options) { |
|
|
|
|
|
|
|
options = options || {}; |
|
|
|
|
|
|
|
options.err = err; |
|
|
|
|
|
|
|
res.render('status', options); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
exports.image = function(req, res) { |
|
|
|
exports.image = function(req, res) { |
|
|
|
console.log(req.headers); |
|
|
|
|
|
|
|
var handle = function (err, options) { |
|
|
|
var handle = function (err, options) { |
|
|
|
if (err === "ReportFileNotFound") { |
|
|
|
if (err === "ReportFileNotFound") { |
|
|
|
options.status = "Building"; |
|
|
|
options.status = "Building"; |
|
|
@ -45,7 +52,7 @@ exports.image = function(req, res) { |
|
|
|
res.render('status-image', options); |
|
|
|
res.render('status-image', options); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
parseOptionsFromReferer(req, function (err, options) { |
|
|
|
parseOptionsFromReferer(url.parse(req.headers.referer || "").pathname || "", function (err, options) { |
|
|
|
if (err) { |
|
|
|
if (err) { |
|
|
|
return handle(err, options); |
|
|
|
return handle(err, options); |
|
|
|
} |
|
|
|
} |
|
|
@ -65,9 +72,16 @@ exports.page = function(req, res) { |
|
|
|
rev: req.params.rev |
|
|
|
rev: req.params.rev |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
statusProcessor.getReport(req.app, options, function (err, options) { |
|
|
|
statusProcessor.getReport(req.app, options, createShowReport(res)); |
|
|
|
options = options || {}; |
|
|
|
|
|
|
|
options.err = err; |
|
|
|
|
|
|
|
res.render('status', options); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
exports.pageFromGithub = function (req, res) { |
|
|
|
|
|
|
|
parseOptionsFromReferer(req.params[0], function (err, options) { |
|
|
|
|
|
|
|
if (err) { |
|
|
|
|
|
|
|
return showReport(err, options); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return statusProcessor.getReport(req.app, options, createShowReport(res)); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|