mirror of
https://github.com/vale981/Vulcan
synced 2025-03-10 12:36:39 -04:00
Merge branch 'master' of https://github.com/TelescopeJS/Telescope into telescope-master-seo2
This commit is contained in:
commit
53bb789c15
16 changed files with 158 additions and 77 deletions
|
@ -1,3 +1,8 @@
|
|||
* Added new `userCreatedCallbacks` callback hook.
|
||||
* Added new `debug` setting.
|
||||
* `siteUrl` setting now affects `Meteor.absoluteUrl()`.
|
||||
* Added new `clog` function that only logs if `debug` setting is true.
|
||||
|
||||
## v0.10.0 “RefactorScope”
|
||||
|
||||
* Renaming Errors to Messages (thanks @yourcelf!).
|
||||
|
|
|
@ -15,6 +15,4 @@ Template[getTemplate('post_page')].helpers({
|
|||
|
||||
Template[getTemplate('post_page')].rendered = function(){
|
||||
$('body').scrollTop(0);
|
||||
if(this.data) // XXX
|
||||
document.title = $(".post-title").text();
|
||||
};
|
||||
|
|
5
client/views/users/sign_out.html
Normal file
5
client/views/users/sign_out.html
Normal file
|
@ -0,0 +1,5 @@
|
|||
<template name="sign_out">
|
||||
<div class="grid-small grid-block dialog">
|
||||
<p>{{_ "you_ve_been_signed_out"}}</p>
|
||||
</div>
|
||||
</template>
|
|
@ -294,6 +294,15 @@ settingsSchemaObject = {
|
|||
private: true
|
||||
}
|
||||
},
|
||||
debug: {
|
||||
type: Boolean,
|
||||
optional: true,
|
||||
label: 'Debug Mode',
|
||||
autoform: {
|
||||
group: 'debug',
|
||||
instructions: 'Enable debug mode for more details console logs'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// add any extra properties to settingsSchemaObject (provided by packages for example)
|
||||
|
@ -328,4 +337,10 @@ if (Meteor.isClient){
|
|||
setLanguage(fields.language)
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Meteor.startup(function () {
|
||||
// override Meteor.absoluteUrl() with URL provided in settings
|
||||
Meteor.absoluteUrl.defaultOptions.rootUrl = getSetting('siteUrl', Meteor.absoluteUrl());
|
||||
debug = getSetting('debug', false);
|
||||
});
|
|
@ -51,6 +51,7 @@
|
|||
"extraCode": "Extra Code",
|
||||
"emailFooter": "Email Footer",
|
||||
"notes": "Notes",
|
||||
"debug": "Debug Mode",
|
||||
|
||||
// Settings Fieldsets
|
||||
"general": "General",
|
||||
|
@ -253,6 +254,7 @@
|
|||
"posted_time": "Posted Time",
|
||||
"profile": "Profile",
|
||||
"sign_out": "Sign Out",
|
||||
"you_ve_been_signed_out": "You've been signed out. Come back soon!",
|
||||
"invitedcount": "InvitedCount",
|
||||
"invites": "Invites",
|
||||
"invited": "Invited?",
|
||||
|
|
4
lib/debug.js
Normal file
4
lib/debug.js
Normal file
|
@ -0,0 +1,4 @@
|
|||
clog = function (s) {
|
||||
if(getSetting('debug', false))
|
||||
console.log(s);
|
||||
}
|
|
@ -44,10 +44,11 @@ Meteor.startup(function () {
|
|||
|
||||
Router.route('/sign-out', {
|
||||
name: 'signOut',
|
||||
template: getTemplate('sign_out'),
|
||||
onBeforeAction: function() {
|
||||
Meteor.logout(function() {
|
||||
return Router.go('/');
|
||||
});
|
||||
this.next();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -6,10 +6,6 @@ isAdmin=function(user){
|
|||
user = (typeof user === 'undefined') ? Meteor.user() : user;
|
||||
return !!user && !!user.isAdmin;
|
||||
};
|
||||
setAdmin = function(user, admin){
|
||||
user = (typeof user === 'undefined') ? Meteor.user() : user;
|
||||
user.isAdmin = !!admin;
|
||||
};
|
||||
updateAdmin = function(userId, admin) {
|
||||
Meteor.users.update(userId, {$set: {isAdmin: admin}});
|
||||
};
|
||||
|
|
|
@ -243,6 +243,11 @@ commentEditClientCallbacks = [];
|
|||
commentEditMethodCallbacks = []; // not used yet
|
||||
commentAfterEditMethodCallbacks = []; // not used yet
|
||||
|
||||
userEditRenderedCallbacks = [];
|
||||
userEditClientCallbacks = [];
|
||||
userCreatedCallbacks = [];
|
||||
userProfileCompleteChecks = [];
|
||||
|
||||
// ------------------------------------- User Profiles -------------------------------- //
|
||||
|
||||
userProfileDisplay = [
|
||||
|
@ -275,14 +280,11 @@ userProfileEdit = [
|
|||
}
|
||||
]
|
||||
|
||||
userEditRenderedCallbacks = [];
|
||||
userEditClientCallbacks = [];
|
||||
|
||||
userProfileCompleteChecks = [
|
||||
userProfileCompleteChecks.push(
|
||||
function(user) {
|
||||
return !!getEmail(user) && !!getUserName(user);
|
||||
}
|
||||
];
|
||||
);
|
||||
|
||||
// ------------------------------ Dynamic Templates ------------------------------ //
|
||||
|
||||
|
|
|
@ -57,6 +57,7 @@ Package.onUse(function (api) {
|
|||
'userProfileCompleteChecks',
|
||||
'userProfileDisplay',
|
||||
'userProfileEdit',
|
||||
'userCreatedCallbacks',
|
||||
|
||||
'getTemplate',
|
||||
'templates',
|
||||
|
|
|
@ -92,4 +92,21 @@ Meteor.methods({
|
|||
var email = buildAndSendEmail (getSetting('defaultEmail'), 'Telescope email test', 'emailTest', {date: new Date()});
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
function adminUserCreationNotification (user) {
|
||||
// send notifications to admins
|
||||
var admins = adminUsers();
|
||||
admins.forEach(function(admin){
|
||||
if(getUserSetting('notifications.users', false, admin)){
|
||||
var emailProperties = {
|
||||
profileUrl: getProfileUrl(user),
|
||||
username: getUserName(user)
|
||||
};
|
||||
var html = getEmailTemplate('emailNewUser')(emailProperties);
|
||||
sendEmail(getEmail(admin), 'New user account: '+getUserName(user), buildEmailTemplate(html));
|
||||
}
|
||||
});
|
||||
return user;
|
||||
}
|
||||
userCreatedCallbacks.push(adminUserCreationNotification);
|
|
@ -31,4 +31,34 @@ Invites.deny({
|
|||
userProfileEdit.push({
|
||||
template: 'userInvites',
|
||||
order: 2
|
||||
});
|
||||
});
|
||||
|
||||
function setStartingInvites (user) {
|
||||
// give new users a few invites (default to 3)
|
||||
user.inviteCount = getSetting('startInvitesCount', 3);
|
||||
return user;
|
||||
}
|
||||
userCreatedCallbacks.push(setStartingInvites);
|
||||
|
||||
function checkIfInvited (user) {
|
||||
// if the new user has been invited
|
||||
// set her status accordingly and update invitation info
|
||||
if(invitesEnabled() && getEmail(user)){
|
||||
var invite = Invites.findOne({ invitedUserEmail : getEmail(user) });
|
||||
if(invite){
|
||||
var invitedBy = Meteor.users.findOne({ _id : invite.invitingUserId });
|
||||
|
||||
user = _.extend(user, {
|
||||
isInvited: true,
|
||||
invitedBy: invitedBy._id,
|
||||
invitedByName: getDisplayName(invitedBy)
|
||||
});
|
||||
|
||||
Invites.update(invite._id, {$set : {
|
||||
accepted : true
|
||||
}});
|
||||
}
|
||||
}
|
||||
return user;
|
||||
}
|
||||
userCreatedCallbacks.push(checkIfInvited);
|
||||
|
|
|
@ -134,6 +134,19 @@ var newsletterFrequency = {
|
|||
}
|
||||
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 {
|
||||
|
@ -149,4 +162,15 @@ viewParameters.campaign = function (terms) {
|
|||
|
||||
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);
|
||||
|
|
|
@ -78,12 +78,15 @@ scheduleCampaign = function (campaign, isTest) {
|
|||
}
|
||||
|
||||
addToMailChimpList = function(userOrEmail, confirm, done){
|
||||
|
||||
var user, email;
|
||||
|
||||
if(typeof userOrEmail == "string"){
|
||||
var confirm = (typeof confirm === 'undefined') ? false : confirm // default to no confirmation
|
||||
|
||||
if (typeof userOrEmail == "string") {
|
||||
user = null;
|
||||
email = userOrEmail;
|
||||
}else if(typeof userOrEmail == "object"){
|
||||
} else if (typeof userOrEmail == "object") {
|
||||
user = userOrEmail;
|
||||
email = getEmail(user);
|
||||
if (!email)
|
||||
|
@ -100,16 +103,16 @@ addToMailChimpList = function(userOrEmail, confirm, done){
|
|||
|
||||
try {
|
||||
var api = new MailChimp();
|
||||
} catch ( error ) {
|
||||
} catch (error) {
|
||||
console.log( error.message );
|
||||
}
|
||||
|
||||
api.call( 'lists', 'subscribe', {
|
||||
api.call('lists', 'subscribe', {
|
||||
id: MailChimpOptions.listId,
|
||||
email: {"email": email},
|
||||
double_optin: confirm
|
||||
}, Meteor.bindEnvironment(function ( error, result ) {
|
||||
if ( error ) {
|
||||
if (error) {
|
||||
console.log( error.message );
|
||||
done(error, null);
|
||||
} else {
|
||||
|
|
|
@ -63,4 +63,17 @@ var emailNotifications = {
|
|||
}
|
||||
}
|
||||
}
|
||||
addToSettingsSchema.push(emailNotifications);
|
||||
addToSettingsSchema.push(emailNotifications);
|
||||
|
||||
|
||||
function setNotificationDefaults (user) {
|
||||
// set notifications default preferences
|
||||
user.profile.notifications = {
|
||||
users: false,
|
||||
posts: false,
|
||||
comments: true,
|
||||
replies: true
|
||||
};
|
||||
return user;
|
||||
}
|
||||
userCreatedCallbacks.push(setNotificationDefaults);
|
|
@ -1,4 +1,7 @@
|
|||
Accounts.onCreateUser(function(options, user){
|
||||
|
||||
// ------------------------------ Properties ------------------------------ //
|
||||
|
||||
var userProperties = {
|
||||
profile: options.profile || {},
|
||||
karma: 0,
|
||||
|
@ -15,78 +18,40 @@ Accounts.onCreateUser(function(options, user){
|
|||
};
|
||||
user = _.extend(user, userProperties);
|
||||
|
||||
// set email on profile
|
||||
if (options.email)
|
||||
user.profile.email = options.email;
|
||||
|
||||
// if email is set, use it to generate email hash
|
||||
if (getEmail(user))
|
||||
user.email_hash = getEmailHash(user);
|
||||
|
||||
// set username on profile
|
||||
if (!user.profile.name)
|
||||
user.profile.name = user.username;
|
||||
|
||||
// set notifications default preferences
|
||||
user.profile.notifications = {
|
||||
users: false,
|
||||
posts: false,
|
||||
comments: true,
|
||||
replies: true
|
||||
};
|
||||
|
||||
// create slug from username
|
||||
user.slug = slugify(getUserName(user));
|
||||
|
||||
// if this is the first user ever, make them an admin
|
||||
if (!Meteor.users.find().count() ) {
|
||||
setAdmin(user, true);
|
||||
} else {
|
||||
setAdmin(user, false);
|
||||
}
|
||||
user.isAdmin = Meteor.users.find().count() === 0 ? true : false;
|
||||
|
||||
// give new users a few invites (default to 3)
|
||||
user.inviteCount = getSetting('startInvitesCount', 3);
|
||||
// ------------------------------ Callbacks ------------------------------ //
|
||||
|
||||
// run all post submit client callbacks on properties object successively
|
||||
clog('// Start userCreatedCallbacks')
|
||||
user = userCreatedCallbacks.reduce(function(result, currentFunction) {
|
||||
clog('// Running '+currentFunction.name+'…')
|
||||
return currentFunction(result);
|
||||
}, user);
|
||||
clog('// Finished userCreatedCallbacks')
|
||||
clog('// User object:')
|
||||
clog(user)
|
||||
|
||||
// ------------------------------ Analytics ------------------------------ //
|
||||
|
||||
trackEvent('new user', {username: user.username, email: user.profile.email});
|
||||
|
||||
// if user has already filled in their email, add them to MailChimp list
|
||||
// if(user.profile.email)
|
||||
// addToMailChimpList(user, false, function(error, result){
|
||||
// if(error){
|
||||
// console.log(error)
|
||||
// }
|
||||
// });
|
||||
|
||||
// if the new user has been invited
|
||||
// set her status accordingly and update invitation info
|
||||
if(invitesEnabled() && user.profile.email){
|
||||
var invite = Invites.findOne({ invitedUserEmail : user.profile.email });
|
||||
if(invite){
|
||||
var invitedBy = Meteor.users.findOne({ _id : invite.invitingUserId });
|
||||
|
||||
user = _.extend(user, {
|
||||
isInvited: true,
|
||||
invitedBy: invitedBy._id,
|
||||
invitedByName: getDisplayName(invitedBy)
|
||||
});
|
||||
|
||||
Invites.update(invite._id, {$set : {
|
||||
accepted : true
|
||||
}});
|
||||
}
|
||||
}
|
||||
|
||||
// send notifications to admins
|
||||
var admins = adminUsers();
|
||||
admins.forEach(function(admin){
|
||||
if(getUserSetting('notifications.users', false, admin)){
|
||||
var emailProperties = {
|
||||
profileUrl: getProfileUrl(user),
|
||||
username: getUserName(user)
|
||||
};
|
||||
var html = getEmailTemplate('emailNewUser')(emailProperties);
|
||||
sendEmail(getEmail(admin), 'New user account: '+getUserName(user), buildEmailTemplate(html));
|
||||
}
|
||||
});
|
||||
|
||||
return user;
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue