So I have started developing a simple plugin called who is in?. Before I get to the technical problems, let me explain what it will do (when finished), it will look something like this mockup:
The idea is to easily embed a signup or RSVP button into a post by using a magic phrase such as "who is in?". The plugin would then insert a button in place. Others viewing the post see the call to join and can add their avatar to a list next to the button by pressing it. This I hope will be a really simple and light way to ask people to signup for something.
I started based off of the quickstart plugin but did not make it very far. I have only got as far as displaying the button. Here is the code: https://github.com/modlabca/nodebb-plugin-whoisin
I am a little stuck now, and could not find my way in the docs or examples I have looked at so far. Here are a couple of questions I have so far:
- How can I load a template+JS file where the who is in button will be displayed? I tried doing something like below but I could not figure out how to get this working:
whoisin.parse = function(postContent, callback) {
postContent = postContent.replace(/Who is in\?/gi, mainTemplate);
/*
app.render('templates/views/main', {title: 'who is in test'}, function(err, html) {
if (err) {
console.log('ERROR rendering template: ', err);
}
console.log('rendering the whoisin template: ', html);
});
*/
callback(null, postContent);
};
where templates/views/main.tpl
is the template I want to use instead of the hard coded mainTemplate
value above. I am not sure how to connect the two here. In other words, I think I need to render the template with the right context and JS file in place of "Who is in". Is that the right approach? If so, how can I do that?
- Is there a way for me to add some custom data to a post?
In this case I will be getting the id of current logged in user, and when they click on the button I would need to store that id somewhere. I could not find this in the docs. How would you suggest I store this data?
I am fairly new to all of this, so any help will be appreciated