How to append HTML to submitted post content of a file uploaded with the post



  • Hi, I've been watching this project for a while and finally decided to try it out.
    The installation in DigitalOcean was mostly painless (curse you nginx) and now that i have my nodeBB instance running I want to give it a shot at making plugins.

    The Idea is:

    Somebody uploads a specific file (in this case a homebrew beer recipe) along with a post detailing/sharing/bragging about said recipe.

    when will the appropiate hook be to be able to parse the recipe and arrange and pretty it to show it to the users? when the post is saved? when the file is uploaded? when the post is being fetched?

    How are posts saved? in raw text? is the text parsed with Marked when each post loads?
    or are they saved in HTML? (which would make things so much easier for me)

    Looking forward to your answers

    TarekP


  • Admin

    when will the appropiate hook be to be able to parse the recipe and arrange and pretty it to show it to the users?

    The hook you want is probably plugins.fireHook('filter:post.save', postData, next);. This is called right before the post is saved into the database.

    How are posts saved? in raw text? is the text parsed with Marked when each post loads?

    Yes the raw text is saved into the database and parsed on the way out.

    The easiest way for this to work would be to listen to that hook and find the file links in the postData.content they will be in the form [link text](link url). You can grab link url, make sure it exists and read it and then append it to the postData.content in your plugin.


Log in to reply
 


Looks like your connection to NodeBB was lost, please wait while we try to reconnect.