mirror of
https://github.com/vale981/Vulcan
synced 2025-03-06 01:51:40 -05:00
cleanup while getting familiar with the codebase
This commit is contained in:
parent
8250f52450
commit
6fc6b9eb78
30 changed files with 67 additions and 67 deletions
|
@ -20,7 +20,7 @@ SharrreOptions={
|
|||
share: {
|
||||
googlePlus: true,
|
||||
// facebook: true,
|
||||
twitter: true,
|
||||
twitter: true
|
||||
},
|
||||
buttons: {
|
||||
googlePlus: {size: 'tall', annotation:'bubble'},
|
||||
|
|
|
@ -10,7 +10,7 @@ Template[getTemplate('comment_edit')].rendered = function(){
|
|||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Template[getTemplate('comment_edit')].events({
|
||||
'click input[type=submit]': function(e, instance){
|
||||
|
@ -38,7 +38,7 @@ Template[getTemplate('comment_edit')].events({
|
|||
|
||||
if(confirm(i18n.t("Are you sure?"))){
|
||||
Meteor.call('removeComment', comment._id);
|
||||
Router.go("/posts/"+comment.postId)
|
||||
Router.go("/posts/"+comment.postId);
|
||||
throwError("Your comment has been deleted.");
|
||||
// Router.go("/comments/deleted");
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ Template[getTemplate('comment_form')].helpers({
|
|||
canComment: function(){
|
||||
return canComment(Meteor.user());
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
Template[getTemplate('comment_form')].rendered = function(){
|
||||
if(Meteor.user() && !this.editor){
|
||||
|
@ -11,7 +11,7 @@ Template[getTemplate('comment_form')].rendered = function(){
|
|||
$(window.editor).closest('form').find('input[type="submit"]').click();
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Template[getTemplate('comment_form')].events({
|
||||
'submit form': function(e, instance){
|
||||
|
|
|
@ -60,7 +60,7 @@ Template[getTemplate('comment_item')].created = function() {
|
|||
// if comments are supposed to be queued, then queue this comment on create
|
||||
this.isQueued = window.queueComments;
|
||||
window.openedComments = [];
|
||||
}
|
||||
};
|
||||
|
||||
Template[getTemplate('comment_item')].helpers({
|
||||
comment_item: function () {
|
||||
|
@ -138,7 +138,7 @@ Template[getTemplate('comment_item')].rendered=function(){
|
|||
// // TODO: take the user back to their previous scroll position
|
||||
// }
|
||||
// }
|
||||
}
|
||||
};
|
||||
|
||||
Template.comment_item.events({
|
||||
'click .queue-comment': function(e){
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
Template[getTemplate('comment_list')].created = function(){
|
||||
postObject = this.data;
|
||||
}
|
||||
};
|
||||
|
||||
Template[getTemplate('comment_list')].helpers({
|
||||
comment_item: function () {
|
||||
|
@ -16,4 +16,4 @@ Template[getTemplate('comment_list')].helpers({
|
|||
Template[getTemplate('comment_list')].rendered = function(){
|
||||
// once all comments have been rendered, activate comment queuing for future real-time comments
|
||||
window.queueComments = true;
|
||||
}
|
||||
};
|
|
@ -1,10 +1,10 @@
|
|||
Template[getTemplate('error_item')].helpers({
|
||||
|
||||
})
|
||||
});
|
||||
|
||||
Template[getTemplate('error_item')].created = function(){
|
||||
var error_id=this.data._id;
|
||||
Meteor.setTimeout(function(){
|
||||
Errors.update(error_id, {$set: {seen:true}});
|
||||
}, 100);
|
||||
}
|
||||
};
|
|
@ -30,11 +30,11 @@ Template[getTemplate('layout')].helpers({
|
|||
|
||||
Template[getTemplate('layout')].created = function(){
|
||||
Session.set('currentScroll', null);
|
||||
}
|
||||
};
|
||||
|
||||
Template[getTemplate('layout')].rendered = function(){
|
||||
if(currentScroll=Session.get('currentScroll')){
|
||||
$('body').scrollTop(currentScroll);
|
||||
Session.set('currentScroll', null);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -8,7 +8,7 @@ Template[getTemplate('unsubscribe')].created = function(){
|
|||
}
|
||||
});
|
||||
trackEvent('notificationsUnsubcribe', {hash: hash});
|
||||
}
|
||||
};
|
||||
|
||||
Template[getTemplate('unsubscribe')].helpers({
|
||||
unsubscribed : function(){
|
||||
|
|
|
@ -2,4 +2,4 @@ Template[getTemplate('loading')].helpers({
|
|||
log: function () {
|
||||
console.log('loading…')
|
||||
}
|
||||
})
|
||||
});
|
|
@ -20,14 +20,14 @@ Template[getTemplate('mobile_nav')].helpers({
|
|||
});
|
||||
|
||||
Template[getTemplate('mobile_nav')].events({
|
||||
'click .dropdown-sub-level':function(event){
|
||||
'click .dropdown-sub-level': function () {
|
||||
$('body').toggleClass('mobile-nav-open');
|
||||
}
|
||||
});
|
||||
|
||||
Template[getTemplate('mobile_nav')].rendered = function () {
|
||||
$('.mobile-nav .dropdown-menu').hide();
|
||||
}
|
||||
};
|
||||
|
||||
Template[getTemplate('mobile_nav')].events({
|
||||
'click .dropdown-top-level': function (e) {
|
||||
|
|
|
@ -62,7 +62,7 @@ Template[getTemplate('nav')].events({
|
|||
e.preventDefault();
|
||||
Router.go('/account');
|
||||
},
|
||||
'click #login-name-link': function(e){
|
||||
'click #login-name-link': function(){
|
||||
if(Meteor.user() && !$('account-link').exists()){
|
||||
$('#login-buttons-logout').before('<a href="/users/'+Meteor.user().slug+'" class="account-link button">View Profile</a>');
|
||||
$('#login-buttons-logout').before('<a href="/account" class="account-link button">Edit Account</a>');
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
var filteredModules = function (group) {
|
||||
// return the modules whose positions start with group
|
||||
return _.filter(postModules, function(module){return module.position.indexOf(group) == 0});
|
||||
}
|
||||
};
|
||||
|
||||
var post = {};
|
||||
|
||||
|
|
|
@ -11,10 +11,10 @@ Template[getTemplate('post_page')].helpers({
|
|||
comment_list: function () {
|
||||
return getTemplate('comment_list');
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
Template[getTemplate('post_page')].rendered = function(){
|
||||
$('body').scrollTop(0);
|
||||
if(this.data) // XXX
|
||||
document.title = $(".post-title").text();
|
||||
}
|
||||
};
|
||||
|
|
|
@ -32,7 +32,7 @@ Template[getTemplate('user_edit')].helpers({
|
|||
hasPassword: function () {
|
||||
return hasPassword(Meteor.user());
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
Template[getTemplate('user_edit')].events({
|
||||
'submit #account-form': function(e){
|
||||
|
|
|
@ -66,4 +66,4 @@ Template[getTemplate('user_item')].events({
|
|||
if(confirm(i18n.t("Are you sure you want to delete ")+getDisplayName(instance.data)+"?"))
|
||||
Meteor.users.remove(instance.data._id);
|
||||
}
|
||||
})
|
||||
});
|
|
@ -3,7 +3,7 @@ Template[getTemplate('user_profile')].created = function () {
|
|||
Session.set('upvotedPostsShown', 5);
|
||||
Session.set('downvotedPostsShown', 5);
|
||||
Session.set('commentsShown', 5);
|
||||
}
|
||||
};
|
||||
|
||||
Template[getTemplate('user_profile')].helpers({
|
||||
avatarUrl: function() {
|
||||
|
|
|
@ -17,7 +17,7 @@ Comments = new Meteor.Collection("comments", {
|
|||
optional: true
|
||||
},
|
||||
body: {
|
||||
type: String,
|
||||
type: String
|
||||
},
|
||||
htmlBody: {
|
||||
type: String,
|
||||
|
@ -102,9 +102,9 @@ Comments.before.update(function (userId, doc, fieldNames, modifier, options) {
|
|||
Meteor.methods({
|
||||
comment: function(postId, parentCommentId, text){
|
||||
var user = Meteor.user(),
|
||||
post=Posts.findOne(postId),
|
||||
postUser=Meteor.users.findOne(post.userId),
|
||||
timeSinceLastComment=timeSinceLast(user, Comments),
|
||||
post = Posts.findOne(postId),
|
||||
postUser = Meteor.users.findOne(post.userId),
|
||||
timeSinceLastComment = timeSinceLast(user, Comments),
|
||||
commentInterval = Math.abs(parseInt(getSetting('commentInterval',15))),
|
||||
now = new Date();
|
||||
|
||||
|
@ -157,13 +157,13 @@ Meteor.methods({
|
|||
var notificationProperties = {
|
||||
comment: _.pick(comment, '_id', 'userId', 'author', 'body'),
|
||||
post: _.pick(post, '_id', 'title', 'url')
|
||||
}
|
||||
};
|
||||
|
||||
if(!this.isSimulation){
|
||||
if(parentCommentId){
|
||||
// child comment
|
||||
var parentComment=Comments.findOne(parentCommentId);
|
||||
var parentUser=Meteor.users.findOne(parentComment.userId);
|
||||
var parentComment = Comments.findOne(parentCommentId);
|
||||
var parentUser = Meteor.users.findOne(parentComment.userId);
|
||||
|
||||
notificationProperties.parentComment = _.pick(parentComment, '_id', 'userId', 'author');
|
||||
|
||||
|
@ -187,7 +187,7 @@ Meteor.methods({
|
|||
return comment;
|
||||
},
|
||||
removeComment: function(commentId){
|
||||
var comment=Comments.findOne(commentId);
|
||||
var comment = Comments.findOne(commentId);
|
||||
if(canEdit(Meteor.user(), comment)){
|
||||
// decrement post comment count and remove user ID from post
|
||||
Posts.update(comment.postId, {
|
||||
|
|
|
@ -27,5 +27,5 @@ Invites = new Meteor.Collection("invites", {
|
|||
Invites.deny({
|
||||
insert: function(){ return true; },
|
||||
update: function(){ return true; },
|
||||
remove: function(){ return true; },
|
||||
remove: function(){ return true; }
|
||||
});
|
|
@ -38,7 +38,7 @@ createNotification = function(event, properties, userToNotify) {
|
|||
properties: properties,
|
||||
read: false
|
||||
};
|
||||
var newNotificationId=Notifications.insert(notification);
|
||||
var newNotificationId = Notifications.insert(notification);
|
||||
|
||||
// 2. Send notification by email (if on server)
|
||||
if(Meteor.isServer && getUserSetting('notifications.replies', false, userToNotify)){
|
||||
|
@ -56,14 +56,14 @@ buildSiteNotification = function (notification) {
|
|||
post = notification.properties.post,
|
||||
userToNotify = Meteor.users.findOne(notification.userId),
|
||||
template,
|
||||
html
|
||||
html;
|
||||
|
||||
var properties = {
|
||||
profileUrl: getProfileUrlById(comment.userId),
|
||||
author: comment.author,
|
||||
postCommentUrl: getPostCommentUrl(post._id, comment._id),
|
||||
postTitle: post.title
|
||||
}
|
||||
};
|
||||
|
||||
switch(event){
|
||||
case 'newReply':
|
||||
|
|
|
@ -13,7 +13,7 @@ postSchemaObject = {
|
|||
},
|
||||
title: {
|
||||
type: String,
|
||||
label: "Title",
|
||||
label: "Title"
|
||||
},
|
||||
url: {
|
||||
type: String,
|
||||
|
@ -119,7 +119,7 @@ clickedPosts = [];
|
|||
|
||||
getPostProperties = function(post) {
|
||||
|
||||
var postAuthor = Meteor.users.findOne(post.userId)
|
||||
var postAuthor = Meteor.users.findOne(post.userId);
|
||||
var p = {
|
||||
postAuthorName : getDisplayName(postAuthor),
|
||||
postTitle : cleanUp(post.title),
|
||||
|
@ -136,7 +136,7 @@ getPostProperties = function(post) {
|
|||
p.htmlBody = post.htmlBody;
|
||||
|
||||
return p;
|
||||
}
|
||||
};
|
||||
|
||||
getPostPageUrl = function(post){
|
||||
return getSiteUrl()+'posts/'+post._id;
|
||||
|
@ -149,7 +149,7 @@ getPostEditUrl = function(id){
|
|||
// for a given post, return its link if it has one, or else its post page URL
|
||||
getPostLink = function (post) {
|
||||
return !!post.url ? getOutgoingUrl(post.url) : getPostPageUrl(post);
|
||||
}
|
||||
};
|
||||
|
||||
Posts.before.insert(function (userId, doc) {
|
||||
if(Meteor.isServer && !!doc.body)
|
||||
|
@ -222,8 +222,8 @@ Meteor.methods({
|
|||
commentsCount: 0,
|
||||
baseScore: 0,
|
||||
score: 0,
|
||||
inactive: false,
|
||||
}
|
||||
inactive: false
|
||||
};
|
||||
|
||||
// UserId
|
||||
if(isAdmin(Meteor.user()) && !!post.userId){ // only let admins post as other users
|
||||
|
@ -288,7 +288,7 @@ Meteor.methods({
|
|||
var postedAt = new Date(); // default to current date and time
|
||||
|
||||
if(isAdmin(Meteor.user()) && typeof customPostedAt !== 'undefined') // if user is admin and a custom datetime has been set
|
||||
var postedAt = customPostedAt;
|
||||
postedAt = customPostedAt;
|
||||
|
||||
Posts.update(post._id, {$set: {postedAt: postedAt}});
|
||||
},
|
||||
|
@ -323,7 +323,7 @@ Meteor.methods({
|
|||
// if(!this.isSimulation) {
|
||||
// Comments.remove({post: postId});
|
||||
// }
|
||||
// NOTE: actually, keep comments afer all
|
||||
// NOTE: actually, keep comments after all
|
||||
|
||||
// decrement post count
|
||||
var post = Posts.findOne({_id: postId});
|
||||
|
|
|
@ -62,7 +62,7 @@ settingsSchemaObject = {
|
|||
label: view.label
|
||||
}
|
||||
})
|
||||
},
|
||||
}
|
||||
},
|
||||
postInterval: {
|
||||
type: Number,
|
||||
|
|
|
@ -76,7 +76,7 @@ analyticsRequest = function() {
|
|||
// Google Analytics
|
||||
if (typeof window.ga !== 'undefined'){
|
||||
ga('send', 'pageview', {
|
||||
'page': window.location.pathname,
|
||||
'page': window.location.pathname
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
cl = function(something){
|
||||
console.log(l);
|
||||
}
|
||||
};
|
||||
|
||||
getCurrentTemplate = function() {
|
||||
return Router.current().lookupTemplate();
|
||||
|
@ -111,7 +111,7 @@ sanitize = function (s) {
|
|||
// console.log(s)
|
||||
}
|
||||
return s;
|
||||
}
|
||||
};
|
||||
stripHTML = function(s){
|
||||
return s.replace(/<(?:.|\n)*?>/gm, '');
|
||||
};
|
||||
|
|
12
lib/users.js
12
lib/users.js
|
@ -22,7 +22,7 @@ getUserName = function(user){
|
|||
return user.services.twitter.screenName
|
||||
}
|
||||
catch (error){
|
||||
console.log(error)
|
||||
console.log(error);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
@ -143,17 +143,17 @@ setUserSetting = function (setting, value, userArgument) {
|
|||
}
|
||||
|
||||
if(!user)
|
||||
throw new Meteor.Error(500, 'User not defined')
|
||||
throw new Meteor.Error(500, 'User not defined');
|
||||
|
||||
console.log('Setting user setting "'+setting+'" to "'+value+'" for '+getUserName(user))
|
||||
console.log('Setting user setting "'+setting+'" to "'+value+'" for '+getUserName(user));
|
||||
var find = {_id: user._id};
|
||||
var field = {};
|
||||
field['profile.'+setting] = value;
|
||||
var options = {$set: field};
|
||||
console.log(find)
|
||||
console.log(options)
|
||||
console.log(find);
|
||||
console.log(options);
|
||||
var result = Meteor.users.update(find, options, {validate: false});
|
||||
}
|
||||
};
|
||||
|
||||
getProperty = function(object, property){
|
||||
// recursive function to get nested properties
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
var removeVote = function (userId, itemId, collection, upOrDown) {
|
||||
var field = 'votes.' + upOrDown + 'voted' + collection;
|
||||
var remove = {};
|
||||
remove[field] = {itemId: itemId}
|
||||
remove[field] = {itemId: itemId};
|
||||
Meteor.users.update({_id: userId}, {
|
||||
$pull: remove
|
||||
});
|
||||
|
|
|
@ -68,7 +68,7 @@ Meteor.methods({
|
|||
actionLink : user ? getSigninUrl() : getSignupUrl(),
|
||||
invitedBy : getDisplayName(currentUser),
|
||||
profileUrl : getProfileUrl(currentUser)
|
||||
}
|
||||
};
|
||||
|
||||
Meteor.setTimeout(function () {
|
||||
buildAndSendEmail(userEmail, emailSubject, getTemplate('emailInvite'), emailProperties);
|
||||
|
|
|
@ -18,7 +18,7 @@ var runMigration = function (migrationName) {
|
|||
if (migration){
|
||||
if(typeof migration.finishedAt === 'undefined'){
|
||||
// if migration exists but hasn't finished, remove it and start fresh
|
||||
console.log('!!! Found incomplete migration "'+migrationName+'", removing and running again.')
|
||||
console.log('!!! Found incomplete migration "'+migrationName+'", removing and running again.');
|
||||
Migrations.remove({name: migrationName});
|
||||
}else{
|
||||
// do nothing
|
||||
|
@ -39,7 +39,7 @@ var runMigration = function (migrationName) {
|
|||
console.log("//----------------------------------------------------------------------//");
|
||||
console.log("//------------// Ending "+migrationName+" Migration //-----------//");
|
||||
console.log("//----------------------------------------------------------------------//");
|
||||
}
|
||||
};
|
||||
|
||||
var migrationsList = {
|
||||
updatePostStatus: function () {
|
||||
|
@ -119,7 +119,7 @@ var migrationsList = {
|
|||
i++;
|
||||
console.log('> Updating user '+user._id+' ('+user.username+')');
|
||||
|
||||
var properties = {}
|
||||
var properties = {};
|
||||
// update user slug
|
||||
if(getUserName(user))
|
||||
properties.slug = slugify(getUserName(user));
|
||||
|
@ -219,7 +219,7 @@ var migrationsList = {
|
|||
console.log("Posts: "+post.title);
|
||||
var createdAt = new Date(post.createdAt);
|
||||
var submitted = new Date(post.submitted);
|
||||
console.log(createdAt)
|
||||
console.log(createdAt);
|
||||
Posts.update(post._id, { $set: { 'createdAt': createdAt, submitted: submitted}}, {multi: true, validate: false});
|
||||
console.log("---------------------");
|
||||
}
|
||||
|
@ -365,4 +365,4 @@ var migrationsList = {
|
|||
});
|
||||
return i;
|
||||
}
|
||||
}
|
||||
};
|
|
@ -40,7 +40,7 @@ buildEmailNotification = function (notification) {
|
|||
subject: subject,
|
||||
html: html
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
newPostNotification = function(post, excludedIDs){
|
||||
var excludedIDs = typeof excludedIDs == 'undefined' ? [] : excludedIDs;
|
||||
|
@ -54,7 +54,7 @@ newPostNotification = function(post, excludedIDs){
|
|||
if(excludedIDs.indexOf(user._id) == -1)
|
||||
sendEmail(getEmail(user), subject, html);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Meteor.methods({
|
||||
unsubscribeUser : function(hash){
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
|
||||
Meteor.startup(function () {
|
||||
var scoreInterval = getSetting("scoreUpdateInterval") || 30;
|
||||
if(scoreInterval>0){
|
||||
if (scoreInterval > 0) {
|
||||
|
||||
// active items get updated every N seconds
|
||||
intervalId=Meteor.setInterval(function () {
|
||||
intervalId = Meteor.setInterval(function () {
|
||||
var updatedPosts = 0;
|
||||
var updatedComments = 0;
|
||||
// console.log('tick ('+scoreInterval+')');
|
||||
|
@ -19,7 +19,7 @@ Meteor.startup(function () {
|
|||
}, scoreInterval * 1000);
|
||||
|
||||
// inactive items get updated every hour
|
||||
inactiveIntervalId=Meteor.setInterval(function () {
|
||||
inactiveIntervalId = Meteor.setInterval(function () {
|
||||
var updatedPosts = 0;
|
||||
var updatedComments = 0;
|
||||
Posts.find({'inactive': true}).forEach(function (post) {
|
||||
|
|
|
@ -79,7 +79,7 @@ Accounts.onCreateUser(function(options, user){
|
|||
var emailProperties = {
|
||||
profileUrl: getProfileUrl(user),
|
||||
username: getUserName(user)
|
||||
}
|
||||
};
|
||||
var html = getEmailTemplate('emailNewUser')(emailProperties);
|
||||
sendEmail(getEmail(admin), 'New user account: '+getUserName(user), buildEmailTemplate(html));
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue