summaryrefslogtreecommitdiff
path: root/jekyll-hook.js
diff options
context:
space:
mode:
Diffstat (limited to 'jekyll-hook.js')
-rwxr-xr-xjekyll-hook.js31
1 files changed, 20 insertions, 11 deletions
diff --git a/jekyll-hook.js b/jekyll-hook.js
index dcc1410..72785c7 100755
--- a/jekyll-hook.js
+++ b/jekyll-hook.js
@@ -44,7 +44,7 @@ app.post('/hooks/jekyll/:branch', function(req, res) {
// Queue request handler
tasks.defer(function(req, res, cb) {
- var data = JSON.parse(req.body.payload);
+ var data = req.body;
var branch = req.params.branch;
var params = [];
@@ -71,7 +71,14 @@ app.post('/hooks/jekyll/:branch', function(req, res) {
/* repo */ params.push(data.repo);
/* branch */ params.push(data.branch);
/* owner */ params.push(data.owner);
- /* giturl */ params.push('git@' + config.gh_server + ':' + data.owner + '/' + data.repo + '.git');
+
+ /* giturl */
+ if (config.public_repo) {
+ params.push('https://' + config.gh_server + '/' + data.owner + '/' + data.repo + '.git');
+ } else {
+ params.push('git@' + config.gh_server + ':' + data.owner + '/' + data.repo + '.git');
+ }
+
/* source */ params.push(config.temp + '/' + data.owner + '/' + data.repo + '/' + data.branch + '/' + 'code');
/* build */ params.push(config.temp + '/' + data.owner + '/' + data.repo + '/' + data.branch + '/' + 'site');
@@ -97,7 +104,7 @@ app.post('/hooks/jekyll/:branch', function(req, res) {
// Done running scripts
console.log('Successfully rendered: ' + data.owner + '/' + data.repo);
- send('Your website at ' + data.owner + '/' + data.repo + ' was succesfully published.', 'Succesfully published site', data);
+ send('Your website at ' + data.owner + '/' + data.repo + ' was successfully published.', 'Successfully published site', data);
if (typeof cb === 'function') cb();
return;
@@ -129,13 +136,15 @@ function run(file, params, cb) {
}
function send(body, subject, data) {
- if (config.email && data.pusher.email) {
- var message = {
- text: body,
- from: config.email.user,
- to: data.pusher.email,
- subject: subject
- };
- mailer.send(message, function(err) { if (err) console.warn(err); });
+ if (config.email.isActivated) {
+ if (config.email && data.pusher.email) {
+ var message = {
+ text: body,
+ from: config.email.user,
+ to: data.pusher.email,
+ subject: subject
+ };
+ mailer.send(message, function(err) { if (err) console.warn(err); });
+ }
}
}