mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 20:16:04 +01:00
closes #590
This commit is contained in:
@@ -6,6 +6,8 @@
|
|||||||
"403.message": "You seem to have stumbled upon a page that you do not have access to. Perhaps you should <a href='/login'>try logging in</a>?",
|
"403.message": "You seem to have stumbled upon a page that you do not have access to. Perhaps you should <a href='/login'>try logging in</a>?",
|
||||||
"404.title": "Not Found",
|
"404.title": "Not Found",
|
||||||
"404.message": "You seem to have stumbled upon a page that does not exist. Return to the <a href='/''>home page</a>.",
|
"404.message": "You seem to have stumbled upon a page that does not exist. Return to the <a href='/''>home page</a>.",
|
||||||
|
"500.title": "Internal error.",
|
||||||
|
"500.message": "Ooops! Looks like something went wrong!",
|
||||||
"logout": "Logout",
|
"logout": "Logout",
|
||||||
"logout.title": "You are now logged out.",
|
"logout.title": "You are now logged out.",
|
||||||
"logout.message": "You have successfully logged out of NodeBB",
|
"logout.message": "You have successfully logged out of NodeBB",
|
||||||
|
|||||||
@@ -3,10 +3,6 @@ define(['forum/accountheader'], function(header) {
|
|||||||
|
|
||||||
AccountHeader.init = function() {
|
AccountHeader.init = function() {
|
||||||
header.init();
|
header.init();
|
||||||
|
|
||||||
$('.user-favourite-posts .topic-row').on('click', function() {
|
|
||||||
ajaxify.go($(this).attr('topic-url'));
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return AccountHeader;
|
return AccountHeader;
|
||||||
|
|||||||
@@ -172,7 +172,7 @@
|
|||||||
} else if (data && data.status === 403) {
|
} else if (data && data.status === 403) {
|
||||||
return ajaxify.go('403');
|
return ajaxify.go('403');
|
||||||
} else {
|
} else {
|
||||||
app.alertError("Can't load template data!");
|
app.alertError(data.responseJSON.error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
5
public/templates/500.tpl
Normal file
5
public/templates/500.tpl
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<div class="alert alert-danger">
|
||||||
|
<strong>[[global:500.title]]</strong>
|
||||||
|
<p>[[global:500.message]]</p>
|
||||||
|
<p>{errorMessage}</p>
|
||||||
|
</div>
|
||||||
@@ -6,17 +6,31 @@
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="no-favourites-notice" class="alert alert-warning {show_nofavourites}">You don't have any favourites, favourite some posts to see them here!</div>
|
<!-- IF show_nofavourites -->
|
||||||
|
<div id="no-favourites-notice" class="alert alert-warning">You don't have any favourites, favourite some posts to see them here!</div>
|
||||||
|
<!-- ENDIF show_nofavourites -->
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12 user-favourite-posts">
|
<div class="col-md-12 user-favourite-posts">
|
||||||
<!-- BEGIN posts -->
|
<!-- BEGIN posts -->
|
||||||
<div class="topic-row img-thumbnail clearfix" topic-url="topic/{posts.tid}/#{posts.pid}">
|
<div class="topic-row img-thumbnail clearfix">
|
||||||
<span><strong>{posts.username}</strong> : </span>
|
<a href="/user/baris">
|
||||||
<span>{posts.category_name} >> {posts.title}</span>
|
<img title="{posts.username}" class="img-rounded user-img" src="{posts.picture}">
|
||||||
<div>{posts.content}</div>
|
</a>
|
||||||
|
|
||||||
|
<a href="../../topic/{posts.tid}/#{posts.pid}">
|
||||||
|
<strong><span>{posts.username}</span></strong>
|
||||||
|
<p>{posts.content}</p>
|
||||||
|
</a>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<span class="pull-right timeago" title="{posts.relativeTime}"></span>
|
<span class="pull-right">
|
||||||
|
posted in
|
||||||
|
<a href="../../category/{posts.categorySlug}">
|
||||||
|
<i class="fa {posts.categoryIcon}"></i> {posts.categoryName}
|
||||||
|
</a>
|
||||||
|
<span class="timeago" title="{posts.relativeTime}"></span>
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<br/>
|
<br/>
|
||||||
|
|||||||
30
src/posts.js
30
src/posts.js
@@ -250,8 +250,9 @@ var RDB = require('./redis'),
|
|||||||
async.waterfall([
|
async.waterfall([
|
||||||
function(next) {
|
function(next) {
|
||||||
Posts.getPostFields(pid, ['pid', 'tid', 'content', 'uid', 'timestamp', 'deleted'], function(err, postData) {
|
Posts.getPostFields(pid, ['pid', 'tid', 'content', 'uid', 'timestamp', 'deleted'], function(err, postData) {
|
||||||
if (postData.deleted === '1') return callback(null);
|
if (postData.deleted === '1') {
|
||||||
else {
|
return callback(null);
|
||||||
|
} else {
|
||||||
postData.relativeTime = new Date(parseInt(postData.timestamp || 0, 10)).toISOString();
|
postData.relativeTime = new Date(parseInt(postData.timestamp || 0, 10)).toISOString();
|
||||||
next(null, postData);
|
next(null, postData);
|
||||||
}
|
}
|
||||||
@@ -264,10 +265,15 @@ var RDB = require('./redis'),
|
|||||||
},
|
},
|
||||||
function(postData, next) {
|
function(postData, next) {
|
||||||
topics.getTopicFields(postData.tid, ['title', 'cid', 'slug', 'deleted'], function(err, topicData) {
|
topics.getTopicFields(postData.tid, ['title', 'cid', 'slug', 'deleted'], function(err, topicData) {
|
||||||
if (err) return callback(err);
|
if (err) {
|
||||||
else if (topicData.deleted === '1') return callback(null);
|
return callback(err);
|
||||||
categories.getCategoryField(topicData.cid, 'name', function(err, categoryData) {
|
} else if (topicData.deleted === '1') {
|
||||||
postData.category_name = categoryData;
|
return callback(null);
|
||||||
|
}
|
||||||
|
categories.getCategoryFields(topicData.cid, ['name', 'icon', 'slug'], function(err, categoryData) {
|
||||||
|
postData.categoryName = categoryData.name;
|
||||||
|
postData.categoryIcon = categoryData.icon;
|
||||||
|
postData.categorySlug = categoryData.slug;
|
||||||
postData.title = validator.sanitize(topicData.title).escape();
|
postData.title = validator.sanitize(topicData.title).escape();
|
||||||
postData.topicSlug = topicData.slug;
|
postData.topicSlug = topicData.slug;
|
||||||
next(null, postData);
|
next(null, postData);
|
||||||
@@ -277,13 +283,19 @@ var RDB = require('./redis'),
|
|||||||
function(postData, next) {
|
function(postData, next) {
|
||||||
if (postData.content) {
|
if (postData.content) {
|
||||||
postTools.parse(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);
|
||||||
});
|
});
|
||||||
} else next(null, postData);
|
} else {
|
||||||
|
next(null, postData);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
], function(err, postData) {
|
], function(err, postData) {
|
||||||
if (!err) posts.push(postData);
|
if (!err) {
|
||||||
|
posts.push(postData);
|
||||||
|
}
|
||||||
callback(err);
|
callback(err);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -143,14 +143,14 @@ var path = require('path'),
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get('/recent/:term?', function (req, res) {
|
app.get('/recent/:term?', function (req, res, next) {
|
||||||
var uid = (req.user) ? req.user.uid : 0;
|
var uid = (req.user) ? req.user.uid : 0;
|
||||||
topics.getLatestTopics(uid, 0, 19, req.params.term, function (err, data) {
|
topics.getLatestTopics(uid, 0, 19, req.params.term, function (err, data) {
|
||||||
if (!err) {
|
if(err) {
|
||||||
res.json(data);
|
return next(err);
|
||||||
} else {
|
|
||||||
res.send(500);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
res.json(data);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -295,6 +295,10 @@ var path = require('path'),
|
|||||||
app.get('/403', function (req, res) {
|
app.get('/403', function (req, res) {
|
||||||
res.json({});
|
res.json({});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.get('/500', function(req, res) {
|
||||||
|
res.json({errorMessage: 'testing'});
|
||||||
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}(exports));
|
}(exports));
|
||||||
@@ -351,15 +351,17 @@ var fs = require('fs'),
|
|||||||
}
|
}
|
||||||
|
|
||||||
user.getUserFields(uid, ['username', 'userslug'], function (err, userData) {
|
user.getUserFields(uid, ['username', 'userslug'], function (err, userData) {
|
||||||
if (err)
|
if (err) {
|
||||||
return next(err);
|
return next(err);
|
||||||
|
}
|
||||||
|
|
||||||
if (userData) {
|
if (userData) {
|
||||||
posts.getFavourites(uid, function (err, posts) {
|
posts.getFavourites(uid, function (err, posts) {
|
||||||
if (err)
|
if (err) {
|
||||||
return next(err);
|
return next(err);
|
||||||
|
}
|
||||||
userData.posts = posts;
|
userData.posts = posts;
|
||||||
userData.show_nofavourites = posts.length ? 'hide' : 'show';
|
userData.show_nofavourites = posts.length === 0;
|
||||||
res.json(userData);
|
res.json(userData);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -301,10 +301,10 @@ var path = require('path'),
|
|||||||
// here and next(err) appropriately, or if
|
// here and next(err) appropriately, or if
|
||||||
// we possibly recovered from the error, simply next().
|
// we possibly recovered from the error, simply next().
|
||||||
console.error(err.stack);
|
console.error(err.stack);
|
||||||
|
var status = err.status || 500;
|
||||||
|
res.status(status);
|
||||||
|
|
||||||
res.status(err.status || 500);
|
res.json(status, {
|
||||||
|
|
||||||
res.json('500', {
|
|
||||||
error: err.message
|
error: err.message
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -360,7 +360,7 @@ var path = require('path'),
|
|||||||
|
|
||||||
// Basic Routes (entirely client-side parsed, goal is to move the rest of the crap in this file into this one section)
|
// Basic Routes (entirely client-side parsed, goal is to move the rest of the crap in this file into this one section)
|
||||||
(function () {
|
(function () {
|
||||||
var routes = ['login', 'register', 'account', 'recent', '403', '404'],
|
var routes = ['login', 'register', 'account', 'recent', '403', '404', '500'],
|
||||||
loginRequired = ['unread', 'search', 'notifications'];
|
loginRequired = ['unread', 'search', 'notifications'];
|
||||||
|
|
||||||
async.each(routes.concat(loginRequired), function(route, next) {
|
async.each(routes.concat(loginRequired), function(route, next) {
|
||||||
|
|||||||
Reference in New Issue
Block a user