From 4f3687e67e70a6404bb173af9fc0766fc0e733d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Sun, 30 Jul 2023 18:59:13 -0400 Subject: [PATCH 1/3] update for ^3.2 change admin route to admin/plugins/rss-widget, so it doesn't conflict with nodebb-plugin-rss and matches other plugin pages moved admin.js to public/admin.js updated templates to use bootstrap5 classes --- admin.js | 20 -------------------- package.json | 2 +- plugin.js | 14 +++++++++----- plugin.json | 9 ++++----- public/admin.js | 12 ++++++++++++ templates/admin/plugins/rss-widget.tpl | 18 ++++++++++++++++++ templates/admin/rss.tpl | 20 -------------------- templates/widgets/rss.tpl | 12 +++++------- 8 files changed, 49 insertions(+), 58 deletions(-) delete mode 100644 admin.js create mode 100644 public/admin.js create mode 100644 templates/admin/plugins/rss-widget.tpl delete mode 100644 templates/admin/rss.tpl diff --git a/admin.js b/admin.js deleted file mode 100644 index 47caebf..0000000 --- a/admin.js +++ /dev/null @@ -1,20 +0,0 @@ -'use strict'; - -define('admin/rss', ['settings'], function(Settings) { - let ACP = {}; - ACP.init = function() { - Settings.load('rss', $('.rss-settings')); - $('#save').on('click', function() { - Settings.save('rss', $('.rss-settings'), function() { - app.alert({ - alert_id: 'rss-saved', - message: 'Updated RSS settings', - timeout: 2000, - title: 'Settings Saved', - type: 'success' - }); - }); - }); - }; - return ACP; -}); diff --git a/package.json b/package.json index 2d678d4..77eb5d2 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "main": "plugin.js", "name": "nodebb-widget-rss", "nbbpm": { - "compatibility": "^1.18.0" + "compatibility": "^3.2.0" }, "repository": { "type": "git", diff --git a/plugin.js b/plugin.js index c13ad59..b20c6b1 100644 --- a/plugin.js +++ b/plugin.js @@ -1,6 +1,8 @@ 'use strict'; const meta = require.main.require('./src/meta'); +const routeHelpers = require.main.require('./src/routes/helpers'); + const rssparser = new (require('rss-parser')); let nodebb = {}; let rss = { data: {}, updated: Math.round(new Date().getTime() / 1000) }; @@ -39,7 +41,9 @@ const updateFeed = async (force = false) => { else { return false } } const renderAdmin = async (req, res) => { - res.render('admin/rss', {}); + res.render('admin/plugins/rss-widget', { + title: 'RSS Widget', + }); } const rsort = async (data) => { return Object.keys(data).sort().reverse().reduce((r, k) => (r[k] = data[k], r), {}); @@ -48,8 +52,8 @@ const rsort = async (data) => { exports.filterAdminHeaderBuild = async (data) => { data.plugins.push({ icon: 'fa-link', - name: 'RSS', - route: '/rss' + name: 'RSS Widget', + route: '/plugins/rss-widget' }); return data; }; @@ -75,8 +79,8 @@ exports.filterWidgetsGetWidgets = async (data) => { }; exports.staticAppLoad = async (data) => { console.log('Loading Jenkler RSS widget ' + require('./package.json').version); - data.router.get('/admin/rss', data.middleware.admin.buildHeader, renderAdmin); - data.router.get('/api/admin/rss', renderAdmin); + + routeHelpers.setupAdminPageRoute(data.router, '/admin/plugins/rss-widget', renderAdmin); nodebb.app = data.app; await updateFeed(true); }; diff --git a/plugin.json b/plugin.json index d7846ec..3a69fda 100644 --- a/plugin.json +++ b/plugin.json @@ -1,5 +1,4 @@ { - "acpScripts": [ "admin.js" ], "description": "A widget that shows your rss feeds", "hooks": [ { "hook": "filter:admin.header.build", "method": "filterAdminHeaderBuild" }, @@ -10,9 +9,9 @@ "id": "nodebb-widget-rss", "library": "plugin.js", "name": "NodeBB RSS", - "nbbpm": { - "compatibility": "^1.18.0" - }, "templates": "templates", - "url": "https://github.com/Jenkler/nodebb-widget-rss" + "url": "https://github.com/Jenkler/nodebb-widget-rss", + "modules": { + "../admin/plugins/rss-widget.js": "public/admin.js" + } } diff --git a/public/admin.js b/public/admin.js new file mode 100644 index 0000000..15c11d9 --- /dev/null +++ b/public/admin.js @@ -0,0 +1,12 @@ +'use strict'; + +define('admin/plugins/rss-widget', ['settings'], function(Settings) { + let ACP = {}; + ACP.init = function() { + Settings.load('rss', $('.rss-settings')); + $('#save').on('click', function() { + Settings.save('rss', $('.rss-settings')); + }); + }; + return ACP; +}); diff --git a/templates/admin/plugins/rss-widget.tpl b/templates/admin/plugins/rss-widget.tpl new file mode 100644 index 0000000..4aaa7e6 --- /dev/null +++ b/templates/admin/plugins/rss-widget.tpl @@ -0,0 +1,18 @@ +
+ +
+
+
+

A widget that shows your rss feeds

+
+ + +
+
+ + +
+
+
+
+
diff --git a/templates/admin/rss.tpl b/templates/admin/rss.tpl deleted file mode 100644 index 148044d..0000000 --- a/templates/admin/rss.tpl +++ /dev/null @@ -1,20 +0,0 @@ -
-
-
RSS
-
-

A widget that shows your rss feeds

-
- - -
-
- - -
-
-
-
- - diff --git a/templates/widgets/rss.tpl b/templates/widgets/rss.tpl index 9aea4a3..a6d4525 100644 --- a/templates/widgets/rss.tpl +++ b/templates/widgets/rss.tpl @@ -6,12 +6,10 @@ #nyheter iframe { max-width: 100%; } #nyheter td { border-top: 1px solid #ddd; padding: 8px; } #nyheter tr:nth-of-type(odd) { background-color: #f9f9f9; } -.panel.panel-info {overflow: hidden; overflow-wrap: break-word; } +.rss-widget-card {overflow: hidden; overflow-wrap: break-word; } -
-
-

{title}

-
-
{body}
-
+
+
{title}
+
{body}
+
\ No newline at end of file From 9783c56b0498e6b5bdf5d313f4fc16e34a5c5ddf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Sun, 26 Jul 2026 21:13:05 -0400 Subject: [PATCH 2/3] refactor: update for nodebb 4.14.0 and up --- package.json | 2 +- plugin.js | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 77eb5d2..68a5feb 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "main": "plugin.js", "name": "nodebb-widget-rss", "nbbpm": { - "compatibility": "^3.2.0" + "compatibility": "^4.14.0" }, "repository": { "type": "git", diff --git a/plugin.js b/plugin.js index b20c6b1..8b16a67 100644 --- a/plugin.js +++ b/plugin.js @@ -1,10 +1,10 @@ 'use strict'; -const meta = require.main.require('./src/meta'); -const routeHelpers = require.main.require('./src/routes/helpers'); +const meta = nodebb.require('./src/meta'); +const routeHelpers = nodebb.require('./src/routes/helpers'); const rssparser = new (require('rss-parser')); -let nodebb = {}; +let app; let rss = { data: {}, updated: Math.round(new Date().getTime() / 1000) }; const updateFeed = async (force = false) => { @@ -65,7 +65,7 @@ exports.filterWidgetRenderRss = async (data) => { body += '' + key + '
' + rss.data[key]['content'] + '
'; } body += ''; - data.html = await nodebb.app.renderAsync('widgets/rss', { body: body, title: data.data.title }); + data.html = await app.renderAsync('widgets/rss', { body: body, title: data.data.title }); return data; }; exports.filterWidgetsGetWidgets = async (data) => { @@ -81,6 +81,6 @@ exports.staticAppLoad = async (data) => { console.log('Loading Jenkler RSS widget ' + require('./package.json').version); routeHelpers.setupAdminPageRoute(data.router, '/admin/plugins/rss-widget', renderAdmin); - nodebb.app = data.app; + app = data.app; await updateFeed(true); }; From 29a0e40b1155fcbadcf082ddc9aa53a337cfc6ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Sun, 26 Jul 2026 21:15:45 -0400 Subject: [PATCH 3/3] wrap body --- templates/widgets/rss.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/widgets/rss.tpl b/templates/widgets/rss.tpl index 3010f30..8b877f9 100644 --- a/templates/widgets/rss.tpl +++ b/templates/widgets/rss.tpl @@ -11,5 +11,5 @@
{title}
-
{body}
+
{{body}}