Skip to content

Plugin Development

Have a question about building a plugin? Ask here
427 Topics 1.9k Posts
  • 0 Votes
    1 Posts
    13 Views
    Bharat RathiB

    Hi all,
    Well this is my first time writing a plugin which involves using client side hooks...
    For a start, i would want my plugin to listen to a hook which activates when the topic page is completely loaded and topic tools are loaded too.

    For which I wrote this function:

    'use strict'; /* globals document, $ */ $(document).ready(function () { function alertType(type, message) { require(['alerts'], function (alerts) { alerts[type](message); }); } console.log('nodebb-plugin-quickstart: loaded'); $(window).on('action:topic.loaded', notifyBox); function notifyBox() { console.log("in notify box"); alertType('success', "done") } });

    but this is not working... I can only see "nodebb-plugin-quickstart: loaded" on the console.

    Where am i going wrong here??

  • How to write plugin in typescript?

    1
    0 Votes
    1 Posts
    22 Views
    starkorebaS

    Hello, first of' thanks for the amazing work !
    For the context: I'm a junior developer from France, so excuse my english (and my limited understanding of everything lol). I was looking for a software alternative to build a forum RPG. I just installed NodeBB on Ubuntu 20 (Focal) working on WSL 2. I'm using redis and want to write plugin using typescript.

    It would be great to have a guide version of the Quickstart plugin in typescript !
    I know its possible to write plugin in typescript, the emoji plugin does that. But it would save me so much time to have a guide that explain the extra step we need to do in order of compiler and make it work on NodeBB.

    Here's my questions tho:

    Is it in the roadmap team of NodeBB to document how to write plugin in typescript? Did the team plan to write a typescript version of NodeBB?

    Although it would be great to have some more advanced example right in the documentation on how to do something and what are the step to make it work.
    Like here : https://community.nodebb.org/topic/16994/how-do-i-add-custom-user-fields-to-my-theme

    Like "if I want to add/ change something, I have to think of the scope of this features and what's need to be modify in other file to be working properly". Or at least, say it in the documentation a little bit more straightforward. So that beginner will understand that first sight. But I think examples are more worthy than tons of words.

    Is it possible for beginner to contribute on the documentation to make it more specific and understandable for beginners, or is it a documentation for more experienced developers and a choice of the team (and don't want to change that)?

    Is it because from a plugin to another, things might be working so differently that it's not worthy to do a more detailed documentation ?

    Because people might be wanted to write plugin over time, mutualisation of knowledge would be great, so that might simplified the process of each developer trying to write plugin have to go throw investigations to understand how NodeBB works before even start to develop the actual plugin.

    For example: How to interact with the database explain in this answer: https://community.nodebb.org/topic/17657/best-way-to-store-plugin-data-in-database-in-context-of-compatibility/2?_=1714543873650 for me this should be in the documentation.

    In conclusion, I feel like in general people agree that it's difficult to start writting plugin without investigate and dive in the structure file of the source code. I'm willing to help on that make it easier to really understand how NodeBB works for developer. So that anyone not familiar with the source code can start almost immediately customization. :emo:

  • This topic is deleted!

    2
    0 Votes
    2 Posts
    29 Views
  • Custom helper function for benchpress

    2
    0 Votes
    2 Posts
    69 Views
    barisB

    https://community.nodebb.org/post/88242 I think this answers your question. Let me know if it doesn't work.

  • Create custom fields in composer

    4
    0 Votes
    4 Posts
    328 Views
    K

    Hi @Ali-Hussain ,
    Did you ever figure this out?
    I am trying to do something similar by adding a custom field to the post object based on a button I've added to the composer.

  • 1 Votes
    2 Posts
    128 Views
    barisB

    You can modify/override methods on the db object but not sure if it's worth the trouble.

  • Clean way to provide alias for link

    5
    0 Votes
    5 Posts
    130 Views
    Johan WathermanJ

    Ok, looks like I know what I need to know, what's possible, what doesn't make sense, and what could be a workaround.
    Thank you very much.

  • Some question about upload image

    2
    0 Votes
    2 Posts
    100 Views
    barisB

    filter:uploadImage hook receives some params that you can use to differentiate between a profile/cover picture for a user vs an image that is uploaded to a post.

    When a cover or profile image is uploaded the folder passed to the hook is set to profile. Also the image object will have a name field that is set to either profileAvatar or profileCover depending on what is being uploaded. When you upload a image to a post the folder is set to files.

    I think the upload from url is no longer used since that is handled client side now when someone tries to set their profile image from a url. In the past we used to download the image from that url server side but not it is handled client side with the cropper lib.

  • 0 Votes
    2 Posts
    186 Views
    barisB
    Do I understand correctly that I should simply save the collection of X objects like any other data in NodeBB, using its abstract data access mechanisms?

    Yes, just use the db.setObject and other methods available, this ensures your plugin works on redis/psql/mongodb.

    Can I expand the user data, topic, posts, etc. with an additional field in the database (probably containing the id of related X objects so that I can immediately ask about the right objects)?

    Yes, some plugins like QnA do this and add solved/isQuestion fields into the topic objects.

    NodeBB is very flexible in terms of data structure.

  • 0 Votes
    9 Posts
    412 Views
    S

    @julian, I am trying to implement your suggestion.

    @julian said in Share your opinion on my unique user registration process, please?:

    As long as those form fields have name, then it is added to the form data, and sent to the backend.

    So, I would still need to implement some backend code to save this to the user object, right? using the setter here: https://community.nodebb.org/topic/16994/how-do-i-add-custom-user-fields-to-my-theme

    Because, doing db.objects.find({username: "test"}) doesn't include the custom fields.

    @julian said in Share your opinion on my unique user registration process, please?:

    You probably can't see the additional info in the registration queue template, so you may have to modify that one too.

    The API response for /api/admin/manage/registration does not contain the custom fields. Am I doing something wrong, or is this expected? What is the easiest way to add these fields to the API response? Thank you.

  • nodebb-plugin-audioplayer

    16
    4 Votes
    16 Posts
    7k Views
    DownPWD

    UP UP 🙂

    yep very cool to update it for V3 with a possibility to add flac and a playlist or several style of music

  • 0 Votes
    2 Posts
    135 Views
    julianJ

    Most likely all server-side hooks are not specific to users (unless the UID is in the hook name, but I doubt we have any), so you'll have to just do an early-return if the condition doesn't match. It is likely not going to cause issues with the server. There are a thousand things that would need to be optimized before something like this causes a slowdown 🙂

  • 0 Votes
    7 Posts
    270 Views
    julianJ

    @baris perhaps it shouldn't be .btn-primary as it doesn't often get clicked 😄

  • 0 Votes
    4 Posts
    199 Views
    Eduardo SilvaE

    Tks so much, @baris and @julian!

    The await User.setUserField(user.uid, 'picture', user.profile_picture_url) approach worked!

    Yes, @julian, it's listening to the import-users-csv plugin hook.

    As soon as I finish the plugin I'll make a proper post announcing and explaining it.

  • 0 Votes
    3 Posts
    184 Views
    Eduardo SilvaE

    Great, tks!

    Just sent an e-mail :))

  • User avatar occurred error via sso

    1
    0 Votes
    1 Posts
    87 Views
    Sky凌空S

    I write a sso plugin,but when user loading their sso avatar,the error occurred
    屏幕截图 2023-10-14 162931.png
    And the server can get this url.
    This is code screenshot:
    屏幕截图 2023-10-14 154845.png
    How could i fix it?

  • 0 Votes
    1 Posts
    97 Views
    T

    A new question concerning the development of my Backblaze B2 storage plugin:

    I kind of have it working now, where files are uploaded and filenames returned properly, though it's lacking the sophisticated ways of setting host, bucket and credentials as the old s3 plugins (I'm still struggling figuring out what the hooks and functions are available to a plugin developer, since the documentation doesn't seem to be very updated and detailed).

    I noticed there is this button to export personal data, including uploaded files. How should I possibly integrate this functionality into my plugin?

    Thom

  • Convenient way for plugin test

    3
    0 Votes
    3 Posts
    204 Views
    T

    @josef Thank you. I'll give it a try.

  • 0 Votes
    9 Posts
    425 Views
    oplik0O

    @eeeee Probably local to the user computer 🙂

    You can generally use non-http URIs for launching different applications. If you were ever redirected from a desktop or mobile app to a browser to log in you've probably seen this in action. Windows actually uses some internally and usually transparently for the user (for example, to abuse their monopoly, MS started using microsoft-edge: scheme instead of https: in some links in Windows to only allow opening them in Edge. They didn't have to build some highly custom mechanism, just restrict other apps from registering this scheme), but usually can be just registered by applications you install. What they do also depends on the application - for example, I think calculator: only launches the calculator app (or at least the obvious way to write math doesn't work), but others can launch specific actions and even pass some information (for example, authentication token for the web login use case I mentioned). For example Spotify allows linking to artists, playlists, albums etc. via spotify: scheme and steam supports doing a ton of things via URI, including launching and even installing/uninstalling games.

    All you need is an <a> tag with the right href= set. So yeah, you can put that kind of a link in a widget, but if they wanted to have it be an action under a post, especially if it was supposed to include some information from the post, it wouldn't be that simple.
    (side note: NodeBB doesn't allow links using non-standard schemes in markdown, so you can't just put something like this in a post or signature)

  • Child theme from Harmony theme - build problem

    4
    0 Votes
    4 Posts
    242 Views
    barisB

    It is actually something nodebb specific, when building the active theme nodebb core looks for the overrides.scss file. This file needs to be imported in a specific order for it to work.