|
| 1 | +## Background and Design |
| 2 | + |
| 3 | +There are a few things you need to know in order to understand why |
| 4 | +this template is organized the way it is: |
| 5 | + |
| 6 | +1. Git uses the term *clone* to mean "a copy of a repository". |
| 7 | + GitHub uses the term *fork* to mean, "a copy of a GitHub-hosted |
| 8 | + repo that is also hosted on GitHub", and the term *clone* to mean |
| 9 | + "a copy of a GitHub-hosted repo that's located on someone else's |
| 10 | + machine". In both cases, the duplicate has a remote called |
| 11 | + `origin` that points to the original repo; other remotes can be |
| 12 | + added manually. |
| 13 | + |
| 14 | +2. A user on GitHub can only have one fork of a particular repo. |
| 15 | + This is a problem for us because an author may be involved in |
| 16 | + writing several lessons, each of which has its own website repo. |
| 17 | + Those website repositories ought to be forks of this one, but |
| 18 | + since GitHub doesn't allow that, we've had to find a workaround. |
| 19 | + |
| 20 | +3. If a repository has a branch called `gh-pages` (which stands for |
| 21 | + "GitHub pages"), then GitHub uses the HTML and Markdown files in |
| 22 | + that branch to create a website for the repository. If the |
| 23 | + repository's URL is `http://github.com/darwin/finches`, the URL |
| 24 | + for the website is `http://darwin.github.io/finches`. |
| 25 | + |
| 26 | +4. We use Markdown for writing pages because it's simple to learn, |
| 27 | + and isn't tied to any specific language (the ReStructured Text |
| 28 | + format popular in the Python world, for example, is a complete |
| 29 | + unknown to R programmers). If authors want to use something else |
| 30 | + to author their lessons (e.g., IPython Notebooks), it's up to them |
| 31 | + to generate and commit Markdown formatted according to the rules |
| 32 | + below. |
| 33 | + |
| 34 | + **Note:** we do *not* prescribe what tools instructors should use |
| 35 | + when actually teaching. The IPython Notebook, Python IDEs like |
| 36 | + Spyder, and the GOCLI (Good Ol' Command Line Interpreter) are all |
| 37 | + equally welcome up on stage --- all we specify is the format of |
| 38 | + the lesson notes. |
| 39 | + |
| 40 | +5. We use Pandoc to process pages instead of Jekyll (GitHub's default |
| 41 | + conversion tool) because Pandoc supports a much richer dialect of |
| 42 | + Markdown than Jekyll. Like Jekyll, Pandoc looks for a header at |
| 43 | + the top of each page formatted like this: |
| 44 | + |
| 45 | + ~~~ |
| 46 | + --- |
| 47 | + variable: value |
| 48 | + other_variable: other_value |
| 49 | + --- |
| 50 | + ...stuff in the page... |
| 51 | + ~~~ |
| 52 | +
|
| 53 | + and inserts the values of those variables into the page when |
| 54 | + formatting this. Lesson authors will usually not have to worry |
| 55 | + about this. |
| 56 | +
|
| 57 | +6. Using Pandoc instead of Jekyll means that we have to compile our |
| 58 | + Markdown into HTML on our own machines and commit it to the |
| 59 | + `gh-pages` branch of the lesson's GitHub repository. In order to |
| 60 | + keep our source files and generated files separate, we put our |
| 61 | + source files in a sub-directory called `pages`, and compile them |
| 62 | + "upward" into the root directory of the lesson's repository. |
| 63 | +
|
| 64 | + **Note:** while it's usually considered bad practice to put |
| 65 | + computer-generated files under version control, the HTML pages put |
| 66 | + into the lesson's root directory by Pandoc *must* be committed to |
| 67 | + version control in order for the lesson to be displayed properly |
| 68 | + on GitHub. |
| 69 | +
|
| 70 | +7. In order to display properly, our generated HTML pages need |
| 71 | + artwork, CSS style files, and a few bits of Javascript. We could |
| 72 | + load these from the web, but that would make offline authoring |
| 73 | + difficult. Instead, each lesson's repository has a copy of these |
| 74 | + files, and a way of updating them (and only them) on demand. |
| 75 | +
|
| 76 | +One final note: we try not to put HTML inside Markdown because it's |
| 77 | +ugly to read and write, and error-prone to process. Instead, we put |
| 78 | +things that ought to be in `<div>` blocks, like the learning |
| 79 | +objectives and challenge exercises, in blocks indented with `>`, and |
| 80 | +do a bit of post-processing to attach the right CSS classes to these |
| 81 | +blocks. |
0 commit comments