fixed conflict

v1.18.x
Baris Usakli 12 years ago
commit 170ed8cc01

@ -102,26 +102,29 @@ var ajaxify = {};
// Enhancing all anchors to ajaxify... // Enhancing all anchors to ajaxify...
$(document.body).on('click', 'a', function(e) { $(document.body).on('click', 'a', function(e) {
function hrefEmpty(href) { function hrefEmpty(href) {
return href == 'javascript:;' || href == window.location.href + "#" || href.slice(-1) === "#"; return href == 'javascript:;' || href == window.location.href + "#" || href.slice(-1) === "#";
} }
if (hrefEmpty(this.href)) return; if (hrefEmpty(this.href)) return;
var url = this.href.replace(rootUrl + '/', '');
if (this.target !== '') return; if (this.target !== '') return;
if (this.protocol === 'javascript:') return;
if (!e.ctrlKey && e.which === 1) { if (!e.ctrlKey && e.which === 1) {
if (this.host === window.location.host) {
var url = this.href.replace(rootUrl + '/', '');
if (ajaxify.go(url)) { if (ajaxify.go(url)) {
e.preventDefault(); e.preventDefault();
} }
} else {
ajaxify.go('outgoing?url=' + encodeURIComponent(this.href));
e.preventDefault();
}
} }
}); });
}); });
function exec_body_scripts(body_el) { function exec_body_scripts(body_el) {
// modified from http://stackoverflow.com/questions/2592092/executing-script-elements-inserted-with-innerhtml // modified from http://stackoverflow.com/questions/2592092/executing-script-elements-inserted-with-innerhtml

@ -21,7 +21,6 @@ var socket,
var reconnectTries = 0; var reconnectTries = 0;
socket.on('event:connect', function (data) { socket.on('event:connect', function (data) {
console.log('connected to nodebb socket: ', data);
app.username = data.username; app.username = data.username;
app.showLoginMessage(); app.showLoginMessage();
}); });

@ -87,7 +87,7 @@ var RDB = require('./redis.js'),
}); });
}, },
function(next) { function(next) {
PostTools.toHTML(content, next); PostTools.parse(content, next);
} }
], function(err, results) { ], function(err, results) {
io.sockets.in('topic_' + results[0].tid).emit('event:post_edited', { io.sockets.in('topic_' + results[0].tid).emit('event:post_edited', {
@ -128,7 +128,7 @@ var RDB = require('./redis.js'),
}); });
// Delete the thread if it is the last undeleted post // Delete the thread if it is the last undeleted post
threadTools.get_latest_undeleted_pid(postData.tid, function(err, pid) { threadTools.getLatestUndeletedPid(postData.tid, function(err, pid) {
if (err && err.message === 'no-undeleted-pids-found') { if (err && err.message === 'no-undeleted-pids-found') {
threadTools.delete(postData.tid, -1, function(err) { threadTools.delete(postData.tid, -1, function(err) {
if (err) winston.error('Could not delete topic (tid: ' + postData.tid + ')', err.stack); if (err) winston.error('Could not delete topic (tid: ' + postData.tid + ')', err.stack);
@ -164,7 +164,7 @@ var RDB = require('./redis.js'),
pid: pid pid: pid
}); });
threadTools.get_latest_undeleted_pid(postData.tid, function(err, pid) { threadTools.getLatestUndeletedPid(postData.tid, function(err, pid) {
posts.getPostField(pid, 'timestamp', function(timestamp) { posts.getPostField(pid, 'timestamp', function(timestamp) {
topics.updateTimestamp(postData.tid, timestamp); topics.updateTimestamp(postData.tid, timestamp);
}); });
@ -190,28 +190,11 @@ var RDB = require('./redis.js'),
}); });
} }
PostTools.toHTML = function(raw, callback) { PostTools.parse = function(raw, callback) {
raw = raw || ''; raw = raw || '';
plugins.fireHook('filter:post.parse', raw, function(parsed) {
var cheerio = require('cheerio');
if (parsed && parsed.length > 0) {
var parsedContentDOM = cheerio.load(parsed);
var domain = nconf.get('url');
parsedContentDOM('a').each(function() {
this.attr('rel', 'nofollow');
var href = this.attr('href');
if (href && !href.match(domain) && !utils.isRelativeUrl(href)) { plugins.fireHook('filter:post.parse', raw, function(parsed) {
this.attr('href', domain + 'outgoing?url=' + encodeURIComponent(href)); callback(null, parsed);
}
});
callback(null, parsedContentDOM.html());
} else {
callback(null, '<p></p>');
}
}); });
} }

@ -36,7 +36,7 @@ var RDB = require('./redis.js'),
user.getUserFields(post.uid, ['username', 'userslug', 'reputation', 'postcount', 'picture', 'signature', 'banned'], function(err, userData) { user.getUserFields(post.uid, ['username', 'userslug', 'reputation', 'postcount', 'picture', 'signature', 'banned'], function(err, userData) {
if (err) return callback(); if (err) return callback();
postTools.toHTML(userData.signature, function(err, signature) { postTools.parse(userData.signature, function(err, signature) {
post.username = userData.username || 'anonymous'; post.username = userData.username || 'anonymous';
post.userslug = userData.userslug || ''; post.userslug = userData.userslug || '';
post.user_rep = userData.reputation || 0; post.user_rep = userData.reputation || 0;
@ -91,7 +91,7 @@ var RDB = require('./redis.js'),
}, },
function(postData, next) { function(postData, next) {
if (postData.content) { if (postData.content) {
postTools.toHTML(postData.content, function(err, content) { postTools.parse(postData.content, function(err, content) {
if (!err) postData.content = utils.strip_tags(content); if (!err) postData.content = utils.strip_tags(content);
next(err, postData); next(err, postData);
}); });
@ -164,7 +164,7 @@ var RDB = require('./redis.js'),
postData['edited-class'] = postData.editor !== '' ? '' : 'none'; postData['edited-class'] = postData.editor !== '' ? '' : 'none';
postData['relativeEditTime'] = postData.edited !== '0' ? (new Date(parseInt(postData.edited,10)).toISOString()) : ''; postData['relativeEditTime'] = postData.edited !== '0' ? (new Date(parseInt(postData.edited,10)).toISOString()) : '';
postTools.toHTML(postData.content, function(err, content) { postTools.parse(postData.content, function(err, content) {
postData.content = content; postData.content = content;
posts.push(postData); posts.push(postData);
callback(null); callback(null);
@ -321,7 +321,7 @@ var RDB = require('./redis.js'),
async.parallel({ async.parallel({
content: function(next) { content: function(next) {
plugins.fireHook('filter:post.get', postData, function(postData) { plugins.fireHook('filter:post.get', postData, function(postData) {
postTools.toHTML(postData.content, function(err, content) { postTools.parse(postData.content, function(err, content) {
next(null, content); next(null, content);
}); });
}); });

@ -426,7 +426,7 @@ var user = require('./../user.js'),
if (callerUID !== userData.uid) if (callerUID !== userData.uid)
user.incrementUserFieldBy(userData.uid, 'profileviews', 1); user.incrementUserFieldBy(userData.uid, 'profileviews', 1);
postTools.toHTML(userData.signature, function(err, signature) { postTools.parse(userData.signature, function(err, signature) {
userData.signature = signature; userData.signature = signature;
res.json(userData); res.json(userData);
}); });

@ -297,22 +297,20 @@ var RDB = require('./redis.js'),
}); });
} }
ThreadTools.get_latest_undeleted_pid = function(tid, callback) { ThreadTools.getLatestUndeletedPid = function(tid, callback) {
RDB.lrange('tid:' + tid + ':posts', 0, -1, function(err, pids) {
if (pids.length === 0) return callback(new Error('no-undeleted-pids-found'));
posts.getPostsByTid(tid, 0, -1, function(posts) { pids.reverse();
async.detectSeries(pids, function(pid, next) {
var numPosts = posts.length; RDB.hget('post:' + pid, 'deleted', function(err, deleted) {
if (!numPosts) if (deleted === '0') next(true);
return callback(new Error('no-undeleted-pids-found')); else next(false);
});
while (numPosts--) { }, function(pid) {
if (posts[numPosts].deleted !== '1') { if (pid) callback(null, pid);
callback(null, posts[numPosts].pid); else callback(new Error('no-undeleted-pids-found'));
return; });
}
}
callback(new Error('no-undeleted-pids-found'));
}); });
} }
}(exports)); }(exports));

@ -573,7 +573,7 @@ schema = require('./schema.js'),
} }
Topics.getTeaser = function(tid, callback) { Topics.getTeaser = function(tid, callback) {
threadTools.get_latest_undeleted_pid(tid, function(err, pid) { threadTools.getLatestUndeletedPid(tid, function(err, pid) {
if (!err) { if (!err) {
posts.getPostFields(pid, ['content', 'uid', 'timestamp'], function(postData) { posts.getPostFields(pid, ['content', 'uid', 'timestamp'], function(postData) {
@ -591,7 +591,7 @@ schema = require('./schema.js'),
if (postData.content) { if (postData.content) {
stripped = postData.content.replace(/>.+\n\n/, ''); stripped = postData.content.replace(/>.+\n\n/, '');
postTools.toHTML(stripped, function(err, stripped) { postTools.parse(stripped, function(err, stripped) {
returnObj.text = utils.strip_tags(stripped); returnObj.text = utils.strip_tags(stripped);
callback(null, returnObj); callback(null, returnObj);
}); });

@ -428,7 +428,6 @@ var express = require('express'),
app.get('/robots.txt', function (req, res) { app.get('/robots.txt', function (req, res) {
res.set('Content-Type', 'text/plain'); res.set('Content-Type', 'text/plain');
res.send("User-agent: *\n" + res.send("User-agent: *\n" +
"Disallow: \n" +
"Disallow: /admin/\n" + "Disallow: /admin/\n" +
"Sitemap: " + nconf.get('url') + "sitemap.xml"); "Sitemap: " + nconf.get('url') + "sitemap.xml");
}); });

Loading…
Cancel
Save