From 5a175f81e73cc867ab6ddd5ab49d3ed135b78541 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Thu, 26 Aug 2021 21:08:13 -0400 Subject: [PATCH 001/227] fix: #500, dont load loggedInUser if quickreply isnt enabled --- library.js | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/library.js b/library.js index c5e7473..e914a8c 100644 --- a/library.js +++ b/library.js @@ -68,18 +68,22 @@ function renderAdmin(req, res, next) { } library.addUserToTopic = async function (hookData) { - if (hookData.req.user) { - const userData = await user.getUserData(hookData.req.user.uid); - hookData.templateData.loggedInUser = userData; - } else { - hookData.templateData.loggedInUser = { - uid: 0, - username: '[[global:guest]]', - picture: user.getDefaultAvatar(), - 'icon:text': '?', - 'icon:bgColor': '#aaa', - }; + const settings = await meta.settings.get('persona'); + if (settings.enableQuickReply === 'on') { + if (hookData.req.user) { + const userData = await user.getUserData(hookData.req.user.uid); + hookData.templateData.loggedInUser = userData; + } else { + hookData.templateData.loggedInUser = { + uid: 0, + username: '[[global:guest]]', + picture: user.getDefaultAvatar(), + 'icon:text': '?', + 'icon:bgColor': '#aaa', + }; + } } + return hookData; }; From 44fc76af8f58cee2a63443ab2237826e8c3167bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Thu, 26 Aug 2021 21:23:16 -0400 Subject: [PATCH 002/227] 11.2.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a5ce820..4f22623 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nodebb-theme-persona", - "version": "11.2.2", + "version": "11.2.3", "nbbpm": { "compatibility": "^1.18.0" }, From e9110563c700ae652b24d6662468cee6780b4b73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Thu, 26 Aug 2021 21:34:42 -0400 Subject: [PATCH 003/227] refactor: lint --- .eslintrc | 3 +++ library.js | 48 +++++++++++++++++++++--------------------------- package.json | 8 ++++++++ public/.eslintrc | 3 +++ 4 files changed, 35 insertions(+), 27 deletions(-) create mode 100644 .eslintrc create mode 100644 public/.eslintrc diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..cbdeb84 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,3 @@ +{ + "extends": "nodebb/lib" +} \ No newline at end of file diff --git a/library.js b/library.js index e914a8c..29ede0c 100644 --- a/library.js +++ b/library.js @@ -1,43 +1,38 @@ '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(), diff --git a/package.json b/package.json index 4f22623..fd61ec2 100644 --- a/package.json +++ b/package.json @@ -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" } } diff --git a/public/.eslintrc b/public/.eslintrc new file mode 100644 index 0000000..bf4af75 --- /dev/null +++ b/public/.eslintrc @@ -0,0 +1,3 @@ +{ + "extends": "nodebb/public" +} \ No newline at end of file From 41d6b558951240110f8a0cf72fe0c93c8d65a71a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Fri, 27 Aug 2021 14:40:51 -0400 Subject: [PATCH 004/227] feat: remove key --- languages/en-GB/persona.json | 3 +-- templates/partials/topic/quickreply.tpl | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/languages/en-GB/persona.json b/languages/en-GB/persona.json index 5ad6456..ffbe507 100644 --- a/languages/en-GB/persona.json +++ b/languages/en-GB/persona.json @@ -1,4 +1,3 @@ { - "mobile-menu-side": "Switch which side each mobile menu is on", - "post-quick-reply": "Post quick reply" + "mobile-menu-side": "Switch which side each mobile menu is on" } \ No newline at end of file diff --git a/templates/partials/topic/quickreply.tpl b/templates/partials/topic/quickreply.tpl index 013b218..57421eb 100644 --- a/templates/partials/topic/quickreply.tpl +++ b/templates/partials/topic/quickreply.tpl @@ -14,7 +14,7 @@
- + From dbc87c8a8e90b9cb231bc7f86aaa50cc0011d9ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Thu, 2 Sep 2021 09:52:36 -0400 Subject: [PATCH 005/227] feat: login/register widget areas --- library.js | 1 + templates/login.tpl | 140 +++++++++++++++++++++++------------------ templates/register.tpl | 130 +++++++++++++++++++++----------------- 3 files changed, 152 insertions(+), 119 deletions(-) diff --git a/library.js b/library.js index 29ede0c..5fafee6 100644 --- a/library.js +++ b/library.js @@ -25,6 +25,7 @@ library.defineWidgetAreas = async function (areas) { const templates = [ 'categories.tpl', 'category.tpl', 'topic.tpl', 'users.tpl', 'unread.tpl', 'recent.tpl', 'popular.tpl', 'top.tpl', 'tags.tpl', 'tag.tpl', + 'login.tpl', 'register.tpl', ]; function capitalizeFirst(str) { return str.charAt(0).toUpperCase() + str.slice(1); diff --git a/templates/login.tpl b/templates/login.tpl index 9b01316..abb8b8e 100644 --- a/templates/login.tpl +++ b/templates/login.tpl @@ -1,75 +1,91 @@ +
+ {{{each widgets.header}}} + {{widgets.header.html}} + {{{end}}} +
+