• Home
  • Categories
  • Recent
  • Popular
  • Tags
  • Users
  • Groups
  • Documentation
    • Home
    • Read API
    • Write API
    • Plugin Development
Skins
  • Light
  • Default
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Quartz
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Slate
  • Solar
  • Superhero
  • Vapor
Collapse

Community

oplik0O

oplik0

@oplik0
Plugin & Theme Dev Community Rep
About
Posts
173
Topics
4
Groups
5
Followers
6
Following
2

Posts

Recent Best Controversial

    RE: Nokia launches DIY repairable budget Android phone
  • oplik0O oplik0

    @dave1904 said in Nokia launches DIY repairable budget Android phone:

    It's great. I hope in the future same goes for flagship devices. At the moment it feels like getting a phone like this or Fairphone, you make a compromise in having a sustainable phone but only get mid-range specs.

    It seems things are moving slowly in that direction (obviously thanks to regulatory pressures) - Pixels allowing re-pairing fingerprint sensor after replacement, iPhone 14 allowing for sane back glass replacements, Samsung finally adding battery pull-tabs in S23.
    I just hope these moves don't stop regulation attempts (at least until they go much further), but otherwise they are very promising.


  • RE: Question about SSO and username/userslug uniqueness
  • oplik0O oplik0

    Yeah, it's SΓΈrensen–Dice - though note that it wasn't really some well considered choice - I implemented it as part of an assignment earlier and just went with it because of that. I thought it might do a bit better than Levenshtein distance from my quick reading of a few articles related to discriminating identity based on username which suggested substring based algorithms are doing better for that task (LCS/GST for example).

    I'll probably add phonetic similarity to the mix in the future, and perhaps actually do some tests to see what makes most sense πŸ™‚
    (and the future is most likely February...)


  • RE: Connecting to socket endpoint from a custom frontend
  • oplik0O oplik0

    @nullpointer said in Connecting to socket endpoint from a custom frontend:

    var socket = io('https://dev-forum.domain.io', {
                transport: ["polling", "websocket"],
                path: "/socket.io/",
                extraHeaders: {
                    withCredentials: true,
                    cookie: 'express.sid=s%3Am0UuuyatTTSajjAnI5gGSukaJSHJaiKpIVhb3H7L.TW4c4vZn4blOnWV1gilF9HhMqFc9g9V7NnLLZHMAmFg; Domain=dev-forum.domain.io; Path=/; HttpOnly; SameSite=Lax',
                },
    });
    

    withCredentials is not a header - it's an option that should be on the same level in the settings object as extraHeaders. It should be used instead of setting the cookie header manually in the browser - but it will only work if the browser has the cookies for the website you're connecting to and needs explicit permission from it via headers (the Access-Control-Allow-* headers).
    This should look more like this:

    var socket = io('https://dev-forum.domain.io', {
                transport: ["polling", "websocket"],
                path: "/socket.io/",
                withCredentials: true,
    });
    

    The reason the NodeBB test example works is that it's not ran inside a browser - NodeJS, as a server environment, has quite different security requirements than browsers and also just can't save credentials for each page (imagine what programming horror having this kind of mutable state in code would be...). I'm not sure what is your ultimate goal with this code, so that's why I mentioned the cookies as needed for server-side code.


  • RE: Connecting to socket endpoint from a custom frontend
  • oplik0O oplik0

    I haven't looked too deeply into it, but I'm fairly sure the basic issue you're running into is that you're not in correct rooms - NodeBB actually doesn't just emit the events to every socket connected, instead it specifically selects users who are considered online.

    The first one requires the client to be in a uid_${uid} room, while the latter is related to the way sockets report user activity and configurable via ACP (you can configure how long a client can be inactive before it's considered to be offline). I don't remember the specifics of the latter (I think you might just need to periodically send something), but the former requires your socket client to authenticate (you should be automatically put into an appropriate room if NodeBB can authenticate you).

    It works with cookie auth just fine, but it's won't be used by default across domains since browsers have good reasons not to let you just use other website's cookie. You can make it work by adding the website your code will run under to Access-Control-Allow-Origin (note: * doesn't allow for credentials, you need to explicitly specify an origin here). which you can find under Settings>Advanced in NodeBB ACP (you may also need to set Access-Control-Allow-Credentials to true). Then you can just set withCredentials option in socket.io client configuration to true and it should work with your current logged-in user.

    If your code is running in eg. NodeJS you'll need to set extraHeaders option to an object like this:

    { cookie: `express.sid=${cookieValue}` }
    

    As to how to get the cookie - authorize the user via any HTTP client and retrieve it from the response. Unfortunately AFAIK for socket.io this is the only way to do this right now.

    Which I guess is something that might be changed? Right now sockets just check the session cookie, but now that WriteAPI is integrated with NodeBB it should be fairly simple to allow using Bearer Tokens from the write API if no session cookie is provided. But that's probably a feature request for NodeBB GitHub Issues


  • RE: Keeping Nodebb running after power outage
  • oplik0O oplik0

    EDIT: Oh, I was late...

    To answer in a bit of reverse order:
    @eeeee said in Keeping Nodebb running after power outage:

    Also is the above method better than using nodemon?

    It's not really doing the same thing as nodemon - the latter is mainly for watching file changes and restarting the application in that case. However, it's not tied to system init in any way, if the system restarts (eg. due to a power outage) it just dies in the process and you need to start it manually afterwards.
    Systemd is a software suite which includes the init system and service management, and it's used by majority of modern Linux distributions. The file here is a service unit definition for systemd, and since the same suite handles the init as well you can trivially configure the system to start your service on boot (this is what the systemctl enable command does)

    Systemd also has facilities for doing a lot of other things like timers, watching file paths, etc. but they're not as commonly used as services, so a common configuration might be to use a systemd service to run something like nodemon or PM2 instead of using the harder to configure built-in tools.

    On my server I just have the account I log in with. should I make another user?

    Nothing is stopping you from using the same user, there are some security advantages to separating services but it's not unique to running as a systemd service so it won't decrease your security compared to your current setup.

    Like why does this file need a link to the docs?

    It doesn't - it really is just for the sysadmin (in this instance you) to see a link when they're looking at the service and eg. want to debug something. If you feel you don't need it just leave it out - for units I write for myself I usually wouldn't add it, mostly since there wouldn't really be much relevant documentation - but since someone was already writing a pre-made unit file, why not include something nice that might be very occasionally helpful at a cost of just around 40 bytes of disk space being taken?


  • RE: December 2022 Design Preview (Harmony Theme)
  • oplik0O oplik0

    I for one really like how Harmony is shaping up πŸ™‚

    My only worry is translation of the sidebars to mobile - the current responsive demo doesn't seem to have that part implemented.

    Other than that worry, I really like the sidebars and the general move to text labels whenever there is space for them. I especially like the right sidebar submenus (yay for better drafts πŸ™‚ ).

    I'm not entirely convinced by logo/cover location, as it makes the site look a bit like it's always trying to be a bit of a landing page, but I think I get why it ended there and it doesn't seem that bad (side note probably just for the demo, but shouldn't the logo be on top of the cover image? It being below just seems weird and takes up space).

    Also, I spy a skin switcher - guessing since Harmony is now joining Peace on this, one can at least for now expect any new v3 themes to incorporate them. Any chance of older themes being updated to have one too?

    @julian said in December 2022 Design Preview (Harmony Theme):

    Astute readers will probably have already discovered the theme name, since we've been iterating on our theme in public 😼

    It seems it's not that public, considering the URL returns a 404 and I can't find anything with harmony in its name under NodeBB org - I'm guessing someone forgot to change the visibility from private to public πŸ™‚
    (or it was hidden before I made this reply for some reason)


  • RE: Inspecting mongo db on server, and keys?
  • oplik0O oplik0

    @eveh

    the nodebb seems very small given I have already uploaded some posts and photos on the forum?
    what data may be stored in local? it is much bigger but I dont have anything else running on that machine?
    Photos aren't stored in the database directly (they're usually just stored along NodeBB files in a dedicated folder, but some plugins may change it to use cloud storage etc.), so all you're left with are some bits of text, which doesn't take that much space.

    Don't get me wrong - the DB can grow quite a bit, it just requires a lot of posts.

    While your main question was answered already, I'll just note that you can find more on NodeBB DB schema in the documentation: https://docs.nodebb.org/development/database-structure/


  • RE: Bringing Back Better Bootswatch!
  • oplik0O oplik0

    @gotwf The themes are from Bootswatch, so I suspect you should contact them with suggestions πŸ™‚


  • RE: Possibility to change post URL/routing?
  • oplik0O oplik0

    @rongcuid said in Possibility to change post URL/routing?:

    1. BBCode support

    I unfortunately don't have the time right now to participate in this discussion more, but I might be able to help with thais part: there is actually a fairly ancient but still functional plugin for BBCode support already πŸ™‚ https://github.com/psychobunny/nodebb-plugin-vbcode-to-markdown

    The only issue I noticed is that it doesn't show in preview (which I think should be fairly simple to fix)

    Note that it's support, not first-class support - the default with it would still be markdown, but most BBCode will just work too by being translated to md before it's displayed.


  • RE: [nodebb-plugin-meilisearch] use MeiliSearch as a full-text search backend
  • oplik0O oplik0

    @rongcuid said in [nodebb-plugin-meilisearch] use MeiliSearch as a full-text search backend:

    At the same time, it might be nice to mention it in the README.

    Good idea, added a warning. Hopefully it won't be needed for long πŸ™‚


  • RE: [nodebb-plugin-meilisearch] use MeiliSearch as a full-text search backend
  • oplik0O oplik0

    @rongcuid Sorry, since I was setting up my dev environment before I got ACP working I didn't entirely think out error messages - I'll correct this but unfortunately I'm can't do it this week so it'll take until early october.


  • RE: Eventual migration to TypeScript
  • oplik0O oplik0

    @julian I think it might be possible with some build tooling magic...

    Importing plugins using CJS is as you mentioned the easy part - await import() works both ways with CJS, and in a pinch you can use createRequire to get require back in ESM.

    This even works with ESM plugins by just changing src/plugins/index.js to use (await import(libraryPath)).default (and ideally adding some way to resolve main from package.json since currently that change needs library in plugin.json to be defined πŸ™‚ )

    The other way though is the problem - calling require on ESM will fail. So the big issue are the require.main.require calls.

    However, I imagine it should be possible to fix that in the build step - though it would require building the server-side code too (which TS will require anyway). I'm not sure how one would go about it with Webpack, but Rollup already has a plugin for converting CommonJS to ESM (since it outputs ESM). I'm not sure how it handles require.main.require, but it probably could be transformed to work correctly as just a relative require before that plugin runs (or the plugin could just be improved to handle that).

    But ultimately if there are other breaking plugin changes on the roadmap maybe just pairing migration to ESM with them would be simpler. Since importing CJS from ESM mostly works fine, I imagine it would be similar in difficulty to the switch to require.main.require for most plugins.


  • RE: [nodebb-plugin-meilisearch] use MeiliSearch as a full-text search backend
  • oplik0O oplik0

    @sharonyue said in [nodebb-plugin-meilisearch] use MeiliSearch as a full-text search backend:

    BTW, what version of nodebb should I use? I am using 1.18.6

    Sorry, for late reply, I had to check and didn't have time to do it yesterday - it actually wasn't compatible with NodeBB <2.0.0, but it turns out to have been a simple change (though now the plugin will make NodeBB show a deprecation warning when used in NodeBB v2 - so note that I'll abandon support for 1.x if the deprecated argument is removed).

    It should work now sinve v0.5.7, but note that I won't be testing the plugin on 1.x branches. I'm mainly focused on latest NodeBB versions (so I'm normally testing it with v2.5.2 now), so any updates may break the older ones (I'll try to fix what's reported, unless it makes the experience on the latest version worse, in which case the newer one takes precedence). So even more "use at your own risk" than the general warning here πŸ™‚

    TL;DR - I'd recommend using current NodeBB versions (v2, ideally v2.5.2), but it should work with 1.18.6 now too.

    Does it mean I need to install Meilisearch first?

    Yes, I don't think there is any supported way to embed Meilisearch and even if there was, it ultimately is separate software from NodeBB just like the database, so I prefer this model. You can find a quickstart guide with installation instructions (including quick setups for dedicated guests on a couple of cloud platforms) in Meilisearch documentation: https://docs.meilisearch.com/learn/getting_started/quick_start.html#setup-and-installation


  • RE: Image upload plugin in nodebb 2.x
  • oplik0O oplik0

    More specifically, the issue is that it defines a static directory in plugin.json:

    "staticDirs": {
      "s3": "public"
    },
    

    But doesn't have it.

    It seems to be an artifact of people forking and updating it without fully understanding what exactly it was doing - looking back at some history at some point someone moved the templates from public/templates to just templates/ and apparently NodeBB wasn't enforcing that directories have to exist at that point, so it wasn't noticed and all future forks inherited this bug.

    NodeBB is IMO doing fine here - a lack of directory a plugin declared to have might suggest some issue with the installation or the plugin itself (for example a typo in a path). A plugin incorrectly declaring something it doesn't use can't really be distinguished from these issues.

    Also, @julian while .gitignore works, I feel like it's a bit of abuse of that feature and the name is misleading (upon seeing a directory with .gitignore my first thought would be that something is supposed to go there but will be ignored. And I feel without knowing much about git I might've assumed it meant the whole directory would be ignored by git - the opposite of what it actually does). I personally prefer the convention of using an empty file named .gitkeep (or just .keep), since it more obviously refers to keeping the directory and wouldn't have any other potential impact on files included by git.

    EDIT: TL;DR of the issue:
    why would nodebb do this


  • RE: Systemctl fails to restart nodebb, except as root
  • oplik0O oplik0

    You can try checking if just increasing the node memory limit (this is technically not the full limit of what Node can use, but most cases it can be considered that; Also it governs gc, so even if it's not reaching it, who knows, perhaps the issue is caused by aggressive gc) would work: add --max-old-space-size=<value in MB> in cli parameters to node or via a NODE_OPTIONS=--max-old-space-size=<value in MB> env var.
    I think the default for 64-bit systems is 2GB, but I'm not sure...

    This obviously isn't a real fix even if it works, but would at least clarify if it needs more memory when running as a non-root user for some reason or if it's purely a permission problem and it'll run out as a user no matter what when it doesn't have proper access to something...


  • RE: Solr searching engine is bad
  • oplik0O oplik0

    I got reindexing working mostly fine, with a live progress bar and actually in the background. So v0.5 should have everything this plugin needs now.

    I'll still look into a possibly better frontend integration with their libraries, but I'd probably need to replace the existing NodeBB search preview. There is also a bit more sorting/filtering I want to pass to Meilisearch instead of leaving it to NodeBB later, but that's not a big deal.

    I'm also considering if some LRU cache for recent searches is needed, but I'll have to test performance on a larger instance than my tiny tests πŸ™‚ I'll probably end up adding one with low TTL though.

    So since it's close to release-ready I created a topic for it: https://community.nodebb.org/topic/16658/nodebb-plugin-meilisearch-use-meilisearch-as-a-full-text-search-backend


  • [nodebb-plugin-meilisearch] use MeiliSearch as a full-text search backend
  • oplik0O oplik0

    Meilisearch for NodeBB

    https://github.com/oplik0/nodebb-plugin-meilisearch

    This plugin allows you to use Meilisearch as search backend instead of the database or Solr (see this topic for why some want to switch)

    Installation

    Install via plugins page in the ACP or run this command in NodeBB folder:

    npm install nodebb-plugin-meilisearch
    

    Configuration

    1. install this plugin via ACP or by running npm install nodebb-plugin-meilisearch
    2. Activate in the plugins page (note: make sure dbsearch plugin is disabled)
    3. Rebuild and restart NodeBB
    4. Check that the plugin successfully connected to Meilisearch and adjust the connection settings in /admin/plugins/meilisearch if necessary.
    5. Meilisearch should start indexing all posts as soon as it connects for the first time, but if that didn't happen you can start reindexing from the ACP page
    6. Adjust other search settings as you see fit. Defaults should be good enough for most use cases though.

    Notes

    • This plugin requires a Meilisearch instance or the same server or somewhere else your NodeBB instance can access
    • This plugin conflicts with other search plugins and will not work if nodebb-plugin-dbsearch is active
    • While it should work fine, note that it's still not well tested. User beware πŸ™‚

  • RE: September 2022 Design Preview (New Base Theme)
  • oplik0O oplik0

    @julian said in September 2022 Design Preview (New Base Theme):

    This is one of the bigger changes. I swear I talked about the taskbar in one of my blog posts, but I can't seem to find it now.

    You did, I remember it in the context of what v2 was supposed to be. Quickly looking for that found me this post: https://nodebb.org/blog/slice-and-dice-bringing-nodebb-back-to-basics/

    Though about

    We had to think about just how many users utilised multiple composers

    I use mutliple composers, so I'm glad there seems to be a plan for improving that experience. As I mentioned, I feel the taskbar style isn't ideal due to the guesswork to find the one composer you want if you have more than two, and it places a hard limit on the usable number (about 15 for my screen size at least, though I haven't reached anywhere close to it outside of testing)


  • RE: example/best practice for managing a list of strings
  • oplik0O oplik0

    @sdetweil
    There is documentation on how templates work in the benchpress repository - that is the templating engine NodeBB uses: https://github.com/benchpressjs/benchpressjs/tree/master/docs

    There is a link to the engine in getting started development docs (https://docs.nodebb.org/development/) but I admit that it's not intuitive.

    The documentation for working with included helpers and client-side modules is basically nonexistent though, I mostly just look at other plugins (quickstart is a good reference for common use cases) and ultimately just look at the code. For the included setting types you can see it here: https://github.com/NodeBB/NodeBB/tree/master/public/src/modules/settings


  • RE: September 2022 Design Preview (New Base Theme)
  • oplik0O oplik0

    I really like the right side bar - especially it being the place where the composer hides (I'm honestly not a fan of the current bubbles, especially for writing multiple posts at the same time, since they go up without limit and the only way to find which topic is which one is to go through them all). I'm hoping behind it will be some list to choose from if you have multiple sessions open πŸ™‚

    Also, while I do like the hiding left side bar, it seems to move icons up when you do so, because of the logo being smaller vertically than the banner. I feel like it'd be a good idea to keep at least the functional icons (the hide/reveal icon might look weird if it's not directly below the logo) at the same height both when revealed and hidden.

  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Home
  • Categories
  • Recent
  • Popular
  • Tags
  • Users
  • Groups
  • Documentation
    • Home
    • Read API
    • Write API
    • Plugin Development
  • Login

  • Don't have an account? Register

  • Login or register to search.