A small library that allows GitHub to be used as a wiki
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
dist
example
src
.gitignore
LICENSE.txt
README.md
package.json
webpack.config.js

README.md

Wikihub

Wikihub is a small library that allows GitHub to be used as a wiki. It provides two methods, load which loads the text from a file on GitHub and save which commits changes to a file, creating a fork for the repository if necessary, and submits a pull request to the repo's origin.

wikihub-piclite-gif-crop

Examples

Jekyll Anonymous Example

Jekyll Collaborative Example

Usage

Copy the wikihub.min.js file from the dist folder into your project. This exposes the wikihub object globally.

Load

wikihub
  .load({
    token: 'h38d8h48fj49fji39903kfg84hhf84994jff8940',
    owner: 'jake-cool-user',
    repo: 'awesome-wiki',
    branch: 'master',
    path: '_posts/2015-08-01-whatever-happened-happened.md'
  })
  .then(function(text) {
    /* ...do something with text */
  })
  .catch(function(err) {
    /* ...something went wrong */
  });

Save

wikihub
  .save({
    token: 'h38d8h48fj49fji39903kfg84hhf84994jff8940',
    owner: 'jake-cool-user',
    repo: 'awesome-wiki',
    branch: 'master',
    path: '_posts/2015-08-01-whatever-happened-happened.md',
    text: 'This is what this post should really be about.'
  })
  .then(function(pull) {
    /* ...changes have been commited */
  })
  .catch(function(err) {
    /* ...something went wrong */
  });

The following are optional parameters:

  • message (defaults to "Wikihub changes...") is the commit message for this save.
  • forkBranch (defaults to "wikihub") is the branch on the user's fork that the commit will be saved to.
  • title (defaults to "Wikihub Changes") is the title of the pull request. Only used when the pull request is made and not changed with subsequent commits.
  • body (defaults to "Automatically generated by wikihub") is the body of the pull request. Also only used when the pull request is made and not changed with subsequent commits.

Token

Wikihub uses an oAuth token to authenticate with GitHub. This can either be created using oAuth web flow or through Github's website.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request