Skip to content

Instantly share code, notes, and snippets.

@thomasgohard
Last active December 21, 2015 19:49
Show Gist options
  • Save thomasgohard/6356707 to your computer and use it in GitHub Desktop.
Save thomasgohard/6356707 to your computer and use it in GitHub Desktop.
How to enable Jekyll+Prose on a GitHub repository.
language: ruby
branches:
only:
- master
script:
- "bundle exec jekyll build"
- ./build.sh

Enabling Jekyll+Prose on a GitHub repository

This document describes the steps required to enable Jekyll+Prose on a GitHub repository.

The commands included for some of the steps are for Linux (Ubuntu). If you are using Windows or Mac OS X, the commands may differ.

Assumptions

  • The GitHub repository already exists.
  • The GitHub repository is already cloned locally.
  • Variables are identified using the following format: [~variable name~].

Setting up your local environment

  • Install Ruby (Command: sudo apt-get install ruby1.9.3).
  • Install the GitHub Jekyll environment (Command: sudo gem install github-pages).
  • Install Travis (Command: sudo gem install travis).
  • If you need to convert existing documents to Markdown, install pandoc (Command: sudo apt-get install pandoc).

Setting up Travis to automatically update the gh-pages branch

  • Copy the files .travis.yml and build.sh included in this Gist to the the root folder of your GitHub repository's local copy.
  • If the branch from which you build your gh-pages branch is any branch other than master, replace master with the name of your branch in the branches section of .travis.yml.
  • In build.sh, replace [~GitHub user name~] with your GitHub user name and [~GitHub repository name~] with the name of the repository for which you want to enable Jekyll+Prose.
  • Make build.sh executable (Command: chmod +x build.sh).
  • On GitHub, go to Account Settings -> Applications.
  • In the Personal Access Tokens section of the page, click on 'Create new token'.
  • Give the new token a description (e.g., travis-push-[~name of the repository~]) and click 'Create token'.
  • Copy the token (Warning: If you do not copy the token now, you will not be able to view it again later. You will have to destroy the token and create a new one.).
  • From the root folder of your GitHub repository's local copy, encrypt the token and the email address you use for GitHub to protect them (Command: travis encrypt "GH_TOKEN=[~token you copied in the previous step~] GH_EMAIL=[~email you use for GitHub~]" --add global.env).
  • Add the Travis build status indicator to the README.md file of your GitHub repository as described in http://about.travis-ci.org/docs/user/status-images/#Adding-Status-Images-to-README-Files.
  • Sign-in to Travis at http://travis-ci.org/.
  • Click on your avatar/username at the top of the screen to go to your Profile page.
  • In the Respositories tab, click on the Sync now button, then find the repository for which you want to enable Travis and turn Travis on.

Setting up Jekyll+Prose

  • From the root directory of your GitHub repository's local copy, create a blank Jekyll site (Command: jekyll new --force --blank .).
  • Copy the file _config.yml included in this Gist to the the root folder of your GitHub repository's local copy.
  • If the branch from which you build your gh-pages branch is any branch other than master, replace master with the name of your branch in the value of the prose_branch section of _config.yml.
  • In _config.yml, replace [~GitHub user name~] with your GitHub user name and [~GitHub repository name~] with the name of the repository for which you want to enable Jekyll+Prose.
  • Create one or more layout templates in the _layout folder.
  • Create an include for the Prose edit link in the _includes folder (see the file prose-edit-link.html included in this Gist for an example).
  • Add the line editable: true to the front matter of any document for which you want to enable Prose editing; add the line editable: false to the front matter of any document for which you want to disable Prose editing.
  • Add a link to the file CORS_check.js included in this Gist at the end of the <body> of each of your layout templates to enable the fallback to the GitHub Web interface for browsers that do not support CORS, which is required by Prose.
org_name: [~GitHub user name~]
repo_name: [~GitHub repository name~]
prose_branch: master
#!/bin/bash
GH_ACCOUNT=[~GitHub user name~]
GH_REPOSITORY=[~GitHub repository name~]
GH_REMOTE=live
GH_PAGESBRANCH=gh-pages
function error_exit
{
echo -e "\e[01;31m$1\e[00m" 1>&2
exit 1
}
if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then
git config --global user.email ${GH_EMAIL}
git remote add $GH_REMOTE https://${GH_TOKEN}@github.com/$GH_ACCOUNT/$GH_REPOSITORY.git
git checkout -B $GH_PAGESBRANCH
echo "Push to gh-pages branch"
git push -fq $GH_REMOTE $GH_PAGESBRANCH 2> /dev/null || error_exit "Unable to push to gh-pages."
fi
/*!
*
* Web Experience Toolkit (WET) / Boîte à outils de l'expérience Web (BOEW)
* wet-boew.github.io/wet-boew/License-eng.html / wet-boew.github.io/wet-boew/Licence-fra.html
*
*/
/*global jQuery: false*/
(function () {
"use strict";
// Test that browser supports CORS (uses test from prose/boot.js). Intended to reroute to fallback when Prose won't work.
if (!('withCredentials' in new XMLHttpRequest())) {
var edit_link = document.getElementById('edit-page');
if (edit_link !== null) {
edit_link.href = edit_link.href.replace(/^http:\/\/prose\.io\/#/, 'https://github.com/').replace(/\/edit\//, '/blob/');
}
}
}(jQuery));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment