Skip to content

Commit 663b285

Browse files
committed
Changes to c1s2, stripping out all the juicy git bits.
1 parent dc951a6 commit 663b285

File tree

7 files changed

+73
-219
lines changed

7 files changed

+73
-219
lines changed

_sessions/c1s2/1_using_git.md

+10-108
Original file line numberDiff line numberDiff line change
@@ -12,122 +12,24 @@ Git works on a folder level. To set up a folder to work with git you need to ope
1212

1313
There are some other hidden files (e.g. those used by your operating system) that you don't want to be version controlled. An example of these is the `.DS_Store` file on macs. We'll talk more about this later - for now we'll just quickly exclude them from our repository.
1414

15-
To do this you need to create a file called `.gitignore` in your the folder containing your repo and put the line `.DS_Store` in it. You can do this with sublime text:
15+
To do this you need to change the settings on your repository.
1616

17-
1. Open Sublime Text and write `.DS_Store` in a new window.
18-
2. Save this file as `.gitignore` in your repo folder.
17+
1. Open the settings tab of your repository.
18+
2. Add `.DS_Store` on the first line of the 'Ignored files' section, and press 'Save Changes'.
1919

2020
If you're on Windows you don't need to worry about this.
2121

22-
### Adding files to the repository
22+
### Committing files to the repository
2323

24-
Suppose we've now created a file called `index.html` in the folder. It's in the folder but currently isn't being tracked by git. You can see this by doing `git status`:
24+
Suppose we've now created a file called `index.html` in the folder. It's in the folder but currently isn't being tracked by git.
2525

26-
$ git status
26+
Adding files to a git repository is actually a two-stage process: you have to **add** them and then **commit** them. This is useful when you get more advanced, but we'll usually do those things together for the time being.
2727

28-
# On branch master
29-
#
30-
# Initial commit
31-
#
32-
# Untracked files:
33-
# (use "git add <file>..." to include in what will be committed)
34-
#
35-
# index.html
36-
nothing added to commit but untracked files present (use "git add" to track)
37-
38-
Adding files to a git repository is actually a two-stage process: you have to **add** them and then **commit** them. This is useful when you get more advanced, but we'll usually do those things together for the time being. To add the changes to the repository do:
39-
40-
$ git add --all
41-
$ git status
42-
43-
# On branch master
44-
#
45-
# Initial commit
46-
#
47-
# Changes to be committed:
48-
# (use "git rm --cached <file>..." to unstage)
49-
#
50-
# new file: index.html
51-
#
52-
53-
It is possible to add files one at a time - again, useful when you get more advanced. For the time being the `--all` flag tells git to add everything to the folder. In other tutorials you might see `git add .`. This also adds everything in the folder **but doesn't remove files you have deleted**. I'd encourage you to stick with `git add --all` for the time being.
54-
55-
We will now commit these changes to our repository, along with a description of the changes we have made.
56-
57-
$ git commit -m "Created index.html"
58-
59-
[master (root-commit) e91b6be] Created index.html
60-
0 files changed
61-
create mode 100644 index.html
62-
63-
<div class='alert alert-error' markdown="1">
64-
#### How to get out of vim
65-
66-
If you forget to supply a message with the `-m` tag git will drop you into a text editor (probably vim) so that you can write one. If this happens you will need to do the following:
67-
* Press `i` to get into insert mode, so you can write.
68-
* Write your message.
69-
* Press `esc` then `:` then `wq` then `Enter`.
70-
* Never forget your message again...
71-
* ... or make a note of these instructions!
72-
73-
</div>
74-
75-
You can check that the commit worked with git status:
76-
77-
$ git status
78-
79-
# On branch master
80-
nothing to commit (working directory clean)
81-
82-
You can see your commit by doing
83-
84-
$ git log
85-
86-
commit c63f9bbea211a0240fa1b13287a2aaf5a6d8d81a
87-
Author: Tom Close <[email protected]>
88-
Date: Tue Jul 2 14:19:30 2013 +0100
89-
90-
Created index.html
91-
92-
or you can get a nice diagram showing your repo by doing
93-
94-
$ gitk --all
9528

9629
{% exercise %}
97-
Enable your `first_site` folder as a git repository:
98-
1. Navigate to the `first_site` folder in the command line
99-
2. Type
100-
101-
$ git init
102-
103-
2. **If you are on a mac**, tell git to ignore your `.DS_Store` files:
104-
1. Open Sublime Text and write `.DS_Store` in a new window.
105-
2. Save this file as `.gitignore` in your `first_site` folder.
106-
107-
3. Do a git status to see what it says
108-
109-
$ git status
110-
111-
4. Commit your changes to the repository:
112-
113-
$ git add --all
114-
$ git commit -m "Created index.html"
115-
116-
5. Do a git status and then a git log to see what has happened:
117-
118-
$ git status
119-
$ git log
120-
30+
1. Set up your `first_site` folder as a git repository: open up the github app, select `File > Add Local Repository ...` and select the `first_site` folder.
31+
2. **If you are on a mac**, tell git to ignore your `.DS_Store` files: in the settings panel of the github app, add the line `.DS_Store` in the 'Ignored files' section.
32+
3. Commit your work to the repository: in the 'Changes' panel, click 'Select all', write a 'Commit Summary' in the box (e.g. "Created index.html") and click 'Commit'.
12133
6. Make some change to index.html (in Sublime Text)
122-
7. Go back to the command line and do a git status:
123-
124-
$ git status
125-
126-
8. Add and commit your changes but forget the `-m`:
127-
128-
$ git add --all
129-
$ git commit
130-
131-
9. Use the warning above to add you commit message and escape from vim
132-
34+
7. Go back to the 'Changes' panel. Select and commit your changes, with a 'Commit Summary' describing what you did.
13335
{% endexercise %}

_sessions/c1s2/2_pushing_to_github.md

+13-14
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,23 @@ title: Pushing code to Github
55

66
Github is a site which will host a git repo online for you, making it easy to collaborate with others. We'll now see how to put some code online.
77

8-
Go to github, login, and click "Create New Repo" in the top left hand corner.
8+
### Aside: serving a site via Github Pages
99

10-
![Creating a repo on GitHub](/assets/create_repo.png)
10+
Normally when we push code up to github, it just sits there for others to see and contribute to. The code we're about to push up happens to be the code for a website. Instead of the files just sitting there, we want github to *serve* them as a website. The way github does this is through its [github pages](http://pages.github.com/).
1111

12-
Follow the instructions, calling it something like `first_site`. **Do not** click the box which says 'Create a readme with this repository'. You'll get to a page when it'll describe how to get your code online. You want to follow the instructions for "Pushing an existing repository to github".
12+
There are several ways of getting GitHub to publish your site as a GitHub page. We're going to use a simple trick: in the branches panel of the GitHub app, change the name of the current branch from `master` to `gh-pages`.
1313

14-
![Push repo to GitHub](/assets/push_repo_github.png)
14+
<div class="alert alert-warning">If you haven't verified your email with github (you'll see a warning at the top of the screen when you log in). Your GitHub won't serve your page at all. Make sure you've verified you email address, before continuing!</div>
1515

16-
If you've set up ssh keys, go for the ssh option, if not, go for https. You should end up doing something like:
16+
### Pushing code up to github
1717

18-
$ git remote add origin [email protected]/yourusername/first_site.git
19-
$ git push -u origin master
18+
To push code up to GitHub, in the GitHub app select the 'Push to Github' button (on the top right). You'll be prompted to choose a name (which might as well be `first_site`).
2019

21-
You might now be prompted to add your github username and password (if you're doing the https method). If all goes well, when you go to github you should see the `first_site` folder containing your html file.
22-
23-
{% exercise %}
24-
Push your `first_site` folder to GitHub!
25-
26-
1. Create the new repository on GitHub. (**Don't** create it with a README.)
27-
2. Follow the instructions for "Pushing an existing repository to github" to push your repository up.
20+
{% endexercise %}
21+
1. Log in to GitHub and check you've verified your email address.
22+
1. In the 'Branches' panel of the GitHub app, change the name of the current branch from `master` to `gh-pages`.
23+
2. Click the 'Push to Github' button in the GitHub app.
24+
3. On Github check you can see your `first_site` code.
25+
4. On the code page on github, click on Settings. It should tell you (about half way down) the url where they've published your site. Have a look to see whether you can see it!
26+
5. (If you finish early) Make a change to `index.html` in Sublime Text. Commit the change to the repository and then push it to GitHub. Make sure you can see the change in the code on GitHub and also in the published page.
2827
{% endexercise %}

_sessions/c1s2/3_css.md

+1-6
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,8 @@ h3 {
4747
Note that you can specify multiple properties on one element. When you do this it's nice to lay them out on multiple lines as done above.
4848

4949
{% exercise %}
50-
1. Use git to clone the repo for this part of the session:
51-
52-
$ git clone https://github.com/code61/html2.git
53-
54-
As well as the code, this has given you a local copy of the git repository I'm storing the exercise in. You'll be adding to this repo in a minute.
50+
1. Use git to clone the repo for this part of the session: [https://github.com/code61/html2](https://github.com/code61/html2).
5551
2. Open `exercise1.html` in Sublime Text and in Chrome.
5652
3. Add some css in the `head` to make the `h1` turn red.
57-
5853
5. Continue with the exercise until `exercise1.html` looks like `exercise1_solution.png`.
5954
{% endexercise %}

_sessions/c1s2/5_homework.md

-66
This file was deleted.

_sessions/c1s3/3_separate_css_file.md renamed to _sessions/c1s2/5_separate_css_file.md

+26-24
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ Linking to other files (stylesheets, javascript files, images) can be done in se
5353

5454
and you're going to deploy your site to "http://www.my_first_site.com". Suppose you want to link to `main.css` from `index.html` and to `background.jpg` from `main.css`. There are three different styles of links you can use:
5555

56-
#### 1. Absolute external links
56+
#### 1. Absolute links
5757

58-
Absolute external links include the complete url to the resource you're linking to:
58+
Absolute external links include the complete url to the resource you're linking to. **Absolute links start with either http:// or https://**.
5959

6060
{% highlight html %}
6161
<!-- in index.html -->
@@ -68,11 +68,11 @@ body {
6868
}
6969
{% endhighlight %}
7070

71-
Absolute external links can be used to link to resources held on different sites, but wouldn't usually be used for links between your own site. They're a bit fragile - if you change your domain name all the links will break. They also won't work when you're developing locally.
71+
Absolute external links can be used to link to resources held on different sites, but wouldn't usually be used for links within your own site. They're a bit fragile - if you change your domain name all the links will break. They also won't work when you're developing locally.
7272

73-
#### 2. Absolute local links
73+
#### 2. Root-relative links
7474

75-
Absolute local links contain the path to the resource *relative to the site's root*. The site's root is (roughly) the folder that contains the site - in this case, `first_site`. **Absolute local links begin with a `/`**:
75+
Root-relative links contain the path to the resource *relative to the site's root*. The site's root is (roughly) the folder that contains the site - in this case, `first_site`. **Root-relative links begin with a `/`**:
7676

7777
{% highlight html %}
7878
<!-- in index.html -->
@@ -85,11 +85,11 @@ body {
8585
}
8686
{% endhighlight %}
8787

88-
Absolute local links are a bit more flexible than absolute external links: e.g. if you change your domain name everything will still be fine. They're sometimes useful for your own static sites, but probably won't work when developing locally (because the root will be taken to be the root of your file system and not the folder containing the site!).
88+
Root-relative links are a bit more flexible than absolute external links: e.g. if you change your domain name everything will still be fine. They're sometimes useful for your own static sites, but probably won't work when developing locally (because the root will be taken to be the root of your file system and not the folder containing the site!).
8989

90-
#### 3. Relative local links
90+
#### 3. Document-relative links
9191

92-
Relative local links contain the path to the resource *relative to the file where the link is written*. **Relative local links don't begin with `/`**:
92+
Document-relative links contain the path to the resource *relative to the file where the link is written*. **Document-relative links don't begin with `/`**:
9393

9494
{% highlight html %}
9595
<!-- in index.html -->
@@ -104,27 +104,29 @@ body {
104104

105105
To link to the stylesheet from `index.html` we use `stylesheets/main.css` which says "look in the same folder I'm in (`first_site`) and find a folder called `styleheets` and a file in it called `main.css`".
106106

107-
To link to the image from the stylesheet is slightly more complicated: we use `../images/background.jpg`. This means "go to the folder above the one I'm in (I'm in `stylesheets`, so that's `first_site`) and find a folder called `images` and a file in it called `background.jpg`". Notice how `..` is used to go up a folder, just like in the command `cd ..`.
107+
To link to the image from the stylesheet is slightly more complicated: we use `../images/background.jpg`. This means "go to the folder above the one I'm in (I'm in `stylesheets`, so that's `first_site`) and find a folder called `images` and a file in it called `background.jpg`".
108+
109+
<div class="panel panel-primary">
110+
<div class="panel-heading">
111+
<h3 class="panel-title">Important to know</h3>
112+
</div>
113+
<div class='panel-body'>
114+
In document-relative links (and in many other places e.g. command line navigation)
115+
<ul>
116+
<li><code>.</code> means in the folder <strong>that I'm in</strong></li>
117+
<li><code>..</code> means in the folder <strong>above the one that I'm in</strong></li>
118+
</ul>
119+
</div>
120+
</div>
108121

109122
Relative links are the most flexible - they will work on your local file system. The only think you have to be careful about is moving your files into different folders, which can cause links to break.
110123

111124
**You should be using relative local links in these exercises.**
112125

126+
For a recap of all this, read [this article](https://www.inkling.com/read/dreamweaver-cs6-missing-manual-david-sawyer-mcfarland-1st/chapter-4/understanding-links).
113127

114128
{% exercise %}
115-
1. Move to your `coding_course` folder and clone the repository for this session:
116-
117-
git clone https://github.com/code61/html3.git
118-
119-
2. Open `exercise1.html` in Sublime Text and Chrome.
120-
3. Link in the external stylesheet `exercise1.css`. Save, add and commit. Make sure the results show up in Chrome when you refresh.
121-
4. Open `exercise2.html` in Sublime Text and Chrome.
122-
5. Move the css from the `head` into a separate stylesheet, which you should call `exercise2.css`. Link to this stylesheet in the head.
123-
6. Create another stylesheet called `exercise2-custom.css`.
124-
7. In this stylesheet write:
125-
126-
.color-info { border: 5px dotted purple; }
127-
128-
8. Link in this stylesheet too, so that the changes take effect.
129-
9. If you have time, move any styles you have added to your `first_site` into a separate stylesheet.
129+
1. Return to `exercise1.html` and separate the CSS out into a separate file (called `exercise1.css`).
130+
2. Check that the CSS still shows up when you view the site in the browser.
131+
3. Make a change in `exercise1.css` and check that you can see that in the browser. (You might need to refresh the page a few times).
130132
{% endexercise %}

_sessions/c1s2/6_homework.md

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
title: Homework
3+
---
4+
5+
### Finishing off
6+
7+
{% exercise %}
8+
Finish off both CSS exercises from class. Check your solutions online:
9+
* Find the HTML2 repository on Code61's github page.
10+
* In the `branch` dropdown (just above the list of files) select the `solution` branch.
11+
* Click on the files below to see the solution
12+
{% endexercise %}
13+
14+
### More HTML/CSS
15+
16+
{% exercise %}
17+
1. Complete the whole of Project 3 on the [General Assembly Dash](https://dash.generalassemb.ly/projects) site.
18+
2. Make some changes to your `first_site` based on what you've learnt. Make sure you add them to git, push them to github and check you can see them online.
19+
3. (Optional) Do the projects from the [Codecademy Web Track](http://www.codecademy.com/tracks/web) Sections 7, 8 &amp; 9.
20+
4. (Optional) Read [this article](https://www.inkling.com/read/dreamweaver-cs6-missing-manual-david-sawyer-mcfarland-1st/chapter-4/understanding-links) about absolute vs. relative links.
21+
{% endexercise %}
22+

_sessions/c3s2/2_post_requests.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,5 @@ Note that, like the words matched in the url, the value of the `user_name` field
4141
2. Clone down your fork of the repository onto your laptop.
4242
3. Open the `sinatra_c3s2` project in Sublime Text and have a read through `app.rb`. See if you can predict what the app will do.
4343
4. Run the app from the command line (`ruby app.rb`), to see if you were right.
44-
5. (Optional) Add the line `raise params.inspect` right at the top of the post block. Restart the app and see what happens.
44+
5. (Optional) Add the line `raise params.inspect` right at the top of the post block. Restart the app and see what happens. When you've had a look, make sure you remove the line again!
4545
{% endexercise %}

0 commit comments

Comments
 (0)