From 976e6f19b3e5422ee2e3e8783b01480e69d939e9 Mon Sep 17 00:00:00 2001 From: shmool Date: Sat, 26 Jul 2014 15:27:48 +0300 Subject: [PATCH 1/4] Update README.md --- css/README.md | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/css/README.md b/css/README.md index 490e2ee2ffa..1bff18fb2de 100644 --- a/css/README.md +++ b/css/README.md @@ -6,6 +6,10 @@ Our blog still looks pretty ugly, right? Time to make it nice! We will use CSS f Cascading Style Sheets (CSS) is a style sheet language used for describing the look and formatting of a website written in markup language (like HTML). Treat it as a make-up for our webpage ;). +In a CSS file we determine styles for elements in the HTML file. The elements are identified by the element name (i.e. `a`, `h1`, `body`), the element class or the element id. Class and id are names you give the element by yourself. Classes define groups of elements, and ids point out to specific elements. For example, the following tag may be identified by CSS using the tag name `a`, the class `external_link`, or the id `link_to_wiki_page`: + + + But we don't want to start from scratch again, right? We will, again, use something that has already been done by programmers and released in the Internet for free. You know, inventing a wheel once again is no fun. ## Let's use Bootstrap! @@ -16,12 +20,13 @@ It was written by programmers who worked for Twitter and is now developed by vol ## Install Boostrap -To install Bootstrap, you need to add this to your `` in you `.html` file (`mysite/blog/templates/blog/post_list.html`): +To install Bootstrap, you need to add this to your `` in your `.html` file (`mysite/blog/templates/blog/post_list.html`): +This doesn't add any files to your project. It just points to files that exist on the internet. Then just go ahead, open your website and refresh page. Here it is! ![Figure 14.1](images/bootstrap1.png) @@ -65,6 +70,7 @@ Time to write some CSS! Open up the `mysite/static/css/blog.css` file in your co We won't be going too deep into customizing and learning about CSS here, because it's pretty easy and you can learn it on your own after this workshop. We really recommend doing this [Codeacademy HTML & CSS course](http://www.codecademy.com/tracks/web) to learn everything you need to know about making your websites more pretty with CSS. But let's do at least a little. Maybe we could change the color of our header? To understand colors, computer use special codes. They start with `#` and are followed by 6 letters (A-F) and numbers (0-9). You can find color codes for example here: http://www.colorpicker.com/ +You may also use predefined colors, such as 'red' and 'green'. In your `mysite/static/css/blog.css` file you should add following code: @@ -72,13 +78,14 @@ In your `mysite/static/css/blog.css` file you should add following code: color: #FCA205; } -`a` inside of `h1` (i.e. when we have in code something like: `

link

`) is the tag we're applying our styles to, and we're telling it to change color to `#FCA205`. Of course, you can put your own color here! +'h1 a' is a CSS Selector. `a` element inside of `h1` element (i.e. when we have in code something like: `

link

`) is the tag we're applying our styles to, and we're telling it to change color to `#FCA205`, which is orange. Of course, you can put your own color here! +Read about [CSS Selectors in w3schools](http://www.w3schools.com/cssref/css_selectors.asp) Then, we need to also tell our HTML template that we added some CSS. Open the `mysite/blog/templates/blog/post_list.html` file and add this line at the very beginning of it: {% load staticfiles %} -We're just loading static files here :). Then, between the `` and `` add this line: +We're just loading static files here :). Then, between the `` and ``, after the links to the Bootstrap CSS files (the browser reads the files in the order they're given, so code in our file may override code in Bootstrap files), add this line: @@ -91,8 +98,8 @@ Your file should look like this at this point: Django Girls blog - - + + From c1865f43ddea7c80b81f218eb24c5a0740926f96 Mon Sep 17 00:00:00 2001 From: shmool Date: Sat, 26 Jul 2014 16:02:17 +0300 Subject: [PATCH 2/4] Update README.md Added info about CSS, fixed typos --- css/README.md | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/css/README.md b/css/README.md index 1bff18fb2de..792cfc20128 100644 --- a/css/README.md +++ b/css/README.md @@ -6,10 +6,6 @@ Our blog still looks pretty ugly, right? Time to make it nice! We will use CSS f Cascading Style Sheets (CSS) is a style sheet language used for describing the look and formatting of a website written in markup language (like HTML). Treat it as a make-up for our webpage ;). -In a CSS file we determine styles for elements in the HTML file. The elements are identified by the element name (i.e. `a`, `h1`, `body`), the element class or the element id. Class and id are names you give the element by yourself. Classes define groups of elements, and ids point out to specific elements. For example, the following tag may be identified by CSS using the tag name `a`, the class `external_link`, or the id `link_to_wiki_page`: - - - But we don't want to start from scratch again, right? We will, again, use something that has already been done by programmers and released in the Internet for free. You know, inventing a wheel once again is no fun. ## Let's use Bootstrap! @@ -69,8 +65,7 @@ Time to write some CSS! Open up the `mysite/static/css/blog.css` file in your co We won't be going too deep into customizing and learning about CSS here, because it's pretty easy and you can learn it on your own after this workshop. We really recommend doing this [Codeacademy HTML & CSS course](http://www.codecademy.com/tracks/web) to learn everything you need to know about making your websites more pretty with CSS. -But let's do at least a little. Maybe we could change the color of our header? To understand colors, computer use special codes. They start with `#` and are followed by 6 letters (A-F) and numbers (0-9). You can find color codes for example here: http://www.colorpicker.com/ -You may also use predefined colors, such as 'red' and 'green'. +But let's do at least a little. Maybe we could change the color of our header? To understand colors, computer use special codes. They start with `#` and are followed by 6 letters (A-F) and numbers (0-9). You can find color codes for example here: http://www.colorpicker.com/. You may also use [predefined colors](http://www.w3schools.com/cssref/css_colornames.asp), such as `red` and `green`. In your `mysite/static/css/blog.css` file you should add following code: @@ -78,8 +73,13 @@ In your `mysite/static/css/blog.css` file you should add following code: color: #FCA205; } -'h1 a' is a CSS Selector. `a` element inside of `h1` element (i.e. when we have in code something like: `

link

`) is the tag we're applying our styles to, and we're telling it to change color to `#FCA205`, which is orange. Of course, you can put your own color here! -Read about [CSS Selectors in w3schools](http://www.w3schools.com/cssref/css_selectors.asp) +`h1 a` is a CSS Selector. `a` element inside of `h1` element (i.e. when we have in code something like: `

link

`) is the tag we're applying our styles to, and we're telling it to change color to `#FCA205`, which is orange. Of course, you can put your own color here! + +In a CSS file we determine styles for elements in the HTML file. The elements are identified by the element name (i.e. `a`, `h1`, `body`), the element class or the element id. Class and id are names you give the element by yourself. Classes define groups of elements, and ids point out to specific elements. For example, the following tag may be identified by CSS using the tag name `a`, the class `external_link`, or the id `link_to_wiki_page`: + + + +Read about [CSS Selectors in w3schools](http://www.w3schools.com/cssref/css_selectors.asp). Then, we need to also tell our HTML template that we added some CSS. Open the `mysite/blog/templates/blog/post_list.html` file and add this line at the very beginning of it: @@ -135,7 +135,7 @@ Maybe we can customize the font in our header? Paste this into your `` in This line will import a font called *Lobster* from Google Fonts (https://www.google.com/fonts). -Now add this line in `mysite/static/css/blog.css` and refresh the page: +Now add the line `font-family: 'Lobster';` in the CSS file `mysite/static/css/blog.css` inside the `h1 a` declaration block (the code between the braces `{` and `}`) and refresh the page: h1 a { color: #FCA205; @@ -146,7 +146,8 @@ Now add this line in `mysite/static/css/blog.css` and refresh the page: Great! -CSS has a concept of classes, which basically allows you to name a part of our HTML code and apply styles only to this part, not affecting others. It's super helpful if you have two divs, but they're doing something very different (like your header and your post), so you don't want them to look the same. + +As mentioned above, CSS has a concept of classes, which basically allows you to name a part of the HTML code and apply styles only to this part, not affecting others. It's super helpful if you have two divs, but they're doing something very different (like your header and your post), so you don't want them to look the same. Go ahead and name some parts of the HTML code. Add a class called `page-header` to your `div` that contains header, like this: @@ -162,7 +163,7 @@ And now add a class `post` to your `div` containing blogposts.

{{ post.text }}

-All right. We have only one day, so we need to speed things up a little! We can't explain you every little detail about CSS. For now just copy and paste following code into your `mysite/static/css/blog.css` file: +We will now add declaration blocks to different selectors. Selectors starting with `.` relate to classes. There are many great tutorials and explanations about CSS on the Web to help you understand the following code. For now, just copy and paste it into your `mysite/static/css/blog.css` file: .page-header { background-color: #ff9400; @@ -212,7 +213,7 @@ All right. We have only one day, so we need to speed things up a little! We can' color: #000000; } -Then also replace this: +Then surround the HTML code which desplayes the posts with declarations of classes. Replace this: {% for post in posts %}
@@ -246,7 +247,7 @@ Wohoo! Looks awesome, right? The code we just pasted is not really so hard to un Don't be afraid to tinker with this CSS a little bit and try to change some things. If you break something, don't worry, you can always undo this! -Anyway, we really recommend taking this free online [Codeacademy HTML & CSS course](http://www.codecademy.com/tracks/web) as a post-workshop homework to learn everything you need to know about making your websites more pretty with CSS. +Anyway, we really recommend taking this free online [Codeacademy HTML & CSS course](http://www.codecademy.com/tracks/web) as a post-workshop homework to learn everything you need to know about making your websites prettier with CSS. Ready for next chapter?! :) From 2d2adf819ac3a3479e41cbd020e0a4e412550969 Mon Sep 17 00:00:00 2001 From: shmool Date: Sat, 26 Jul 2014 16:15:51 +0300 Subject: [PATCH 3/4] Update README.md Few small changes --- css/README.md | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/css/README.md b/css/README.md index 792cfc20128..df0f10da863 100644 --- a/css/README.md +++ b/css/README.md @@ -6,7 +6,7 @@ Our blog still looks pretty ugly, right? Time to make it nice! We will use CSS f Cascading Style Sheets (CSS) is a style sheet language used for describing the look and formatting of a website written in markup language (like HTML). Treat it as a make-up for our webpage ;). -But we don't want to start from scratch again, right? We will, again, use something that has already been done by programmers and released in the Internet for free. You know, inventing a wheel once again is no fun. +But we don't want to start from scratch again, right? We will, again, use something that has already been done by programmers and released in the Internet for free. You know, reinventing the wheel is no fun. ## Let's use Bootstrap! @@ -23,7 +23,7 @@ To install Bootstrap, you need to add this to your `` in your `.html` file This doesn't add any files to your project. It just points to files that exist on the internet. -Then just go ahead, open your website and refresh page. Here it is! +Just go ahead, open your website and refresh the page. Here it is! ![Figure 14.1](images/bootstrap1.png) @@ -42,7 +42,7 @@ First, we need to create a folder to store our static files in. Go ahead and cre mysite └───static -Now we need to tell Django how it can find it. Open up the `mysite/mysite/settings.py` file, scroll to the bottom of it and add the following lines: +Now we need to tell Django where it can find it. Open up the `mysite/mysite/settings.py` file, scroll to the bottom of it and add the following lines: STATICFILES_DIRS = ( os.path.join(BASE_DIR, "static"), @@ -50,11 +50,9 @@ Now we need to tell Django how it can find it. Open up the `mysite/mysite/settin This way Django will know where your static files are. -That's it! Time to see if it works :) - ## Your first CSS file! -First things first: let's create a CSS file now. Create a new folder called `css` inside your `static` folder. Then create a new file called `blog.css` inside this `css` directory. Ready? +Let's create a CSS file now, to add your own style to your web-page. Create a new folder called `css` inside your `static` folder. Then create a new file called `blog.css` inside this `css` directory. Ready? mysite └───static @@ -65,7 +63,7 @@ Time to write some CSS! Open up the `mysite/static/css/blog.css` file in your co We won't be going too deep into customizing and learning about CSS here, because it's pretty easy and you can learn it on your own after this workshop. We really recommend doing this [Codeacademy HTML & CSS course](http://www.codecademy.com/tracks/web) to learn everything you need to know about making your websites more pretty with CSS. -But let's do at least a little. Maybe we could change the color of our header? To understand colors, computer use special codes. They start with `#` and are followed by 6 letters (A-F) and numbers (0-9). You can find color codes for example here: http://www.colorpicker.com/. You may also use [predefined colors](http://www.w3schools.com/cssref/css_colornames.asp), such as `red` and `green`. +But let's do at least a little. Maybe we could change the color of our header? To understand colors, computers use special codes. They start with `#` and are followed by 6 letters (A-F) and numbers (0-9). You can find color codes for example here: http://www.colorpicker.com/. You may also use [predefined colors](http://www.w3schools.com/cssref/css_colornames.asp), such as `red` and `green`. In your `mysite/static/css/blog.css` file you should add following code: From 54f087b5009ce92e6674f9b7ba9a1e746ba979ff Mon Sep 17 00:00:00 2001 From: shmool Date: Sat, 26 Jul 2014 17:25:37 +0300 Subject: [PATCH 4/4] Update README.md deleted "mysite" dir since there was directory change in the tutorial files. --- css/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/css/README.md b/css/README.md index df0f10da863..c8dfe4ffc93 100644 --- a/css/README.md +++ b/css/README.md @@ -16,7 +16,7 @@ It was written by programmers who worked for Twitter and is now developed by vol ## Install Boostrap -To install Bootstrap, you need to add this to your `` in your `.html` file (`mysite/blog/templates/blog/post_list.html`): +To install Bootstrap, you need to add this to your `` in your `.html` file (`blog/templates/blog/post_list.html`): @@ -42,7 +42,7 @@ First, we need to create a folder to store our static files in. Go ahead and cre mysite └───static -Now we need to tell Django where it can find it. Open up the `mysite/mysite/settings.py` file, scroll to the bottom of it and add the following lines: +Now we need to tell Django where it can find it. Open up the `mysite/settings.py` file, scroll to the bottom of it and add the following lines: STATICFILES_DIRS = ( os.path.join(BASE_DIR, "static"), @@ -59,13 +59,13 @@ Let's create a CSS file now, to add your own style to your web-page. Create a ne └───css blog.css -Time to write some CSS! Open up the `mysite/static/css/blog.css` file in your code editor. +Time to write some CSS! Open up the `static/css/blog.css` file in your code editor. We won't be going too deep into customizing and learning about CSS here, because it's pretty easy and you can learn it on your own after this workshop. We really recommend doing this [Codeacademy HTML & CSS course](http://www.codecademy.com/tracks/web) to learn everything you need to know about making your websites more pretty with CSS. But let's do at least a little. Maybe we could change the color of our header? To understand colors, computers use special codes. They start with `#` and are followed by 6 letters (A-F) and numbers (0-9). You can find color codes for example here: http://www.colorpicker.com/. You may also use [predefined colors](http://www.w3schools.com/cssref/css_colornames.asp), such as `red` and `green`. -In your `mysite/static/css/blog.css` file you should add following code: +In your `static/css/blog.css` file you should add following code: h1 a { color: #FCA205;