This commit is contained in:
Martin Donnelly 2019-09-10 10:09:19 +01:00
commit 6f95baaa7a
7 changed files with 1604 additions and 0 deletions

55
.eslintrc Normal file
View File

@ -0,0 +1,55 @@
{
"parserOptions": {
"ecmaVersion": 2017,
"sourceType": "module",
"ecmaFeatures": {
"jsx": false
}
},
"env": {
"browser": false,
"node": true,
"es6": true
},
"rules": {
"arrow-spacing": "error",
"block-scoped-var": "error",
"block-spacing": "error",
"brace-style": ["error", "stroustrup", {}],
"camelcase": "error",
"comma-dangle": ["error", "never"],
"comma-spacing": ["error", { "before": false, "after": true }],
"comma-style": [1, "last"],
"consistent-this": [1, "_this"],
"curly": [1, "multi"],
"eol-last": 1,
"eqeqeq": 1,
"func-names": 1,
"indent": ["error", 2, { "SwitchCase": 1 }],
"lines-around-comment": ["error", { "beforeBlockComment": true, "allowArrayStart": true }],
"max-len": [1, 180, 2], // 2 spaces per tab, max 80 chars per line
"new-cap": 1,
"newline-before-return": "error",
"no-array-constructor": 1,
"no-inner-declarations": [1, "both"],
"no-mixed-spaces-and-tabs": 1,
"no-multi-spaces": 2,
"no-new-object": 1,
"no-shadow-restricted-names": 1,
"object-curly-spacing": ["error", "always"],
"padded-blocks": ["error", { "blocks": "never", "switches": "always" }],
"prefer-const": "error",
"prefer-template": "error",
"one-var": 0,
"quote-props": ["error", "always"],
"quotes": [1, "single"],
"radix": 1,
"semi": [1, "always"],
"space-before-blocks": [1, "always"],
"space-infix-ops": 1,
"vars-on-top": 1,
"no-multiple-empty-lines": ["error", { "max": 1, "maxEOF": 1 }],
"spaced-comment": ["error", "always", { "markers": ["/"] }]
}
}

182
.gitignore vendored Normal file
View File

@ -0,0 +1,182 @@
# Created by .ignore support plugin (hsz.mobi)
### Archives template
# It's better to unpack these files and commit the raw source because
# git has its own built in compression methods.
*.7z
*.jar
*.rar
*.zip
*.gz
*.bzip
*.bz2
*.xz
*.lzma
*.cab
#packing-only formats
*.iso
*.tar
#package management formats
*.dmg
*.xpi
*.gem
*.egg
*.deb
*.rpm
*.msi
*.msm
*.msp
### Windows template
# Windows image file caches
Thumbs.db
ehthumbs.db
# Folder config file
Desktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msm
*.msp
# Windows shortcuts
*.lnk
### OSX template
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio
*.iml
## Directory-based project format:
.idea/
# if you remove the above rule, at least ignore the following:
# User-specific stuff:
# .idea/workspace.xml
# .idea/tasks.xml
# .idea/dictionaries
# Sensitive or high-churn files:
# .idea/dataSources.ids
# .idea/dataSources.xml
# .idea/sqlDataSources.xml
# .idea/dynamic.xml
# .idea/uiDesigner.xml
# Gradle:
# .idea/gradle.xml
# .idea/libraries
# Mongo Explorer plugin:
# .idea/mongoSettings.xml
## File-based project format:
*.ipr
*.iws
## Plugin-specific files:
# IntelliJ
/out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
### Node template
# Logs
logs
*.log
npm-debug.log*
# Runtime data
pids
*.pid
*.seed
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# node-waf configuration
.lock-wscript
# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
# Dependency directory
# https://docs.npmjs.com/misc/faq#should-i-check-my-node-modules-folder-into-git
node_modules
bower_components
### VisualStudioCode template
.settings
### Xcode template
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
## Build generated
build/
DerivedData
## Various settings
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
## Other
*.xccheckout
*.moved-aside
*.xcuserstate
dist
/jspm_packages/npm/
/jspm_packages/github/

187
index.js Normal file
View File

@ -0,0 +1,187 @@
const sentence = require('to-sentence-case');
const UltraSES = require('ultrases');
const dateFormat = require('dateformat');
const pug = require('pug');
const logger = require('log4js').getLogger('menuizer');
logger.level = 'debug';
// {'name':'', 'url':''
const email = require('smtp-email-sender')({
'host': 'mail.caliban.io',
'port': '465',
'auth': {
'user': 'aida@caliban.io',
'pass': 'WaF#E+5am7.)\\csD',
'type': 'LOGIN' // PLAIN, LOGIN, MD5 etc...
},
'secure': 'secure'
});
const mailer = new UltraSES({
'aws': {
'accessKeyId': 'AKIAJWJS75F7WNCGK64A',
'secretAccessKey': '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',
'region': 'eu-west-1'
}, 'defaults': {
'from': 'Martin Donnelly <martind2000@gmail.com>'
}
});
const menu = [
{ 'name': 'Asian pepper steak crock pot recipe', 'url': 'https://www.marksdailyapple.com/asian-pepper-steak-crock-pot-recipe/#axzz29jTSubMo' },
{ 'name': 'Beef burgandy', 'url': 'http://www.marksdailyapple.com/beef-burgundy-recipe/#axzz29jTSubMo' },
{ 'name': 'italian sausage meatballs', 'url': 'http://www.marksdailyapple.com/primal-meatballs/#axzz29jTSubMo' },
{ 'name': 'frittata aleta', 'url': 'http://www.marksdailyapple.com/frittata-aleta/#axzz29jTSubMo' },
{ 'name': 'garlic pulled pork', 'url': 'http://www.marksdailyapple.com/garlic-pulled-pork/#axzz29jTSubMo' },
{ 'name': 'crock pot pork stuffed peppers', 'url': 'http://www.marksdailyapple.com/crock-pot-pork-stuffed-peppers/#axzz29jTSubMo' },
{ 'name': 'sesame chicken with "rice"', 'url': 'http://www.marksdailyapple.com/sesame-chicken-and-rice-with-fiery-ginger-and-chile-sauce/#axzz29jTSubMo' },
{ 'name': 'crispy nut and herb fried chicken', 'url': 'http://www.marksdailyapple.com/crispy-nut-and-herb-fried-chicken-with-creamy-avocado/#axzz29jTSubMo' },
{ 'name': 'spicy chicken and bacon poppers', 'url': 'http://www.marksdailyapple.com/spicy-chicken-and-bacon-poppers/#axzz29jTSubMo' },
{ 'name': 'butter chicken in silky sauce', 'url': 'http://www.marksdailyapple.com/butter-chicken-in-a-silky-sauce/#axzz29jTSubMo' },
{ 'name': 'steak', 'url': 'https://www.farmison.com/community/recipe/how-to-cook-your-beef-fillet-steak' },
{ 'name': 'hazelnut crusted chicken', 'url': 'http://www.marksdailyapple.com/hazelnut-crusted-chicken-with-stealth-coconut/#axzz29jTSubMo' },
{ 'name': 'vegetable latkes', 'url': 'http://www.marksdailyapple.com/vegetable-latkes/#axzz29jTSubMo' },
{ 'name': 'beef stew', 'url': 'http://www.marksdailyapple.com/beef-stew-and-chicken-soup-in-35-minutes-or-less/#axzz29jTSubMo' },
{ 'name': 'chicken soup', 'url': 'http://www.marksdailyapple.com/beef-stew-and-chicken-soup-in-35-minutes-or-less/#axzz29jTSubMo' },
{ 'name': 'sausage patties', 'url': 'https://www.tasteslovely.com/homemade-paleo-breakfast-sausage-patties/' },
{ 'name': 'primal tex mex torillas', 'url': 'http://www.marksdailyapple.com/primal-tex-mex-tortillas-and-taco-seasoning/#axzz29jTSubMo' },
{ 'name': 'primal texas chili', 'url': 'http://www.marksdailyapple.com/primal-texas-chili/#axzz29jTSubMo' },
{ 'name': 'moroccan burgers', 'url': 'https://sarahfragoso.com/moroccan-burgers-and-beet-salad/' },
{ 'name': 'paleo spaghetti', 'url': 'https://paleoleap.com/paleo-spaghetti/' },
{ 'name': 'primal chicken tikka masala', 'url': 'http://www.marksdailyapple.com/primal-chicken-tikka-masala/#axzz29jTSubMo' },
{ 'name': 'butter stuffed chicken kiev', 'url': 'http://www.marksdailyapple.com/butter-stuffed-chicken-kiev/#axzz29jTSubMo' },
{ 'name': 'tender lemon parsley brisket', 'url': 'http://www.marksdailyapple.com/tender-lemon-parsley-brisket/#axzz29jTSubMo' },
{ 'name': 'banh mi salad', 'url': 'http://www.marksdailyapple.com/banh-mi-salad/#axzz29jTSubMo' },
{ 'name': 'taco bowl crispy kale', 'url': 'http://www.marksdailyapple.com/taco-bowl-with-crispy-kale-chips/#axzz29jTSubMo' },
{ 'name': 'lime and basil kebabs', 'url': 'http://www.marksdailyapple.com/lime-and-basil-beef-kebabs/#axzz29jTSubMo' },
{ 'name': 'sun dried tomato meatballs', 'url': 'https://sarahfragoso.com/sun-dried-tomato-meatballs-with-creamy-pesto/' },
{ 'name': 'slow cooked coconut ginger pork', 'url': 'http://www.marksdailyapple.com/slow-cooked-coconut-ginger-pork/#axzz29jTSubMo' },
{ 'name': 'balsamic glazed drumsticks', 'url': 'http://www.marksdailyapple.com/balsamic-glazed-drumsticks/#axzz29jTSubMo' },
{ 'name': 'herb chicken cooked under a brick', 'url': 'http://www.marksdailyapple.com/herb-chicken-cooked-under-a-brick/#axzz29jTSubMo' },
{ 'name': 'pork stuffed jalapeno peppers', 'url': 'http://www.marksdailyapple.com/pork-stuffed-jalapeno-peppers/#axzz29jTSubMo' },
{ 'name': 'spiced pork butternut squash', 'url': 'http://www.marksdailyapple.com/spiced-pork-and-butternut-squash-with-sage/#axzz29jTSubMo' },
{ 'name': 'shakshuka', 'url': 'http://www.marksdailyapple.com/shakshuka-eggs-poached-in-spicy-tomato-sauce/#axzz29jTSubMo' },
{ 'name': 'grilled lime chicken', 'url': 'http://www.simplyrecipes.com/recipes/grilled_lime_chicken_with_black_bean_sauce/' },
{ 'name': 'eggs benadict burger', 'url': 'https://paleoleap.com/eggs-benedict-burgers/' },
{ 'name': 'asian marinated steaks', 'url': 'https://web.archive.org/web/20120330045230/http://www.paleotable.com/2011/01/asian-marinated-steaks.html' },
{ 'name': 'tango burgers', 'url': 'https://web.archive.org/web/20120127101048/http://www.paleotable.com/2011/01/tango-burgers.html' },
{ 'name': 'meatza', 'url': 'https://web.archive.org/web/20120118062740/http://www.paleotable.com/2011/02/meatza.html' },
{ 'name': 'baked chicken with roasted tomatos', 'url': 'https://web.archive.org/web/20120125102938/http://www.paleotable.com/2011/01/baked-chicken-with-roasted-tomatoes.html' },
{ 'name': 'blackened chicken', 'url': 'https://web.archive.org/web/20120420232533/http://www.paleotable.com/2011/02/blackened-chicken.html' },
{ 'name': 'breaded baked chicken', 'url': 'https://www.tastesoflizzyt.com/paleo-baked-chicken/' },
{ 'name': 'chicken and avocado tostadas', 'url': 'https://web.archive.org/web/20120707073826/http://www.paleotable.com/2011/03/chicken-and-avocado-tostadas.html' },
{ 'name': 'sausages and pepperonata', 'url': 'https://web.archive.org/web/20120707071653/http://www.paleotable.com/2011/01/sausages-and-pepperonata.html' },
{ 'name': 'Mediterranean Beef Stew with Green Olive Pesto', 'url': 'http://www.health-bent.com/soups/paleo-mediterranean-beef-stew' },
{ 'name': 'Beanless Chili', 'url': 'https://web.archive.org/web/20121004005636/http://www.realfoodfreaks.com/2012/04/02/chili-beanless-cuz-i-dont-eat-em/' },
{ 'name': 'Grilled Steak with Roasted Jalapeño Chimichurri', 'url': 'https://www.seriouseats.com/recipes/2012/05/ted-allens-grilled-steak-with-roasted-jalepeno.html' },
{ 'name': 'Lime and Coconut Chicken', 'url': 'http://chaosinthekitchen.com/2009/07/lime-and-coconut-chicken/' },
{ 'name': 'BEEF AND VEGETABLE CHILI', 'url': 'http://www.paleoplan.com/2011/10-12/steak-and-vegetable-chili/' },
{ 'name': 'PORK LOIN WITH PEPPERS, MUSHROOMS AND ONIONS', 'url': 'https://www.paleoplan.com/2010/02-23/pork-loin-with-peppers-mushrooms-n-onions/' },
{ 'name': 'Melt In Your Mouth Slow Cooker Beef Brisket', 'url': 'https://paleogrubs.com/beef-brisket-recipe' },
{ 'name': 'Yummy Sweet Potato Gnocchi', 'url': 'https://paleogrubs.com/sweet-potato-gnocchi-recipe' },
{ 'name': 'Simple Beef and Broccoli Stir Fry', 'url': 'https://paleogrubs.com/beef-and-broccoli-recipe' },
{ 'name': 'Crockpot Balsamic Roast Beef', 'url': 'https://www.primallyinspired.com/crockpot-balsamic-roast-beef/' },
{ 'name': 'Quick & Easy Crock Pot Chili', 'url': 'https://www.healthstartsinthekitchen.com/2014/01/04/quick-crock-pot-chili/' },
{ 'name': 'Tom Kha Gai -- Thai Coconut Soup', 'url': 'https://www.angsarap.net/2012/03/08/tom-kha-gai/' },
{ 'name': 'Roasted, Herbed Beef Tenderloin Recipe', 'url': 'https://www.chowhound.com/recipes/roasted-herbed-beef-tenderloin-30901' },
{ 'name': 'Chorizo Carbonara', 'url': 'https://www.jamieoliver.com/recipes/pasta-recipes/chorizo-carbonara-with-catalan-market-salad/#1EmLf9RiqepY4Z95.97' },
{ 'name': 'Roasted Tomato Soup with Fresh Basil', 'url': 'https://civilizedcaveman.com/recipes/soups/roasted-tomato-soup/' },
{ 'name': 'swedish meatballs', 'url': 'https://www.paleorunningmomma.com/paleo-swedish-meatballs-whole30/' },
{ 'name': 'Tom Yum Gai - hot and sour soup', 'url': 'http://angsarap.net/2013/08/07/tom-yum-gai/' },
{ 'name': 'Coconut Lime Chicken Soup', 'url': 'https://paleoleap.com/coconut-lime-chicken-soup/' },
{ 'name': 'Hungarian Beef Goulash', 'url': 'https://paleoleap.com/hungarian-beef-goulash/' },
{ 'name': 'Beef Bourguignon', 'url': 'http://paleoleap.com/beef-bourguignon/' },
{ 'name': 'Minted pesto chicken stir-fry', 'url': 'http://paleoleap.com/quick-and-easy-paleo-stir-fries/' },
{ 'name': 'Coconut curry stir-fry', 'url': 'http://paleoleap.com/quick-and-easy-paleo-stir-fries/' },
{ 'name': 'Citrus beef salad stir-fry', 'url': 'http://paleoleap.com/quick-and-easy-paleo-stir-fries/' },
{ 'name': 'Basil and chilli beef stir-fry', 'url': 'http://paleoleap.com/quick-and-easy-paleo-stir-fries/' },
{ 'name': 'a normal chicken stir fry', 'url': '' },
{ 'name': 'hunters chicken ( chicken wrapped in bacon / pancetta )', 'url': '' },
{ 'name': 'Caribbean Pork Chops with Mango Salsa | Paleo Grubs', 'url': 'https://paleogrubs.com/caribbean-pork-chops-recipe' },
{ 'name': 'Paleo Pork Tenderloin with Fig and Balsamic Glaze', 'url': 'http://paleogrubs.com/balsamic-pork-tenderloin-recipe' },
{ 'name': 'Chicken Cordon-Bacon', 'url': 'https://fastpaleo.com/recipe/bacon-wrapped-chicken-cordon-bleu/' },
{ 'name': 'Grilled Tandoori Chicken', 'url': 'http://cookingweekends.blogspot.com/2012/05/grilled-tandoori-chicken.html' },
{ 'name': 'Stuffed Chicken Breast (paleo and grain free)', 'url': 'http://www.cavegirlcuisine.com/recipes/stuffed-chicken-breast/' },
{ 'name': 'Lemon Chicken Breast Recipe', 'url': 'https://www.everydaymaven.com/lemon-chicken-breast/' },
{ 'name': 'Grilled Lemon Garlic Rosemary Chicken Breasts', 'url': 'https://www.phoenixhelix.com/2013/07/21/grilled-lemon-garlic-rosemary-chicken-breasts/' },
{ 'name': 'Paleo Spicy Mustard Crockpot Chicken', 'url': 'https://www.plaidandpaleo.com/2013/10/paleo-spicy-mustard-crockpot-chicken.html' },
{ 'name': 'Creamy Paleo Chicken Skillet', 'url': 'http://paleogrubs.com/skillet-chicken-recipe' },
{ 'name': 'Sweet and Savory Moroccan Chicken', 'url': 'http://paleogrubs.com/moroccan-chicken-recipe' },
{ 'name': 'Simple and Addictive Chicken Kabobs', 'url': 'http://paleogrubs.com/chicken-kabob-recipe' },
{ 'name': 'Indian Paleo Stew with Chicken', 'url': 'http://paleogrubs.com/indian-paleo-stew-recipe' },
{ 'name': 'Slow-Cooker Swedish Kalops Stew', 'url': 'https://web.archive.org/web/20130501032143/http://www.mylivingnutrition.com/2013/04/11/slow-cooker-swedish-kalops-stew/' },
{ 'name': 'Beef, Bacon and Rum Stew', 'url': 'http://domesticsoul.com/2011/12/beef-bacon-rum-stew-recipe.html' },
{ 'name': 'Paleo Orange Cinnamon Beef Stew', 'url': 'https://thehealthyfoodie.com/orange-cinnamon-beef-stew/' },
{ 'name': 'pepper steak', 'url': 'http://paleoleap.com/pepper-steak/' },
{ 'name': 'GARLIC ROASTED COD', 'url': 'http://paleoleap.com/garlic-roasted-cod/' },
{ 'name':'Easy Bacon-Wrapped Paleo Meatloaf Muffins', 'url':'https://paleogrubs.com/bacon-wrapped-meatloaf-muffins' },
{ 'name':'Easy Ground Beef Stuffed Peppers', 'url':'https://paleogrubs.com/ground-beef-stuffed-peppers' },
{ 'name':'Cream of Chicken Soup', 'url':'https://paleogrubs.com/crockpot-cream-of-chicken-soup' },
{ 'name':'balsamic grilled chicken with greek style salad', 'url':'https://paleoleap.com/balsamic-grilled-chicken-greek-style-salad/' },
{ 'name':'slow cooked hawaiian style kalua pork', 'url':'https://paleoleap.com/slow-cooked-hawaiian-style-kalua-pork/' },
{ 'name':'Sweet Thai Chili Chicken With Roasted Peppers', 'url':'http://paleoleap.com/sweet-thai-chili-chicken-roasted-peppers/' },
{ 'name':'Steak Ratatouille', 'url':'http://www.jamieoliver.com/recipes/beef-recipes/grilled-steak-ratatouille-saffron-rice/' },
{ 'name':'Slow Cooked Balsamic Pork Roast', 'url':'https://paleoleap.com/slow-cooked-balsamic-pork-roast/' },
{ 'name':'Seared Cod with Fresh Herb Sauce', 'url':'http://paleoleap.com/seared-cod-fresh-herb-sauce/' },
{ 'name':'Honey Ginger Apple Shredded Pork', 'url':'https://paleomg.com/honey-ginger-apple-shredded-pork/' },
{ 'name':'Orange Pineapple Pulled Pork', 'url':'http://www.smokedngrilled.com/orange-pineapple-pulled-pork/' }
];
// {'name':'', 'url':''}
function sendEmail(data, newpath) {
const now = new Date();
const email = {
'to': 'martind2000@gmail.com', 'subject': `Suggestions - ${ dateFormat(now, 'dddd, mmmm dS, yyyy')}`
};
const template = {
'file': `${newpath }/` + 'pug/email.jade', 'locals': data
};
mailer.sendTemplate(email, template, err => {
if (err) throw err;
logger.info('compiled template email sent');
});
}
function sendSMTP(data, newPath) {
const now = new Date();
const html = pug.renderFile( `${newPath }/` + 'pug/email.pug', data);
email({
'from': 'aida@caliban.io',
'to': 'martind2000@gmail.com',
'subject': `Suggestions - ${ dateFormat(now, 'dddd, mmmm dS, yyyy')}`,
'html': html
});
}
function pugTest(data, newpath) {
logger.debug(pug.renderFile( `${newpath }/` + 'pug/email.pug', data));
}
(function () {
// body
const usedNumbers = [];
const suggestions = [];
const data = {};
const now = new Date();
var options = { 'weekday': 'long', 'year': 'numeric', 'month': 'long', 'day': 'numeric' };
do {
const randomnumber = Math.floor(Math.random() * menu.length);
if (usedNumbers.indexOf(randomnumber) === -1) {
usedNumbers.push(randomnumber);
suggestions.push(menu[randomnumber]);
}
} while(usedNumbers.length < 5);
data.ts = now.toLocaleDateString('en-GB', options);
data.suggestions = suggestions;
// logger.debug(JSON.stringify(data));
sendSMTP(data, './');
}());

1141
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

19
package.json Normal file
View File

@ -0,0 +1,19 @@
{
"name": "menuizer",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"dateformat": "^3.0.3",
"log4js": "^5.1.0",
"pug": "^2.0.4",
"smtp-email-sender": "^1.0.0",
"to-sentence-case": "^1.0.0",
"ultrases": "^0.1.3"
}
}

10
pug/email.jade Normal file
View File

@ -0,0 +1,10 @@
html(lang="en")
head
meta(charset='utf-8')
title
Suggestions
body
h1 Suggestions for !{ts}
ol
each item in suggestions
li: a(href=item.url)= item.name

10
pug/email.pug Normal file
View File

@ -0,0 +1,10 @@
html(lang="en")
head
meta(charset='utf-8')
title
Suggestions
body
h1 Suggestions for !{ts}
ol
each item in suggestions
li: a(href=item.url)= item.name