mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 03:26: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>?",
|
||||
"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>.",
|
||||
"500.title": "Internal error.",
|
||||
"500.message": "Ooops! Looks like something went wrong!",
|
||||
"logout": "Logout",
|
||||
"logout.title": "You are now logged out.",
|
||||
"logout.message": "You have successfully logged out of NodeBB",
|
||||
|
||||
@@ -3,10 +3,6 @@ define(['forum/accountheader'], function(header) {
|
||||
|
||||
AccountHeader.init = function() {
|
||||
header.init();
|
||||
|
||||
$('.user-favourite-posts .topic-row').on('click', function() {
|
||||
ajaxify.go($(this).attr('topic-url'));
|
||||
});
|
||||
};
|
||||
|
||||
return AccountHeader;
|
||||
|
||||
@@ -172,7 +172,7 @@
|
||||
} else if (data && data.status === 403) {
|
||||
return ajaxify.go('403');
|
||||
} else {
|
||||
app.alertError("Can't load template data!");
|
||||
app.alertError(data.responseJSON.error);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -319,18 +319,18 @@
|
||||
|
||||
if (conditionalBlock[1]) {
|
||||
// there is an else statement
|
||||
if (!value) {
|
||||
template = template.replace(matches[i], conditionalBlock[1]);
|
||||
if (!value) {
|
||||
template = template.replace(matches[i], conditionalBlock[1]);
|
||||
} else {
|
||||
template = template.replace(matches[i], conditionalBlock[0]);
|
||||
template = template.replace(matches[i], conditionalBlock[0]);
|
||||
}
|
||||
} else {
|
||||
// regular if statement
|
||||
// regular if statement
|
||||
if (!value) {
|
||||
template = template.replace(matches[i], '');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -341,7 +341,7 @@
|
||||
checkConditional('@first', blockInfo.iterator === 0);
|
||||
checkConditional('@last', blockInfo.iterator === blockInfo.total);
|
||||
}
|
||||
|
||||
|
||||
template = replace(namespace + d, data[d], template);
|
||||
}
|
||||
}
|
||||
|
||||
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>
|
||||
</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="col-md-12 user-favourite-posts">
|
||||
<!-- BEGIN posts -->
|
||||
<div class="topic-row img-thumbnail clearfix" topic-url="topic/{posts.tid}/#{posts.pid}">
|
||||
<span><strong>{posts.username}</strong> : </span>
|
||||
<span>{posts.category_name} >> {posts.title}</span>
|
||||
<div>{posts.content}</div>
|
||||
<div class="topic-row img-thumbnail clearfix">
|
||||
<a href="/user/baris">
|
||||
<img title="{posts.username}" class="img-rounded user-img" src="{posts.picture}">
|
||||
</a>
|
||||
|
||||
<a href="../../topic/{posts.tid}/#{posts.pid}">
|
||||
<strong><span>{posts.username}</span></strong>
|
||||
<p>{posts.content}</p>
|
||||
</a>
|
||||
|
||||
<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>
|
||||
<br/>
|
||||
|
||||
30
src/posts.js
30
src/posts.js
@@ -250,8 +250,9 @@ var RDB = require('./redis'),
|
||||
async.waterfall([
|
||||
function(next) {
|
||||
Posts.getPostFields(pid, ['pid', 'tid', 'content', 'uid', 'timestamp', 'deleted'], function(err, postData) {
|
||||
if (postData.deleted === '1') return callback(null);
|
||||
else {
|
||||
if (postData.deleted === '1') {
|
||||
return callback(null);
|
||||
} else {
|
||||
postData.relativeTime = new Date(parseInt(postData.timestamp || 0, 10)).toISOString();
|
||||
next(null, postData);
|
||||
}
|
||||
@@ -264,10 +265,15 @@ var RDB = require('./redis'),
|
||||
},
|
||||
function(postData, next) {
|
||||
topics.getTopicFields(postData.tid, ['title', 'cid', 'slug', 'deleted'], function(err, topicData) {
|
||||
if (err) return callback(err);
|
||||
else if (topicData.deleted === '1') return callback(null);
|
||||
categories.getCategoryField(topicData.cid, 'name', function(err, categoryData) {
|
||||
postData.category_name = categoryData;
|
||||
if (err) {
|
||||
return callback(err);
|
||||
} else if (topicData.deleted === '1') {
|
||||
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.topicSlug = topicData.slug;
|
||||
next(null, postData);
|
||||
@@ -277,13 +283,19 @@ var RDB = require('./redis'),
|
||||
function(postData, next) {
|
||||
if (postData.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);
|
||||
});
|
||||
} else next(null, postData);
|
||||
} else {
|
||||
next(null, postData);
|
||||
}
|
||||
}
|
||||
], function(err, postData) {
|
||||
if (!err) posts.push(postData);
|
||||
if (!err) {
|
||||
posts.push(postData);
|
||||
}
|
||||
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;
|
||||
topics.getLatestTopics(uid, 0, 19, req.params.term, function (err, data) {
|
||||
if (!err) {
|
||||
res.json(data);
|
||||
} else {
|
||||
res.send(500);
|
||||
if(err) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
res.json(data);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -295,6 +295,10 @@ var path = require('path'),
|
||||
app.get('/403', function (req, res) {
|
||||
res.json({});
|
||||
});
|
||||
|
||||
app.get('/500', function(req, res) {
|
||||
res.json({errorMessage: 'testing'});
|
||||
})
|
||||
});
|
||||
}
|
||||
}(exports));
|
||||
@@ -351,15 +351,17 @@ var fs = require('fs'),
|
||||
}
|
||||
|
||||
user.getUserFields(uid, ['username', 'userslug'], function (err, userData) {
|
||||
if (err)
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
if (userData) {
|
||||
posts.getFavourites(uid, function (err, posts) {
|
||||
if (err)
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
userData.posts = posts;
|
||||
userData.show_nofavourites = posts.length ? 'hide' : 'show';
|
||||
userData.show_nofavourites = posts.length === 0;
|
||||
res.json(userData);
|
||||
});
|
||||
} else {
|
||||
|
||||
@@ -301,10 +301,10 @@ var path = require('path'),
|
||||
// here and next(err) appropriately, or if
|
||||
// we possibly recovered from the error, simply next().
|
||||
console.error(err.stack);
|
||||
var status = err.status || 500;
|
||||
res.status(status);
|
||||
|
||||
res.status(err.status || 500);
|
||||
|
||||
res.json('500', {
|
||||
res.json(status, {
|
||||
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)
|
||||
(function () {
|
||||
var routes = ['login', 'register', 'account', 'recent', '403', '404'],
|
||||
var routes = ['login', 'register', 'account', 'recent', '403', '404', '500'],
|
||||
loginRequired = ['unread', 'search', 'notifications'];
|
||||
|
||||
async.each(routes.concat(loginRequired), function(route, next) {
|
||||
|
||||
Reference in New Issue
Block a user