|
| 1 | +--- |
| 2 | +layout: default |
| 3 | +title: Test |
| 4 | +ignore: true |
| 5 | +--- |
| 6 | + |
| 7 | +# How tutorials.github.com Works |
| 8 | + |
| 9 | +This site works by using [Github Pages](http://pages.github.com/) to automatically generate and serve content. Github Pages works by using by using [Jekyll](https://github.com/mojombo/jekyll), a "blog-aware, static site generator in Ruby." Since it's a completely static site, all interactions are done through javascript on a per-page basis. |
| 10 | + |
| 11 | +## Location and Markup Language |
| 12 | + |
| 13 | +All tutorials are stored in the `/pages` subdirectory of the repo. Although jekyll supports several different markup languages such as markdown, textile, etc., tutorials.github.com has only been tested using markdown (for now). |
| 14 | + |
| 15 | +## Syntax |
| 16 | + |
| 17 | +Since Github Pages are (unfortunately) not parsed using [Github Flavored Markdown](http://github.github.com/github-flavored-markdown/), we use the [kramdown](https://github.com/gettalong/kramdown)'s extended markdown syntax to enable things like syntax highlighting and allowing markdown parsing _within_ an html tag. |
| 18 | + |
| 19 | +## Structure |
| 20 | + |
| 21 | +Tutorials have, at a minimum, the following structure: |
| 22 | + |
| 23 | +{% highlight html %} |
| 24 | +<div markdown="1" class="tutorial" data-facets='{"some": "json"}'> |
| 25 | +some _markdown_ content |
| 26 | +</div> |
| 27 | +{% endhighlight %} |
| 28 | + |
| 29 | +Let's explore each in more detail. |
| 30 | + |
| 31 | +### data-facets |
| 32 | + |
| 33 | +These data attributes that are used to list key-value pairs that javascript uses to "facet" the document with. We store JSON because jQuery automatically converts HTML5 data attributes into `camelCase`, so we'd lose formatting. |
| 34 | + |
| 35 | +### markdown="1" |
| 36 | + |
| 37 | +The `markdown="1"` attribute to tell kramdown to parse the content of the divs as markdown instead. Because of this internal parsing, is it recommended to outdent the content inside the div (that is, type your content without leading whitespace), like in the example above. |
| 38 | + |
| 39 | +### class="tutorial" |
| 40 | + |
| 41 | +Tutorial divs should have `class="tutorial"` to separate them from internally-nested divs. I haven't tested nesting divs, but they should work. |
| 42 | + |
| 43 | +## Faceting |
| 44 | + |
| 45 | +We parse all the tutorials on a page and generate a sidebar so that users can drill-down to the most relevant tutorial. For example, a document like this: |
| 46 | + |
| 47 | +{% highlight html %} |
| 48 | +<div markdown="1" class="tutorial" data-facets='{"Operating System": "OS X", "Package Management": "Homebrew"}'> |
| 49 | + ... |
| 50 | +</div> |
| 51 | + |
| 52 | +<div markdown="1" class="tutorial" data-facets='{"Operating System": "OS X", "Package Management": "Macports"}'> |
| 53 | + ... |
| 54 | +</div> |
| 55 | + |
| 56 | +<div markdown="1" class="tutorial" data-facets='{"Operating System": "Ubuntu", "Package Management": "Source"}'> |
| 57 | + ... |
| 58 | +</div> |
| 59 | +{% endhighlight %} |
| 60 | + |
| 61 | +should show the following sidebar: |
| 62 | + |
| 63 | + Operating System (2) |
| 64 | + OS X (2) |
| 65 | + Ubuntu (1) |
| 66 | + |
| 67 | + Package Management (3) |
| 68 | + Homebrew (1) |
| 69 | + Macports (1) |
| 70 | + Source (1) |
| 71 | + |
| 72 | +If you clicked on the "Source (1)" `li` then you should see this: |
| 73 | + |
| 74 | + Operating System (1) |
| 75 | + Ubuntu (1) |
| 76 | + |
| 77 | + Package Management (3) |
| 78 | + Source |
| 79 | + |
| 80 | +## Installing tutorials.github.com Locally |
| 81 | + |
| 82 | +First we need to [https://github.com/tutorials/tutorials.github.com/fork_select](fork the repo). Then we need to clone it: |
| 83 | + |
| 84 | +{% highlight sh %} |
| 85 | +git clone git@github.com:some_user/tutorials.github.com.git |
| 86 | +{% endhighlight %} |
| 87 | + |
| 88 | +Now we need to install some gems using bundler: |
| 89 | + |
| 90 | +{% highlight sh %} |
| 91 | +cd tutorials.github.com |
| 92 | +bundle |
| 93 | +{% endhighlight %} |
| 94 | + |
| 95 | +Then start the jekyll server: |
| 96 | + |
| 97 | +{% highlight sh %} |
| 98 | +jekyll --server --auto |
| 99 | +{% endhighlight %} |
| 100 | + |
| 101 | +Now you can browse to [http://localhost:4000](http://localhost:4000) and see the site running locally. |
| 102 | + |
| 103 | +{% highlight sh %} |
| 104 | +jekyll --server --auto |
| 105 | +{% endhighlight %} |
| 106 | + |
| 107 | +## Creating a New Tutorial |
| 108 | + |
| 109 | +Creating a new tutorial is easy. All you need to do is create a new file in the `pages` directory, but it's a lot easier if you just start from the `template.md` file: |
| 110 | + |
| 111 | +{% highlight sh %} |
| 112 | +cp pages/template.md pages/my-new-tutorial.md |
| 113 | +{% endhighlight %} |
| 114 | + |
| 115 | +Then just follow the guide and `pages/hello-world.md` as an example. |
| 116 | + |
| 117 | +Once you're done (and it looks good when running locally), send me a pull request and I'll merge in your new page, regenerate the table of contents and other cleanup, and then push it to github. |
0 commit comments