Commit e9110563 authored by Barış Soner Uşaklı's avatar Barış Soner Uşaklı
Browse files

refactor: lint

parent 44fc76af
{
"extends": "nodebb/lib"
}
\ No newline at end of file
'use strict';
var meta = require.main.require('./src/meta');
var user = require.main.require('./src/user');
const meta = require.main.require('./src/meta');
const user = require.main.require('./src/user');
var library = {};
library.init = function(params, callback) {
var app = params.router;
var middleware = params.middleware;
const library = module.exports;
library.init = async function (params) {
const { app, middleware } = params;
app.get('/admin/plugins/persona', middleware.admin.buildHeader, renderAdmin);
app.get('/api/admin/plugins/persona', renderAdmin);
callback();
};
library.addAdminNavigation = function(header, callback) {
library.addAdminNavigation = async function (header) {
header.plugins.push({
route: '/plugins/persona',
icon: 'fa-paint-brush',
name: 'Persona Theme'
name: 'Persona Theme',
});
callback(null, header);
return header;
};
library.defineWidgetAreas = function(areas, callback) {
library.defineWidgetAreas = async function (areas) {
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'
'unread.tpl', 'recent.tpl', 'popular.tpl', 'top.tpl', 'tags.tpl', 'tag.tpl',
];
function capitalizeFirst(str) {
return str.charAt(0).toUpperCase() + str.slice(1)
return str.charAt(0).toUpperCase() + str.slice(1);
}
templates.forEach(template => {
locations.forEach(location => {
templates.forEach((template) => {
locations.forEach((location) => {
areas.push({
name: capitalizeFirst(template.split('.')[0]) + ' ' + capitalizeFirst(location),
name: `${capitalizeFirst(template.split('.')[0])} ${capitalizeFirst(location)}`,
template: template,
location: location,
});
......@@ -46,16 +41,15 @@ library.defineWidgetAreas = function(areas, callback) {
areas = areas.concat([
{
name: "Account Header",
template: "account/profile.tpl",
location: "header"
name: 'Account Header',
template: 'account/profile.tpl',
location: 'header',
},
]);
callback(null, areas);
return areas;
};
library.getThemeConfig = async function(config) {
library.getThemeConfig = async function (config) {
const settings = await meta.settings.get('persona');
config.hideSubCategories = settings.hideSubCategories === 'on';
config.hideCategoryLastPost = settings.hideCategoryLastPost === 'on';
......@@ -63,7 +57,7 @@ library.getThemeConfig = async function(config) {
return config;
};
function renderAdmin(req, res, next) {
function renderAdmin(req, res) {
res.render('admin/plugins/persona', {});
}
......@@ -74,7 +68,7 @@ library.addUserToTopic = async function (hookData) {
const userData = await user.getUserData(hookData.req.user.uid);
hookData.templateData.loggedInUser = userData;
} else {
hookData.templateData.loggedInUser = {
hookData.templateData.loggedInUser = {
uid: 0,
username: '[[global:guest]]',
picture: user.getDefaultAvatar(),
......
......@@ -10,6 +10,9 @@
"type": "git",
"url": "https://github.com/psychobunny/nodebb-theme-persona"
},
"scripts": {
"lint": "eslint ."
},
"keywords": [
"nodebb",
"theme",
......@@ -41,5 +44,10 @@
"dependencies": {
"pulling": "^2.0.0",
"striptags": "^3.2.0"
},
"devDependencies": {
"eslint": "^7.32.0",
"eslint-config-nodebb": "^0.0.2",
"eslint-plugin-import": "^2.24.2"
}
}
{
"extends": "nodebb/public"
}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment