pageFromGithub implemented

dependabot/npm_and_yarn/BuildServer/eslint-7.2.0
Inga 🏳‍🌈 9 years ago
parent 5cc1338744
commit f5f1c8542b
  1. 1
      BuildServer/app.js
  2. 32
      BuildServer/routes/status.js

@ -41,6 +41,7 @@ app.get('/github/postreceive', function (req, res) {
app.get('/manual', routes.manual.get); app.get('/manual', routes.manual.get);
app.post('/manual', routes.manual.post); app.post('/manual', routes.manual.post);
app.get('/status/:owner/:reponame/:branch/:rev?', routes.status.page); app.get('/status/:owner/:reponame/:branch/:rev?', routes.status.page);
app.get('/pos-github.payonline.ru/*', routes.status.pageFromGithub);
app.get('/status.svg', routes.status.image); app.get('/status.svg', routes.status.image);
app.get('/release/:owner/:reponame/:branch/:rev', routes.release); app.get('/release/:owner/:reponame/:branch/:rev', routes.release);
app.get('/artifact/:owner/:reponame/:branch/:rev/*', routes.artifact); app.get('/artifact/:owner/:reponame/:branch/:rev/*', routes.artifact);

@ -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));
});
}

Loading…
Cancel
Save