Discourse Linkify Google Sheets

The plugin allows fetching the linkify Theme Component’s data from a google sheet. For now, you’ll have to install this fork of the theme component but there might be a solution in the future so you’ll be able to use the actual theme component with this plugin.


Setup

Steps:

  1. Create a service account on google cloud Creating and managing service accounts  |  Cloud IAM Documentation
    Google will trigger a download of a JSON file. Store its contents safely.

  2. Create a google sheet and share it with the service account email address.

  3. Paste these lines at the bottom of env section in your app.yml

     GOOGLE_ACCOUNT_TYPE: 'service_account'
     GOOGLE_CLIENT_ID: 'client-id-from-json-file'
     GOOGLE_CLIENT_EMAIL: "service-account-email-address"
     GOOGLE_PRIVATE_KEY:  instructions below
    
  • How to setup GOOGLE_PRIVATE_KEY parameter?

    • Paste the key in the json file to code editor.
    • Use find and replace and replace \n with \\n
    • Copy the result and paste it in app.yml in front of GOOGLE_PRIVATE_KEY
      wrapping it in single quotes ' ' .
  1. Now follow the regular steps of installing the plugin.

  2. Install this fork of the Linkify Theme component.


Plugin Settings

linkify_google_sheet_id: When you open the google sheet in your browser, the long string after https://docs.google.com/spreadsheets/d/ is the spreadsheet id.

linkify_google_sheet_name: You can have multiple sheets in an excel file i.e. Sheet1, Sheet2 etc. That sheet name goes in here.

linkify_google_sheet_cell_range: The columns from where to pick up the linkify data. Its set to first two columns by default. You can change this value. Here’s a guide on the cell ranges work. Introduction to the Google Sheets API  |  Google Developers


:page_facing_up: Get the code

:raising_hand_woman: Request a feature

:bug: Report a bug

Lost?

Thanks for sponsoring the plugin @jrgong

7 Likes

@sam
With this, I’m also proposing a plugin-api method which allows hooking into and replacing the data source of such theme components cleanly.

e.g.

// while using
let data = useDataSource('linkify-data');
// plugins, theme components can do something like this

setDataSource('linkify-data', customDataObject);

The idea here is, some other theme component can setDataSource to another object.
This would allow replacing the data source of such components without changing anything in the code.
Thoughts?

4 Likes

Love it! Thx again for the great work and implementation @fzngagan

2 Likes