This branch has a small Node application that automatically transforms prose definition contributions into data files.
Once configured, deployed, and set as a web hook in Github, this app will take care of syncing any contributions inside the definitions directory of the master branch as JSON equivalents on the gh-pages branch.
First, register a new OAuth token from Github, tied to the user or organization that runs the glossary project this is meant to integrate with. e.g., for unitedstates/glossary, you register an application with the unitedstates organization.
You can configure the app by either:
- copying
config.js.exampletoconfig.jsand filling in fields (lower case below). Good for local or traditional deployment. - not creating a
config.js, and using environment variables (upper case below). Good for Heroku or other PaaS deployment.
The fields you definitely need to fill in are:
github_token/GITHUB_TOKEN: Your OAuth token you registered with Github above.committer_name/COMMITTER_NAME: Full name to attach to commits this app makes.committer_email/COMMITTER_EMAIL: Email address to attach to commits this app makes.
You may want to change the following fields:
owner/OWNER: The user or organization handle owning the repository, defaults tounitedstatesrepository/REPOSITORY: The name of the repository, defaults toglossaryfrom_branch/FROM_BRANCH: The branch with prose definitions, defaults tomasterto_branch/TO_BRANCH: The branch with data definitions, defaults togh-pages
You can also change the port it runs on using a port field in config.js, or a PORT.
This project is in the dat branch, so when deploying to Heroku, run:
git push heroku dat:masterThis will push this repository's dat branch to Heroku's master branch, which will trigger the deploy.
I found testing easiest by forking the repository, and using a convenient tunnelling service like ngrok to make a port on my development machine (my laptop) accessible to the public Internet. Then I added the URL ngrok created to my fork's webhooks and could easily test during development.
You can use the /refresh endpoint with a path parameter to trigger a reprocessing of every definition inside that path.
For example, visiting:
/refresh?path=definitions/congressWill trigger a regeneration of each definition inside definitions/congress.
This is not recursive - it will only affect definitions directly inside the given directory.