|
|
|
@ -26,72 +26,30 @@ library.addAdminNavigation = function(header, callback) {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
library.defineWidgetAreas = function(areas, callback) {
|
|
|
|
|
const locations = ['header', 'sidebar', 'footer'];
|
|
|
|
|
const templates = [
|
|
|
|
|
'categories.tpl', 'category.tpl', 'topic.tpl', 'users.tpl',
|
|
|
|
|
'unread.tpl', 'recent.tpl', 'popular.tpl', 'top.tpl', 'tags.tpl', 'tag.tpl'
|
|
|
|
|
];
|
|
|
|
|
function capitalizeFirst(str) {
|
|
|
|
|
return str.charAt(0).toUpperCase() + str.slice(1)
|
|
|
|
|
}
|
|
|
|
|
templates.forEach(template => {
|
|
|
|
|
locations.forEach(location => {
|
|
|
|
|
areas.push({
|
|
|
|
|
name: capitalizeFirst(template.split('.')[0]) + ' ' + capitalizeFirst(location),
|
|
|
|
|
template: template,
|
|
|
|
|
location: location,
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
areas = areas.concat([
|
|
|
|
|
{
|
|
|
|
|
name: "Categories Sidebar",
|
|
|
|
|
template: "categories.tpl",
|
|
|
|
|
location: "sidebar"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "Category Sidebar",
|
|
|
|
|
template: "category.tpl",
|
|
|
|
|
location: "sidebar"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "Topic Sidebar",
|
|
|
|
|
template: "topic.tpl",
|
|
|
|
|
location: "sidebar"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "Categories Header",
|
|
|
|
|
template: "categories.tpl",
|
|
|
|
|
location: "header"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "Category Header",
|
|
|
|
|
template: "category.tpl",
|
|
|
|
|
location: "header"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "Topic Header",
|
|
|
|
|
template: "topic.tpl",
|
|
|
|
|
location: "header"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "Categories Footer",
|
|
|
|
|
template: "categories.tpl",
|
|
|
|
|
location: "footer"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "Category Footer",
|
|
|
|
|
template: "category.tpl",
|
|
|
|
|
location: "footer"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "Topic Footer",
|
|
|
|
|
template: "topic.tpl",
|
|
|
|
|
location: "footer"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "Account Header",
|
|
|
|
|
template: "account/profile.tpl",
|
|
|
|
|
location: "header"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "Users Header",
|
|
|
|
|
template: "users.tpl",
|
|
|
|
|
location: "header"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "Tags Header",
|
|
|
|
|
template: "tags.tpl",
|
|
|
|
|
location: "header"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "Tag Header",
|
|
|
|
|
template: "tag.tpl",
|
|
|
|
|
location: "header"
|
|
|
|
|
}
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
callback(null, areas);
|
|
|
|
@ -109,26 +67,20 @@ function renderAdmin(req, res, next) {
|
|
|
|
|
res.render('admin/plugins/persona', {});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
library.addUserToTopic = function(data, callback) {
|
|
|
|
|
if (data.req.user) {
|
|
|
|
|
user.getUserData(data.req.user.uid, function(err, userdata) {
|
|
|
|
|
if (err) {
|
|
|
|
|
return callback(err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
data.templateData.loggedInUser = userdata;
|
|
|
|
|
callback(null, data);
|
|
|
|
|
});
|
|
|
|
|
library.addUserToTopic = async function (hookData) {
|
|
|
|
|
if (hookData.req.user) {
|
|
|
|
|
const userData = await user.getUserData(hookData.req.user.uid);
|
|
|
|
|
hookData.templateData.loggedInUser = userData;
|
|
|
|
|
} else {
|
|
|
|
|
data.templateData.loggedInUser = {
|
|
|
|
|
hookData.templateData.loggedInUser = {
|
|
|
|
|
uid: 0,
|
|
|
|
|
username: '[[global:guest]]',
|
|
|
|
|
picture: user.getDefaultAvatar(),
|
|
|
|
|
'icon:text': '?',
|
|
|
|
|
'icon:bgColor': '#aaa',
|
|
|
|
|
};
|
|
|
|
|
callback(null, data);
|
|
|
|
|
}
|
|
|
|
|
return hookData;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
module.exports = library;
|
|
|
|
|