A template for creating an initial plugin for TRC, the Canvassing app hosted by http://Voter-Science.com.
TRC plugins are JScript/HTML that run in the client's browser and make direct calls to the TRC server.
- See https://github.com/Voter-Science/TrcPluginTemplate/wiki for details on Plugins.
- See TrcLib wrappers and utility at: https://github.com/Voter-Science/TrcLibNpm
- These wrappers are written for TypeScript, http://www.typescriptlang.org/ , a superset of JScript. This template pulls in the TypeScript compiler via NPM.
This plugin is a NPM package and uses NPM scripts for build, test, and debugging.
- If you need a TRC account, you can create one at https://start.voter-science.com.
- First install Node and NPM from: https://nodejs.org/en/download/
- Clone/Fork/Copy this repository to a root directory.
- In the root directory, run
npm install
to pull down packages. Packages include the TypeScript compiler, testing framework, core TRC wrappers, etc. This will download them to a 'node_modules' folder.
- Build the plugin. This will compile TypeScript to JScript, run browserify to produce a bundle, and deposit all runtime artifacts in the '/public' directory. That directory is the actual plugin that gets published.
npm run build
- Debug locally:
npm start
. This will actually spin up an NodeJS Express server that hosts the plugin at http://localhost. The host will actually follow the OAuth login flow to let yoiu sign in and select a sheet to use. (see https://github.com/Voter-Science/trc.runplugin for details and other command line options)
And then open a browser window with the URL printed out by that command.
To get the latest version of TrcLib from NPM,
npm upgrade trclib
- This pulls Typescript/JScript wrappers and utility functions from https://github.com/Voter-Science/TrcLibNpm
- Provides TypeScript compilation
- Wires up Browserify so that you can write your plugin as a CommonJs module.
- Includes a pattern for testing the plugin using Mocha and Chai
- Provides a local debugging experience via Express and https://github.com/Voter-Science/trc.runplugin.