Use the request modules and not the https module.
This commit is contained in:
parent
1d13ea4462
commit
f4c7c5b82a
1 changed files with 9 additions and 13 deletions
22
event.js
22
event.js
|
@ -12,7 +12,7 @@ var
|
||||||
,util = require('util')
|
,util = require('util')
|
||||||
,dgram = require('dgram')
|
,dgram = require('dgram')
|
||||||
,config = require('./config')
|
,config = require('./config')
|
||||||
,http = require('https')
|
,request = require('request')
|
||||||
,jsdom = require('jsdom')
|
,jsdom = require('jsdom')
|
||||||
,nodemailer = require("nodemailer")
|
,nodemailer = require("nodemailer")
|
||||||
,log = require('sys').log
|
,log = require('sys').log
|
||||||
|
@ -68,7 +68,6 @@ EventTool.prototype.publishMail = function() {
|
||||||
var view = self.processEventData();
|
var view = self.processEventData();
|
||||||
// load the template
|
// load the template
|
||||||
var template = fs.readFileSync('templates/email/template.mustache','utf-8');
|
var template = fs.readFileSync('templates/email/template.mustache','utf-8');
|
||||||
console.log(view);
|
|
||||||
var output = mustache.render(template, view);
|
var output = mustache.render(template, view);
|
||||||
var transport = null;
|
var transport = null;
|
||||||
if (self.config.mail.mda == 'smtp') {
|
if (self.config.mail.mda == 'smtp') {
|
||||||
|
@ -91,7 +90,7 @@ EventTool.prototype.publishLatex = function() {
|
||||||
var view = self.processEventData();
|
var view = self.processEventData();
|
||||||
// generate the pdfs
|
// generate the pdfs
|
||||||
self.config.latex.templates.forEach(function(template){
|
self.config.latex.templates.forEach(function(template){
|
||||||
var templateData = fs.readFileSync('templates/latex/'+template+'.tex','utf-8');
|
var templateData = fs.readFileSync('templates/latex/'+template+'.tex','utf-8');
|
||||||
var output = mustache.render(templateData, view);
|
var output = mustache.render(templateData, view);
|
||||||
try {
|
try {
|
||||||
fs.mkdirSync(self.config.latex.tempDir);
|
fs.mkdirSync(self.config.latex.tempDir);
|
||||||
|
@ -147,8 +146,8 @@ EventTool.prototype.processEvents = function() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
EventTool.prototype.parseData = function() {
|
EventTool.prototype.parseData = function(et) {
|
||||||
var self = this.req.EventTool;
|
var self = et;
|
||||||
jsdom.env(
|
jsdom.env(
|
||||||
self.RequestData,
|
self.RequestData,
|
||||||
function (errors, window) {
|
function (errors, window) {
|
||||||
|
@ -176,20 +175,17 @@ EventTool.prototype.parseData = function() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
EventTool.prototype.processResponse = function(res) {
|
EventTool.prototype.processResponse = function(error, response, body) {
|
||||||
var self = this.EventTool;
|
var self = this.EventTool;
|
||||||
if (res.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
res.on('data', function(d) {
|
self.RequestData = body;
|
||||||
self.RequestData = self.RequestData + d;
|
self.parseData(self);
|
||||||
});
|
|
||||||
|
|
||||||
res.on('end',self.parseData);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EventTool.prototype.run = function() {
|
EventTool.prototype.run = function() {
|
||||||
log('Suche nach Terminen');
|
log('Suche nach Terminen');
|
||||||
var req = http.request(this.config.url,this.processResponse);
|
var req = request({'url':this.config.url,'strictSSL': false},this.processResponse);
|
||||||
req.EventTool = this;
|
req.EventTool = this;
|
||||||
|
|
||||||
req.end();
|
req.end();
|
||||||
|
|
Reference in a new issue