Skip to content

Commit

Permalink
const the lang
Browse files Browse the repository at this point in the history
  • Loading branch information
SSARCandy committed Jun 26, 2016
1 parent c5e8743 commit 17f2c55
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 10 deletions.
6 changes: 4 additions & 2 deletions i18n/ar_sa.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
'use strict';

const LANG = 'ar_sa';
const BASE_URL = 'http://www.apodar.com/apod';

const handleError = require('../utils/handleError').common;
const notFoundError = require('../utils/handleError').notFound;
const request = require('request');
Expand All @@ -25,12 +27,12 @@ function craw(baseData, callback) {
let explanation = $('body > div.region4 > div:nth-child(1) > div > div').text().trim();

if (!title || !explanation) {
return callback(notFoundError(baseData.date, 'cs_cz'));
return callback(notFoundError(baseData.date, LANG));
}

baseData.title = title;
baseData.explanation = explanation;
baseData.lang = 'ar_sa';
baseData.lang = LANG;
callback(null, baseData);
});
}
Expand Down
6 changes: 4 additions & 2 deletions i18n/cs_cz.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
'use strict';

const LANG = 'cs_cz';
const BASE_URL = 'http://www.astro.cz/apod';

const handleError = require('../utils/handleError').common;
const notFoundError = require('../utils/handleError').notFound;
const request = require('request');
Expand All @@ -25,12 +27,12 @@ function craw(baseData, callback) {
let explanation = $('article.apod > p').eq(1).text().trim().replace(/\r?\n/g, ' ');

if (!title || !explanation) {
return callback(notFoundError(baseData.date, 'cs_cz'));
return callback(notFoundError(baseData.date, LANG));
}

baseData.title = title;
baseData.explanation = explanation;
baseData.lang = 'cs_cz';
baseData.lang = LANG;
callback(null, baseData);
});
}
Expand Down
6 changes: 4 additions & 2 deletions i18n/fr_fr.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
'use strict';

const LANG = 'fr_fr';
const BASE_URL = 'http://www.cidehom.com/apod.php';

const handleError = require('../utils/handleError').common;
const notFoundError = require('../utils/handleError').notFound;
const request = require('request');
Expand All @@ -24,12 +26,12 @@ function craw(baseData, callback) {
let explanation = $('body > div > div:nth-child(6) > div.article_colonne_gauche > div > p').text().trim().replace(/\r?\n/g, ' ');

if (!title || !explanation) {
return callback(notFoundError(baseData.date, 'fr_fr'));
return callback(notFoundError(baseData.date, LANG));
}

baseData.title = title;
baseData.explanation = explanation;
baseData.lang = 'fr_fr';
baseData.lang = LANG;
return callback(null, baseData);
});
}
Expand Down
6 changes: 4 additions & 2 deletions i18n/zh_tw.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
'use strict';

const LANG = 'zh_tw';
const BASE_URL = 'http://www.phys.ncku.edu.tw/~astrolab/mirrors/apod';

const handleError = require('../utils/handleError').common;
const notFoundError = require('../utils/handleError').notFound;
const request = require('request');
Expand All @@ -24,12 +26,12 @@ function craw(baseData, callback) {
let explanation = $('body').children('p').eq(0).text().trim();

if (!title || !explanation) {
return callback(notFoundError(baseData.date, 'zh_tw'));
return callback(notFoundError(baseData.date, LANG));
}

baseData.title = title;
baseData.explanation = explanation;
baseData.lang = 'zh_tw';
baseData.lang = LANG;
return callback(null, baseData);
});
}
Expand Down
2 changes: 0 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ APOD.prototype.get = function(options, callback) {
json: true
};

console.time('i');
request(opt, function(error, response, body) {
console.timeEnd('i');
if (handleError(error, response, body)) {
return callback(handleError(error, response, body));
}
Expand Down

0 comments on commit 17f2c55

Please sign in to comment.