--- post_visible: true status: published title: YSDN Interactivity Workshop – Week 1 subtitle: Learn some web basics for building things like portfolios. slug: 2013-01-24-ysdn-interactivity-workshop-week-1 date: '2013-01-24' author: Nate Butler primary_tag: education tags: - education - dev summary: >- Welcome to the YSDN Interactivity Workshop. Here we will learn how to build a simple website using Bootstrap, and learn some important basics about web development. Hopefully you are excited to get learning, so lets get to it! featured: true --- Welcome to the YSDN Interactivity Workshop. Here we will learn how to build a simple website using Bootstrap, and learn some important basics about web development. Helpfully you are excited to get learning, so let's get to it! Below you will find links to the wiki pages. Choose the appropriate page to get started. Wiki [Schedule](https://github.com/iamnbutler/YSDN-Interactivity-Workshop/wiki/Schedule) [Welcome](https://github.com/iamnbutler/YSDN-Interactivity-Workshop/wiki/Welcome) [Week 1](https://github.com/iamnbutler/YSDN-Interactivity-Workshop/wiki/Week-1) January 24th, 2013 [Week 2](https://github.com/iamnbutler/YSDN-Interactivity-Workshop/wiki/Week-2) February 28th, 2013 [Week 3](https://github.com/iamnbutler/YSDN-Interactivity-Workshop/wiki/Week-3) TBD [Sample Work Sources](https://github.com/iamnbutler/YSDN-Interactivity-Workshop/wiki/Sample-Work-Sources) [View on Github](https://github.com/iamnbutler/YSDN-Interactivity-Workshop) --- Hopefully you are attending in class with us, but I will attempt to write these guides with no assumptions, so hopefully anyone can follow along. Also we plan to screencast the workshop, so once it is recorded there will be a link here! ## Introduction Welcome to the YSDN Interactivity Workshop! In this workshop we will be building a very simple portfolio site using HTML, CSS and jQuery. We will discuss coding standards, walk through how to build the site and how to get it out on the internet. We aim to assume nothing so the workshop is accessible to all skill levels, but feel free to ask a question if you miss something! Asking questions is the best way to learn. This workshop will be taught from a "learning by doing" perspective, so the pace will be quick. ### What we will be teaching in this workshop: - How to build a simple portfolio site - How to indent and comment your code using industry standards - Coding with Sublime Text 2 - Uploading your code to Github - How to use Bootstrap - Add interactivity using jQuery - Optimizing images for the web - Creating mobile friendly templates using Bootstrap - How to host your website ### What we won't be teaching in this workshop: - Advanced web languages outside of HTML, CSS and jQuery. - Advanced topics such as code optimization - Spending time looking for images or plugins ## Goals for Week 1 - How to use the [Sublime Text] (http://www.sublimetext.com/) Editor - Understand how to write and format basic HTML and CSS - Getting started with Git and [Github] (https://github.com/) - Using [Bootstrap] (http://twitter.github.com/bootstrap/) to build templates quickly ## Goals for Week 2 - How to add additional pages - Understand the basics of using [jQuery] (http://jquery.com/) to add interaction to a site - (Optional: Using CSS animations) ## Goals for Week 3 - Wrap up - Web Hosting --- ## Week 1 – Introduction Hello Designers and Developers! This week we are going to get started on our project--A simple portfolio style site. This may be a bit basic for a few of you, but stick with it, I'm sure you will learn something. ### Outline for this week: * How to use the [Sublime Text](http://www.sublimetext.com/) Editor * Understand how to write and format basic HTML and CSS * Getting started with Git and [Github](https://github.com/) * Using [Bootstrap](http://twitter.github.com/bootstrap/) to build templates quickly ### Download the Resources * [Resources Zip](http://www.mediafire.com/download.php?7hc77w0w1n831cc) * [Complete Site Zip](http://www.mediafire.com/download.php?53ap25kllri4vu8) * [Sublime Text 2](http://www.sublimetext.com/2) * Github Client [Mac Version](http://mac.github.com/) | [Windows Version](http://windows.github.com/) * [Twitter Bootstrap](http://twitter.github.com/bootstrap/) ### Final product for this week http://iamnbutler.com/demo/ysdn/workshop-1/week-1/ ## Before Starting Let's go through what we are going to need for this week. ### Installing Sublime Text 2 We are going to be using Sublime Text as our editor for this project. You are free to use another editor that you prefer, but Sublime Text is a strong and light text editor, with great plugins you can install. One of the biggest benefits of Sublime Text is the Package Control, which we will be covering in this workshop. Give this editor a try and I'm sure you won't look back! Head over to the [Downloads](http://www.sublimetext.com/2) page to get started. **Mac Installation** * Grab the Mac download version ([Version 2.0.1](http://c758482.r82.cf2.rackcdn.com/Sublime%20Text%202.0.1.dmg) direct download) * Open the DMG and drag the application to your Applications folder * (If you are on a machine such as a lab computer that does not have write access to the Applications folder, make a folder on the desktop (such as "Portable Applications) and drag the application there.) * Run the application **Windows Installation** * Grab the Windows Portable installation ([Version 2.0.1](http://c758482.r82.cf2.rackcdn.com/Sublime%20Text%202.0.1.zip) direct download) * A portable installation can be installed anywhere, such as a usb stick or flash drive * Extract the zip file to wherever you want the application installed * Run sublime_text.exe ### Registering a Github account * Navigate to the [Github](https://github.com/) site * On the main page enter your registration information * Click on the "Sign up for free" button * Verify your email if necessary * Download and install the client. [Mac](http://mac.github.com/) | [PC](http://windows.github.com/) ### Download the Bootstrap zip * Head on over to [Twitter Bootstrap](http://twitter.github.com/bootstrap/) * Hit the nice big blue download button * Store that zip wherever you are going to be working on this workshop (We'll need it later!) ## Workshop ### Getting Started All right, here we go! Let's start by grabbing the resources we need for this week. [Grab them here](http://www.mediafire.com/download.php?7hc77w0w1n831cc) Also, if you need some help, or are working on this outside of the workshop, for your benefit I've included a complete version of what we will finish this week for you to dissect, or check your own code against. [Grab it here](http://www.mediafire.com/download.php?53ap25kllri4vu8) *** ### Sublime Text 101 Let's go ahead and open up Sublime Text (Sublime from here out). The first thing we are going to do is set Sublime to 2-column mode. We can do this by going to `View -> Layout -> Columns: 2`. This helps us look at two pieces of code at the same time. Next we are going to add our folder as a 'project' in Sublime. Go up to `Project` and hit `Add Folder to Project` (Complete path `Folder -> Add Folder to Project`.) Find the folder you are working from and hit enter. This will add your project's folder structure to the column on the left. You can remove the folder from the project using `Project -> Remove All Folders from Project`. #### *Installing Sublime Package Control* Now we are going to install the Sublime Package Control. To find out more, you can visit its [site](http://wbond.net/sublime_packages/package_control). 1. In Sublime press Control + ` 2. Paste the following code in to the box that shows up:
import urllib2,os; pf='Package Control.sublime-package'; ipp=sublime.installed_packages_path(); os.makedirs(ipp) if not os.path.exists(ipp) else None; urllib2.install_opener(urllib2.build_opener(urllib2.ProxyHandler())); open(os.path.join(ipp,pf),'wb').write(urllib2.urlopen('http://sublime.wbond.net/'+pf.replace(' ','%20')).read()); print 'Please restart Sublime Text to finish installation'
3. Close Sublime and re-open it.
### *Install Emmet*
Now that we have the package control installed, we can grab some awesome packages to make your coding life a little easier. I'm not going to get into too many of these, but the following one is one that you won't be able to live without.
First we are going to install [Emmet](http://docs.emmet.io/):
1. Press `Cmd + Shift + P` (on a PC `Control + Shift + P`)
2. In the box that pops up type the word "Install"
3. Click `Package Control: Install Package`
4. Type in `Emmet` and click the first option
### *Using Emmet*
Nice job so far! Now that we have Emmet, lets see a few cool things we can do.
Examples:
* `.box` + `Tab` becomes ``
* `body.box` + `Tab` becomes `<body class="box"></body>`
There are tons of things you can use Emmet for. Check out the link above to see them all. I'll be teaching a few throughout the workshop.
***
### Getting Started with Github
Lets get our "Repo" (Or Repository) up so we can get started on our site!
####*So what is a repository?* (From here on just "repo")
A repository is a place where you store your code. It will keep the most recent version of your code online, as well as keep a "version history" of all of your changes based on something called "Commits".
#### *Why do I need to use a repo?*
You may not need it today, but a year from now, when you are working on a thirty hour project, and the power goes out, and somehow your project has disappeared, you will be wishing your code was in a repo. A repo holds incremental version info for each "commit" you make, allowing you to store and retrieve versions of your code. Best of all, it is free!
#### *So what is this "Commit" you are talking about?*
A commit is basically a flag post that tells the system the version of the code, and a short message to accompany the flag to help you understand in English (or any other language) what exactly changed in that version. But this probably sounds totally confusing, so lets learn by doing!
Open your Github client and sign in to the account that we made at the beginning of the workshop.
#### Creating the Repo
Once you are at the main application page, create a new repo. On the mac client this is found at the bottom (the + button) and on the PC client it is the "+add" button at the top of the program.
Give your repo a name, and place it somewhere easy (Wherever you want to be building your site.)
Make sure "Push to Github" is checked, and "Keep this code private" is unchecked.
If you browse the Github website while logged in now you should see your repository.
#### Making Our First Commit
Now lets make our first commit!
It's pretty easy.
Lets unzip the files from the [resources zip](http://www.mediafire.com/download.php?7hc77w0w1n831cc) and put them in the folder we made out repo in! Navigate to the folder and paste the extracted files in.
Now in your Github client, double click the name of your repo and you should see a bunch of files with a "new" tag. This is because we have added some new files. Let's commit them now.
Type a message in the "Commit summary" box and hit "commit".
#### Syncing with Github
Now let's sync our changes with Github. On a mac, click the "Publish branch" or "Sync Branch" button up in the top right corner. On a PC, click the "sync" button.
Congrats! You've made your first commit! If you look on GitHub now, you will see your files that you added in the repo. We'll be making more commits throughout the workshop, so for now let's get started!
***
### Coding Standards
#### *Indentation*
Different web languages use different types of indentation. For now though we'll be fine just covering HTML and CSS.
Properly indenting and formatting your code is one of the, if not the single most important thing to learn when coding. If your code is not readable, you can not get help when you need it, and later it is likely that you won't even be able to read it yourself.
Let's start with HTML.
Improper:
```html
<!DOCTYPE HTML>
<html lang="en">
<head>
<title>YSDN Interactivity Workshop</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="" rel="icon" type="image/x-icon" />
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script src="js/scripts.js"></script>
</body>
</html>
```
Proper:
```html
<!DOCTYPE HTML>
<html lang="en">
<head>
<title>YSDN Interactivity Workshop</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="" rel="icon" type="image/x-icon" />
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script src="js/scripts.js"></script>
</body>
</html>
```
See how much easier that is to read?
Basically, every time you "go in" one level, or put a tag inside another, add 4 spaces (or 1 tab.) Spaces are generally better to use than tabs (for compatibility reasons) but at this level it isn't that big of a deal.
All right, let's do CSS next.
#### *CSS*
Improper:
```css
.masthead {height: 280px; background: url(../img/masthead-bg.png);}
.masthead .logo {position: relative; left: -135px; margin: 0 auto; margin-left: 50%; padding-top: 60px;}
.masthead nav {margin-top: 20px; text-align: center;}
```
*Note: Advanced Users: Obviously this syntax is fine for a minified file, but for CSS that is meant to be human read you should not code like this.*
Proper:
```css
.masthead {
height: 280px;
background: url(../img/masthead-bg.png);
}
.masthead .logo {
position: relative;
left: -135px;
margin: 0 auto;
margin-left: 50%;
padding-top: 60px;
}
.masthead nav {
margin-top: 20px;
text-align: center;
}
```
With CSS, always drop to the next line and add 4 spaces (or a tab) after the opening `{`.
Each CSS property should be indented , and the closing `}` should be on its own line.
#### *HTML Elements*
Here is a *very, very* brief overview of HTML elements and what they are used for. You can return here later if you need to take a look at them.
* `<head>` tag contains all of the technical information for the document such as CSS links, meta information and information for search engines.
* No 'visible' information, or anything that physically shows up on the page, should be in your head tag.
* `<body>` tag hold all of our "visible" website data (tags) as well as our scripts.
* But my teacher told me to put the `<script>`tag in the header!
* [Why your script tags should be in the body](http://developer.yahoo.com/blogs/ydn/posts/2007/07/high_performanc_5/)
* Your `<script>` tags should always be located directly before the ending `</body>` tag.
* `