Display all Discourse users' location on Zeemaps.
This script allows you to get all users on a Discourse site and update
a Google Spreadsheet with the users' location
.
By default only active users will be displayed, but this can be changed in config.py
There are quite a few steps to install this script.
- Download this python script, either with git or downloading a zip-file.
- Rename
config.example.py
toconfig.py
indiscoursemap
- Open
config.py
- Update
API_USERNAME
to your Discourse username. - If you want to show all users (included suspended) change
SHOW_SUSPENDED
toTrue
. - We will update the rest of the config in other sections.
- Open
- Get Discourse user API key.
- For this you have to message an admin (if you aren't one yourself).
The admin can generate an user API key here:
admin --> Users --> click on the user --> scroll to Permissions section, API Key, press Generate
. - Update
API_KEY
to the Discourse API key you got.
- For this you have to message an admin (if you aren't one yourself).
The admin can generate an user API key here:
- Create a new Google Spreadsheet.
- Write
Name
inA1
,Location
inB1
, andAvatar
inC1
. - Update
SHEET_ID
inconfig.py
to your sheet id. You can find the sheet's id in the url, it's the part betweenspreadsheets/d/
and/edit#gid=99999
. - If you changed the sheet name, be sure to update the
SHEET_NAME
as well.
- Write
- Create Google Spreadsheet API authorization. This is the most advanced part.
- Use this wizard.
- Choose
Create a project
. - Click
Go to credentials
. - Click
Cancel
at the bottom. - Click
Create credentials
and chooseOAuth client ID
. - Click
Configure consent screen
- Fill in
Product name shown to users
withDiscourse map
or something similar and clickSave
. - Choose
Other
, name itDiscourse map
or similar and clickCreate
. - Click
OK
. - Download the
client_secret.json
by clicking on the download icon furthest to the right. - Save the
client_secret.json
file (with that exact name) in the same directory asconfig.py
- Run the script by being in the
discourse-map
directory (with a-
), run it with this command:python -m discoursemap
- You will now see a link to authorize this script to access your Google Spreadsheets. Copy the link to your browser and authorize this script.
- Run the script again (to update the spreadsheet).
- Create a map in [Zeemaps.com].
- Click
Map my Spreadsheet
. - Select
Google Drive
and clickFetch My Spreadsheets
. - Select the spreadsheet you created earlier.
- Under
Basic
- Select
Default country
to the appropriate country. - Select
City
toLocation
. - Check all three checkboxes.
- (optional) Select
Default color
to your choice.
- Select
- Under
Media
.- Select
Photo URL
toAvatar
.
- Select
- Click
Submit
.
- Click
- Done :)