Share badges on social media

Hello world,

I’m trying to enhance my community activeness. In order to do so, I’d like my members to be able to brag about obtaining a badge on social media. It would reinforce the gamification aspect of the forum and lead the community into wanting to obtain badges, thus increasing the overall activity.

Is there a way to share a badge on social media (mainly facebook and twitter) ? If not, what kind of development would it take to do so ? I’m willing to make a plugin if it’s what it takes.

Best regards,

Rémi

1 Like

I think that adding the necessary og tags on the badges page is welcome as a PR to the core.

1 Like

Yeah, that too, it would be nice to have the icon and description in the metadata. So if I understand you correctly, metadata description should be handled in the core of the forum and the share button should be a plugin, right ?

Yes!

I’m not sure yet.

Do the metadata first, and wait for @codinghorror call on the share button ok?

I’ll try to see what I can do, I never dived into the core of discourse and I’m not really familiar with ruby. But that sounds like a fun challenge :wink:

1 Like

I believe metadata description to the badges page can be added by making a new view badges/show.html.erb which has crawlable_meta_data as content_for head.

I also changed the show method in badges_controller to render to :show , instead of default/empty .

Am unable to see the changes (og tags) in the local instance of discourse set up using vagrant. I am new to the community and would appreciate help with this!

1 Like

Hi 7ev3n welcome to the forum

Did you see this?

Thank you :slight_smile:

Yes. I have gone through the resources provided there, and have a basic idea about the code structure of Discourse.

That sounds correct.

That is odd. I can see the og (Open Graph) tags just fine on my local dev instance if I create badges/show.html.erb file and removing render "badges/show" in controller.

Perhaps try again, and see index method in CategoriesController for reference implementation?

2 Likes

Am able to see the change now. Instead of render :show, I left it as render only.

I have submitted a PR for the same. Should the share button be added as a plugin, or in the core?

2 Likes

Might as well start it off as a plugin; will be a worthwhile exercise :wink:

This feature is now available via:

https://github.com/discourse/discourse/commit/402eaaa7733405f926d04f23704b1a69e8088890

Thanks @7ev3n.

7 Likes