mirror of
https://github.com/vale981/Vulcan
synced 2025-03-08 19:11:38 -05:00
Merge branch 'master' of github.com:christianbundy/Telescope into christianbundy-master
This commit is contained in:
commit
f57c6ab064
31 changed files with 214 additions and 214 deletions
|
@ -3,7 +3,7 @@
|
|||
Handlebars.registerHelper('eachWithRank', function(items, options) {
|
||||
// not used, forces multiple renders
|
||||
// note: cannot use this because it would delete and recreate all nodes
|
||||
items.rewind()
|
||||
items.rewind();
|
||||
var out = '';
|
||||
items.forEach(function(item, i){
|
||||
var key = 'Branch-' + i;
|
||||
|
|
|
@ -61,7 +61,7 @@
|
|||
* image url (or null if the user cancelled). If this hook returns false, the default dialog will be used.
|
||||
*/
|
||||
|
||||
this.getConverter = function () { return markdownConverter; }
|
||||
this.getConverter = function () { return markdownConverter; };
|
||||
|
||||
var that = this,
|
||||
panels;
|
||||
|
@ -85,7 +85,7 @@
|
|||
undoManager.setCommandMode();
|
||||
f();
|
||||
that.refreshPreview();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
uiManager = new UIManager(idPostfix, panels, undoManager, previewManager, commandManager, help);
|
||||
|
@ -96,7 +96,7 @@
|
|||
forceRefresh();
|
||||
};
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
// before: contains all the text in the input box BEFORE the selection.
|
||||
// after: contains all the text in the input box AFTER the selection.
|
||||
|
@ -157,8 +157,8 @@
|
|||
if (remove) {
|
||||
beforeReplacer = afterReplacer = "";
|
||||
} else {
|
||||
beforeReplacer = function (s) { that.before += s; return ""; }
|
||||
afterReplacer = function (s) { that.after = s + that.after; return ""; }
|
||||
beforeReplacer = function (s) { that.before += s; return ""; };
|
||||
afterReplacer = function (s) { that.after = s + that.after; return ""; };
|
||||
}
|
||||
|
||||
this.selection = this.selection.replace(/^(\s*)/, beforeReplacer).replace(/(\s*)$/, afterReplacer);
|
||||
|
@ -250,7 +250,7 @@
|
|||
this.buttonBar = doc.getElementById("wmd-button-bar" + postfix);
|
||||
this.preview = doc.getElementById("wmd-preview" + postfix);
|
||||
this.input = doc.getElementById("wmd-input" + postfix);
|
||||
};
|
||||
}
|
||||
|
||||
// Returns true if the DOM element is visible, false if it's hidden.
|
||||
// Checks if display is anything other than none.
|
||||
|
@ -262,7 +262,7 @@
|
|||
}
|
||||
else if (elem.currentStyle) {
|
||||
// IE
|
||||
return elem.currentStyle["display"] !== "none";
|
||||
return elem.currentStyle.display !== "none";
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -332,7 +332,7 @@
|
|||
pattern = pre + pattern + post;
|
||||
|
||||
return new re(pattern, flags);
|
||||
}
|
||||
};
|
||||
|
||||
// UNFINISHED
|
||||
// The assignment in the while loop makes jslint cranky.
|
||||
|
@ -650,7 +650,7 @@
|
|||
this.text = inputArea.value;
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
// Sets the selected text in the input box after we've performed an
|
||||
// operation.
|
||||
|
@ -767,7 +767,7 @@
|
|||
this.scrollTop = chunk.scrollTop;
|
||||
};
|
||||
this.init();
|
||||
};
|
||||
}
|
||||
|
||||
function PreviewManager(converter, panels, previewRefreshCallback) {
|
||||
|
||||
|
@ -902,11 +902,11 @@
|
|||
parent.appendChild(preview);
|
||||
else
|
||||
parent.insertBefore(preview, sibling);
|
||||
}
|
||||
};
|
||||
|
||||
var nonSuckyBrowserPreviewSet = function (text) {
|
||||
panels.preview.innerHTML = text;
|
||||
}
|
||||
};
|
||||
|
||||
var previewSetter;
|
||||
|
||||
|
@ -962,7 +962,7 @@
|
|||
};
|
||||
|
||||
init();
|
||||
};
|
||||
}
|
||||
|
||||
// Creates the background behind the hyperlink text entry box.
|
||||
// And download dialog
|
||||
|
@ -1321,7 +1321,7 @@
|
|||
if (button.execute) {
|
||||
button.execute(undoManager);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function setupButton(button, isEnabled) {
|
||||
|
||||
|
@ -1359,7 +1359,7 @@
|
|||
}
|
||||
doClick(this);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -1371,7 +1371,7 @@
|
|||
function bindCommand(method) {
|
||||
if (typeof method === "string")
|
||||
method = commandManager[method];
|
||||
return function () { method.apply(commandManager, arguments); }
|
||||
return function () { method.apply(commandManager, arguments); };
|
||||
}
|
||||
|
||||
function makeSpritedButtonRow() {
|
||||
|
@ -1409,7 +1409,7 @@
|
|||
spacer.id = "wmd-spacer" + num + postfix;
|
||||
buttonRow.appendChild(spacer);
|
||||
xPosition += 25;
|
||||
}
|
||||
};
|
||||
|
||||
buttons.bold = makeButton("wmd-bold-button", "Strong <strong> Ctrl+B", "0px", bindCommand("doBold"));
|
||||
buttons.italic = makeButton("wmd-italic-button", "Emphasis <em> Ctrl+I", "-20px", bindCommand("doItalic"));
|
||||
|
@ -1467,7 +1467,7 @@
|
|||
setupButton(buttons.undo, undoManager.canUndo());
|
||||
setupButton(buttons.redo, undoManager.canRedo());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
this.setUndoRedoButtonStates = setUndoRedoButtonStates;
|
||||
|
||||
|
@ -2154,7 +2154,7 @@
|
|||
chunk.startTag = "----------\n";
|
||||
chunk.selection = "";
|
||||
chunk.skipLines(2, 1, true);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
})();
|
|
@ -13,7 +13,7 @@
|
|||
converter.hooks.chain("postConversion", sanitizeHtml);
|
||||
converter.hooks.chain("postConversion", balanceTags);
|
||||
return converter;
|
||||
}
|
||||
};
|
||||
|
||||
function sanitizeHtml(html) {
|
||||
return html.replace(/<[^>]*>?/gi, sanitizeTag);
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
//https://github.com/bryanwoods/autolink-js
|
||||
(function(){var a,b=[].slice;a=function(){var j,i,d,f,e,c,g,h;c=1<=arguments.length?b.call(arguments,0):[];g=/(^|\s)(\b(https?):\/\/[\-A-Z0-9+&@#\/%?=~_|!:,.;]*[\-A-Z0-9+&@#\/%=~_|]\b)/ig;if(c.length>0){e=c[0];i=e.callback;if((i!=null)&&typeof i==="function"){j=i;delete e.callback}f="";for(d in e){h=e[d];f+=" "+d+"='"+h+"'"}return this.replace(g,function(l,o,k){var n,m;m=j&&j(k);n=m||("<a href='"+k+"'"+f+">"+k+"</a>");return""+o+n})}else{return this.replace(g,"$1<a href='$2'>$2</a>")}};String.prototype.autoLink=a}).call(this);
|
||||
(function(){var a,b=[].slice;a=function(){var j,i,d,f,e,c,g,h;c=1<=arguments.length?b.call(arguments,0):[];g=/(^|\s)(\b(https?):\/\/[\-A-Z0-9+&@#\/%?=~_|!:,.;]*[\-A-Z0-9+&@#\/%=~_|]\b)/ig;if(c.length>0){e=c[0];i=e.callback;if((i!=null)&&typeof i==="function"){j=i;delete e.callback;}f="";for(d in e){h=e[d];f+=" "+d+"='"+h+"'";}return this.replace(g,function(l,o,k){var n,m;m=j&&j(k);n=m||("<a href='"+k+"'"+f+">"+k+"</a>");return""+o+n;});}else{return this.replace(g,"$1<a href='$2'>$2</a>");}};String.prototype.autoLink=a;}).call(this);
|
||||
|
|
8
client/js/bootstrap-datepicker.js
vendored
8
client/js/bootstrap-datepicker.js
vendored
|
@ -171,7 +171,7 @@
|
|||
|
||||
fillMonths: function(){
|
||||
var html = '';
|
||||
var i = 0
|
||||
var i = 0;
|
||||
while (i < 12) {
|
||||
html += '<span class="month">'+DPGlobal.dates.monthsShort[i++]+'</span>';
|
||||
}
|
||||
|
@ -362,10 +362,10 @@
|
|||
monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
|
||||
},
|
||||
isLeapYear: function (year) {
|
||||
return (((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0))
|
||||
return (((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0));
|
||||
},
|
||||
getDaysInMonth: function (year, month) {
|
||||
return [31, (DPGlobal.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]
|
||||
return [31, (DPGlobal.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month];
|
||||
},
|
||||
parseFormat: function(format){
|
||||
var separator = format.match(/[.\/\-\s].*?/),
|
||||
|
@ -451,4 +451,4 @@
|
|||
'</div>'+
|
||||
'</div>';
|
||||
|
||||
}( window.jQuery )
|
||||
}( window.jQuery );
|
|
@ -9,7 +9,7 @@ Categories.allow({
|
|||
Meteor.methods({
|
||||
category: function(category){
|
||||
if (!Meteor.user() || !isAdmin(Meteor.user()))
|
||||
throw new Meteor.Error(i18n.t('You need to login and be an admin to add a new category.'))
|
||||
throw new Meteor.Error(i18n.t('You need to login and be an admin to add a new category.'));
|
||||
var categoryId=Categories.insert(category);
|
||||
return category.name;
|
||||
}
|
||||
|
|
|
@ -6,4 +6,4 @@ throwError = function(message, type){
|
|||
type = (typeof type === 'undefined') ? 'error': type;
|
||||
// Store errors in the 'Errors' local collection
|
||||
Errors.insert({message:message, type:type, seen: false, show:true});
|
||||
}
|
||||
};
|
||||
|
|
|
@ -23,7 +23,7 @@ getNotificationContents = function(notification, context){
|
|||
subject: 'Someone replied to your comment on "'+p.postHeadline+'"',
|
||||
text: p.commentAuthorName+' has replied to your comment on "'+p.postHeadline+'": '+getPostCommentUrl(p.postId, p.commentId),
|
||||
html: '<p><a href="'+getProfileUrlById(p.commentAuthorId)+'">'+p.commentAuthorName+'</a> has replied to your comment on "<a href="'+getPostCommentUrl(p.postId, p.commentId)+'" class="action-link">'+p.postHeadline+'</a>"</p>'
|
||||
}
|
||||
};
|
||||
if(context == 'email')
|
||||
n.html += '<p>'+p.commentExcerpt+'</p><a href="'+getPostCommentUrl(p.postId, p.commentId)+'" class="action-link">Read more</a>';
|
||||
break;
|
||||
|
@ -33,7 +33,7 @@ getNotificationContents = function(notification, context){
|
|||
subject: 'A new comment on your post "'+p.postHeadline+'"',
|
||||
text: 'You have a new comment by '+p.commentAuthorName+' on your post "'+p.postHeadline+'": '+getPostCommentUrl(p.postId, p.commentId),
|
||||
html: '<p><a href="'+getProfileUrlById(p.commentAuthorId)+'">'+p.commentAuthorName+'</a> left a new comment on your post "<a href="'+getPostCommentUrl(p.postId, p.commentId)+'" class="action-link">'+p.postHeadline+'</a>"</p>'
|
||||
}
|
||||
};
|
||||
if(context == 'email')
|
||||
n.html += '<p>'+p.commentExcerpt+'</p><a href="'+getPostCommentUrl(p.postId, p.commentId)+'" class="action-link">Read more</a>';
|
||||
break;
|
||||
|
@ -43,7 +43,7 @@ getNotificationContents = function(notification, context){
|
|||
subject: p.postAuthorName+' has created a new post: "'+p.postHeadline+'"',
|
||||
text: p.postAuthorName+' has created a new post: "'+p.postHeadline+'" '+getPostUrl(p.postId),
|
||||
html: '<a href="'+getProfileUrlById(p.postAuthorId)+'">'+p.postAuthorName+'</a> has created a new post: "<a href="'+getPostUrl(p.postId)+'" class="action-link">'+p.postHeadline+'</a>".'
|
||||
}
|
||||
};
|
||||
break;
|
||||
|
||||
case 'accountApproved':
|
||||
|
@ -51,7 +51,7 @@ getNotificationContents = function(notification, context){
|
|||
subject: 'Your account has been approved.',
|
||||
text: 'Welcome to '+getSetting('title')+'! Your account has just been approved.',
|
||||
html: 'Welcome to '+getSetting('title')+'!<br/> Your account has just been approved. <a href="'+Meteor.absoluteUrl()+'">Start posting.</a>'
|
||||
}
|
||||
};
|
||||
break;
|
||||
|
||||
case 'newUser':
|
||||
|
@ -59,7 +59,7 @@ getNotificationContents = function(notification, context){
|
|||
subject: 'New user: '+p.username,
|
||||
text: 'A new user account has been created: '+p.profileUrl,
|
||||
html: 'A new user account has been created: <a href="'+p.profileUrl+'">'+p.username+'</a>'
|
||||
}
|
||||
};
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -74,7 +74,7 @@ getNotificationContents = function(notification, context){
|
|||
}
|
||||
|
||||
return n;
|
||||
}
|
||||
};
|
||||
|
||||
Meteor.methods({
|
||||
markAllNotificationsAsRead: function() {
|
||||
|
|
|
@ -39,7 +39,7 @@ Meteor.methods({
|
|||
|
||||
// only let admins post as another user
|
||||
if(isAdmin(Meteor.user()))
|
||||
userId = post.userId || user._id
|
||||
userId = post.userId || user._id;
|
||||
|
||||
// check that user can post
|
||||
if (!user || !canPost(user))
|
||||
|
@ -105,7 +105,7 @@ Meteor.methods({
|
|||
postHeadline : headline,
|
||||
postId : postId
|
||||
}
|
||||
}
|
||||
};
|
||||
// call a server method because we do not have access to users' info on the client
|
||||
Meteor.call('newPostNotify', notification, function(error, result){
|
||||
//run asynchronously
|
||||
|
|
|
@ -67,7 +67,7 @@ else
|
|||
if (original === identity)
|
||||
this[hookname] = func;
|
||||
else
|
||||
this[hookname] = function (x) { return func(original(x)); }
|
||||
this[hookname] = function (x) { return func(original(x)); };
|
||||
},
|
||||
set: function (hookname, func) {
|
||||
if (!this[hookname])
|
||||
|
@ -251,8 +251,8 @@ else
|
|||
// "paragraphs" that are wrapped in non-block-level tags, such as anchors,
|
||||
// phrase emphasis, and spans. The list of tags we're looking for is
|
||||
// hard-coded:
|
||||
var block_tags_a = "p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del"
|
||||
var block_tags_b = "p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math"
|
||||
var block_tags_a = "p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del";
|
||||
var block_tags_b = "p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math";
|
||||
|
||||
// First, look for nested blocks, e.g.:
|
||||
// <div>
|
||||
|
@ -1137,7 +1137,7 @@ else
|
|||
else if (/\S/.test(str)) {
|
||||
str = _RunSpanGamut(str);
|
||||
str = str.replace(/^([ \t]*)/g, "<p>");
|
||||
str += "</p>"
|
||||
str += "</p>";
|
||||
grafsOut.push(str);
|
||||
}
|
||||
|
||||
|
@ -1206,7 +1206,7 @@ else
|
|||
|
||||
// autolink anything like <http://example.com>
|
||||
|
||||
var replacer = function (wholematch, m1) { return "<a href=\"" + m1 + "\">" + pluginHooks.plainLinkText(m1) + "</a>"; }
|
||||
var replacer = function (wholematch, m1) { return "<a href=\"" + m1 + "\">" + pluginHooks.plainLinkText(m1) + "</a>"; };
|
||||
text = text.replace(/<((https?|ftp):[^'">\s]+)>/gi, replacer);
|
||||
|
||||
// Email addresses: <address@domain.foo>
|
||||
|
@ -1257,7 +1257,7 @@ else
|
|||
text = text.replace(/^(\t|[ ]{1,4})/gm, "~0"); // attacklab: g_tab_width
|
||||
|
||||
// attacklab: clean up hack
|
||||
text = text.replace(/~0/g, "")
|
||||
text = text.replace(/~0/g, "");
|
||||
|
||||
return text;
|
||||
}
|
||||
|
@ -1299,7 +1299,7 @@ else
|
|||
return "%24";
|
||||
if (match == ":") {
|
||||
if (offset == len - 1 || /[0-9\/]/.test(url.charAt(offset + 1)))
|
||||
return ":"
|
||||
return ":";
|
||||
}
|
||||
return "%" + match.charCodeAt(0).toString(16);
|
||||
});
|
||||
|
|
|
@ -17,17 +17,17 @@ analyticsInit = _.once(function() {
|
|||
var c = b.split(".");
|
||||
2 == c.length && (a = a[c[0]], b = c[1]);
|
||||
a[b] = function () {
|
||||
a.push([b].concat(Array.prototype.slice.call(arguments, 0)))
|
||||
}
|
||||
a.push([b].concat(Array.prototype.slice.call(arguments, 0)));
|
||||
};
|
||||
}
|
||||
var g = a;
|
||||
"undefined" !== typeof f ? g = a[f] = [] : f = "mixpanel";
|
||||
g.people = g.people || [];
|
||||
h = "disable track track_pageview track_links track_forms register register_once unregister identify name_tag set_config people.identify people.set people.increment".split(" ");
|
||||
for (e = 0; e < h.length; e++) d(g, h[e]);
|
||||
a._i.push([b, c, f])
|
||||
a._i.push([b, c, f]);
|
||||
};
|
||||
a.__SV = 1.1
|
||||
a.__SV = 1.1;
|
||||
})(document, window.mixpanel || []);
|
||||
mixpanel.init(mixpanelId);
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ analyticsInit = _.once(function() {
|
|||
if (goSquaredId = getSetting("goSquaredId")) {
|
||||
window.GoSquared = {};
|
||||
GoSquared.acct = goSquaredId;
|
||||
window._gstc_lt = +new Date;
|
||||
window._gstc_lt = +new Date();
|
||||
var d = document, g = d.createElement("script");
|
||||
g.type = "text/javascript";
|
||||
g.src = "//d1l6p2sc9645hc.cloudfront.net/tracker.js";
|
||||
|
@ -110,4 +110,4 @@ analyticsRequest = function() {
|
|||
clicky.log(encodeURIComponent(window.location.pathname), getCurrentTemplate(), "pageview");
|
||||
}
|
||||
|
||||
}
|
||||
};
|
|
@ -22,35 +22,35 @@ deepExtend = function () {
|
|||
},
|
||||
jQuery = {
|
||||
isFunction: function (obj) {
|
||||
return jQuery.type(obj) === "function"
|
||||
return jQuery.type(obj) === "function";
|
||||
},
|
||||
isArray: Array.isArray ||
|
||||
function (obj) {
|
||||
return jQuery.type(obj) === "array"
|
||||
return jQuery.type(obj) === "array";
|
||||
},
|
||||
isWindow: function (obj) {
|
||||
return obj != null && obj == obj.window
|
||||
return obj != null && obj == obj.window;
|
||||
},
|
||||
isNumeric: function (obj) {
|
||||
return !isNaN(parseFloat(obj)) && isFinite(obj)
|
||||
return !isNaN(parseFloat(obj)) && isFinite(obj);
|
||||
},
|
||||
type: function (obj) {
|
||||
return obj == null ? String(obj) : class2type[toString.call(obj)] || "object"
|
||||
return obj == null ? String(obj) : class2type[toString.call(obj)] || "object";
|
||||
},
|
||||
isPlainObject: function (obj) {
|
||||
if (!obj || jQuery.type(obj) !== "object" || obj.nodeType) {
|
||||
return false
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
if (obj.constructor && !hasOwn.call(obj, "constructor") && !hasOwn.call(obj.constructor.prototype, "isPrototypeOf")) {
|
||||
return false
|
||||
return false;
|
||||
}
|
||||
} catch (e) {
|
||||
return false
|
||||
return false;
|
||||
}
|
||||
var key;
|
||||
for (key in obj) {}
|
||||
return key === undefined || hasOwn.call(obj, key)
|
||||
return key === undefined || hasOwn.call(obj, key);
|
||||
}
|
||||
};
|
||||
if (typeof target === "boolean") {
|
||||
|
@ -59,7 +59,7 @@ deepExtend = function () {
|
|||
i = 2;
|
||||
}
|
||||
if (typeof target !== "object" && !jQuery.isFunction(target)) {
|
||||
target = {}
|
||||
target = {};
|
||||
}
|
||||
if (length === i) {
|
||||
target = this;
|
||||
|
@ -71,12 +71,12 @@ deepExtend = function () {
|
|||
src = target[name];
|
||||
copy = options[name];
|
||||
if (target === copy) {
|
||||
continue
|
||||
continue;
|
||||
}
|
||||
if (deep && copy && (jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)))) {
|
||||
if (copyIsArray) {
|
||||
copyIsArray = false;
|
||||
clone = src && jQuery.isArray(src) ? src : []
|
||||
clone = src && jQuery.isArray(src) ? src : [];
|
||||
} else {
|
||||
clone = src && jQuery.isPlainObject(src) ? src : {};
|
||||
}
|
||||
|
@ -89,4 +89,4 @@ deepExtend = function () {
|
|||
}
|
||||
}
|
||||
return target;
|
||||
}
|
||||
};
|
|
@ -11,4 +11,4 @@ trackEvent = function(event, properties){
|
|||
GoSquared.DefaultTracker.TrackEvent(event, JSON.stringify(properties));
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
|
@ -9,7 +9,7 @@ Gravatar = {
|
|||
var hash = user.email_hash;
|
||||
var url = protocol + '://www.gravatar.com/avatar/' + hash;
|
||||
|
||||
var params = _.map(options, function(val, key) { return key + "=" + val}).join('&');
|
||||
var params = _.map(options, function(val, key) { return key + "=" + val;}).join('&');
|
||||
if (params !== '')
|
||||
url += '?' + params;
|
||||
|
||||
|
@ -21,4 +21,4 @@ Gravatar = {
|
|||
return 'http://graph.facebook.com/'+user.services.facebook.id+'/picture';//for the oauth-login avatar, diff for diff oauth, maybe it could be better
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
|
@ -4,34 +4,34 @@ getSetting = function(setting, defaultValue){
|
|||
return settings[setting];
|
||||
}
|
||||
return typeof defaultValue === 'undefined' ? '' : defaultValue;
|
||||
}
|
||||
};
|
||||
getCurrentTemplate = function() {
|
||||
return Router._currentController.template;
|
||||
}
|
||||
};
|
||||
getCurrentRoute = function() {
|
||||
return Router._currentController.path;
|
||||
}
|
||||
};
|
||||
clearSeenErrors = function(){
|
||||
Errors.update({seen:true}, {$set: {show:false}}, {multi:true});
|
||||
}
|
||||
};
|
||||
t=function(message){
|
||||
var d=new Date();
|
||||
console.log("### "+message+" rendered at "+d.getHours()+":"+d.getMinutes()+":"+d.getSeconds());
|
||||
}
|
||||
};
|
||||
nl2br= function(str) {
|
||||
var breakTag = '<br />';
|
||||
return (str + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1'+ breakTag +'$2');
|
||||
}
|
||||
};
|
||||
getAuthorName = function(item){
|
||||
// since we are not publishing the user collection except for admins, just display the normalized author field
|
||||
return item.author;
|
||||
}
|
||||
};
|
||||
scrollPageTo = function(selector){
|
||||
$('body').scrollTop($(selector).offset().top);
|
||||
}
|
||||
};
|
||||
getDigestURL = function(moment){
|
||||
return '/digest/'+moment.year()+'/'+(moment.month()+1)+'/'+moment.date()
|
||||
}
|
||||
return '/digest/'+moment.year()+'/'+(moment.month()+1)+'/'+moment.date();
|
||||
};
|
||||
getDateRange= function(pageNumber){
|
||||
var now = moment(new Date());
|
||||
var dayToDisplay=now.subtract('days', pageNumber-1);
|
||||
|
@ -41,7 +41,7 @@ getDateRange= function(pageNumber){
|
|||
// console.log("after: ", dayToDisplay.startOf('day').format("dddd, MMMM Do YYYY, h:mm:ss a"));
|
||||
// console.log("before: ", dayToDisplay.endOf('day').format("dddd, MMMM Do YYYY, h:mm:ss a"));
|
||||
return range;
|
||||
}
|
||||
};
|
||||
// getPostCategories = function(post){
|
||||
// var postCategories = _.map(post.categories, function(categoryId){
|
||||
// return Categories.findOne(categoryId);
|
||||
|
@ -53,23 +53,23 @@ getDateRange= function(pageNumber){
|
|||
// ---------------------------------- URL Helper Functions ----------------------------------- //
|
||||
goTo = function(url){
|
||||
Router.go(url);
|
||||
}
|
||||
};
|
||||
getPostUrl = function(id){
|
||||
return Meteor.absoluteUrl()+'posts/'+id;
|
||||
}
|
||||
};
|
||||
getPostEditUrl = function(id){
|
||||
return Meteor.absoluteUrl()+'posts/'+id+'/edit';
|
||||
}
|
||||
};
|
||||
getCommentUrl = function(id){
|
||||
return Meteor.absoluteUrl()+'comments/'+id;
|
||||
}
|
||||
};
|
||||
getPostCommentUrl = function(postId, commentId){
|
||||
// get link to a comment on a post page
|
||||
return Meteor.absoluteUrl()+'posts/'+postId+'/comment/'+commentId;
|
||||
}
|
||||
};
|
||||
getCategoryUrl = function(slug){
|
||||
return Meteor.absoluteUrl()+'category/'+slug;
|
||||
}
|
||||
};
|
||||
slugify = function(text) {
|
||||
if(text){
|
||||
text = text.replace(/[^-a-zA-Z0-9,&\s]+/ig, '');
|
||||
|
@ -78,38 +78,38 @@ slugify = function(text) {
|
|||
text = text.toLowerCase();
|
||||
}
|
||||
return text;
|
||||
}
|
||||
};
|
||||
getShortUrl = function(post){
|
||||
return post.shortUrl ? post.shortUrl : post.url;
|
||||
}
|
||||
};
|
||||
getDomain = function(url){
|
||||
urlObject = Npm.require('url');
|
||||
return urlObject.parse(url).hostname;
|
||||
}
|
||||
};
|
||||
invitesEnabled = function () {
|
||||
return getSetting("requireViewInvite") || getSetting("requirePostInvite");
|
||||
}
|
||||
};
|
||||
getOutgoingUrl = function(url){
|
||||
return Meteor.absoluteUrl() + 'out?url=' + encodeURIComponent(url);
|
||||
}
|
||||
};
|
||||
// ---------------------------------- String Helper Functions ----------------------------------- //
|
||||
cleanUp = function(s){
|
||||
return stripHTML(s);
|
||||
}
|
||||
};
|
||||
stripHTML = function(s){
|
||||
return s.replace(/<(?:.|\n)*?>/gm, '');
|
||||
}
|
||||
};
|
||||
stripMarkdown = function(s){
|
||||
var converter = new Markdown.Converter();
|
||||
var html_body = converter.makeHtml(s);
|
||||
return stripHTML(html_body);
|
||||
}
|
||||
};
|
||||
trimWords = function(s, numWords) {
|
||||
expString = s.split(/\s+/,numWords);
|
||||
if(expString.length >= numWords)
|
||||
return expString.join(" ")+"…";
|
||||
return s;
|
||||
}
|
||||
};
|
||||
|
||||
// http://stackoverflow.com/questions/2631001/javascript-test-for-existence-of-nested-object-key
|
||||
checkNested = function(obj /*, level1, level2, ... levelN*/) {
|
||||
|
@ -123,4 +123,4 @@ checkNested = function(obj /*, level1, level2, ... levelN*/) {
|
|||
obj = obj[args[i]];
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
|
@ -187,4 +187,4 @@ i18n.translations.es = {
|
|||
"Please log in first": "Por favor, inicia sesión",
|
||||
"Sign In/Sign Up with Twitter": "Inicia sesión/Inscribete con Twitter",
|
||||
"Load more": "Cargar más"
|
||||
}
|
||||
};
|
||||
|
|
|
@ -15,7 +15,7 @@ getParameters = function (terms) {
|
|||
options: {
|
||||
limit: 10
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
switch (terms.view) {
|
||||
|
||||
|
@ -72,7 +72,7 @@ getParameters = function (terms) {
|
|||
}
|
||||
|
||||
// sort by _id to break ties
|
||||
deepExtend(true, parameters, {options: {sort: {_id: -1}}})
|
||||
deepExtend(true, parameters, {options: {sort: {_id: -1}}});
|
||||
|
||||
if(typeof terms.limit != 'undefined' && !!terms.limit)
|
||||
_.extend(parameters.options, {limit: parseInt(terms.limit)});
|
||||
|
@ -83,7 +83,7 @@ getParameters = function (terms) {
|
|||
// console.log(parameters)
|
||||
|
||||
return parameters;
|
||||
}
|
||||
};
|
||||
|
||||
getUsersParameters = function(filterBy, sortBy, limit) {
|
||||
var find = {},
|
||||
|
@ -121,4 +121,4 @@ getUsersParameters = function(filterBy, sortBy, limit) {
|
|||
find: find,
|
||||
options: {sort: sort, limit: limit}
|
||||
};
|
||||
}
|
||||
};
|
|
@ -24,7 +24,7 @@ canView = function(user){
|
|||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
canViewById = function(userId, returnError){
|
||||
// if an invite is required to view, run permission check, else return true
|
||||
if(getSetting('requireViewInvite', false)){
|
||||
|
@ -32,7 +32,7 @@ canViewById = function(userId, returnError){
|
|||
return userId ? canView(Meteor.users.findOne(userId), returnError) : false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
canPost = function(user, returnError){
|
||||
var user=(typeof user === 'undefined') ? Meteor.user() : user;
|
||||
|
||||
|
@ -51,32 +51,32 @@ canPost = function(user, returnError){
|
|||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
};
|
||||
canPostById = function(userId, returnError){
|
||||
var user = Meteor.users.findOne(userId);
|
||||
return canPost(user, returnError);
|
||||
}
|
||||
};
|
||||
canComment = function(user, returnError){
|
||||
return canPost(user, returnError);
|
||||
}
|
||||
};
|
||||
canCommentById = function(userId, returnError){
|
||||
var user = Meteor.users.findOne(userId);
|
||||
return canComment(user, returnError);
|
||||
}
|
||||
};
|
||||
canUpvote = function(user, collection, returnError){
|
||||
return canPost(user, returnError);
|
||||
}
|
||||
};
|
||||
canUpvoteById = function(userId, returnError){
|
||||
var user = Meteor.users.findOne(userId);
|
||||
return canUpvote(user, returnError);
|
||||
}
|
||||
};
|
||||
canDownvote = function(user, collection, returnError){
|
||||
return canPost(user, returnError);
|
||||
}
|
||||
};
|
||||
canDownvoteById = function(userId, returnError){
|
||||
var user = Meteor.users.findOne(userId);
|
||||
return canDownvote(user, returnError);
|
||||
}
|
||||
};
|
||||
canEdit = function(user, item, returnError){
|
||||
var user=(typeof user === 'undefined') ? Meteor.user() : user;
|
||||
|
||||
|
@ -89,14 +89,14 @@ canEdit = function(user, item, returnError){
|
|||
}else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
};
|
||||
canEditById = function(userId, item){
|
||||
var user = Meteor.users.findOne(userId);
|
||||
return canEdit(user, item);
|
||||
}
|
||||
};
|
||||
currentUserCanEdit = function(item) {
|
||||
return canEdit(Meteor.user(), item);
|
||||
}
|
||||
};
|
||||
canInvite = function(user){
|
||||
return isInvited(user) || isAdmin(user);
|
||||
}
|
||||
};
|
|
@ -128,7 +128,7 @@ var filters = {
|
|||
|
||||
isLoggedIn: function() {
|
||||
if (!(Meteor.loggingIn() || Meteor.user())) {
|
||||
throwError(i18n.t('Please Sign In First.'))
|
||||
throwError(i18n.t('Please Sign In First.'));
|
||||
this.render('signin');
|
||||
this.stop();
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ var filters = {
|
|||
isAdmin: function() {
|
||||
if(!this.ready()) return;
|
||||
if(!isAdmin()){
|
||||
throwError(i18n.t("Sorry, you have to be an admin to view this page."))
|
||||
throwError(i18n.t("Sorry, you have to be an admin to view this page."));
|
||||
this.render('no_rights');
|
||||
this.stop();
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ var filters = {
|
|||
canView: function() {
|
||||
if(!this.ready()) return;
|
||||
if(!canView()){
|
||||
console.log('cannot view')
|
||||
console.log('cannot view');
|
||||
this.render('no_rights');
|
||||
this.stop();
|
||||
}
|
||||
|
@ -162,7 +162,7 @@ var filters = {
|
|||
canPost: function () {
|
||||
if(!this.ready()) return;
|
||||
if(!canPost()){
|
||||
throwError(i18n.t("Sorry, you don't have permissions to add new items."))
|
||||
throwError(i18n.t("Sorry, you don't have permissions to add new items."));
|
||||
this.render('no_rights');
|
||||
this.stop();
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ var filters = {
|
|||
// Already subscribed to this post by route({waitOn: ...})
|
||||
var post = Posts.findOne(this.params._id);
|
||||
if(!currentUserCanEdit(post)){
|
||||
throwError(i18n.t("Sorry, you cannot edit this post."))
|
||||
throwError(i18n.t("Sorry, you cannot edit this post."));
|
||||
this.render('no_rights');
|
||||
this.stop();
|
||||
}
|
||||
|
@ -184,7 +184,7 @@ var filters = {
|
|||
// Already subscribed to this commit by CommentPageController
|
||||
var comment = Comments.findOne(this.params._id);
|
||||
if(!currentUserCanEdit(comment)){
|
||||
throwError(i18n.t("Sorry, you cannot edit this comment."))
|
||||
throwError(i18n.t("Sorry, you cannot edit this comment."));
|
||||
this.render('no_rights');
|
||||
this.stop();
|
||||
}
|
||||
|
@ -199,7 +199,7 @@ var filters = {
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
if(Meteor.isClient){
|
||||
|
||||
|
@ -253,7 +253,7 @@ if(Meteor.isClient){
|
|||
Router.after(filters.resetScroll, {except:['posts_top', 'posts_new', 'posts_best', 'posts_pending', 'posts_category', 'all-users']});
|
||||
Router.after( function () {
|
||||
analyticsInit(); // will only run once thanks to _.once()
|
||||
analyticsRequest() // log this request with mixpanel, etc
|
||||
analyticsRequest(); // log this request with mixpanel, etc
|
||||
});
|
||||
|
||||
// Unload Hooks
|
||||
|
@ -287,7 +287,7 @@ PostsListController = FastRender.RouteController.extend({
|
|||
return [
|
||||
Meteor.subscribe('postsList', this._terms),
|
||||
Meteor.subscribe('postsListUsers', this._terms)
|
||||
]
|
||||
];
|
||||
},
|
||||
data: function () {
|
||||
var parameters = getParameters(this._terms),
|
||||
|
@ -299,7 +299,7 @@ PostsListController = FastRender.RouteController.extend({
|
|||
return {
|
||||
postsList: posts,
|
||||
postsCount: postsCount
|
||||
}
|
||||
};
|
||||
},
|
||||
after: function() {
|
||||
var view = this.path == '/' ? 'top' : this.path.split('/')[1];
|
||||
|
@ -318,11 +318,11 @@ PostsDigestController = FastRender.RouteController.extend({
|
|||
view: 'digest',
|
||||
after: moment(currentDate).startOf('day').valueOf(),
|
||||
before: moment(currentDate).endOf('day').valueOf()
|
||||
}
|
||||
};
|
||||
return [
|
||||
Meteor.subscribe('postsList', terms),
|
||||
Meteor.subscribe('postsListUsers', terms)
|
||||
]
|
||||
];
|
||||
},
|
||||
data: function() {
|
||||
var currentDate = this.params.day ? new Date(this.params.year, this.params.month-1, this.params.day) : Session.get('today'),
|
||||
|
@ -335,7 +335,7 @@ PostsDigestController = FastRender.RouteController.extend({
|
|||
Session.set('currentDate', currentDate);
|
||||
return {
|
||||
posts: Posts.find(parameters.find, parameters.options)
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -368,12 +368,12 @@ CommentPageController = FastRender.RouteController.extend({
|
|||
Meteor.subscribe('singleComment', this.params._id),
|
||||
Meteor.subscribe('commentUser', this.params._id),
|
||||
Meteor.subscribe('commentPost', this.params._id)
|
||||
]
|
||||
];
|
||||
},
|
||||
data: function() {
|
||||
return {
|
||||
comment: Comments.findOne(this.params._id)
|
||||
}
|
||||
};
|
||||
},
|
||||
after: function () {
|
||||
window.queueComments = false;
|
||||
|
@ -395,7 +395,7 @@ UserPageController = FastRender.RouteController.extend({
|
|||
}else{
|
||||
return {
|
||||
user: (typeof findById == "undefined") ? findBySlug : findById
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -560,7 +560,7 @@ Router.map(function() {
|
|||
data: function() {
|
||||
return {
|
||||
user: Meteor.user()
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -587,7 +587,7 @@ Router.map(function() {
|
|||
users: Meteor.users.find(parameters.find, parameters.options),
|
||||
filterBy: filterBy,
|
||||
sortBy: sortBy
|
||||
}
|
||||
};
|
||||
},
|
||||
fastRender: true
|
||||
});
|
||||
|
@ -599,7 +599,7 @@ Router.map(function() {
|
|||
data: function() {
|
||||
return {
|
||||
hash: this.params.hash
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
|
|
48
lib/users.js
48
lib/users.js
|
@ -1,37 +1,37 @@
|
|||
isAdminById=function(userId){
|
||||
var user = Meteor.users.findOne(userId);
|
||||
return !!(user && isAdmin(user));
|
||||
}
|
||||
};
|
||||
isAdmin=function(user){
|
||||
user = (typeof user === 'undefined') ? Meteor.user() : user;
|
||||
return !!user && !!user.isAdmin;
|
||||
}
|
||||
};
|
||||
isInvited=function(user){
|
||||
if(!user || typeof user === 'undefined')
|
||||
return false;
|
||||
return isAdmin(user) || !!user.isInvited;
|
||||
}
|
||||
};
|
||||
adminUsers = function(){
|
||||
return Meteor.users.find({isAdmin : true}).fetch();
|
||||
}
|
||||
};
|
||||
getUserName = function(user){
|
||||
return user.username;
|
||||
}
|
||||
};
|
||||
getDisplayName = function(user){
|
||||
return (user.profile && user.profile.name) ? user.profile.name : user.username;
|
||||
}
|
||||
};
|
||||
getDisplayNameById = function(userId){
|
||||
return getDisplayName(Meteor.users.findOne(userId));
|
||||
}
|
||||
};
|
||||
getProfileUrl = function(user) {
|
||||
return Meteor.absoluteUrl()+'users/' + slugify(getUserName(user));
|
||||
}
|
||||
};
|
||||
getProfileUrlById = function(id){
|
||||
return Meteor.absoluteUrl()+'users/'+ id;
|
||||
}
|
||||
};
|
||||
getProfileUrlBySlug = function(slug) {
|
||||
return Meteor.absoluteUrl()+'users/' + slug;
|
||||
}
|
||||
};
|
||||
getTwitterName = function(user){
|
||||
// return twitter name provided by user, or else the one used for twitter login
|
||||
if(checkNested(user, 'profile', 'twitter')){
|
||||
|
@ -40,7 +40,7 @@ getTwitterName = function(user){
|
|||
return user.services.twitter.screenName;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
getGitHubName = function(user){
|
||||
// return twitter name provided by user, or else the one used for twitter login
|
||||
if(checkNested(user, 'profile', 'github')){
|
||||
|
@ -49,10 +49,10 @@ getGitHubName = function(user){
|
|||
return user.services.github.screenName;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
getTwitterNameById = function(userId){
|
||||
return getTwitterName(Meteor.users.findOne(userId));
|
||||
}
|
||||
};
|
||||
getSignupMethod = function(user){
|
||||
if(user.services && user.services.twitter){
|
||||
return 'twitter';
|
||||
|
@ -61,14 +61,14 @@ getSignupMethod = function(user){
|
|||
}else{
|
||||
return 'regular';
|
||||
}
|
||||
}
|
||||
};
|
||||
getEmail = function(user){
|
||||
if(user.profile && user.profile.email){
|
||||
return user.profile.email;
|
||||
}else{
|
||||
return '';
|
||||
}
|
||||
}
|
||||
};
|
||||
getAvatarUrl = function(user){
|
||||
if(getSignupMethod(user)=='twitter'){
|
||||
return 'http://twitter.com/api/users/profile_image/'+user.services.twitter.screenName;
|
||||
|
@ -80,24 +80,24 @@ getAvatarUrl = function(user){
|
|||
s: 80
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
getCurrentUserEmail = function(){
|
||||
return Meteor.user() ? getEmail(Meteor.user()) : '';
|
||||
}
|
||||
};
|
||||
userProfileComplete = function(user) {
|
||||
return !!getEmail(user);
|
||||
}
|
||||
};
|
||||
|
||||
findLast = function(user, collection){
|
||||
return collection.findOne({userId: user._id}, {sort: {createdAt: -1}});
|
||||
}
|
||||
};
|
||||
timeSinceLast = function(user, collection){
|
||||
var now = new Date().getTime();
|
||||
var last = findLast(user, collection);
|
||||
if(!last)
|
||||
return 999; // if this is the user's first post or comment ever, stop here
|
||||
return Math.abs(Math.floor((now-last.createdAt)/1000));
|
||||
}
|
||||
};
|
||||
numberOfItemsInPast24Hours = function(user, collection){
|
||||
var mDate = moment(new Date());
|
||||
var items=collection.find({
|
||||
|
@ -107,22 +107,22 @@ numberOfItemsInPast24Hours = function(user, collection){
|
|||
}
|
||||
});
|
||||
return items.count();
|
||||
}
|
||||
};
|
||||
getUserSetting = function(setting, defaultValue, user){
|
||||
var user = (typeof user == 'undefined') ? Meteor.user() : user;
|
||||
var defaultValue = (typeof defaultValue == "undefined") ? null: defaultValue;
|
||||
var settingValue = getProperty(user.profile, setting);
|
||||
return (settingValue == null) ? defaultValue : settingValue;
|
||||
}
|
||||
};
|
||||
getProperty = function(object, property){
|
||||
// recursive function to get nested properties
|
||||
var array = property.split('.');
|
||||
if(array.length > 1){
|
||||
var parent = array.shift();
|
||||
// if our property is not at this level, call function again one level deeper if we can go deeper, else return null
|
||||
return (typeof object[parent] == "undefined") ? null : getProperty(object[parent], array.join('.'))
|
||||
return (typeof object[parent] == "undefined") ? null : getProperty(object[parent], array.join('.'));
|
||||
}else{
|
||||
// else return property
|
||||
return object[array[0]];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
16
lib/vote.js
16
lib/vote.js
|
@ -10,12 +10,12 @@
|
|||
};
|
||||
|
||||
var hasUpvotedItem= function(item, user){
|
||||
return item.upvoters && item.upvoters.indexOf(user._id) != -1
|
||||
}
|
||||
return item.upvoters && item.upvoters.indexOf(user._id) != -1;
|
||||
};
|
||||
|
||||
var hasDownvotedItem= function(item, user){
|
||||
return item.downvoters && item.downvoters.indexOf(user._id) != -1
|
||||
}
|
||||
return item.downvoters && item.downvoters.indexOf(user._id) != -1;
|
||||
};
|
||||
|
||||
var upvoteItem = function(collection, item) {
|
||||
var user = Meteor.user(),
|
||||
|
@ -27,7 +27,7 @@
|
|||
|
||||
// if user is upvoting a previously downvoted item, cancel downvote first
|
||||
if (hasDownvotedItem(item, user))
|
||||
cancelDownvote(collection, item, user)
|
||||
cancelDownvote(collection, item, user);
|
||||
|
||||
// Votes & Score
|
||||
var result = collection.update({_id: item && item._id},{
|
||||
|
@ -50,7 +50,7 @@
|
|||
if(getSetting('redistributeKarma', false)){
|
||||
_.each(item.upvoters, function(upvoterId){
|
||||
// share the karma equally among all upvoters, but cap the value at 0.1
|
||||
var karmaIncrease = Math.min(0.1, votePower/item.upvoters.length)
|
||||
var karmaIncrease = Math.min(0.1, votePower/item.upvoters.length);
|
||||
modifyKarma(upvoterId, 0.1);
|
||||
});
|
||||
}
|
||||
|
@ -68,7 +68,7 @@
|
|||
|
||||
// if user is downvoting a previously upvoted item, cancel upvote first
|
||||
if (hasUpvotedItem(item, user))
|
||||
cancelUpvote(collection, item, user)
|
||||
cancelUpvote(collection, item, user);
|
||||
|
||||
// Votes & Score
|
||||
collection.update({_id: item && item._id},{
|
||||
|
@ -146,7 +146,7 @@
|
|||
// only let admins specify different users for voting
|
||||
// if no user is specified, use current user by default
|
||||
return (isAdmin(Meteor.user()) && typeof user !== 'undefined') ? user : Meteor.user();
|
||||
}
|
||||
};
|
||||
|
||||
Meteor.methods({
|
||||
upvotePost: function(post, user){
|
||||
|
|
|
@ -16,16 +16,16 @@ serveAPI = function(limitSegment){
|
|||
};
|
||||
|
||||
if(post.body)
|
||||
properties['body'] = post.body;
|
||||
properties.body = post.body;
|
||||
|
||||
if(post.url)
|
||||
properties['domain'] = getDomain(url);
|
||||
properties.domain = getDomain(url);
|
||||
|
||||
if(twitterName = getTwitterNameById(post.userId))
|
||||
properties['twitterName'] = twitterName;
|
||||
properties.twitterName = twitterName;
|
||||
|
||||
posts.push(properties);
|
||||
});
|
||||
|
||||
return JSON.stringify(posts);
|
||||
}
|
||||
};
|
|
@ -5,14 +5,14 @@ sendEmail = function(to, subject, text, html){
|
|||
|
||||
var from = getSetting('defaultEmail', 'noreply@example.com');
|
||||
var siteName = getSetting('title');
|
||||
var subject = '['+siteName+'] '+subject
|
||||
var subject = '['+siteName+'] '+subject;
|
||||
|
||||
console.log('sending email…');
|
||||
console.log(from)
|
||||
console.log(to)
|
||||
console.log(subject)
|
||||
console.log(text)
|
||||
console.log(html)
|
||||
console.log(from);
|
||||
console.log(to);
|
||||
console.log(subject);
|
||||
console.log(text);
|
||||
console.log(html);
|
||||
|
||||
Email.send({
|
||||
from: from,
|
||||
|
|
|
@ -22,7 +22,7 @@ Meteor.methods({
|
|||
invitedBy: currentUser._id,
|
||||
invitedByName: getDisplayName(currentUser)
|
||||
}});
|
||||
console.log(a)
|
||||
console.log(a);
|
||||
|
||||
createNotification({
|
||||
event: 'accountApproved',
|
||||
|
|
|
@ -7,23 +7,23 @@ Meteor.startup(function () {
|
|||
|
||||
// migration updatePostStatus: make sure posts have a status
|
||||
if (!Migrations.findOne({name: "updatePostStatus"})) {
|
||||
console.log("//----------------------------------------------------------------------//")
|
||||
console.log("//------------// Starting updatePostStatus Migration //-----------//")
|
||||
console.log("//----------------------------------------------------------------------//")
|
||||
console.log("//----------------------------------------------------------------------//");
|
||||
console.log("//------------// Starting updatePostStatus Migration //-----------//");
|
||||
console.log("//----------------------------------------------------------------------//");
|
||||
Posts.find({status: {$exists : false}}).forEach(function (post) {
|
||||
Posts.update(post._id, {$set: {status: 2}});
|
||||
|
||||
// START CONSOLE LOGS
|
||||
console.log("---------------------")
|
||||
console.log("---------------------");
|
||||
console.log("Post: "+post.headline);
|
||||
console.log("Updating status to approved");
|
||||
// END CONSOLE LOGS
|
||||
|
||||
});
|
||||
Migrations.insert({name: "updatePostStatus"});
|
||||
console.log("//----------------------------------------------------------------------//")
|
||||
console.log("//------------// Ending updatePostStatus Migration //-----------//")
|
||||
console.log("//----------------------------------------------------------------------//")
|
||||
console.log("//----------------------------------------------------------------------//");
|
||||
console.log("//------------// Ending updatePostStatus Migration //-----------//");
|
||||
console.log("//----------------------------------------------------------------------//");
|
||||
}
|
||||
|
||||
|
||||
|
@ -31,25 +31,25 @@ Meteor.startup(function () {
|
|||
|
||||
// migration updateCategories: make sure categories have slugs
|
||||
if (!Migrations.findOne({name: "updateCategories"})) {
|
||||
console.log("//----------------------------------------------------------------------//")
|
||||
console.log("//------------// Starting updateCategories Migration //-----------//")
|
||||
console.log("//----------------------------------------------------------------------//")
|
||||
console.log("//----------------------------------------------------------------------//");
|
||||
console.log("//------------// Starting updateCategories Migration //-----------//");
|
||||
console.log("//----------------------------------------------------------------------//");
|
||||
Categories.find().forEach(function (category) {
|
||||
if(typeof category.slug === "undefined"){
|
||||
var slug = slugify(category.name);
|
||||
Categories.update(category._id, {$set: {slug: slug}});
|
||||
|
||||
// START CONSOLE LOGS
|
||||
console.log("---------------------")
|
||||
console.log("---------------------");
|
||||
console.log("Category: "+category.name);
|
||||
console.log("Updating category with new slug: "+slug);
|
||||
// END CONSOLE LOGS
|
||||
}
|
||||
});
|
||||
Migrations.insert({name: "updateCategories"});
|
||||
console.log("//----------------------------------------------------------------------//")
|
||||
console.log("//------------// Ending updateCategories Migration //-----------//")
|
||||
console.log("//----------------------------------------------------------------------//")
|
||||
console.log("//----------------------------------------------------------------------//");
|
||||
console.log("//------------// Ending updateCategories Migration //-----------//");
|
||||
console.log("//----------------------------------------------------------------------//");
|
||||
}
|
||||
|
||||
|
||||
|
@ -57,9 +57,9 @@ Meteor.startup(function () {
|
|||
|
||||
// migration updateCategories: store full category object in post instead of just the name
|
||||
if (!Migrations.findOne({name: "updatePostCategories"})) {
|
||||
console.log("//----------------------------------------------------------------------//")
|
||||
console.log("//------------// Starting updatePostCategories Migration //-----------//")
|
||||
console.log("//----------------------------------------------------------------------//")
|
||||
console.log("//----------------------------------------------------------------------//");
|
||||
console.log("//------------// Starting updatePostCategories Migration //-----------//");
|
||||
console.log("//----------------------------------------------------------------------//");
|
||||
Posts.find().forEach(function (post) {
|
||||
var oldCategories = post.categories;
|
||||
var newCategories = [];
|
||||
|
@ -88,10 +88,10 @@ Meteor.startup(function () {
|
|||
}
|
||||
|
||||
// START CONSOLE LOGS
|
||||
console.log("---------------------")
|
||||
console.log("---------------------");
|
||||
console.log("Post: "+post.headline);
|
||||
if(updating){
|
||||
console.log(oldCategories.length+" categories: "+oldCategories)
|
||||
console.log(oldCategories.length+" categories: "+oldCategories);
|
||||
console.log("Updating categories array to: ");
|
||||
console.log(newCategories);
|
||||
}else{
|
||||
|
@ -101,16 +101,16 @@ Meteor.startup(function () {
|
|||
|
||||
});
|
||||
Migrations.insert({name: "updatePostCategories"});
|
||||
console.log("//----------------------------------------------------------------------//")
|
||||
console.log("//------------// Ending updateCategories Migration //-----------//")
|
||||
console.log("//----------------------------------------------------------------------//")
|
||||
console.log("//----------------------------------------------------------------------//");
|
||||
console.log("//------------// Ending updateCategories Migration //-----------//");
|
||||
console.log("//----------------------------------------------------------------------//");
|
||||
}
|
||||
|
||||
// migration updateUserProfiles: update user profiles with slugs and a few other properties
|
||||
if (!Migrations.findOne({name: "updateUserProfiles"})) {
|
||||
console.log("//----------------------------------------------------------------------//")
|
||||
console.log("//------------// Starting updateUserProfiles Migration //-----------//")
|
||||
console.log("//----------------------------------------------------------------------//")
|
||||
console.log("//----------------------------------------------------------------------//");
|
||||
console.log("//------------// Starting updateUserProfiles Migration //-----------//");
|
||||
console.log("//----------------------------------------------------------------------//");
|
||||
|
||||
var allUsers = Meteor.users.find();
|
||||
console.log('> Found '+allUsers.count()+' users.\n');
|
||||
|
@ -136,9 +136,9 @@ Meteor.startup(function () {
|
|||
|
||||
});
|
||||
Migrations.insert({name: "updateUserProfiles"});
|
||||
console.log("//----------------------------------------------------------------------//")
|
||||
console.log("//------------// Ending updateUserProfiles Migration //-----------//")
|
||||
console.log("//----------------------------------------------------------------------//")
|
||||
console.log("//----------------------------------------------------------------------//");
|
||||
console.log("//------------// Ending updateUserProfiles Migration //-----------//");
|
||||
console.log("//----------------------------------------------------------------------//");
|
||||
}
|
||||
|
||||
});
|
|
@ -19,7 +19,7 @@ createNotification = function(options) {
|
|||
event: event,
|
||||
properties: properties,
|
||||
read: false
|
||||
}
|
||||
};
|
||||
var newNotificationId=Notifications.insert(notification);
|
||||
|
||||
// send the notification if notifications are activated,
|
||||
|
@ -29,7 +29,7 @@ createNotification = function(options) {
|
|||
var contents = getNotificationContents(notification, 'email');
|
||||
sendNotification(contents);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Meteor.methods({
|
||||
unsubscribeUser : function(hash){
|
||||
|
@ -51,7 +51,7 @@ Meteor.methods({
|
|||
},
|
||||
newPostNotify : function(properties){
|
||||
var currentUser = Meteor.users.findOne(this.userId);
|
||||
console.log('newPostNotify')
|
||||
console.log('newPostNotify');
|
||||
// send a notification to every user according to their notifications settings
|
||||
Meteor.users.find().forEach(function(user) {
|
||||
// don't send users notifications for their own posts
|
||||
|
@ -68,4 +68,4 @@ sendNotification = function (notification) {
|
|||
// console.log('send notification:')
|
||||
// console.log(notification)
|
||||
sendEmail(notification.to, notification.subject, notification.text, notification.html);
|
||||
}
|
||||
};
|
|
@ -27,7 +27,7 @@ Meteor.publish('singleUser', function(userIdOrSlug) {
|
|||
if(canViewById(this.userId)){
|
||||
var options = isAdminById(this.userId) ? {limit: 1} : {limit: 1, fields: privacyOptions};
|
||||
var findById = Meteor.users.find(userIdOrSlug, options);
|
||||
var findBySlug = Meteor.users.find({slug: userIdOrSlug}, options)
|
||||
var findBySlug = Meteor.users.find({slug: userIdOrSlug}, options);
|
||||
// if we find something when treating the argument as an ID, return that; else assume it's a slug
|
||||
return findById.count() ? findById : findBySlug;
|
||||
}
|
||||
|
|
|
@ -19,4 +19,4 @@ serveRSS = function() {
|
|||
});
|
||||
|
||||
return feed.xml();
|
||||
}
|
||||
};
|
||||
|
|
|
@ -2,5 +2,5 @@ logSearch = function (keyword) {
|
|||
Searches.insert({
|
||||
timestamp: new Date().getTime(),
|
||||
keyword: keyword
|
||||
})
|
||||
}
|
||||
});
|
||||
};
|
|
@ -38,4 +38,4 @@ Meteor.methods({
|
|||
);
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
|
@ -7,7 +7,7 @@ Accounts.onCreateUser(function(options, user){
|
|||
postCount: 0,
|
||||
commentCount: 0,
|
||||
invitedCount: 0
|
||||
}
|
||||
};
|
||||
user = _.extend(user, userProperties);
|
||||
|
||||
if (options.email)
|
||||
|
@ -25,7 +25,7 @@ Accounts.onCreateUser(function(options, user){
|
|||
posts: false,
|
||||
comments: true,
|
||||
replies: true
|
||||
}
|
||||
};
|
||||
|
||||
// create slug from username
|
||||
user.slug = slugify(getUserName(user));
|
||||
|
@ -66,7 +66,7 @@ Accounts.onCreateUser(function(options, user){
|
|||
getEmailHash = function(user){
|
||||
// todo: add some kind of salt in here
|
||||
return CryptoJS.MD5(getEmail(user).trim().toLowerCase() + user.createdAt).toString();
|
||||
}
|
||||
};
|
||||
|
||||
addToMailChimpList = function(user){
|
||||
// add a user to a MailChimp list.
|
||||
|
@ -87,7 +87,7 @@ addToMailChimpList = function(user){
|
|||
double_optin: false
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Meteor.methods({
|
||||
changeEmail: function(newEmail) {
|
||||
|
|
Loading…
Add table
Reference in a new issue