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

  • Default (No Skin)
  • No Skin
Collapse
v3.5.2 Latest
Buy Hosting

Topic preview

Scheduled Pinned Locked Moved Plugin Development
19 Posts 3 Posters 453 Views
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    razibal
    wrote on last edited by
    #7

    Please? I think this would be a useful route as it would make nodeBB posts embeddable in any external website

    1 Reply Last reply
    0
  • julianJ Offline
    julianJ Offline
    julian GNU/Linux
    wrote on last edited by
    #8

    In looking at this briefly, I see that we already have a GET route for a post, would this work for you?

    1 Reply Last reply
    0
  • R Offline
    R Offline
    razibal
    wrote on last edited by
    #9

    This would be a little different in that I wouldn't need to get the content and then render myself. My thought, at least for the plugin was that the route /preview/{pid} would provide a rendered post that could then be embedded in an iframe.

    julianJ 1 Reply Last reply
    0
  • julianJ Offline
    julianJ Offline
    julian GNU/Linux
    replied to razibal on last edited by
    #10

    @razibal https://github.com/NodeBB/NodeBB/pull/11475

    1 Reply Last reply
    1
  • R Offline
    R Offline
    razibal
    wrote on last edited by
    #11

    Hi guys, the plugin to return the embeddable post works great. However, I noticed that there appears to be caching of the results somewhere in the pipeline. If I make a change to the post, its not reflected in the posts.getPostSummaryByPid call until after a restart. Is there a way to force retrieval of the refreshed post content?

    1 Reply Last reply
    0
  • barisB Offline
    barisB Offline
    <baris> NodeBB
    wrote on last edited by
    #12

    How are you editing the post? When a post is edited through nodebbs post.edit method the cache is cleared so posts.getPostSummaryByPid should return the latest data.

    1 Reply Last reply
    0
  • R Offline
    R Offline
    razibal
    wrote on last edited by
    #13

    @baris, It's just a normal post edit and the action:posts.edited hook fires as I have another plugin that waits for this hook

    1 Reply Last reply
    0
  • R Offline
    R Offline
    razibal
    wrote on last edited by
    #14

    @baris my bad, I was using a different test instance that was connected to the same DB. You are absolutely correct, the cache is cleared when using the same instances.
    Thanks!

    1 Reply Last reply
    1
  • R Offline
    R Offline
    razibal
    wrote on last edited by
    #15

    One more question, how are events bound to template elements? As an example, lets say I want to include the post/upvote or post/downvote components in a custom template, how would these links get bound to an action that ultimately calls the appropriate upvote/downvote method?

    1 Reply Last reply
    0
  • barisB Offline
    barisB Offline
    <baris> NodeBB
    wrote on last edited by
    #16

    It happens here https://github.com/NodeBB/NodeBB/blob/master/public/src/client/topic/postTools.js#L124-L130. The module that handles upvoting is https://github.com/NodeBB/NodeBB/blob/master/public/src/client/topic/votes.js. When a click is detected on the vote buttons this function is called https://github.com/NodeBB/NodeBB/blob/master/public/src/client/topic/votes.js#L73.

    So if you want the upvoting on a different template you need to add the click handlers and call votes.toggleVote and pass the correct parameters like we do.

    1 Reply Last reply
    1
  • R Offline
    R Offline
    razibal
    wrote on last edited by
    #17

    @baris Thank you, that works perfectly. Now the only thing left is listening for the change to update the vote count. I aplogize for the many questions but I've been working so long in the react/vuejs ecosystem that I've forgotten how data bindings are handled in jquery.

    1 Reply Last reply
    0
  • barisB Offline
    barisB Offline
    <baris> NodeBB
    wrote on last edited by
    #18

    That happens here https://github.com/NodeBB/NodeBB/blob/master/public/src/client/topic/events.js#L43-L45,
    when a vote happens (upvoted,downvote or unvote) an event is sent from the server. We listen to that with socket.on(eventName, handler) and update the UI in this function https://github.com/NodeBB/NodeBB/blob/master/public/src/client/topic/events.js#L224

    1 Reply Last reply
    1
  • R Offline
    R Offline
    razibal
    wrote on last edited by
    #19

    Perfect, as always your help is much appreciated.

    1 Reply Last reply
    1

Copyright © 2023 NodeBB | Contributors
  • Login

  • Don't have an account? Register

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