Skip to content

Commit 3cf800f

Browse files
author
Tom Clark
committed
Revamped the docs to actually be useful
1 parent 2037cb8 commit 3cf800f

File tree

7 files changed

+159
-116
lines changed

7 files changed

+159
-116
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Examples
88

99
* [Installing MySQL](http://tutorials.github.com/pages/installing-mysql.html)
1010
* [Hello, World!](http://tutorials.github.com/pages/hello-world.html "Hello, World!")
11-
* [Explanation of how it works](http://tutorials.github.com/pages/test.html)
11+
* [Syntax explanation](http://tutorials.github.com/pages/explanation.html)
1212

1313
Contributing
1414
============

index.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ In the future, I'll add cookies so the site will apply filters for you and a cen
1515

1616
This project originated as a full-blown rails app backed by a database, and I reached a point where I needed user accounts and git repos. Dreading that, I threw it all away for a simpler, git-based workflow to upload data. I sincerely hope you enjoy it and find it useful.
1717

18+
All Tutorials
19+
-------------
20+
21+
You can [browse all tutorials here](/pages/table-of-contents.html).
22+
1823
Newest Tutorials
1924
----------------
2025

@@ -27,7 +32,7 @@ Examples
2732

2833
* [Installing MySQL](/pages/installing-mysql.html)
2934
* [Hello, World!](/pages/hello-world.html "Hello, World!")
30-
* [Explanation of how it works](/pages/test.html)
35+
* [Syntax explanation](/pages/explanation.html)
3136

3237
Contributing
3338
------------

pages/another_test.md

Lines changed: 0 additions & 38 deletions
This file was deleted.

pages/explanation.md

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
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.
File renamed without changes.

pages/template.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
layout: default
3+
title: Template
4+
ignore: true
5+
---
6+
7+
# Page Title
8+
9+
Introductory content: Salvia freegan pickled post-ironic. Hoodie mcsweeney's beard, lomo aesthetic semiotics echo park pitchfork typewriter. Fanny pack organic 3 wolf moon shoreditch. Swag cardigan thundercats, marfa authentic fap gastropub small batch scenester.
10+
11+
Portland quinoa hella. Biodiesel forage pickled bushwick fingerstache godard. Put a bird on it tofu aesthetic organic flexitarian.
12+
13+
Now here are two tutorials:
14+
15+
<div markdown="1" class="tutorial" data-facets='{"Language": ["Ruby", "JRuby"]}'>
16+
## Ruby and JRuby
17+
18+
{% highlight ruby %}
19+
puts "Hello, World!"
20+
{% endhighlight %}
21+
</div>
22+
23+
<div markdown="1" class="tutorial" data-facets='{"Language": "C"}'>
24+
## C
25+
26+
{% highlight c %}
27+
#include <stdio.h>
28+
29+
int main(void)
30+
{
31+
printf("Hello, World!");
32+
return 0;
33+
}
34+
{% endhighlight %}
35+
</div>

pages/test.md

Lines changed: 0 additions & 76 deletions
This file was deleted.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy