Want to create macro that adds or delete record on confluence page

I want to create a macro or plugin which allows me to add or delete records on Confluence page. Records will be Urls of external or internal confluence pages.
Attached is the image which gives glimpse of what is expected.

Please help me out to decide how can I implement this requirement.

Requirement

I’ve written an app with similar functionality which you could take a look at.

Basically you want a macro that renders its data (in my case diary entries, in your case links) as some kind of nice looking list. Then you of course want some buttons that allow you to create, edit and delete those entries/links. Simply create a REST endpoint for each of these.

My macro saves its entries inside its macro body which can be a bit of effort to program as you need to parse and change the page content every time (without breaking stuff!) but it has some nice benefits like getting versioning of the entries for free.

Thank you Sven Schatter very much for your quick reply.
When you say to use Rest API endpoint for Add,Delete button, do you mean to use Rest API to pass data to backend to store data in database.
Do I have to create separate table to store data in this case?

As I mentioned my macro saves the data inside the macro body. The macro body is simple page content. So you if you want to create a new entry, you parse the XHTML/storage format of the page, find your macro, enter a new entry into it’s body tag and then save the modified XHTML.

Of course you could also create your own table or something like that. However then you have some other problems to deal with like how would you delete the data of a macro if it’s been removed from a page, etc.

As I said, storing your macros data inside its body has a lot of benefits and probably also makes the most sense since your data is always “linked to your macro”. But if you rather store it elsewhere you can of course do so.

Thank You Sven Schatter. You advice and example plugin really help me to achieve my requirement. Thank you for your quick response.

1 Like