My first paragraph
28 |My second paragraph.
30 | 31 | 32 | ``` 33 | 34 | - The text between ```` and ```` describes an HTML document. 35 | - The text between ```` and ```` provides information about the document. 36 | - The text between ```` and ``
`` describes a paragraph. 40 | 41 | 42 | ## HTML DOM TREE 43 | 44 | If you look the above sample carefully, you will find the structure of the HTML is a tree. 45 | 46 | ``` 47 | html 48 | | \ 49 | head body 50 | | | \ 51 | title div p 52 | | 53 | p 54 | ``` 55 | 56 | This standard makes HTML more structuring, and be easy converted to object model which we can easily modify it. 57 | 58 | ## Reference 59 | 60 | - [W3schoool HTML Tutorial](http://www.w3schools.com/html/default.asp) 61 | 62 | -------------------------------------------------------------------------------- /web/2016-spring/git-html/images/branch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dyweb/course/2d6f7b4207be3a62861fce4332e8fb72d2d2b8e9/web/2016-spring/git-html/images/branch.png -------------------------------------------------------------------------------- /web/2016-spring/git-html/images/commit_message_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dyweb/course/2d6f7b4207be3a62861fce4332e8fb72d2d2b8e9/web/2016-spring/git-html/images/commit_message_0.png -------------------------------------------------------------------------------- /web/2016-spring/git-html/images/commit_message_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dyweb/course/2d6f7b4207be3a62861fce4332e8fb72d2d2b8e9/web/2016-spring/git-html/images/commit_message_1.png -------------------------------------------------------------------------------- /web/2016-spring/git-html/images/git_vs_svn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dyweb/course/2d6f7b4207be3a62861fce4332e8fb72d2d2b8e9/web/2016-spring/git-html/images/git_vs_svn.png -------------------------------------------------------------------------------- /web/2016-spring/git-html/index.rst: -------------------------------------------------------------------------------- 1 | Git & HTML 2 | ==================================== 3 | 4 | This course mainly tells you how to start writing HTMLs in an editor, using Git for version control. 5 | 6 | Contents: 7 | 8 | .. toctree:: 9 | :maxdepth: 2 10 | 11 | introduce 12 | setup 13 | workflow 14 | branch 15 | teamwork 16 | html 17 | 18 | 19 | 20 | You will start form the defination of environment to your how to organize your local workspace, the editor you use. 21 | How to use commandline, what is virtual machine, how vagrant makes a difference. The famous LNMP stack. The homework 22 | is quite simple, write a helloworld in php, and show the result in your browser. 23 | -------------------------------------------------------------------------------- /web/2016-spring/git-html/introduce.md: -------------------------------------------------------------------------------- 1 | # Git Introduce 2 | 3 | ## What is Git? 4 | 5 | The widely used source code management system for software development in the world. 6 | 7 | ## History 8 | 9 | - In 2002, the developers of the Linux kernel use [Bitkeeper](https://en.wikipedia.org/wiki/BitKeeper) to maintain the project, but the Bitkeeper is not good for developing. 10 | - In 2005, the copyright holder of BitKeeper, Larry McVoy, had withdrawn gratis use of the product after claiming that Andrew Tridgell had reverse-engineered the BitKeeper protocols. 11 | - In 2005, Torvalds decided to develop a distributed system to replace the Bitkeeper. So, he create git. 12 | 13 | ## Version Control 14 | 15 | You won't like this: 16 | 17 | ```` 18 | D:/Schoolwork/Group-work-1 19 | -- our-fancy-work-v1-outline-only 20 | -- our-fancy-work-v2-victor-part-done 21 | -- our-fancy-work-v2-cece-part-done 22 | -- our-fancy-work-v3-victor-and-cece-merged 23 | -- our-fancy-work-v3-victor-part-updated 24 | -- our-fancy-work-v4-victor-part-updated-again 25 | -- our-fancy-work-v5-victor-part-updated-again-and-cece-merged 26 | -- our-fancy-work-v8-final 27 | -- our-fancy-work-v9-final-updated-by-victor 28 | -- our-fancy-work-v9-final-updated-by-cece 29 | -- our-fancy-work-v10-final-updated-merged 30 | -- our-fancy-work-v11-final-final 31 | ```` 32 | 33 | What if we have Git? 34 | 35 | ```` 36 | D:/Schoolwork/Group-work-1 37 | -- our-fancy-work 38 | -- .git # <- Hidden 39 | ```` 40 | 41 | ```` 42 | $ git log --graph --oneline 43 | * 1fa35d1 final final 44 | * d0eb39d Merge branch 'cece' 45 | |\ 46 | | * 10604d8 final updated by cece 47 | * | 243bd99 final updated by victor 48 | |/ 49 | * 8e4c071 final 50 | * a8e02e7 Merge branch 'master' into cece 51 | |\ 52 | | * 222a46f victor part updated again 53 | | * 391ea6c victor part updated 54 | * | 7b3fe97 Merge branch 'master' into cece 55 | |\ \ 56 | | |/ 57 | | * e919d2d victor part done 58 | * | e0c35e5 cece part done 59 | |/ 60 | * 8ab6c50 outline only 61 | ```` 62 | 63 | ## Collaboration 64 | 65 | When you work in a team. It's necessary to integrate everyone's work. 66 | 67 | - copying and cover the files ? 68 | - svn, working-copy collaboration 69 | - git, repo-to-repo collaboration 70 | 71 |  72 | 73 | 74 | ## Benefit 75 | 76 | - Detailed history. 77 | - Better collaboration: safely write on your own, then merge. 78 | - Peer review. 79 | 80 | 81 | ## Reference 82 | 83 | - [Wike.Git(software)](https://en.wikipedia.org/wiki/Git_(software)) 84 | -------------------------------------------------------------------------------- /web/2016-spring/git-html/setup.md: -------------------------------------------------------------------------------- 1 | # Git Setup 2 | 3 | ## Install on windows 4 | 5 | Maybe it's complicated, but I don't use windows for several years. But with the big news for ubuntu in windows10, everything may become easy. 6 | 7 | ## Install on Mac OS X or Linux 8 | 9 | I don't want to tell you, because it's so easy. 10 | 11 | ## Use command line 12 | 13 | If you are in Windows 14 | 15 | - Go to the directory you want to work in, and click your right mouse and choose git bash. 16 | - Input 'git' to see the usage 17 | 18 | if you are in Mac OS X or Linux 19 | - Input 'git' to see the usage 20 | 21 | if should look like this 22 | 23 | ``` 24 | $ git 25 | usage: git [--version] [--help] [-CYou are ordering tickets of the concert Hello World.
10 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /web/2016-spring/instant-php/src/v1/process.php: -------------------------------------------------------------------------------- 1 | 19 |Your order was created successfully.
21 |You are ordering tickets of the concert Hello World.
13 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /web/2016-spring/instant-php/src/v2/process.php: -------------------------------------------------------------------------------- 1 | 5 || $quantities[$i] < 0) { // If quantity[i] is not in the range of [0, 5] 18 | die('Quantity should be between 0 and 5'); // Print error message and exit 19 | } 20 | } 21 | 22 | // Prepare data to store on our disk 23 | $data = "Name: $name "; // Set $data with "Name: xxx" 24 | $data .= "Tickets: " . implode($quantities, ','); // Append ticket info with turning $quantities into a string 25 | $data .= PHP_EOL; // Append EOL (usually "\n" in Linux) character 26 | 27 | // Open data.txt and write our data to this file 28 | $result = @file_put_contents('data.txt', $data, FILE_APPEND); 29 | if ($result === false) { // If the writing operation failed 30 | $error = error_get_last(); // Get last error 31 | echo $error['message'] . 'Your order was created successfully.
46 |Here is your cart.
16 | 17 | 18 | 34 | 35 | 36 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /web/2016-spring/instant-php/src/v3/include/function.php: -------------------------------------------------------------------------------- 1 | 'Area A Ticket', 'quantity' => 1], // Every item in the array is an array ['name' => x, 'quantity' => x] 22 | ['name' => 'Area B Ticket', 'quantity' => 2], // Use ',' to separate each item in an array 23 | ['name' => 'Area C Ticket', 'quantity' => 3], 24 | ['name' => 'Area D Ticket', 'quantity' => 4] // The ',' after the last item can be omitted 25 | ]; 26 | } 27 | 28 | /** 29 | * Get the cart from user session. 30 | * @return array 31 | */ 32 | function get_cart() { 33 | // Create a new cart if no cart available 34 | if (!isset($_SESSION['cart'])) { 35 | create_cart(); 36 | } 37 | 38 | // Return the cart fetched from user session 39 | return $_SESSION['cart']; 40 | } 41 | 42 | /** 43 | * Set the quantity of the given item in the cart. 44 | * @param string $item_name 45 | * @param int $quantity If $quantity <= 0, the item will be 46 | * removed from the cart. 47 | */ 48 | function set_item_quantity($item_name, $quantity) { 49 | if ($quantity <= 0) { // If the quantity of the item is not positive 50 | remove_item($item_name); // Remove the item directly 51 | return; // Exit function handling 52 | } 53 | 54 | foreach ($_SESSION['cart'] as &$item) { // Iterate each item in the cart by reference 55 | if ($item['name'] === $item_name) { // Look for the item with the given name 56 | $item['quantity'] = $quantity; // Set the new quantity 57 | return; // Exit function handling 58 | } 59 | } 60 | 61 | // If the item is not found, add it into the cart 62 | $_SESSION['cart'][] = [ // $val[] = 1 is the same as array_push($val, 1) 63 | 'name' => $item_name, 64 | 'quantity' => $quantity 65 | ]; 66 | } 67 | 68 | /** 69 | * Get the given item in the cart specified by item name. 70 | * @param string $item_name 71 | * @return array|null If the item is not found, null will be returned. 72 | */ 73 | function get_item($item_name) { 74 | foreach ($_SESSION['cart'] as $item) { 75 | if ($item['name'] === $item_name) { 76 | return $item_name; // Return the item when found 77 | } 78 | } 79 | 80 | return null; // Return null when not found 81 | } 82 | 83 | /** 84 | * Add a new item into the cart. 85 | * @param string $item_name 86 | */ 87 | function add_item($item_name) { 88 | if (get_item($item_name) !== null) { // If the item exists in the cart 89 | return; // Exit function handling 90 | } 91 | 92 | $_SESSION['cart'][] = [ 93 | 'name' => (string) $item_name, 94 | 'quantity' => 1 // The quantity must be positive 95 | ]; 96 | } 97 | 98 | /** 99 | * Remove an item from the cart. 100 | * @param string $item_name 101 | */ 102 | function remove_item($item_name) { 103 | foreach ($_SESSION['cart'] as $i => $item) { 104 | if ($item['name'] === $item_name) { 105 | unset($_SESSION['cart'][$i]); // Remove the item from the cart 106 | return; 107 | } 108 | } 109 | } 110 | 111 | // No closing tag needed in pure php file 112 | -------------------------------------------------------------------------------- /web/2016-spring/instant-php/src/v3/remove_item.php: -------------------------------------------------------------------------------- 1 | $quantity) { 13 | set_item_quantity((string) $name, $quantity); 14 | } 15 | 16 | // Redirect to cart page 17 | redirect('cart.php'); 18 | 19 | // No closing tag needed in pure php file 20 | -------------------------------------------------------------------------------- /web/2016-spring/instant-php/src/v4/add_item.php: -------------------------------------------------------------------------------- 1 | getItem($name) !== null) { 21 | die('Item exists'); 22 | } 23 | 24 | // Add it to the cart 25 | $cart->addItem($name); 26 | 27 | // Redirect to cart page 28 | header('Location: cart.php'); 29 | -------------------------------------------------------------------------------- /web/2016-spring/instant-php/src/v4/cart.php: -------------------------------------------------------------------------------- 1 | removeItem($name); 19 | 20 | // Redirect to cart page 21 | header('Location: cart.php'); 22 | -------------------------------------------------------------------------------- /web/2016-spring/instant-php/src/v4/save_cart.php: -------------------------------------------------------------------------------- 1 | $quantity) { 19 | $cart->setItemQuantity((string) $name, $quantity); 20 | } 21 | 22 | // Redirect to cart page 23 | header('Location: cart.php'); 24 | -------------------------------------------------------------------------------- /web/2016-spring/instant-php/src/v4/src/Dy/Component/Cart.php: -------------------------------------------------------------------------------- 1 | cartKey = $cartKey; 29 | session_start(); 30 | } 31 | 32 | /** 33 | * Get the cart from user session. 34 | * @return array 35 | */ 36 | public function getItems() 37 | { 38 | // Create a new cart if no cart available 39 | if (!isset($_SESSION[$this->cartKey])) { 40 | $this->createCart(); 41 | } 42 | 43 | // Return the cart fetched from user session 44 | return $_SESSION[$this->cartKey]; 45 | } 46 | 47 | /** 48 | * Set the quantity of the given item in the cart. 49 | * @param string $itemName 50 | * @param int $quantity If $quantity <= 0, the item will be 51 | * removed from the cart. 52 | */ 53 | public function setItemQuantity($itemName, $quantity) 54 | { 55 | if ($quantity <= 0) { // If the quantity of the item is not positive 56 | $this->removeItem($itemName); // Remove the item directly 57 | return; // Exit function handling 58 | } 59 | 60 | foreach ($_SESSION[$this->cartKey] as &$item) { // Iterate each item in the cart by reference 61 | if ($item['name'] === $itemName) { // Look for the item with the given name 62 | $item['quantity'] = $quantity; // Set the new quantity 63 | return; // Exit function handling 64 | } 65 | } 66 | 67 | // If the item is not found, add it into the cart 68 | $this->addItem($itemName); 69 | } 70 | 71 | /** 72 | * Get the given item in the cart specified by item name. 73 | * @param string $itemName 74 | * @return array|null If the item is not found, null will be returned. 75 | */ 76 | public function getItem($itemName) 77 | { 78 | foreach ($_SESSION[$this->cartKey] as $item) { 79 | if ($item['name'] === $itemName) { 80 | return $itemName; // Return the item when found 81 | } 82 | } 83 | 84 | return null; // Return null when not found 85 | } 86 | 87 | /** 88 | * Add a new item into the cart. 89 | * @param string $itemName 90 | */ 91 | public function addItem($itemName) 92 | { 93 | if ($this->getItem($itemName) !== null) { // If the item exists in the cart 94 | return; // Exit function handling 95 | } 96 | 97 | $_SESSION[$this->cartKey][] = [ 98 | 'name' => (string) $itemName, 99 | 'quantity' => 1 // The quantity must be positive 100 | ]; 101 | } 102 | 103 | /** 104 | * Remove an item from the cart. 105 | * @param string $itemName 106 | */ 107 | public function removeItem($itemName) 108 | { 109 | foreach ($_SESSION[$this->cartKey] as $i => $item) { 110 | if ($item['name'] === $itemName) { 111 | unset($_SESSION[$this->cartKey][$i]); // Remove the item from the cart 112 | return; 113 | } 114 | } 115 | } 116 | 117 | /** 118 | * Create an example cart. 119 | */ 120 | private function createCart() 121 | { 122 | $_SESSION['cart'] = [ // The following lines are defining an array with several array items 123 | ['name' => 'Area A Ticket', 'quantity' => 1], // Every item in the array is an array ['name' => x, 'quantity' => x] 124 | ['name' => 'Area B Ticket', 'quantity' => 2], // Use ',' to separate each item in an array 125 | ['name' => 'Area C Ticket', 'quantity' => 3], 126 | ['name' => 'Area D Ticket', 'quantity' => 4] // The ',' after the last item can be omitted 127 | ]; 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /web/2016-spring/instant-php/src/v4/view/cart.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |Here is your cart.
10 | 11 | 12 | 28 | 29 | 30 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /web/index.rst: -------------------------------------------------------------------------------- 1 | .. Web develop courses, provided by the following awesome members 2 | arrowrowe 3 | at15 4 | ComMouse 5 | 6 | Web develop courses 7 | ==================================== 8 | 9 | Contents: 10 | 11 | .. toctree:: 12 | :maxdepth: 2 13 | 14 | 2016-spring/index 15 | --------------------------------------------------------------------------------