Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 21x 1x 4x 1x 3x 21x 1x | const stampit = require('stampit'); const DEFAULT_CONFIG_WARNING_MESSAGE = 'No configuration object included.'; const DEFAULT_TEMPLATE_URL = 'https://raw.githubusercontent.com/portable-cto/rss-to-email/master/src/templates/default.mjml'; const HeaderConfig = stampit({ props: { banner: undefined, link: undefined, title: undefined, }, /** * Initialize * @param {object} options * @return {void} */ init(options) { this.banner = options.banner; this.link = options.link; this.title = options.title; }, }); const FeedConfig = stampit({ props: { description: undefined, title: undefined, url: undefined, }, /** * Initialize * @param {object} options * @return {void} */ init(options) { this.description = options.description; this.title = options.title; this.url = options.url; }, }); const DEFAULT_CONFIG_OBJECT = { accentColor: 'red', filename: 'example', header: HeaderConfig({ description: 'A short custom feed description', title: 'A custom feed title', url: 'http://www.feedforall.com/sample.xml', }), intro: 'Hey there,<br/><br/>Thanks for opening the email! Here are some links I want you to check out:', feeds: [FeedConfig({ publishedSince: undefined, description: 'A short custom feed description', title: 'A custom feed title', url: 'http://www.feedforall.com/sample.xml', })], outro: "Thanks for reading. We'll be back next week with more!<br/><br/>John Smith, CMO at Example Co.", templateUrl: DEFAULT_TEMPLATE_URL, }; /** * Determine whether or not a value is null or undefined * @param {any} val * @return {boolean} */ function isNullOrUndefined(val) { return val === undefined || val === null; } const Config = stampit({ props: DEFAULT_CONFIG_OBJECT, /** * Initialize * @param {object} options * @return {void} */ init(options) { if (Object.keys(options).length === 0 && options.constructor === Object) { throw DEFAULT_CONFIG_WARNING_MESSAGE; } Object.keys(this).forEach((property) => { this[property] = !isNullOrUndefined(options[property]) ? options[property] : DEFAULT_CONFIG_OBJECT[property]; }); }, }); module.exports = Config; |