Skip to content
  • 0 Votes
    1 Posts
    9 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:

  • 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
    96 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

  • 0 Votes
    1 Posts
    154 Views
    vijay kumavatV

    Hi Team NodeBB,

    I am trying to create plugin to add one set image/icon field in the user setting page (user/username/settings) and this value display after user name in topic list page.

    var Plugin = {}; console.log('outside - called properly'); Plugin.addCustomFields = function(hookData, callback) { console.log('Custom Field function is called properly'); // Add your custom fields to the `fields` object here hookData.custom_field_1 = { type: 'text', required: true, title: 'Custom Field 1' }; }; module.exports = Plugin;

    could you please guide me which method i need to use and for image/icon field how to write filed attribute?

  • 0 Votes
    1 Posts
    202 Views
    E

    See GitHub for reference, https://github.com/LM1LC3N7/nodebb-plugin-private-forum/issues/4#issuecomment-1034840197

    Wondering if anyone has an idea why the calendar page is accessible when not logged in while using the private forum plugin.

  • 1 Votes
    1 Posts
    282 Views
    A

    After install "nodebb-plugin-sso-beer-qq", my server crashed and nginx return code 502.

    After reset all plugins, my server is back to normal again.

  • 0 Votes
    1 Posts
    187 Views
    שמח לעזורש

    איך אני בונה תוסף?

  • 0 Votes
    1 Posts
    203 Views
    M

    Hi there,

    I am trying to customize plugin: https://github.com/julianlam/nodebb-plugin-sso-oauth

    I have made my own:
    https://github.com/MaxWaldorf/nodebb-plugin-sso-keycloak

    I know the sso works since I am testing it with other systems like wordpress, etc...

    But even though I enter the right info in config file, I don't succeed to anything so far...

    Here is my code in config file:

    "oauth": { "id": "my_id", "secret": "my_key", "type": "oauth", "name": "nodebb", "scope": "email profile openid", "auth2": "https://<SSO_domain>/auth/realms/Public/protocol/openid-connect/auth", "token2": "https://<SSO_domain>/auth/realms/Public/protocol/openid-connect/token", "user": "https://<SSO_domain>/auth/realms/Public/protocol/openid-connect/userinfo" }

    The login page shows and I am able to enter my credentials but... After that, I receive an error:

    Internal Error. /auth/nodebb/callback undefined

    Am I missing something?
    I feel I don't understand correctly the scope part...

    If anyone has an idea, it would be greatly appreciated...

    Cheers

  • 0 Votes
    1 Posts
    243 Views
    N

    Hi, I have following:
    {
    "hook": "filter:config.get",
    "method": "configGet"
    }

    My purpose is to use my own sort method for sorting topics in a category, automatically modifying visible "Sort By" html element with a special sorting method that I implemented, and make it selected automatically.

    I tried many hooks but "filter:config.get" was only one that is called before rendering or sending anything to client side. Other hooks such as "filter:categories.buildTopicsSortedSet", "filter:categories.getSortedSetRangeDirection","filter:category.topics.prepare", they all didn't work.

    For example, if I changed like following in a method for "filter:categories.buildTopicsSortedSet":
    data.settings.categoryTopicSort = 'most_myown';
    but in client side, it only shows the previous value of "data.settings.categoryTopicSort", not the value "most_myown".

    So I had to use "filter:config.get" because changing config there actually reflects to client side.

    To implement it, I first need to check information about category that the user just entered, and append it to config, and send it to client. They are supposed to be done in "configGet" method, which you see above. But I do not know how to get information about category that the user is in. I need to know about category info because my own sorting will only work for certain categories.

    Thank you very much.

  • nodebb-plugin-question-and-answer

    Unsolved Plugin Development
    1
    0 Votes
    1 Posts
    309 Views
    S

    I have installed nodebb-plugin-question-and-answer v0.7.7 on nodebb v1.13.3. but when I post a topic as question, "mark this post as correct answer" is not available. "unsolved" tag is not appearing for topic which is posted as question. Please help me with this.

  • 0 Votes
    1 Posts
    221 Views
    M

    Hi, I wonder how can I get user votes based on category IDs?

  • 0 Votes
    1 Posts
    585 Views
    dogsD
    This is just a little snippet.

    This is about the question How can I add custom data to a post? a small tutorial

    How to add custom data permanently to a post It will be saved into the object:

    You need the following hook:

    { "hook": "filter:post.create", "method": "postCreate" }

    This hook is fired, when a Post is created. So it contains RAW Data.

    A filter:hook like "hook": "filter:post.create" can be edited before beeing proceeded.

    plugin.postCreate = function(data, callback){ // Edit data here callback(null, data); }

    You can access all Data you can work with via the data object.

    All those filter-hooks needs callbacks. The callback contains the modified / added / removed data.

    Whats inside the data object?

    The data object contains two main objects.

    this.post this.data post: { pid: 259, uid: 2, tid: 111, content: '### This is just a little snippet.', timestamp: 1617150411838 }, data: { uuid: '7277s31-6d23-43sa-1284-ad27e42yx879', title: 'How to add custom data to post serverside - in a nutshell', content: '### This is just a little snippet.', thumb: '', cid: '2', tags: [], uid: 2, req: { [...] }, timestamp: 1617150411838, fromQueue: false, tid: 111, ip: '111.123.2123.21', isMain: true } }

    With all the data you can work with. But only this.post is directly effected (lol) to the post Object.
    If you add data here. It will be attached to the post forever and you can access it any time. Even after plugin disable.

    So now add custom data:

    plugin.postCreate = function(data, callback){ // adds data **PERMANENT** to post // before any other procession -> RAW DATA (markdown) //data.post.myData = "directly effected to post you can work with it in next step"; //data.data.myData = "other data for other things I don't know"; var myData = {}; myData.name = "Schmock"; myData.signature = "raz0rn"; // Stick myData to post object data.post.myData = myData; // Debug? // console.log("POST CREATE", data); // finish the process() - passes on modified data callback(null, data); }

    So myData has added to post:

    post: { pid: 259, uid: 2, tid: 111, content: '### This is just a little snippet.', timestamp: 1617150411838, myData: { name = "Schmock", signature = "raz0rn", } }

    The data is stored. Everybody is happy.

    dance minions

    How to add dynamic data before render a post in template It wont be saved to the object. You can use this for dynamic things or logic before rendering the page.:

    You need the following hook:

    { "hook": "filter:topics.addPostData", "method": "addPostData" }

    This hook is fired before engine renders the template.
    It also needs a callback because its a filter-hook.

    plugin.addPostData = function(data, callback){ // modify data temporarily before it gets passed on to next step callback(null, data); }

    Same thing as above. Only the hook is different. And the data we are changing is temporarily.
    Data contains all data we can use for the dynamicness lol: .

    plugin.addPostData = function(data, callback){ // You can work with pre-parsed and already saved data .... // or put in something very flexible without saving to db like jquery-like dynamic etc etc // Debug? // console.log("addPostData?", data) var _posts = data.posts; _posts.forEach(function(post){ if(post.myData){ // add data to post if "myData" is there post.content = "THIS POST HAS MY OWN DATA -> CONTENT IS OVERWRITTEN"; } // this here affects all posts post.user.signature = "Ihr seid alle Schmocks!"; }); // Overwrite data and pass modified data on to the template engine data.posts = _posts; callback(null, data); }

    Now you can work with posts like a boss.

    Bildschirmfoto 2021-03-31 um 03.10.32.png

    dab

    Thanks and bye

    Important Note:

    Remind, that myData is available via API.

    https://nodebb.development.fail/api/topic/114/new-post

    returns your added data

    "content": "THIS POST AS MY OWN DATA -> CONTENT IS OVERWRITTEN", "myData": { "name": "Schmock", "signature": "raz0rn" }
  • 0 Votes
    1 Posts
    343 Views
    magnusvhendinM

    Is there some way to hide all topics within a category from all feeds (recent, popular, new, the digest)?

    I need the topics to be accessible (and usable) to all users directly, but not searchable or showing up at random.

  • 2 Votes
    1 Posts
    415 Views
    dogsD

    Whats the right way to use third party libraries?

    I tried to do it descriped in the docs:
    https://docs.nodebb.org/development/plugins/libraries/

    But it doenst work.

    I want to use Swiper in my Theme:
    https://swiperjs.com/get-started/

    I tried it with

    "modules": { "swiper.js": "node_modules/swiper/swiper-bundle.min.js" }

    in client.js i used:

    require(['swiper'], function (Swiper) { var mySwiper = new Swiper('.swiper-container', { // Optional parameters direction: 'vertical', loop: true, // If we need pagination pagination: { el: '.swiper-pagination', }, // Navigation arrows navigation: { nextEl: '.swiper-button-next', prevEl: '.swiper-button-prev', }, // And if we need scrollbar scrollbar: { el: '.swiper-scrollbar', }, }) });

    The Javascript from Swiper does not load.

    Can you help me?

    I also treid to import it directly via html

    <link rel="stylesheet" href="https://unpkg.com/swiper/swiper-bundle.min.css"> <script src="https://unpkg.com/swiper/swiper-bundle.min.js"></script>

    and I also copied the contents of:
    https://unpkg.com/[email protected]/swiper-bundle.js

    and createt a file unter /lib/swiper-bundle.min.js. Nothing worked for me. The JS is still not loading...

    Looking forward to your answers! 🙂

    I fixed it.

    I am sorry. In my development I use grunt. But it seems that I doesnt load new libraries if installen. So I determinated the process Ctrl+C and restarted it using grunt. The librariers are loaded and the third party library works well now using:

    "modules": { "swiper.js": "node_modules/swiper/swiper-bundle.min.js" } require(['swiper'], function (Swiper) { var mySwiper = new Swiper('.swiper-container', { ... ... ... }) }
  • 1 Votes
    1 Posts
    195 Views
    selkkieS

    I'm having a frustrating time with setTopicFields, but only on filter:post.edit. filter:post.create works fine, and the code is pretty similar so I'm not sure what I'm missing. At first, it looks like it works properly, but when I restart NodeBB the data reverts back to how it was on post.create.

    The post data works correctly, but it creates a discrepancy where the post content says the right thing and the custom topicField says something out of date.

    plugin.createPostTruth = function (payload, callback) { topics.getTopicFields(payload.data.tid, ['truths'], function (err, topicData) { if (err) return console.log(err); var topicTruths = topicData.truths; var parsed = parseColored(payload.post.content); var truthpost = { 'pid': payload.post.pid, 'uid': payload.post.uid, 'truths': parsed }; if (truthpost.truths) { if (topicTruths && Array.isArray(topicTruths)) { topicTruths.push(truthpost); } else { topicTruths = [truthpost]; } } topics.setTopicFields(payload.data.tid, { 'truths': topicTruths }); }); callback(null, payload); } plugin.editPostTruth = function (payload, callback) { posts.getPostFields(payload.data.pid, ['tid'], function (err, postData) { topics.getTopicFields(postData.tid, ['truths'], function (err, topicData) { if (err) return console.log(err); var topicTruths = topicData.truths; var parsed = parseColored(payload.post.content); var truthpost = { 'pid': payload.post.pid, 'uid': payload.post.uid, 'truths': parsed }; if (!truthpost.truths) { console.log("checking for pid " + truthpost.pid); var i = topicTruths.findIndex(function (o) { return o.pid == truthpost.pid; }); if (i >= 0) { console.log("removing truths"); topicTruths.splice(i, 1); } //else return payload; } else { if (topicTruths && Array.isArray(topicTruths)) { console.log("checking to find pid " + truthpost.pid); var i = topicTruths.findIndex(function (o) { return o.pid == truthpost.pid; }); if (i >= 0) { console.log("Found pid. splicing truth"); topicTruths.splice(i, 1, truthpost); } else { topicTruths.push(truthpost); console.log("No pid found. adding truth to bottom of stack."); } } else { topicTruths = [truthpost]; console.log("There were no truths at all. making this the first truth..."); } } topics.setTopicFields(payload.data.tid, { 'truths': topicTruths }); }); }); callback(null, payload); }

    The topic json before edit, and after restart:

    "title": "Example Topic", "uid": 1, "viewcount": 1, "truths": [ { "pid": 136, "uid": 1, "truths": [ { "type": "red", "text": "This is a red." } ] }, { "pid": 137, "uid": 1, "truths": [ { "type": "blue", "text": "This is a blue." } ] } ],

    The topic json just after edit, and what it should look like:

    "title": "Example Topic", "uid": 1, "viewcount": 1, "truths": [ { "pid": 136, "uid": 1, "truths": [ { "type": "red", "text": "This is a red." } ] }, { "pid": 137, "uid": 1, "truths": [ { "type": "gold", "text": "This is not a blue." } ] } ],
  • 0 Votes
    1 Posts
    246 Views
    G

    i need get the fields of an authorized user

  • 0 Votes
    1 Posts
    281 Views
    Jovan IvanovićJ

    Hello, I modified the post.tpl to my liking and added some more elements and stuff.

    When I use composer to make a new post in a topic, it works just fine, I get the post.tpl I modified, but when I try to edit any of the posts in the topic, it looks like the default post.tpl file.

    What am I doing wrong here?

  • Cached scripts

    Plugin Development
    1
    1 Votes
    1 Posts
    289 Views
    magnusvhendinM

    Hi all!
    I've run into an issue that when I deploy a new version of my theme/plugin, most users don't get any changes done until they do a hard refresh. This only seems to affect the client side Javascript, so everything looks updated, but in reality functionality gets lost.

    Has anyone stumbled upon something similar? Is there a better way to release code?

    The background in this is that I have forked Persona and built upon it, so all changes to the platform is basically in the theme. Is there a way to make sure all clients receive all updates?

    Thanks!

  • Hooks on build

    Plugin Development
    1
    0 Votes
    1 Posts
    265 Views
    asdrubalivanA

    Hello! I've been reading the code of NodeBB since I'm developing a plugin for it. Right now I have some ES6 code that needs to be transpiled to ES5 and I'm looking for a way to transpile it in the build process. Are there any hooks that can help me with this process?

    Thanks in advance

  • 0 Votes
    1 Posts
    195 Views
    magnusvhendinM

    Hi all!
    I was wondering if there's a simple way to add my custom fields (from the ns-custom-fields plugin) to the regular edit.tpl. I'm making a private forum aimed at professionals and would really love it if I could have everything in one place.

    What I'm currently looking to add is Company, Title and possible some more in the future.

    An idea I have is to just put them in the available form and then using the custom-fields "API" in the backend (on save) to store them separately.

    Any ideas are welcome.

    Sorry to tag you (@Nicolas, the creator) but I believe you can answer this question quite easily.

    Thanks!