Skip to content

Senth/discourse-map

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Discourse Map

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

Installation

There are quite a few steps to install this script.

  1. Download this python script, either with git or downloading a zip-file.
  2. Rename config.example.py to config.py in discoursemap
    1. Open config.py
    2. Update API_USERNAME to your Discourse username.
    3. If you want to show all users (included suspended) change SHOW_SUSPENDED to True.
    4. We will update the rest of the config in other sections.
  3. Get Discourse user API key.
    1. 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.
    2. Update API_KEY to the Discourse API key you got.
  4. Create a new Google Spreadsheet.
    1. Write Name in A1, Location in B1, and Avatar in C1.
    2. Update SHEET_ID in config.py to your sheet id. You can find the sheet's id in the url, it's the part between spreadsheets/d/ and /edit#gid=99999.
    3. If you changed the sheet name, be sure to update the SHEET_NAME as well.
  5. Create Google Spreadsheet API authorization. This is the most advanced part.
    1. Use this wizard.
    2. Choose Create a project.
    3. Click Go to credentials.
    4. Click Cancel at the bottom.
    5. Click Create credentials and choose OAuth client ID.
    6. Click Configure consent screen
    7. Fill in Product name shown to users with Discourse map or something similar and click Save.
    8. Choose Other, name it Discourse map or similar and click Create.
    9. Click OK.
    10. Download the client_secret.json by clicking on the download icon furthest to the right.
    11. Save the client_secret.json file (with that exact name) in the same directory as config.py
  6. Run the script by being in the discourse-map directory (with a -), run it with this command: python -m discoursemap
    1. 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.
    2. Run the script again (to update the spreadsheet).
  7. Create a map in [Zeemaps.com].
    1. Click Map my Spreadsheet.
    2. Select Google Drive and click Fetch My Spreadsheets.
    3. Select the spreadsheet you created earlier.
    4. Under Basic
      1. Select Default country to the appropriate country.
      2. Select City to Location.
      3. Check all three checkboxes.
      4. (optional) Select Default color to your choice.
    5. Under Media.
      1. Select Photo URL to Avatar.
    6. Click Submit.
  8. Done :)

About

A web scraper for Discourse that outputs the active users' location into a Google Spreadsheet which can be used by Zeemaps to display everyones location

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages