forked from ERNICommunity/at11
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/daddy32/at11
- Loading branch information
Showing
13 changed files
with
387 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,4 +18,5 @@ node_modules | |
/nbproject/private/ | ||
.idea/ | ||
*.iml | ||
.vscode | ||
.vscode | ||
/sh.exe.stackdump |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,72 @@ | ||
module.exports = { | ||
port: process.env.PORT || 54321, | ||
cacheExpiration: 2 * 60 * 60 * 1000, //2h | ||
parserTimeout: 10 * 1000, //10s | ||
restaurants: [ | ||
{ id: 1, name: 'U Daňováka', url: 'http://www.udanovaka.sk/obedove-menu/', module: 'danovak' }, | ||
{ id: 11, name: 'Kaša', url: 'https://restauracie.sme.sk/restauracia/kasa-2_8386-petrzalka_664/denne-menu', module: 'kasa' }, | ||
{ id: 3, name: 'ITB', url: 'http://www.citycantina.sk/prevadzka/1', module: 'itb' }, | ||
{ id: 2, name: 'Giuliano', url: 'http://www.giuliano.sk/-denne-menu', module: 'giuliano' }, | ||
{ id: 4, name: 'Alfa', url: 'http://restauracie.sme.sk/restauracia/restauracia-alfa_2512-petrzalka_664/denne-menu', module: 'alfa' }, | ||
{ id: 5, name: 'Škôlka', url: 'http://jedalen.vysnivany.sk/ukazka-strany', module: 'skolka' }, | ||
{ id: 6, name: 'Pizza Pazza', url: 'http://pizzapazza.sk/?page_id=645', module: 'pizzapazza', post: 'prevadzka2=1' }, | ||
{ id: 7, name: 'Kamenica - Corleone Pizza', url: 'http://www.pizzacorleone.sk/obedove-menu.html', module: 'kamenica' }, | ||
{ id: 8, name: 'Numero Uno', url: 'http://www.numerouno.sk/denne-menu/', module: 'numerouno' }, | ||
{ id: 9, name: 'Engerau restaurant', url: 'https://www.zomato.com/sk/bratislava/engerau-restaurant-petr%C5%BEalka-bratislava-v/denn%C3%A9-menu', module: 'engerau' }, | ||
{ id: 10, name: 'Lokálka', url: 'http://www.lokalka.sk/kopcianska-2/', module: 'lokalka' } | ||
], | ||
themes: { | ||
'jano': { name: 'Jano', template: '../views/index.html' }, | ||
'matus': { name: 'Matúš', template: '../views/index3.html' }, | ||
'iveta': { name: 'Iveta', template: '../views/index4.html' }, | ||
'diana': { name: 'Diana', template: '../views/index6.html' }, | ||
'telka': { name: 'Telka', template: '../views/index5.html' } | ||
} | ||
port: process.env.PORT || 54321, | ||
cacheExpiration: 2 * 60 * 60 * 1000, //2h | ||
parserTimeout: 20 * 1000, //20s | ||
restaurants: [ | ||
{ | ||
id: 1, | ||
name: 'Trattoria', | ||
url: 'http://restauracie.sme.sk/restauracia/trattoria-pepe_3300-zilina_2737/denne-menu', | ||
module: 'trattoria_za' | ||
}, | ||
{ | ||
id: 2, | ||
name: 'Spirit', | ||
url: 'http://restauracie.sme.sk/restauracia/restauracia-spirit_6918-zilina_2737/denne-menu', | ||
module: 'chef_spirit_za' | ||
}, | ||
{ | ||
id: 3, | ||
name: 'O2', | ||
url: 'http://restauracie.sme.sk/restauracia/restauracia-02_2492-zilina_2737/denne-menu', | ||
module: 'chef_spirit_za' | ||
}, | ||
{ | ||
id: 4, | ||
name: 'Gusto', | ||
url: 'http://restauracie.sme.sk/restauracia/gusto_4537-zilina_2737/denne-menu', | ||
module: 'chef_spirit_za' | ||
}, | ||
{ | ||
id: 8, | ||
name: 'Level 7', | ||
url: 'http://restauracie.sme.sk/restauracia/level-7_4546-zilina_2737/denne-menu', | ||
module: 'trattoria_za' | ||
}, | ||
{ | ||
id: 9, | ||
name: 'Chef restaurant', | ||
url: 'http://restauracie.sme.sk/restauracia/chef-restaurant-bar_7274-zilina_2737/denne-menu', | ||
module: 'chef_spirit_za' | ||
}, | ||
/* NOK! | ||
{ | ||
id: 5, | ||
name: 'Vulcano', | ||
url: 'http://www.vulcano.sk/?page_id=12', | ||
module: 'vulcano_za' | ||
},*/ | ||
/* | ||
TODO: Tempo: http://www.dobreobedy.sk/ | ||
*/ | ||
{ | ||
id: 5, | ||
name: 'Kamélia', | ||
url: 'http://restauracie.sme.sk/restauracia/penzion-kamelia_2004-zilina_2737/denne-menu', | ||
module: 'kamelia_za' | ||
}, | ||
{ | ||
id: 10, | ||
name: 'Central Park', | ||
url: 'http://restauracie.sme.sk/restauracia/penzion-central-park_5515-zilina_2737/denne-menu', | ||
module: 'central_park_za' | ||
}, | ||
], | ||
themes: { | ||
'jano': { name: 'Jano', template: '../views/index.html' }, | ||
'matus': { name: 'Matúš', template: '../views/index3.html' }, | ||
'iveta': { name: 'Iveta', template: '../views/index4.html' }, | ||
'diana': { name: 'Diana', template: '../views/index6.html' }, | ||
'telka': { name: 'Telka', template: '../views/index5.html' } | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
var cheerio = require('cheerio'); | ||
require('./parserUtil'); | ||
|
||
module.exports.parse = function(html, date, callback) { | ||
var $ = cheerio.load(html); | ||
var dayMenu = []; | ||
|
||
|
||
// dayMenu.push({ isSoup: false, text: normalize(text), price: price }); | ||
|
||
/* | ||
dayMenu = dayMenu.map(function(item) { | ||
var label = $('.left', item).text(); | ||
var price = $('.right', item).text(); | ||
return { isSoup: soupPattern.test(label.trim()), text: normalize(label), price: parseFloat(price) }; | ||
}); | ||
*/ | ||
callback(dayMenu); | ||
|
||
function normalize(str) { | ||
return str.removeItemNumbering() | ||
.removeMetrics() | ||
.correctCommaSpacing() | ||
; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
var cheerio = require('cheerio'); | ||
var parserUtil = require('./parserUtil'); | ||
|
||
module.exports.parse = function(html, date, callback) { | ||
var $ = cheerio.load(html); | ||
var dayMenu = []; | ||
var soupPattern = /0,[1-9]*$/; | ||
var junkPattern = /2 polievky|Dezert|Týždenné menu/; | ||
|
||
var denneMenu = parserUtil.findMenuSme($, date); | ||
|
||
denneMenu.first().find('.jedlo_polozka').each(function() { | ||
if ($(this).find('.left>b').length === 0 && !(junkPattern.test($(this).text()))) { | ||
dayMenu.push(this); | ||
} | ||
}); | ||
sdd | ||
//convert to menu item object | ||
dayMenu = dayMenu.map(function(item) { | ||
var label = $('.left', item).text(); | ||
var price = $('.right', item).text(); | ||
return { | ||
isSoup: soupPattern.test(label.trim()), | ||
text: normalize(label), | ||
price: parseFloat(price) | ||
}; | ||
}); | ||
|
||
callback(dayMenu); | ||
|
||
function normalize(str) { | ||
return str.normalizeWhitespace() | ||
.replace(soupPattern, '') | ||
.removeMetrics() | ||
.correctCommaSpacing() | ||
.removeItemNumbering(); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
var cheerio = require('cheerio'); | ||
var parserUtil = require('./parserUtil'); | ||
|
||
module.exports.parse = function(html, date, callback) { | ||
var $ = cheerio.load(html); | ||
var dayMenu = []; | ||
var index = 0; | ||
var max_soup_index = 0; | ||
var junkPattern = /Mini dezert/; | ||
|
||
var denneMenu = parserUtil.findMenuSme($, date); | ||
|
||
var restaurantName = $('.res_page .nazov-restauracie h1').text(); | ||
if (restaurantName.toLowerCase().includes('chef') || restaurantName.toLowerCase().includes('02')) { | ||
max_soup_index = 1; | ||
} | ||
|
||
denneMenu.first().find('.jedlo_polozka').each(function() { | ||
if ($(this).find('.left>b').length === 0 && !(junkPattern.test($(this).text()))) { | ||
dayMenu.push(this); | ||
} | ||
}); | ||
|
||
//convert to menu item object | ||
dayMenu = dayMenu.map(function(item) { | ||
var label = $('.left', item).text(); | ||
var price = $('.right', item).text(); | ||
return { | ||
isSoup: index++ <= max_soup_index, | ||
text: normalize(label), | ||
price: parseFloat(price) | ||
}; | ||
}); | ||
|
||
callback(dayMenu); | ||
|
||
function normalize(str) { | ||
return str.normalizeWhitespace() | ||
.removeMetrics() | ||
.correctCommaSpacing() | ||
.removeItemNumbering(); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
var cheerio = require('cheerio'); | ||
var parserUtil = require('./parserUtil'); | ||
|
||
module.exports.parse = function(html, date, callback) { | ||
var $ = cheerio.load(html); | ||
var dayMenu = []; | ||
var soupPattern = /^Polievk|^Hlavné|^ŠPECIALITA/; | ||
var junkPattern = /Hlavné jedlá/; | ||
|
||
var denneMenu = parserUtil.findMenuSme($, date); | ||
var restaurantName = $('.res_page .nazov-restauracie h1').text(); | ||
|
||
if (restaurantName.toLowerCase().includes('chef')) { | ||
max_soup_index = 1; | ||
} | ||
|
||
denneMenu.first().find('.jedlo_polozka').each(function() { | ||
if (/*$(this).find('.left>b').length === 0 &&*/ !(junkPattern.test($(this).text()))) { | ||
dayMenu.push(this); | ||
} | ||
}); | ||
|
||
//convert to menu item object | ||
dayMenu = dayMenu.map(function(item) { | ||
var label = $('.left', item).text(); | ||
var price = $('.right', item).text(); | ||
return { | ||
isSoup: soupPattern.test(label.trim()), | ||
text: normalize(label), | ||
price: parseFloat(price) | ||
}; | ||
}); | ||
|
||
callback(dayMenu); | ||
|
||
function normalize(str) { | ||
return str.normalizeWhitespace() | ||
//.replace(soupPattern, '') | ||
.removeMetrics() | ||
.correctCommaSpacing() | ||
.removeItemNumbering(); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
var cheerio = require('cheerio'); | ||
var parserUtil = require('./parserUtil'); | ||
|
||
module.exports.parse = function(html, date, callback) { | ||
var $ = cheerio.load(html); | ||
var dayMenu = []; | ||
var soupPattern = /^Polievka[^:]+: /; | ||
|
||
var denneMenu = parserUtil.findMenuSme($, date); | ||
|
||
denneMenu.first().find('.jedlo_polozka').each(function() { | ||
if ($(this).find('.left>b').length === 0) { | ||
dayMenu.push(this); | ||
} | ||
}); | ||
|
||
//convert to menu item object | ||
dayMenu = dayMenu.map(function(item) { | ||
var label = $('.left', item).text(); | ||
var price = $('.right', item).text(); | ||
return { | ||
isSoup: soupPattern.test(label.trim()), | ||
text: normalize(label), | ||
price: parseFloat(price) | ||
}; | ||
}); | ||
|
||
callback(dayMenu); | ||
|
||
function normalize(str) { | ||
return str.normalizeWhitespace() | ||
.replace(soupPattern, '') | ||
.removeMetrics() | ||
.correctCommaSpacing() | ||
.removeItemNumbering(); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
var cheerio = require('cheerio'); | ||
var parserUtil = require('./parserUtil'); | ||
|
||
module.exports.parse = function(html, date, callback) { | ||
var $ = cheerio.load(html); | ||
var dayMenu = []; | ||
var soupPattern = /^0[\.,]\d+\s?l/; | ||
var junkPattern = /Mini dezert/; | ||
|
||
var denneMenu = parserUtil.findMenuSme($, date); | ||
|
||
denneMenu.first().find('.jedlo_polozka').each(function() { | ||
if ($(this).find('.left>b').length === 0 && !(junkPattern.test($(this).text()))) { | ||
dayMenu.push(this); | ||
} | ||
}); | ||
|
||
//convert to menu item object | ||
dayMenu = dayMenu.map(function(item) { | ||
var label = $('.left', item).text(); | ||
var price = $('.right', item).text(); | ||
return { | ||
isSoup: soupPattern.test(label.trim()), | ||
text: normalize(label), | ||
price: parseFloat(price) | ||
}; | ||
}); | ||
|
||
callback(dayMenu); | ||
|
||
function normalize(str) { | ||
return str.normalizeWhitespace() | ||
.replace(soupPattern, '') | ||
.removeMetrics() | ||
.correctCommaSpacing() | ||
.removeItemNumbering(); | ||
} | ||
}; |
Oops, something went wrong.