Created
January 26, 2015 16:34
-
-
Save jaredpalmer/834839a8e1f49d170edb to your computer and use it in GitHub Desktop.
telescope-newsletter-fork
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
campaignSchema = new SimpleSchema({ | |
_id: { | |
type: String, | |
optional: true | |
}, | |
createdAt: { | |
type: Date, | |
optional: true | |
}, | |
sentAt: { | |
type: String, | |
optional: true | |
}, | |
status: { | |
type: String, | |
optional: true | |
}, | |
posts: { | |
type: [String], | |
optional: true | |
}, | |
webHits: { | |
type: Number, | |
optional: true | |
}, | |
}); | |
Campaigns = new Meteor.Collection("campaigns", { | |
schema: campaignSchema | |
}); | |
addToPostSchema.push( | |
{ | |
propertyName: 'scheduledAt', | |
propertySchema: { | |
type: Date, | |
optional: true, | |
autoform: { | |
omit: true | |
} | |
} | |
} | |
); | |
// Settings | |
var enableNewsletter = { | |
propertyName: 'enableNewsletter', | |
propertySchema: { | |
type: Boolean, | |
optional: true, | |
autoform: { | |
group: 'newsletter', | |
instructions: 'Enable newsletter (requires restart).' | |
} | |
} | |
} | |
addToSettingsSchema.push(enableNewsletter); | |
var showBanner = { | |
propertyName: 'showBanner', | |
propertySchema: { | |
type: Boolean, | |
optional: true, | |
label: 'Newsletter banner', | |
autoform: { | |
group: 'newsletter', | |
instructions: 'Show newsletter sign-up form on the front page.' | |
} | |
} | |
} | |
addToSettingsSchema.push(showBanner); | |
var mailChimpAPIKey = { | |
propertyName: 'mailChimpAPIKey', | |
propertySchema: { | |
type: String, | |
optional: true, | |
autoform: { | |
group: 'newsletter', | |
private: true | |
} | |
} | |
} | |
addToSettingsSchema.push(mailChimpAPIKey); | |
var mailChimpListId = { | |
propertyName: 'mailChimpListId', | |
propertySchema: { | |
type: String, | |
optional: true, | |
autoform: { | |
group: 'newsletter', | |
instructions: 'The ID of the list you want to send to.', | |
private: true | |
} | |
} | |
} | |
addToSettingsSchema.push(mailChimpListId); | |
var postsPerNewsletter = { | |
propertyName: 'postsPerNewsletter', | |
propertySchema: { | |
type: Number, | |
optional: true, | |
autoform: { | |
group: 'newsletter' | |
} | |
} | |
} | |
addToSettingsSchema.push(postsPerNewsletter); | |
var newsletterFrequency = { | |
propertyName: 'newsletterFrequency', | |
propertySchema: { | |
type: Number, | |
optional: true, | |
autoform: { | |
group: 'newsletter', | |
instructions: 'Defaults to once a week. Changes require restarting your app to take effect.', | |
options: [ | |
{ | |
value: 1, | |
label: 'Every Day' | |
}, | |
{ | |
value: 2, | |
label: 'Mondays, Wednesdays, Fridays' | |
}, | |
{ | |
value: 3, | |
label: 'Mondays & Thursdays' | |
}, | |
{ | |
value: 7, | |
label: 'Once a week (Mondays)' | |
} | |
] | |
} | |
} | |
} | |
addToSettingsSchema.push(newsletterFrequency); | |
var autoSubscribe = { | |
propertyName: 'autoSubscribe', | |
propertySchema: { | |
type: Boolean, | |
optional: true, | |
autoform: { | |
group: 'newsletter', | |
instructions: 'Automatically subscribe new users on sign-up.' | |
} | |
} | |
} | |
addToSettingsSchema.push(autoSubscribe); | |
// create new "campaign" lens for all posts from the past X days that haven't been scheduled yet | |
viewParameters.campaign = function (terms) { | |
return { | |
find: { | |
scheduledAt: {$exists: false}, | |
postedAt: { | |
$gte: terms.after | |
} | |
}, | |
options: {sort: {sticky: -1, shares: -1}} | |
}; | |
} | |
heroModules.push({ | |
template: 'newsletterBanner' | |
}); | |
function subscribeUserOnCreation (user) { | |
if (!!getSetting('autoSubscribe') && !!getEmail(user)) { | |
addToMailChimpList(user, false, function (error, result) { | |
console.log(error) | |
console.log(result) | |
}); | |
} | |
return user; | |
} | |
userCreatedCallbacks.push(subscribeUserOnCreation); |
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
Package.describe({ | |
summary: "Telescope email newsletter package", | |
version: '0.1.0', | |
name: "telescope-newsletter" | |
}); | |
Npm.depends({ | |
"html-to-text": "0.1.0", | |
"later": "1.1.6" | |
}); | |
Package.onUse(function (api) { | |
api.use([ | |
'telescope-lib', | |
'telescope-base', | |
'aldeed:simple-schema', | |
'iron:router', | |
'miro:mailchimp', | |
'tap:i18n', | |
'fourseven:scss', | |
'crunchhunt' | |
], ['client', 'server']); | |
api.use([ | |
'jquery', | |
'underscore', | |
'templating', | |
'mrt:cookies' | |
], 'client'); | |
api.use([ | |
'percolatestudio:synced-cron', | |
'cmather:handlebars-server', | |
'meteorhacks:npm' | |
], ['server']); | |
api.add_files([ | |
'package-tap.i18n', | |
'lib/newsletter.js' | |
], ['client', 'server']); | |
api.add_files([ | |
'lib/client/templates/newsletter_banner.html', | |
'lib/client/templates/newsletter_banner.js', | |
'lib/client/stylesheets/newsletter_banner.scss' | |
], ['client']); | |
api.add_files([ | |
'lib/server/campaign.js', | |
'lib/server/cron.js', | |
'lib/server/mailchimp.js', | |
'lib/server/routes.js', | |
'lib/server/templates/emailDigest.handlebars', | |
'lib/server/templates/emailDigestConfirmation.handlebars', | |
'lib/server/templates/emailPostItem.handlebars' | |
], ['server']); | |
api.add_files([ | |
"i18n/de.i18n.json", | |
"i18n/en.i18n.json", | |
"i18n/es.i18n.json", | |
"i18n/fr.i18n.json", | |
"i18n/it.i18n.json", | |
"i18n/zh-CN.i18n.json", | |
], ["client", "server"]); | |
api.export([ | |
'resetNewsletterSchedule' | |
]); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment