After some more careful examination, I think the Fairphone setup is actually not that well integrated with the forum as it can be. It can be made much easier.
Fairphone at the moment uses this yaml formatted topic to populate the map. Where the location name is used to compile an email address for the group. The coordinates are manually inserted and they manually maintain a list of users. Furthermore, they use a boolean to switch a listing on or off or indicate if it’s active or not. This yaml file is then converted to json and then looped through it to compile the listing for the map as well.
We could simplify this. We could simply use the json layout of our groups. If a group is not active, it’s not listed. So when the parser loops through it, it drops from the map/list. We can show the amount of users, since the
user_count is listed there. And if a group is listed on the forum, but has no members, then it should not be on the map with the email address. Because then no one will receive those emails.
name of the group is e.g.
chapter_netherlands, we could do a substring replacement for the
_ with a
- and that then becomes our email address. We could also filter based on the name, if it starts with
chapter, process it. Then we can split the name, e.g.
chapter_netherlands based on the
_ and then use a public API to get some coordinates for
netherlands and put the
title of the group, e.g. “Chapter Netherlands” on the map with those coordinates.
The only “downside” is that we won’t have flags this way. Maybe there is a public API that can give us the correct emoji for a flag based on
amsterdam, like . But I’ll drop that feature. The map shows where it is, flags may be nice for a future iteration of this, if needed at all.
Edit, yes, I think I’ll create my own version of this which will be even simpler and easier to maintain than the Fairphone one.
Another edit: I’ll make a theme component out of this, for Discourse. That way I inherent the security maintenance from the Discourse devs and benefit from their security layers and libraries. But first a simple proof of concept will be made.
So since the plan changed, a new checklist of todo’s.
Get data source to extract all necessary data (chapter name, email address, members and if the chapter is considered active) (Discourse API Docs) - https://tzm.one/g.json?filter=chapter
A way to query cities/countries and get coordinates in return to be used to draw a point on the map (https://nominatim.openstreetmap.org/search?q=amsterdam&format=json)
Or create plugin to add custom field for groups, to include coordinates
Loop through the data
Draw all the chapters on the map
Create all the mail aliases for the groups
Cherry pick some parts from the Fairphone map listing to show and sort chapters with member count, group URL and group email address
Create standalone proof of concept
Expand the proof of concept into a Discourse theme component (Beginner's guide to developing Discourse Themes - theme developers - Discourse Meta)