• So I am in the process of writing a simple plugin for nodeBB which replaces this: [mtg]<card name>[/mtg] with a special link that shows the card on mouse hover.

    Using the "writing your first plugin" guide, I have written a quick plugin which parses the text correctly, but once the element [mtg][/mtg] is parsed, each letter I type after this element creates another AJAX request. As you know this could become a problem very quickly.

    Does anyone have a solution for this? I am currently looking over the XKCD plugin to see how @julian solved it.

    Note: I'll be posting screenshots of the plugin once it is finished.


  • I'm pretty sure you can cache the response if you're using an api to stop repeat calls, unfortunately the composer refreshes embedded media after key press, so you're only other alternative would be to wait until the post is submitted before fetching the info you're looking for.

    This is what I did with the youtube-lite plugin I made. Look in static/lib for more info. My main.js file has the same call twice at two different hooks. It's hacky, but there's a reason I did it. Not that I remember why. 😆

    But basically in the composer it shows the YouTube url, then when you post, it fetches the data and creates the embedded media.

    Also what is MgT? Is it like dungeons & warhammer? (In before down votes from the entire world for not knowing what it is) 😆 (I know it's card based, that's about it)

  • Admin

    Magic the gathering. Used to love that game. Have a mox diamond that I should have probably ebay'd off 10 years ago when it was worth $200 something. Now the postage is probably more expensive than that card.

    EDIT: @a_5mith time for me to hax your downvotes... dungeons & warhammer. my goodness.

    EDIT2: @Nivix don't forget to submit your plugin for our plugin competition!


  • @psychobunny said:

    EDIT: @a_5mith time for me to hax your downvotes... dungeons & warhammer. my goodness.

    An old friend of mine used to paint them as a hobby, (warhammer, not dungeons), pretty sure he left his dungeon cold and damp. 😆

    I've never been into those sorts of games though, not since the rune based game about scaping. I've never played WoW, or dota2 etc. mainly because I know I'll get killed by some basement nerd shouting old 4chan memes over a microphone. This is also the reason I don't play call of duty. 😄

  • GNU/Linux Admin

    @Nivix In the xkcd plugin, I save the ajax call response in an lru-cache (with a timeout of something like an hour or so), that's all. Quick and effective 😄

  • Admin

    Haha played runescape as well. And WoW. Man, the amount of hours of my life that I could have spent doing more productive things

    EDIT: In WoW there's a command called /played I think, and it tells you how many hours you've played. Last time I checked it a few years ago was something like 6 months I think. SIX MONTHS.

  • GNU/Linux Admin

    As a point of reference, we had launched NodeBB v0.0.7 by the 6 month mark, and v0.1.0 was not far away 😛


  • Wow, I am really falling in love with this community! You guys are the best. 😄

    So it appears there are two possible solutions--(1) cache the response to stop repetitive API calls or (2) parse the text after the post is submitted (not while composing or editing). Am I correct in assuming that the first option will prevent a user from posting multiple cards within the same post?

    @a_5mith MtG is what psychobunny said. Magic the Gathering is something invented by Wizards of the Coast--same company which developed D&D. It is a card game of good quality, and although I don't play it as much as I did in college it's a great way to spend time with friends. Also i do NOT recommend you start playing--it will absorb your money, your mind, your time, and eventually your soul.

    Oh and +1 for reference to warhammer. 😄

    @psychobunny Mox is still a viable card in the Commando/EDH tournaments. You could (probably) auction it at a decent price. Depending on the condition.

    And this isn't a competition worthy plugin. MtG has too small of a niche. No, I need something more...palpable by the masses.. hmmm


  • @Nivix said:

    Wow, I am really falling in love with this community! You guys are the best. 😄

    So it appears there are two possible solutions--(1) cache the response to stop repetitive API calls or (2) parse the text after the post is submitted (not while composing or editing). Am I correct in assuming that the first option will prevent a user from posting multiple cards within the same post?

    No, it will just stop looking for the same "card" if it's in the cache. each [mtg]card[/mtg] would be cached.


  • Then that is exactly what I am looking for. Thanks!

Suggested Topics

| |