yariplus
Posts
-
Why all the seriousness let's loosen up a bit -
How to get all the groups that the user subscribed to?On the server, you can do
var groups = require.main.require('./src/groups'); groups.getUserGroups([1] /*array of uids*/, function(err, userGroups){ if (err) return; // Returns an array of an array of group data. console.log(userGroups[0]); // Prints an array of groups for uid 1 });
on the client, you can get a list of visible groups by doing:
$.getJSON('/api/user/USERSLUG/groups', function (data) { // Returns an object with a 'groups' property, an array of visible group data. console.log(data.groups); });
-
Get password via MongoDBA bit of explanation here. NodeBB was not originally designed for mongodb, thus does not use mongo collections. Every object is stored in one large "objects" collection, and is indexed by a unique string stored in the
_key
field. For user objects this key isuser:UID
, where UID is the user's identifier.If you wanted to look up just the password field (the password hash), you can use query projection as such:
db.objects.find({_key:"user:1"}, {password: true, _id: false})
and you can add other fields as such:
db.objects.find({_key:"user:1"}, {password: true, uid: true, email: true, username: true, _id: false})
-
Need to hook to /api/user/username/topics .buildAs of this commit, a hook now exists for every page.
closes #4587 · NodeBB/NodeBB@25f3a31
Node.js based forum software built for the modern web - closes #4587 · NodeBB/NodeBB@25f3a31
GitHub (github.com)
So, for this page, the hook would be
filter:account/topics.build
(the hook name is based on the template). It is passed the parameters ({req, res, templateData}, next) like the other hooks. -
i wanna 5 new topic display / persona theme over there how can..It depends how you want to do it really. You could just remove the
@first
if statement frompartials/categories/lastpost.tpl
template. You may have to adjust the html so it fits, and the css height of the card class.Also, please try not to double post.
-
What do you mean like "moderator"?The end result is that it's turning an array of Category Objects into an array of Category IDs
[{name:'General', cid:'0'},{name:'Help', cid:'1'}]
will become['0', '1']
-
request - Nodebb Blog plugin -
Get actual request inside a plugin hookoh, very nice, that does appear to be a better solution.
-
The most weakest point of nodebb@Schamper had mentioned it briefly a while ago. An API or abstraction layer, like we have for the databases, might be a nice feature for the composer module. So that plugins that are compatible with one editor would be 99% compatible with the other, without developer intervention.
-
How to check if a visitor is registered or a guest?I'm not sure why that appears on the docs. That change has not been added into the code yet.
https://github.com/NodeBB/NodeBB/pull/4162 -
Host NodeBB?I'm done with this guy.
-
Database integration, permissions and custom routes in pluginUsing only the currently logged in nodebb user and minecraft player.
Two routes needed:
- Server-only route: POST route. Requires a unique key parameter. Only the forum and the minecraft server know the key. e.g.
/mc/link?key=key
- User route: GET route. Used to link accounts, requires a UUID and a unique player key. e.g.
/mc/link/:uuid/:key
Minimum two DB keys need:
{uuid}:key
String key, stores the unique player key for the UUID. (Could also be a hash to store additional data.)user:{uid}:uuid
String key, stores the UUID linked to the user. (Could also be stored on the user hash, or made into a set for multiple linkings.)
Process:
https://www.lucidchart.com/documents/view/382333e7-c772-43b7-8061-57b3bbd83e97
- Minecraft player types a command.
- Server users server-only route to tell the forum it needs a registration link. Sending the unique key to verify the request is valid.
- Forum creates a unique player key and stores it in the DB, then sends the player key to the server.
- Server gives a link to the player, using the unique player key and the players' UUID.
- User visits link, if the user is logged in, and the uuid-key pair matches what is already in the DB, then the accounts are linked, using additional DB entries.
- The player key is deleted.
Concerns:
- The player key should expire relatively quickly, like 5 minutes.
- Invalid requests to the user route should be monitored and blocked after a low threshold, like 3 tries.
- NodeBB middleware already validates the logged in user, which is why we do no additional checks.
Note:
On the last line in the diagram, I send a confirmation message, but we can't actually do this because we have not established a persistent connection. You could solve this by either having an http server on the server, or creating a socket connection to the forum.
Or you could use Minecraft-Integration - Server-only route: POST route. Requires a unique key parameter. Only the forum and the minecraft server know the key. e.g.
-
New to NodeBBWelcome!
-
Recent cards localizationPlease don't do this. Submit an issue on github with the correct translation, and I will add the translation strings.
Build software better, together
GitHub is where people build software. More than 100 million people use GitHub to discover, fork, and contribute to over 420 million projects.
GitHub (github.com)
-
Custom Homepage: Recent + CategoriesYou might be able to just replace the widget templates with the category and recent templates from your theme. I doubt the data is different.
-
Custom Homepage: Recent + CategoriesIf your homepage is the Recent page, you can add a widget area only to the bottom of that page. To do so, you need to edit your theme in two places, once to define the widget area placement in the recent template, and then define the widget area so you can place a category widget inside from the admin panel.
-
Key-value tags for topics or postsStore the values in a database hash. Call it
topic:{tid}:yourplugin
, where {tid} is the topic id.The hash is a key-value store, so you would do,
db.setObjectField('topic:{tid}:yourplugin', 'priority', 'low')
to set a value. You do not need to define the object ahead of time.
Now you probably want to add that data to the template vars so it can be displayed to the user, so hook into
filter:topic.build
and add the values.plugin.topicBuild = function(data, next) { db.getObject('topic:' + data.templateData.tid + ':yourplugin', function (err, yourdata){ if (err) console.log(err) if (err || !yourdata) return next(null, data) // Add your key-values to the template data. data.templateData.yourplugin = yourdata next(null, data) }) }
Now you will be able to see the data in your template using, e.g.
{yourplugin.priority}
-
Custom Homepage: Recent + CategoriesThere's a few different ways you could do it.
You can install a forked version using npm install with a git url. So if I wanted to install my forked version linked above (on branch rw):
yari@yaricraft:~/nodebb$ npm install yariplus/nodebb-theme-persona#rw
You may also want to rename the theme, since nbb depends on nodebb-theme-persona, your changes could get overwritten when you update. Or just run this command again after you update to repull your forked version.
-
Hook to avoid unread topics management (related to nodebb-plugin-ignored-users).That's a good question. The format is a bit different than other hooks, to maintain compatibility with existing plugins. The hook right now is '
filter:*.build
', which isn't recognized by the generator (it would just see'filter:'
).We could either change the generator so that it recognizes that form of hook (we could filter out the variable pattern for a star), or change the hook to a format the generator recognizes, like
'filter:render.*'
, which would be a huge breaking change, but possibly better in the long-run.