GithubHelp home page GithubHelp logo

nicolassiver / nodebb-plugin-ns-points Goto Github PK

View Code? Open in Web Editor NEW
22.0 6.0 19.0 615 KB

Additional metrics for User Profiles. It's like experience in video games. Plugin is good for gamification of your board.

License: MIT License

JavaScript 99.59% CSS 0.25% Smarty 0.16%

nodebb-plugin-ns-points's Introduction

NodeBB: Points

Additional metrics for User Profiles. It's like experience in video games. Plugin is good for gamification of your board.

Version Dependencies

The Ranking Calculation

The Ranking calculator is a function, that should accept 2 parameters - settings and raw points. Settings could vary from one calculator to another. Calculator must return object with properties listed below:

  • rank [Number] - user's rank, level
  • rankProgress [Number] - amount of points on current level
  • rankTotal [Number] - amount of points needed to level-up
  • total [Number] - raw amount of points

Example: Default Function

Themes

Plugin populates both: Profile and Topic views. Search for points property in corresponding entities. Don't forget to add link on overview page, link should look like - /points

Profile View

If you want points in Profile, do very basic changes to your theme:

Example: Persona Theme, v4, find templates/account/profile.tpl, edit template in package directory - node_modules

Find block that is responsible for stats, and insert template where you want:

<div class="account-stats">

    ...

    <!-- IMPORT partials/points_profile.tpl -->
    
    ...

</div>

Topic View

Every post will have additional field: points. If you want utilize points calculation feature in topic view, you should use theme that supports such type of integration.

nodebb-plugin-ns-points's People

Contributors

nicolassiver avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

nodebb-plugin-ns-points's Issues

Theme Lavender

/account/profile.tpl there isn't in Theme Lavender.
What file have i to edit?

Post object is null. Plugin Crashes forum

Nodebb 1.12.1
MongoDB 3.4

@NicolasSiver There is something in our database that makes this plugin and ns-awards crash when certain calculation is made. Which leads to crashing whole nodebb server.

Here is the log of area where it crashes

2019-04-16T22:09:48.190Z [4567/24494] - �[31merror�[39m: uncaughtException: Cannot read property 'uid' of null
TypeError: Cannot read property 'uid' of null
    at /var/www/community/node_modules/nodebb-plugin-ns-points/plugin/filters.js:67:37
    at /var/www/community/node_modules/async/dist/async.js:1135:9
    at eachOfArrayLike (/var/www/community/node_modules/async/dist/async.js:1069:9)
    at eachOf (/var/www/community/node_modules/async/dist/async.js:1117:5)
    at _asyncMap (/var/www/community/node_modules/async/dist/async.js:1133:5)
    at Object.map (/var/www/community/node_modules/async/dist/async.js:1122:16)
    at Object.Filter.postGetPosts [as method] (/var/www/community/node_modules/nodebb-plugin-ns-points/plugin/filters.js:66:15)
    at /var/www/community/src/plugins/hooks.js:136:12
    at /var/www/community/node_modules/async/dist/async.js:2516:9
    at replenish (/var/www/community/node_modules/async/dist/async.js:1011:17) {"error":{},"stack":"TypeError: Cannot read property 'uid' of null\n    at /var/www/community/node_modules/nodebb-plugin-ns-points/plugin/filters.js:67:37\n    at /var/www/community/node_modules/async/dist/async.js:1135:9\n    at eachOfArrayLike (/var/www/community/node_modules/async/dist/async.js:1069:9)\n    at eachOf (/var/www/community/node_modules/async/dist/async.js:1117:5)\n    at _asyncMap (/var/www/community/node_modules/async/dist/async.js:1133:5)\n    at Object.map (/var/www/community/node_modules/async/dist/async.js:1122:16)\n    at Object.Filter.postGetPosts [as method] (/var/www/community/node_modules/nodebb-plugin-ns-points/plugin/filters.js:66:15)\n    at /var/www/community/src/plugins/hooks.js:136:12\n    at /var/www/community/node_modules/async/dist/async.js:2516:9\n    at replenish (/var/www/community/node_modules/async/dist/async.js:1011:17)","exception":true,"date":"Tue Apr 16 2019 22:09:48 GMT+0000 (UTC)","process":{"pid":24494,"uid":0,"gid":0,"cwd":"/var/www/community","execPath":"/root/.nvm/versions/node/v8.11.4/bin/node","version":"v8.11.4","argv":["/root/.nvm/versions/node/v8.11.4/bin/node","/var/www/community/app.js"],"memoryUsage":{"rss":438337536,"heapTotal":304680960,"heapUsed":255611952,"external":54099262}},"os":{"loadavg":[1.5625,1.14306640625,1.07568359375],"uptime":7181824},"trace":[{"column":37,"file":"/var/www/community/node_modules/nodebb-plugin-ns-points/plugin/filters.js","function":null,"line":67,"method":null,"native":false},{"column":9,"file":"/var/www/community/node_modules/async/dist/async.js","function":null,"line":1135,"method":null,"native":false},{"column":9,"file":"/var/www/community/node_modules/async/dist/async.js","function":"eachOfArrayLike","line":1069,"method":null,"native":false},{"column":5,"file":"/var/www/community/node_modules/async/dist/async.js","function":"eachOf","line":1117,"method":null,"native":false},{"column":5,"file":"/var/www/community/node_modules/async/dist/async.js","function":"_asyncMap","line":1133,"method":null,"native":false},{"column":16,"file":"/var/www/community/node_modules/async/dist/async.js","function":"Object.map","line":1122,"method":"map","native":false},{"column":15,"file":"/var/www/community/node_modules/nodebb-plugin-ns-points/plugin/filters.js","function":"Object.Filter.postGetPosts [as method]","line":66,"method":"Filter.postGetPosts [as method]","native":false},{"column":12,"file":"/var/www/community/src/plugins/hooks.js","function":null,"line":136,"method":null,"native":false},{"column":9,"file":"/var/www/community/node_modules/async/dist/async.js","function":null,"line":2516,"method":null,"native":false},{"column":17,"file":"/var/www/community/node_modules/async/dist/async.js","function":"replenish","line":1011,"method":null,"native":false}]}
2019-04-16T22:09:48.193Z [4567/24494] - �[31merror�[39m: Cannot read property 'uid' of null
2019-04-16T22:09:48.193Z [4567/24494] - �[32minfo�[39m: [app] Shutdown (SIGTERM/SIGINT) Initialised.

Within /nodebb-plugin-ns-points/plugin/filters.js:67

Filter.postGetPosts = function (payload, callback) {
        async.map(payload.posts, function (post, next) {
            database.getPoints(post.uid, function (error, points) {
                if (error) {
                    return next(error);
                }
                post.points = points || 0;
                next(null, post);
            });
        }, function (error, results) {
            if (error) {
                return callback(error);
            }
            payload.posts = results;
            callback(null, payload);
        });
    };

So some how the post object is null. Is there any way we can catch this error and fail gracefully and not crash the whole server? Or alternatively any way we can run a query to find this dataset to fix the issue which causes the crash?

Plugin dont workin at 1.10.1 of NodeBB

Version - 1.10.1
base - mongodb
version of plugin - 4.0 and 5.0

I inserted code with at my theme (profile)

But at /points i see only one GUEST with 0 points.
I writed messages / new topics and i still not exist at /points and at my profile zero info about it.

What i need to do?

https://ibb.co/e6vUrK

this is my /points page.

error: Error: Cannot find module './src/emitter'

Hi,I ran into error installing this plugin. NodeBB version 13.3
Here's the complete error log:

2020-06-13T09:40:31.540Z [4567/4840] - warn: [plugins] Unable to parse library for: nodebb-plugin-ns-points
2020-06-13T09:40:31.541Z [4567/4840] - error: Error: Cannot find module './src/emitter'
Require stack:

  • D:\Coding\Web_Project\myExpress\NodeBB-v1.13x\require-main.js
  • D:\Coding\Web_Project\myExpress\NodeBB-v1.13x\app.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:966:15)
    at Function.Module._load (internal/modules/cjs/loader.js:842:27)
    at Module.require (internal/modules/cjs/loader.js:1026:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Module.require.main.require (D:\Coding\Web_Project\myExpress\NodeBB-v1.13x\require-main.js:8:10)
    at D:\Coding\Web_Project\myExpress\NodeBB-v1.13x\node_modules\nodebb-plugin-ns-points\plugin\nodebb.js:7:31
    at Object. (D:\Coding\Web_Project\myExpress\NodeBB-v1.13x\node_modules\nodebb-plugin-ns-points\plugin\nodebb.j
    s:19:3)
    at Module._compile (internal/modules/cjs/loader.js:1138:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
    at Module.load (internal/modules/cjs/loader.js:986:32)
    2020-06-13T09:40:31.542Z [4567/4840] - verbose: [plugins] Could not load plugin : nodebb-plugin-ns-points

Set point values in ACP?

Just thought that being able to manually enter a value to use as a number of points to award from within the ACP would be awesome. There will be certain things that some admins wish to reward, while others may not.

While the plugin could be edited locally, its a pain to have to note which plugins you have to keep an eye on to re-edit after an upgrade.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.