For everyone, there is an Official Discourse affiliate plugin allowing you to automatically add your amazon ID in each links that will be published on your forum.
I want to use this plugin to add other websites that offer Affiliate program. I tried another one few weeks ago but it broke the polls in preview for some reason.
Anyway, I tried working on the official one tonight even if I don't have a lot of knowloedge.
Here is my example : I want to add the french website LDLC. The tag to add on each page is something like this : #52325a32
(this is not my real tag)
There is three links that we usually share :
-
http://ldlc.com/#52325a32
(homepage, I can live without this one)
-
http://www.ldlc.com/b-06b841d7761b563e.html#52325a32
(a cart - useful when we "build" a PC for our users)
-
http://www.ldlc.com/fiche/PB00200087.html#52325a32
(a product page)
I managed to make the easy one work (the product page) with a clever copy/paste because it looked a lot like the amazon one (all caps and numbers, 10 characters). Here is my take on this : https://github.com/iunctis/discourse-affiliate/blob/master/assets/javascripts/lib/discourse-markdown/affiliate.js.es6
But when I tried something else to make all three types of links work, it didn't work. I tried this : https://github.com/iunctis/discourse-affiliate/blob/26ba1cbb8efb49b1abc5cd2e6c92a38769e5f774/assets/javascripts/lib/discourse-markdown/affiliate.js.es6
But with this versions, none of the pages added the tag. I think i'm missing something obvious, it's probably the regex that I messed up. If anyone has a solution, it'd be great
I think I can make everything work if I do three versions of the code. Leave the one that works, plus one for the homepage, and one for the cart. But I think there is a better solution to make it works in one try..
There is nothing urgent here, I can wait.
Thanks for reading