SlideShare a Scribd company logo
(Ebook) Practical Web Development by kan
download
https://ebooknice.com/product/practical-web-development-50195080
Download more ebook instantly today at https://ebooknice.com
Instant digital products (PDF, ePub, MOBI) ready for you
Download now and discover formats that fit your needs...
Start reading on any device today!
(Ebook) Learning Django Web Development_ From idea to prototype, a learner's guide
for web development with the Django application framework by kan
https://ebooknice.com/product/learning-django-web-development-from-idea-to-
prototype-a-learner-s-guide-for-web-development-with-the-django-application-
framework-50195350
ebooknice.com
(Ebook) The Complete Web Design Edition by kan
https://ebooknice.com/product/the-complete-web-design-edition-50194588
ebooknice.com
(Ebook) Practical Electronics for Inventors by kan
https://ebooknice.com/product/practical-electronics-for-inventors-50195098
ebooknice.com
(Ebook) JavaScript Cookbook, 2nd Edition_ Programming the Web by kan
https://ebooknice.com/product/javascript-cookbook-2nd-edition-programming-the-
web-50195402
ebooknice.com
(Ebook) Learning LibGDX Game Development, 2nd Edition by kan
https://ebooknice.com/product/learning-libgdx-game-development-2nd-
edition-50195342
ebooknice.com
(Ebook) Python, PyGame and Raspberry Pi Game Development by kan
https://ebooknice.com/product/python-pygame-and-raspberry-pi-game-
development-50196044
ebooknice.com
(Ebook) Complete Vue.js 2 Web Development: Practical guide to building end-to-end
web development solutions with Vue.js 2 by Mike Street, Andrea Passaglia, Paul
Halliday ISBN 9781789959901, 178995990X
https://ebooknice.com/product/complete-vue-js-2-web-development-practical-guide-
to-building-end-to-end-web-development-solutions-with-vue-js-2-7336226
ebooknice.com
(Ebook) HTML5 Game Development by Example: Beginner's Guide by kan
https://ebooknice.com/product/html5-game-development-by-example-beginner-s-
guide-50195518
ebooknice.com
(Ebook) Practical Webix: Learn to Expedite and Improve your Web Development by Frank
Zammetti ISBN 9781484233832, 1484233832
https://ebooknice.com/product/practical-webix-learn-to-expedite-and-improve-
your-web-development-6981952
ebooknice.com
(Ebook) Practical Web Development  by kan
(Ebook) Practical Web Development  by kan
Practical Web Development
Table of Contents
Practical Web Development
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. The World Wide Web
World Wide Web
The Internet
HTTP and HTML
HTML
HTTP
The World Wide Web Consortium (W3C)
Mosaic
The first browser
Netscape
Internet Explorer
The explosion of the Web
Amazon.com and e-commerce
Google and Yahoo!
Social networking
Web development
HTML
HTML editors and other tools
Browsers and web servers
CSS
JavaScript
PHP
Data
Summary
2. HTML
HTML versions
Semantic and presentational HTML
The structure and syntax of an HTML document
Doctype
<html>
<head>
<body>
Syntax for tags or elements inside the document
HTML comments
Links
The <a> tag and attributes
The href attribute
The <a> name attribute
The <a> target attribute
Classic document elements
<h1>, <h2>, <h3>, … <h6> – headings
<p> – paragraph
<span> – span
Lists
Images
<img> element and attributes
Image width and height
Input forms
Form elements
Form attributes
The label attribute
Input attributes
The name attribute
The value attribute
The checked attribute
The readonly attribute
Textarea
Dropdown lists
The disabled attribute
The selected attribute
Tables
Table elements
<table>
<thead> <tbody>
<tr>
<th> <td>
Table attributes
colspan (td)
rowspan (td)
<div>, the "uebertag"
HTML entities
HTML5-specific tags
Summary
3. CSS
Adding styles to our documents
External style sheets
Internal CSS
Inline styles
The Document Object Model (DOM)
Selectors
Multiple classes
Descendants
Selecting children or siblings
Specificity
Block elements and inline elements
Colors
Fonts
So what are fonts?
Font families
Serif fonts
Sans-serif fonts
Monospace fonts
The font-family property
Font-weight and font-style
Font-size
Line-height
The box model
Padding
Border
Margin
Collapsing margins
Positioning
Float
position:relative
position:absolute
Styling lists
list-style-type
list-style-image
list-style-position
Styling anchors – pseudo-classes
Firebug
Summary
4. JavaScript
Programming 101
Compiled and interpreted languages compared
JavaScript is not the same as Java
Java
JavaScript
Our first JavaScript program
Variables
Variable declarations
Values of variables
Numbers
Strings
Converting strings to numbers
Expressions and operators
Arithmetic operators
Addition(+)
Subtraction (-)
Multiplication (*)
Division (/)
Modulo (%)
Relational operators
Control flow
if
while
switch
Functions
Scope of variables
Objects
JSON
DOM objects, properties, methods, and events
The Window object
The Document object
write and writeln methods
Nodes and DOM traversing
Events
Summary
5. PHP
Introduction to PHP
Our first real PHP program
PHP and web hosting
Web hosting 101
Domain name
Web hosting companies
Server-side setup
Additional server-side services
PHP development environment
PHP as a web development language
Variables, values, operators, and expressions
Scope of variables
Local variables
Global variables
Static variables
String operators
To double quote or to single quote, that is the question
Control flow
Functions
String functions
strpos()
strlen()
substr()
Date functions
time()
date()
strtotime()
Arrays
Numeric arrays or indexed arrays
Associative arrays
Cool control statements for associative arrays
Sending data back to the server – forms
POST or GET, what should we get?
$_POST and $_GET arrays
Files
include, require, and require_once
Regular files
File functions or f-functions
fopen
file_exists(), is_file(), and is_dir()
fread and fwrite
One line at a time – fgets()
The printf family
Syntax of printf family of functions
Summary
6. PHP and MySQL
Databases
Relational databases
SQL
MySQL
phpMyAdmin
Creating databases
Creating and managing users
Creating and managing database tables
MySQLi in PHP
Connecting to the database
Our first SQL query, really!
Writing a MySQL query in PHP
Fetching the result
Obtaining data from more than one table
Adding data
Updating data
Summary
7. jQuery
Obtaining the jQuery library
Where to place the jQuery library on your page?
jQuery UI and jQuery Mobile
Using jQuery selectors and methods
html()
text()
attr()
.val()
show() and hide()
.find()
.parent()
.next()
.css()
jQuery documentation
Event handlers and jQuery
preventDefault()
$(this)
updateNewsContent()
Summary
8. Ajax
XMLHttpRequest
Ajax and jQuery
jQuery Ajax methods
$.load() method
$.post()
$.ajax()
Summary
9. The History API – Not Forgetting Where We Are
The problem we are trying to solve
The self-service restaurant
HTML5 History API and the history object
pushState()
popstate event
popstate and different browsers
The History plugin
Bookmarking
Summary
10. XML and JSON
XML
XML format
Displaying XML files
XML editors
XML Schema
SimpleXML
The XML file
The XML Schema file
The CSS file
The PHP file
Creating XML files with SimpleXML
Generating our HTML on the client side
XSLT
JSON
JSON syntax
JSON values
JSON objects
JSON strings
JSON arrays
JSON numbers
JSON and PHP
JSON with Ajax and jQuery
Two useful JSON methods
Summary
11. MongoDB
Relational database management systems
NoSQL databases
MongoDB
Installing MongoDB
The MongoDB shell
Creating databases, collections, and documents
_id and ObjectIds
Loading scripts
Removing documents
Updating documents
MongoDB data types
Basic data types
Dates
Embedded documents
One more example
MongoDB and PHP
Getting our gallery data
CRUD operations with MongoDB and PHP
Insert documents
Update documents
Queries with conditions
MongoDB cursor object
Summary
12. Mobile First, Responsive Design with Progressive Enhancement
Responsive design
Déjà vu
Media queries
Using the media attribute
Do more with less
Mobile first
Why mobile first?
We have come a long way
Mobile devices have newer capabilities
Mobile devices are not only used while on the road
Content first, navigation next
Small means big
Mobile input
Mobile first recap
Progressive enhancement
EnhanceJS
enhance.js
loadStyles and loadScripts
enhanced and FOUC
Modernizr
The Modernizr object
Polyfills and Modernizr
yepnope.js or Modernizr.load
Summary
13. Foundation – A Responsive CSS/JavaScript Framework
Our responsive toolkit – Foundation
Foundation components
The grid system
Class end
Visibility classes
The block grid system
Useful UI elements
Thumbnails – for simple galleries
Reveal modals – your better pop-up
Dropdowns
Example – a simple photo gallery
Accordions
Awesome Font awesome
Equalizer – the hardest thing to do with two <div>s made easy
Navigation
Top bar – not just your regular menu bar
Adding more magic
Yet more magic – off-canvas, the coolest thing
Summary
14. Node.js
Node.js
Installing node.js
npm
node
Adding HTML
Serving up static content
A tale of two (JavaScript) cities
node.js and MongoDB
Déjà vu … once more
Express
Installing Express
Our first Express app
An example with middleware
Templating and handlebars.js
Creating a layout
Our last Hello, World example
Summary
A. Bootstrap – An Alternative to Foundation
Bootstrap components
The Bootstrap grid system
Visibility classes
Buttons
Other UI elements
Thumbnails
Dropdowns
Modal – the Bootstrap popup
Combining dropdowns and modals
Collapse – an accordion for Bootstrap
Navigation
Summary
Index
Practical Web Development
Practical Web Development
Copyright © 2015 Packt Publishing All rights reserved. No part of this book
may be reproduced, stored in a retrieval system, or transmitted in any form or by
any means, without the prior written permission of the publisher, except in the
case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy
of the information presented. However, the information contained in this book is
sold without warranty, either express or implied. Neither the author, nor Packt
Publishing, and its dealers and distributors will be held liable for any damages
caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of
the companies and products mentioned in this book by the appropriate use of
capitals. However, Packt Publishing cannot guarantee the accuracy of this
information.
First published: July 2015
Production reference: 1240715
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78217-591-9
www.packtpub.com
Credits
Author
Paul Wellens
Reviewers
Jorge Albaladejo
Elvis Boansi
Adam Maus
Jesús Pérez Paz
Commissioning Editor
Edward Gordon
Acquisition Editors
James Jones
Sonali Vernekar
Content Development Editor
Ritika Singh
Technical Editor
Ryan Kochery
Copy Editors
Alpha Singh
Ameesha Green
Jasmine Nadar
Jasmine Nadar
Project Coordinator
Milton Dsouza
Proofreader
Safis Editing
Indexer
Rekha Nair
Production Coordinator
Manu Joseph
Cover Work
Manu Joseph
About the Author
Paul Wellens has been a senior product manager for a major computer company
in the Los Angeles area and Silicon Valley for over two decades. Before that, he
used to install Unix systems and train companies in Europe, from his native
Belgium. Later in his career, he became a web development aficionado because
it brought him back to another passion of his: programming.
This is not his first book. His prior publication is of a different nature. Nature is
what it is all about as it is a guidebook on Eastern California, which is illustrated
with his own photographs. Therefore, it should not come as a surprise to learn
that, besides experimenting with new web technologies, his major hobbies are
photography and hiking in the Eastern Sierra.
Acknowledgments
I have written books before and I know that the result can only be successful if
there are some nice people to assist you. This is the first time that I have worked
with a publisher, Packt Publishing, so these are the first people I would like to
thank. I would like to thank Shivani Wala for discovering me and James Jones
for working with me to figure out the right book for me to write and for you to
read. I enjoyed working with Priyanka Shah, Ritika Singh, and Ryan Kochery
who assisted me in bringing this cool project to completion, without a single
complaint, even though I was once again late with a deliverable. Thank you for
being so patient with me.
I would also like to thank (yes, this is a note of cynicism) the three companies
that "manage" the railroads in Belgium. Without their comedy of errors with
trains—delays, cancellations, failure to depart because of mechanical problems,
or trains departing from the station where you want to get to, as opposed to
depart from, I would never had so much time to work on this book on my iPad.
It is not in their honor, but, because for 2 years, it was the highlight of my day to
safely arrive at Antwerp Central Station—which was rated by an American
newspaper as the most beautiful train station in the world—that we decided to
use it as the cover photo.
Next, I would like to thank my web developer buddy, Björn Beheydt, for taking
the time to read the early versions of the chapters of this book and providing
constructive feedback. I would also like to mention Steve Drach and Bart
Reunes for always being there when I needed some technical advice.
Then, there are places that I would like to call a home away from home, where
folks did not mind that I was typing away on my Bluetooth keyboard when
inspiration kicked in. Most notably, I have to thank the folks at Trapke Op
(Caro, Maressa, Evi, Klaartje and Jill) in Brecht, Belgium, where I typed these
sentences. These wonderful people helped me make it to the finish line. Het
Boshuisje in Zoersel, where Hendrik Conscience wrote books over a hundred
years before I did, also comes to mind. I would like to thank Theo for always
giving me a seat to land with my iPad, keyboard, and work.
Less related to this book, but still in need of a mention, are all my friends in
California that inspired me to carry on doing great things in hard times. In
particular, I want to express my appreciation to the people that work(ed) at the
particular, I want to express my appreciation to the people that work(ed) at the
Gordon Biersch Restaurant in Palo Alto, which I can still proudly call my photo
gallery. I thank them for their support for over 11 years and for still welcoming
me when I visit them; they make me feel as if I only left last night. That also
includes the patrons of the place with whom I've had numerous conversations
and enjoyed every single one of them.
If you read this book, or my previous book, you will notice that I have a certain
affinity and passion for a particular part of California. So, I would like to thank
all the wonderful folks that live in the town of June Lake, California, for always
having inspired me to come back and be creative. My goal in life is to go there
as often as I can.
Finally, I would like to thank my mother. It has been hard for her since my father
passed away and her son returned. I am dedicating this book to her, not that I
expect her to read it, but I really appreciate the patience she had with me while I
was writing it.
About the Reviewers
Jorge Albaladejo is a software engineer with a master's degree in information
and communication technologies from HES-SO, Switzerland. With over a
decade of experience building cloud, SaaS, and web applications, he considers
himself to be a passionate and versatile full-stack web developer.
Throughout his professional experience, he has worked with many companies in
different fields, such as project management, social networks, quality assurance,
weather data visualization, and video games. He devours countless books about
software engineering, project management, and science fiction, and he is
passionate about clean, long-lasting software architectures.
He is currently working as a freelance contractor under the commercial name of
CometaStudio, and he is mostly interested in start-ups and mid-sized companies
that build great web experiences for great causes that make a difference. His next
dream is to become a digital nomad who travels around the globe while working
at the same time—and learn languages in the process!
Elvis Boansi is a software developer at John Jay College. He develops and
maintains custom web applications that are used by members of the college. In
his spare time, he enjoys playing soccer and basketball with his friends.
I'd like to thank my employers at John Jay College for all of their support. I
would also like to thank my supervisors, Ana and Juan, for their feedback. I
thank my friends, Sanga, Steve, and Loric, for constantly sharing their
knowledge with me.
Adam Maus is a software developer with a master's degree in computer science
and works at the Center for Health Enhancement Systems Studies at the
University of Wisconsin in Madison in the United States. His interests lie in
developing web technologies that utilize data mining to create better user
experiences. He primarily works on websites that help people undergoing
addiction recovery support, as well as people who are aging. In his free time, he
enjoys running, biking, and reading books.
Jesús Pérez Paz is a full-stack web developer with experience in project
management. He works at PepitaStore Inc. and collaborates with Mozilla.
His main area of work is design, and he integrates the user interface (or
frontend) of web pages / applications; however, lately, he has been diving into
backend stuff and has become a full-stack web developer.
He loves the open/free Internet and thinks that the Internet is a global public
resource that must remain open and accessible to everyone.
www.PacktPub.com
Support files, eBooks, discount offers, and more
For support files and downloads related to your book, please visit
www.PacktPub.com.
Did you know that Packt offers eBook versions of every book published, with
PDF and ePub files available? You can upgrade to the eBook version at
www.PacktPub.com and as a print book customer, you are entitled to a discount
on the eBook copy. Get in touch with us at <service@packtpub.com> for more
details.
At www.PacktPub.com, you can also read a collection of free technical articles,
sign up for a range of free newsletters and receive exclusive discounts and offers
on Packt books and eBooks.
https://www2.packtpub.com/books/subscription/packtlib
Do you need instant solutions to your IT questions? PacktLib is Packt's online
digital book library. Here, you can search, access, and read Packt's entire library
of books.
Why subscribe?
Fully searchable across every book published by Packt
Copy and paste, print, and bookmark content
On demand and accessible via a web browser
Free access for Packt account holders
If you have an account with Packt at www.PacktPub.com, you can use this to
access PacktLib today and view 9 entirely free books. Simply use your login
credentials for immediate access.
Preface
I am fortunate to have lived and worked in California for a long time. The
majority of that time, I lived in Palo Alto, which is the center of Silicon Valley,
the home of Stanford University, and the birthplace of many companies, big and
small, such as Sun Microsystems, where I worked. I sat on the front row to see
how the World Wide Web developed, as well as being present for the advent of
social media. Facebook started on the other side of the wall of my favorite
restaurant. Now, some Facebook guy or girl is sitting in what used to be my
office at the bottom of the Dumbarton Bridge. As a product manager for Solaris,
one of my tasks was to make sure that Netscape Navigator was included with our
operating system. So, I was right at the source in which the development of the
Web began. I even went to the Web 2.0 conference and bought the book of the
same name.
Then, I felt the need to have my own website to display my photographs and
inform people about the beauty and interesting places of the parts of California
that I had discovered during my many journeys travelling around the state. So, I
created one. One day, I was telling a friend about it and he tried to look at it on
his mobile phone. It looked terrible. So, I bought a Nokia phone (a brick
compared to what we have today) so that I could test my own site to make sure
that it looked good on a phone as well. This is how I caught the bug of
responsive design, years before someone started calling it this.
Upon my return to Belgium, I decided that it was time to learn as much as
possible (I love to learn new things) about what is out there beyond creating
websites and took a 6-month course on PHP web development. A lot of it looked
familiar as I was previously a UNIX and C developer. There were only 12
people in the class, who were all bright minds, and I quickly discovered that
there was more to learn.
As the classes took place in Leuven, a major university town in Belgium, I went
to the local university bookstore and bought book after book on all kinds of
related topics and quickly became a jQuery fan. jQuery, by the way, was not
even included in the course. I started wondering why someone needed to have 35
different books to learn about web development and that writing a single book
that gave a comprehensive overview of what you need to know to engage in web
development would not be a bad idea.
Since then, web development has changed a lot; more books were needed,
eBooks this time, but the concept remained the same. So, now you know why I
wrote the book.
This book gives you an overview of all the general aspects of web development,
in a traditional way, using plain HTML to do static websites, as well as the
current way, to enable you to create your web pages dynamically and make sure
that they look great on mobile devices as well, by using responsive design. We
conclude by giving you a hint of what is yet to come if you replace the
traditional web server by writing your own using node.js.
What this book covers
Chapter 1, The World Wide Web, gives you an overview of the history of what
we know today as the World Wide Web.
Chapter 2, HTML, introduces HTML and gives you an overview of the most
commonly used HTML tags to do web development. You will be able to create a
basic website after reading this chapter.
Chapter 3, CSS, explains how to use Cascading Style Sheets (CSS). This is used
for the presentation part or layout of your website, from color to dimensions to
typefaces. The most commonly used CSS properties are explained here. Once
you are done with this chapter, you will be able to make your basic website look
good.
Chapter 4, JavaScript, first gives you an introduction to the world of
programming and programming languages. Next, the overall syntax of
JavaScript and how to use it for client-side programming is introduced.
Chapter 5, PHP, explains PHP, which is another programming language. This
one is used to do server-side programming. It requires a web server to do the
development of your website and deploy it. You will learn how to dynamically
create your web pages, rather than having to write a bunch of HTML files.
Chapter 6, PHP and MySQL, introduces MySQL, an open source database. You
will learn how to create a database, manage it using the phpMyAdmin tool, and
perform basic CRUD (create, replace, update, delete) operations from within a
PHP program.
Chapter 7, jQuery, covers a popular JavaScript library. It allows you to write
more compact and clean code and handles browser incompatibilities for you.
With this, it is going to be a lot easier and faster for you to write JavaScript code
that traverses and manipulates the web page. It does so by using selectors, which
you learned to use with CSS. So, with jQuery, you can write JavaScript code
without having to learn a lot of JavaScript.
Chapter 8, Ajax, introduces Ajax. It represents a collection of techniques to make
it easy to dynamically change only portions of a website. With this chapter, we
have entered the world of what I call "modern web development". The interface
that we use for our Ajax calls is jQuery.
Chapter 9, The History API—Not Forgetting Where We Are, explains a very
important piece of the web development puzzle. Once we are changing pages on
the fly so they look different but actually remain the same page (URL), strange
things can happen when visitors want to go back to what they think is the
previous page. A solution for this is described here that will not only work for
HTML5 but for HTML4 as well.
Chapter 10, XML and JSON, describes XML and JSON. They are two popular
formats to exchange data, for example the server and the client. Although XML
is used in a variety of environments, JSON is closer to the web development
community.
Chapter 11, MongoDB, describes an alternative to MySQL as a database. This is
a so-called NoSQL database and a document database. Documents are
conveniently in the JSON format. Here, how to access a MongoDB database
from within a PHP program is described.
Chapter 12, Mobile First, Responsive Design with Progressive Enhancement,
has the longest chapter title of the book. It explains how modern web
development has to be done now that more people are using mobile devices
instead of traditional computer screens to go to websites.
Chapter 13, Foundation – A Responsive CSS/JavaScript Framework, describes
most of the features of the Foundation framework, which helps you with your
responsive design. It contains everything that I have always wanted to write
myself but never had the time to do. This concludes the part of the book that
covers what I call modern web development.
Chapter 14, Node.js, gives an overview of what I call the avant-garde of web
development. It introduces node.js, which allows you to write your server-side
code in JavaScript, including your own web server, which is facilitated by using
the Express framework.
Appendix, Bootstrap – An Alternative to Foundation, describes the popular
CSS/JavaScript framework, which is an alternative to Foundation to help you
with responsive design. The main reason to include this is to point out key
differences and similarities.
The online chapter, The Mono County Site, provides a full example of a website
or application where we apply most, if not all, the things we learned. It is
available at
https://www.packtpub.com/sites/default/files/downloads/B03816_Appendix.pdf.
What you need for this book
You will need the following software to work with the examples in this book:
Software Source
Firefox and Firebug http://www.mozilla.org
Apache Web Server Part of the OS
XAMPP (includes MySQL and
PHPMyAdmin)
http://www.apachefriends.org
MySQL http://www.mysql.com
PHPMyAdmin phpmyadmin.net
jQuery http://www.jquery.com
The History jQuery plugin https://github.com/browserstate/history.js
MongoDB mongodb.org
Foundation foundation.zurb.com
Node.js nodejs.org
Bootstrap getbootstrap.com
Who this book is for
This book is for anyone who wants to get to grips with the broader picture of
web development today. It is perfect for beginners who want to get started and
learn web development basics, such as HTML, but it also offers experienced
developers a web development road map that will help them to extend their
capabilities and gain a greater insight into how different technologies interact
and work together.
Conventions
In this book, you will find a number of text styles that distinguish between
different kinds of information. Here are some examples of these styles and an
explanation of their meaning.
Code words in text, database table names, folder names, filenames, file
extensions, pathnames, dummy URLs, user input, and Twitter handles are shown
as follows: "We can include other contexts through the use of the include
directive."
A block of code is set as follows:
<body>
<div id="header"></div>
<div id="container">
<div id="left"></div><div id="middle"></div><div id="right"></div>
</div>
<div id="footer"></div>
</body>
When we wish to draw your attention to a particular part of a code block, the
relevant lines or items are set in bold:
<tag class="value1 value2">text<?tag>
Any command-line input or output is written as follows:
{ "key" : { "name":"Schwarzenegger","first":"Arnold",
"profession":"governator" } }
New terms and important words are shown in bold. Words that you see on the
screen, for example, in menus or dialog boxes, appear in the text like this: "
Now, not until a user clicks the Beach button, Hello, World will turn into Hello,
Beach."
Note
Warnings or important notes appear in a box like this.
Tip
Tips and tricks appear like this.
Tips and tricks appear like this.
Reader feedback
Feedback from our readers is always welcome. Let us know what you think
about this book—what you liked or disliked. Reader feedback is important for us
as it helps us develop titles that you will really get the most out of.
To send us general feedback, simply e-mail <feedback@packtpub.com>, and
mention the book's title in the subject of your message.
If there is a topic that you have expertise in and you are interested in either
writing or contributing to a book, see our author guide at
www.packtpub.com/authors.
Customer support
Now that you are the proud owner of a Packt book, we have a number of things
to help you to get the most from your purchase.
Downloading the example code
You can download the example code files from your account at
http://www.packtpub.com for all the Packt Publishing books you have
purchased. If you purchased this book elsewhere, you can visit
http://www.packtpub.com/support and register to have the files emailed directly
to you.
Errata
Although we have taken every care to ensure the accuracy of our content,
mistakes do happen. If you find a mistake in one of our books—maybe a mistake
in the text or the code—we would be grateful if you could report this to us. By
doing so, you can save other readers from frustration and help us improve
subsequent versions of this book. If you find any errata, please report them by
visiting http://www.packtpub.com/submit-errata, selecting your book, clicking
on the Errata Submission Form link, and entering the details of your errata.
Once your errata are verified, your submission will be accepted and the errata
will be uploaded to our website or added to any list of existing errata under the
Errata section of that title.
To view the previously submitted errata, go to
https://www.packtpub.com/books/content/support and enter the name of the
book in the search field. The required information will appear under the Errata
section.
Piracy
Piracy of copyrighted material on the Internet is an ongoing problem across all
media. At Packt, we take the protection of our copyright and licenses very
seriously. If you come across any illegal copies of our works in any form on the
Internet, please provide us with the location address or website name
immediately so that we can pursue a remedy.
Please contact us at <copyright@packtpub.com> with a link to the suspected
pirated material.
We appreciate your help in protecting our authors and our ability to bring you
valuable content.
Questions
If you have a problem with any aspect of this book, you can contact us at
<questions@packtpub.com>, and we will do our best to address the problem.
Chapter 1. The World Wide Web
This book talks about the past, present, and future of Web Development.
Beginning with Chapter 2, HTML, we will walk you through all the technologies
you need to know about, in order to practice web development. Before we do
that, we want to set the stage, so that we all know which Web we are talking
about: this would be the World Wide Web (www).
World Wide Web
I love history! So let us start with a little history about the World Wide Web. I
was fortunate enough to be able to work at a company that developed the first
commercial version of the UNIX Operating System. They were founded in 1977
and I joined them ten years later. UNIX is an Operating System (the thing you
need to make your computer do something) that was intended to run on
minicomputers (although they were called that, they could not fit into your
apartment and required air-cooling). These computers were typically used as an
isolated system that had quite a number of text-based terminals attached to them.
Today UNIX lives on, and forms the basis of Linux, Solaris, MacOS, and others.
Our company spotted an opportunity to add products that would add features and
technologies that today are standard. Some of these examples are email (ability
to send a mail to a person on another computer), and ftp (ability to transfer a file
to another computer, or to just access another computer). Yes, you had to pay
extra if you wanted to be able to send mail. Thanks to the Internet, all of this was
made possible.
The Internet
The Internet is a global network that today interconnects billions of computers
worldwide. Its origin dates back to research done for the US government, but
today everybody can get on the Internet, using its standard set of protocols,
commonly referred to as TCP/IP (the IP here being Internet Protocol).
Every computer or device that is connected to the Internet will have a unique
Internet address, aka IP address. It is a set of 4 numbers separated by dots, for
example, 192.25.13.90. Of course, you will never tell your friend that you
bought something at 192.25.13.90 but at, for instance, www.amazon.com. This
is because the Internet also uses a feature that translates IP addresses into easier
to remember domain names. The example I used happens to be a website you
can go to and buy things from a practice that we all know has caused the www to
become what it is today.
The Internet and the www are, in everyday speech, treated as if they are
synonyms but they are indeed not. There are a lot of different services provided
on the Internet (by companies called Internet Service Providers (ISP)), and
that was already the case before the www existed (for example, giving you
access to electronic mail). What it took for the www to emerge was (just like in
JavaScript) a series of asynchronous events. Two of those are too important to
not mention.
HTTP and HTML
You have probably heard this story many times, but the World Wide Web would
not have existed without it. It is the story of Tim Berners Lee, an engineer at the
European Centre for Nuclear Research (CERN). The centre had many
computers that were, of course, hooked up to the Internet. It also produced a
tremendous amount of data and documents, and that became almost impossible
to manage. Tim worked out a solution by developing a language to write these
documents in, a protocol on top of the Internet to manage them, as well as a
computer program for users to access them.
HTML
HTML, short for Hypertext Markup Language is the name of that language.
Hypertext is text that contains hyperlinks, which in turn are those parts of a
document which readers can click on to take them to a different document, using
the link. You have all seen the blue underlined parts of a text, in not-so-good-
looking web pages. These are hyperlinks.
A document in HTML consists of tags, with text in between them. There are
opening and closing tags for example, as follows:
<h1>Hello, world</h1>
Here, <h1> is the opening tag and </h1> the closing one. We will learn about a
similar markup language: XML. HTML and XML are not the same though. One
important difference is that in XML you can define your own tags, as long as
you close each one you've opened. XML is used to transfer the data and the tags
are used to organize the data.
In HTML, tags do have a specific meaning. <h1> would be used in a document
for the text of a level one header. A <a> tag—the anchor tag—is the one used to
include the hyperlinks we just discussed. So the purpose of writing HTML is not
to transfer data, but to present it to human users.
To do so, these tags are interpreted by the computer program we mentioned
earlier. Such a program is called a browser. When the reader clicks on a
hyperlink, the browser will detect that as well, and send a request to yet another
program, the web server, to go fetch another document.
Random documents with unrelated
content Scribd suggests to you:
particular about a few pigs and chickens and sweet potatoes, for he
was really getting hungry, and when a man is in this condition he is
not in a fit mood to grapple with fine-spun theories of governmental
policy.
So when a fat pig came wabbling and grunting toward his post, it
was to Si like a vision of manna to the children of Israel in the
wilderness. A wild, uncontrollable desire to taste a fresh spare-rib
took possession of him. Naturally, his first idea was to send a bullet
through the animal, but on second thought he saw that wouldn't do
at all. It would "give him away" at once, and, besides, he had found
that a single shot on the picket-line would keep Buell's entire army in
line-of-battle for a whole day.
Si wrote to his mother that his bright new bayonet was stained
with Southern blood, and the old lady shuddered at the awful
thought. "But," added Si, "it was only a pig, and not a man, that I
killed!"
"I'm so glad!" she exclaimed.
By the time Si had been in the service a year there was less zeal
in the enforcement of orders of this kind, and Si had become a very
skillful and successful forager. He had still been unable to reach with
his bayonet the body of a single one of his misguided fellow citizens,
but he had stabbed a great many pigs and sheep. In fact, Si found
his bayonet a most useful auxiliary in his predatory operations. He
could not well have gotten along without it.
Uncle Sam generally furnished Si with plenty of coffee—roasted
and unground—but did not supply him with a coffee mill. Si thought
at first that the Government had forgotten something. He saw that
several of the old veterans of '61 had coffee mills, but he found on
inquiry that they had been obtained by confiscation only. He
determined to supply himself at the first opportunity, but in the
meantime he was obliged to 'use his bayonet as a substitute, just as
all the rest of the soldiers did.
We regret to say that Si, having thrown away his "Baxter's Call to
the Unconverted" in his first march, and having allowed himself to
forget the lessons he had learned but a few years before in Sunday-
school, soon learned to play poker and other sinful games. These, at
night, developed another use for the bayonet. In its capacity as a
"handy" candlestick it was "equaled by few and excelled by none."
The "shank" was always ready to receive the candle, while the point
could be thrust into the ground in an instant, and nothing more was
necessary. This was perhaps the most general sphere of usefulness
found by the bayonet during the war. Barrels of candle-grease
flowed down the furrowed sides of this weapon for every drop of
human blood that dimmed its luster.
CHAPTER IV. THE AWFUL
HARDTACK
THE HARD AND SOLID STAFF OF MILITARY
LIFE.
"APPETITE'S a queer thing," said Si to Shorty one day, when both
were in a philosophical mood. "It's an awful bother when you
haven't it, and it's a great deal worse when you have it, and can't
get anything for it." "Same as money," returned sage Shorty. During
the first few months of Si Klegg's service in the army the one thing
that bothered him more than anything else was his appetite. It was
a very robust, healthy one that Si had, for he had grown up on his
father's farm in Indiana, and had never known what it was to be
hungry without abundant means at hand for appeasing his desires in
that direction. His mother's cupboard was never known to be in the
condition of Old Mother Hubbard's, described in the nursery rhyme.
The Kleggs might not have much tapestry and bric-a-brac in their
home, but their smoke-house was always full, and Mrs. Klegg's
kitchen could have fed a camp-meeting any time without warning.
So it was that when Si enlisted his full, rosy face and his roundness
of limb showed that he had been well fed, and that nature had made
good use of the ample daily supplies that were provided. His
digestive organs were kept in perfect condition by constant exercise.
After Si had put down his name on the roll of Co. Q of the 200th
Ind. he had but a few days to remain at home before his regiment
was to start for Louisville. During this time his mother and sisters
kept him filled up with "goodies" of every sort. In fact, it was the
biggest thing in the way of a protracted picnic that Si had ever
struck.
"You must enjoy these things while you can, Si," said his mother,
"for goodness knows what you'll do when you really git into the
army. I've heerd 'em tell awful things about how the poor sogers
don't have half enough to eat, and what they do git goes agin' any
Christian stomach. Here, take another piece of this pie. A little while,
and it'll be a long time, I reckon, till ye git any more."
"Don't keer if I do!" said Si, for there was scarcely any limit to his
capacity.
And so during those days and nights the old lady and the girls
cooked and cooked, and Si ate and ate, until it seemed as if he
wouldn't want any more till the war was over.
Si was full, and as soon as Co. Q was, it was ordered to camp, and
Si had to go. They loaded him down with good things enough to last
him a week. The pretty Annabel—the neighbor's daughter who had
solemnly promised Si that she wouldn't go with any other fellow
while he was away—came around to see Si off and brought him a
rich fruit cake.
"I made that for you," she said.
"Bully for you!" said Si, for he felt that he must begin to talk like a
soldier.
The first day or two after reaching Louisville the 200th received
rations of "soft bread." But that didn't last long. It was only a way
they had of letting the fresh soldier down easy. Orders came to get
ready to pull out after Bragg, and then Si'a regiment had its first
issue of army rations. As the Orderly pried open a box of hardtack
and began to distribute them to the boys, exclaimed:
"Them's nice-looking soda crackers. I don't believe the grub is
going to be so bad, after all."
Si had never seen a hardtack before.
"Better taste one and see how you like it!" said one of Buell's
ragged Indiana veterans, who had come over to see the boys of the
200th and hear the latest news from "God's country."
It happened that this lot was one of extra quality as to hardness.
The baker's watch had stopped, or he had gone to sleep, and they
had been left in the oven or dry-kiln too long. Si took one of them
and carried it to his mouth. He first tried on it the bite which made
such havoc with a quarter section of custard pie, but his incisors
made no more impression upon it than if it had been a shingle.
"You have to bear on hard," said the veteran, with a grim smile.
"Je-ru-sa-lem!" exclaimed Si after he had made two or three
attempts equally barren of results.
Then he tried his "back teeth." His molars were in prime order,
and his jaw power was sufficient to crack a hickory nut every time.
Si crowded one corner of the hardtack as far as he could between
his "grinders," where he could get a good "purchase" on it, shut his
eyes and turned on a full head of steam. His teeth and jaws fairly
cracked under the strain, but he couldn't even "phase" it.
"If that ain't old pizen!" said Si. "It beats anything I ever seen up
in the Wabash country."
But his blood was up, and laying the cracker upon a log, he
brought the butt of his gun down upon it like a pile-driver.
"I thought I'd fix ye," he said, as he picked up the fragments, and
tried his teeth upon the smaller ones. "Have I got to eat such stuff
as that?" with a despairing look at his veteran friend. "I'd just as
soon be a billy-goat and live on circus-posters, fruit-cans and old
hoop-skirts."
"You'll get used to it after a while, same's we did. You'll see the
time when you'll be mighty glad to get even as hard a tack as that!"
Si's heart sank almost into his shoes at the prospect, for the taste
of his mother's pie and Annabel's fruit cake were yet fresh in his
mouth. But Si was fully bent on being a loyal, obedient soldier,
determined to make the best of everything without any more
"kicking" than was the inalienable right of every man who wore a
uniform.
For the first time in his life Si went to bed hungry that night.
Impelled by the gnawings of his appetite he made repeated assaults
upon the hardtack, but the result was wholly insufficient to satisfy
the longings of his stomach. His supper wasn't anything to speak of.
Before going to bed he began to exercise his ingenuity on various
schemes to reduce the hardtack to a condition in which it would be
more gratifying to his taste and better suited to the means with
which nature had provided him for disposing of his rations. Naturally
Si thought that soaking in water would have a beneficial effect. So
he laid five or six of them in the bottom of a camp-kettle, anchored
them down with a stone, and covered them with water. He thought
that with the aid of a frying-pan he would get up a breakfast that he
could eat, anyway.
Si felt a little blue as he lay curled up under his blanket with his
head pillowed on his knapsack. He thought some about his mother,
and sister Maria, and pretty Annabel, but he thought a good deal
more about the beef and potatoes, the pies and the puddings, that
were so plentifully spread upon the table at home.
It was a long time before he got to sleep. As he lay there, thinking
and thinking, there came to his mind some ether uses to which it
seemed to him the hardtack might be put, which would be much
more consistent with its nature than to palm it off on the soldiers as
alleged food. He thought he could now understand why, when he
enlisted, they examined his teeth so carefully, as if they were going
to buy him for a mule. They said it was necessary to have good
teeth in order to bite "cartridges" successfully, but now he knew it
was with reference to his ability to eat hardtack.
Si didn't want to be killed if he could help it.
While he was lying there he determined to line one of his shirts
with hardtacks, and he would put that on whenever there was going
to be a fight. He didn't believe the bullets would go through them.
He wanted to do all he could toward paralyzing the rebels, and with
such a protection he could be very brave, while his comrades were
being mowed down around him. The idea of having such' a shirt
struck Si as being a brilliant one.
Then, he thought hardtack would be excellent for half-soling his
shoes. He didn't think they would ever wear out.
If he ran short of ammunition he could ram pieces of hardtack into
his gun and he had no doubt they would do terrible execution in the
ranks of the enemy.
All these things and many more Si thought of until finally he was
lost in sleep. Then he dreamed that somebody was trying to cram
stones down his throat.
The company was called out at daylight, and immediately after
roll-call Si went to look after the hardtacks he had put to soak the
night before. He thought he had never felt so hungry in his life. He
fished out the hardtack and carefully inspected them, to note the
result of the submerging and to figure out the chances on his much-
needed breakfast.
To any old soldier it would be unnecessary to describe the
condition in which Si found those hardtacks, and the effect of the
soaking. For the information of any who never soaked a hardtack it
may be said that Si found them transformed, to all appearances, into
sole-leather. They were flexible, but as tough as the hide that was
"found in the vat when the tanner died."
Si tried to bite a piece off one of them to see what it was like, but
he couldn't get his teeth through it. In sheer desperation he laid it
on a log, seized a hatchet, and chopped off a corner. He put it in his
mouth and chewed on it a while, but found it as tasteless as cold
codfish.
Si thought he would try the frying-pan. He chopped the hardtacks
into bits, put in equal parts of water and grease, sifted over the
mixture a little salt and pepper, and then gave it a thorough frying.
Si's spirits rose during the gradual development of this scheme, as it
seemed to offer a good prospect for his morning meal. And when it
came to the eating. Si found it really good, comparatively speaking,
even though it was very much like a dish compounded of the
sweepings from around a shoemaker's bench. A good appetite was
indispensable to a real enjoyment of this—which the soldiers called
by a name that cannot be given here—but Si had the appetite, and
he ate and was thankful.
"I thought I'd get the bulge on them things some way or other,"
said Si, as he drank the last of his coffee and arose from his meal,
feeling like a giant refreshed with new wine.
For the next two or three months Si largely devoted his surplus
energies to further experimenting with the hardtack. He applied
every conceivable process of cookery he could think of that was
possible with the meager outfit at his command in the way of
utensils and materials. Nearly all of his patient and persevering
efforts resulted only in vexation of spirit.
He continued to eat hardtack from day to day, in these various
forms, but it was only because he had to do it. He didn't hanker
after it, but it was a military necessity—hardtack or starvation. It was
a hard choice, but Si's love of life—and Annabel—induced him to
choose the hardtack.
But for a long-time Si's stomach was in a state of chronic
rebellion, and on the whole he had a hard time of it getting used to
this staple article of army diet. He did not become reconciled to it
until after his regiment had rations of flour for a week, when the
"cracker-line" had been cut by the guerillas and the supply of that
substantial edible was exhausted. Si's experience with the flour
swept away all his objections to the hardtack. Those slapjacks, so
fearfully and wonderfully made, and those lumps of dough, mixed
with cold water and dried on flat stones before the fire, as hard as
cannon balls, played sad havoc with his internal arrangements. For
the first time he was obliged to fall into the cadaverous squad at
sick-call and wabble up to the doctor's shop, where he was dosed
with castor-oil and blue-mass. Si was glad enough to see hardtack
again. Most of the grumbling he did thereafter concerning the
hardtack was because he often couldn't get enough.
About six months taught Si what all the soldiers learned by
experience, that the best way to eat the average hardtack was to
take it "straight"—just as it came out of the box, without any
soaking or frying or stewing. At meal-time he would make a quart or
so of coffee, stab the end of a ramrod through three or four slices of
sowbelly, and cook them over the coals, allowing some of the
drippings to fall upon the hardtack for lubricating purposes, and
these constituted his frugal repast.
CHAPTER V. FAT PORK—
INDISPENSABLE BODY TIMBER FOR
PATRIOTISM.
IT WAS told in the last chapter how the patriotic impulses of Si
Klegg, of the 200th Ind., reached his stomach and digestive
apparatus, and brought them under obedient subjection to hardtack.
He didn't have quite so rough an experience with that other staple of
army diet, which was in fact the very counterpart of the hardtack,
and which took its most popular name from that part of the body of
the female swine which is usually nearest the ground. Much of Si's
muscle and brawn was due to the fact that meat was always plenty
on his father's farm. When Si enlisted he was not entirely free from
anxiety on the question of meat, for to his appetite it was not even
second in importance to bread. If bread was the "staff of life" meat
was life itself to Si. It didn't make much difference to him what kind
it was, only so it was meat. He didn't suppose Uncle Sam would
keep him supplied with quail on toast and porterhouse steaks all the
time, but he did hope he would give him as much as he wanted of
something in that line.
"You won't get much pork, unless you're a good forager," said one
of Si's friends he met at Louisville, and who had been a year in the
service.
Si thought he might, with practice and a little encouragement, be
fairly successful in foraging on his' own hook, but at the same time
he said he wouldn't grumble if he could only get plenty of pork.
Fortunately for him he had not been imbued with the teachings of
the Hebraic dispensation which declared "unclean" the beast that
furnished the great bulk of the animal food for the American
defenders of the Union.
Co. Q of the 200th Ind. received with the first issue of army
rations at Louisville a bountiful supply of bacon of prime quality, and
Si was happy at the prospect. He thought it would always be that
way.
"I don't see anything the matter with such grub as that!" said Si.
"Looks to me as though we were goin' to live like fighting-cocks."
"You're just a little bit brash," said his veteran friend, who had just
been through the long, hungry march from Huntsville, Ala., to
Louisville. "Better eat all you can lay yer hands on now, while ye've
got a chance. One o' these days ye'll git into a tight place and ye
won't see enough hog's meat in a week to grease a griddle. I've bin
there, myself! Jest look at me and see what short rations 'll bring
you to?"
But Si thought he wouldn't try to cross a bridge till he got to it,
nor lie awake nights worrying over troubles that were yet in the
future. Si had a philosophical streak in his mental make-up and this,
by the way, was a good thing for a soldier to have. "Sufficient unto
the day is the evil thereof," was an excellent rule for him to go by.
So Si assimilated all the pork that fell to his share, with an extra
bit now and then from a comrade whose appetite was less vigorous.
He thrived under its fructifying influence, and gave good promise of
military activity and usefulness. No scientific processes of cookery
were necessary to prepare it for immediate use. A simple boiling or
frying or toasting was all that was required.
During the few days at Louisville fresh beef was issued
occasionally. It is true that the animals slain for the soldiers were not
always fat and tender, nor did each of them have four hind-quarters.
This last fact was the direct cause of a good deal of inflammation in
the 200th Ind., as in every other regiment. The boys who got
sections of the forward part of the "critter," usually about three-
quarters bone, invariably kicked, and fired peppery remarks at those
who got the juicy steaks from the rear portion of the animal. Then
when their turn came for a piece of hind-quarter the other fellows
would growl. Four-fifths of the boys generally had to content
themselves with a skinny rib or a soupshank. Si shared the common
lot, and did his full quota of grumbling because his "turn" for a slice
of steak didn't come every time beef was issued.
The pickled pork was comparatively free from this cause of
irritation. It was all alike, and was simply "Hobson's choice." Si
remembered the fragrant and delicious fried ham that so often
garnished his mother's breakfast table and wondered why there was
not the same proportion of hams and sides in the Commissary that
he remembered in the meathouse on the Wabash. He remarked to
Shorty one day:
"I wonder where all this pork comes from?"
"It comes from Illinoy, I suppose," said Shorty. "I notice the
barrels are all marked 'Chicago'."
"Must grow funny kind o' hogs out there—a mile long each, I
should say. What do you mean?"
"Why, we've drawn a full mile o' sides from the Commissary, and
haint struck a ham yit. I'm wonderin' jest how long that hog is!"
"Well, you are green. You oughter know by this time that there are
only enough hams for the officers."
Now and then a few pigs' shoulders were handed round among
the boys, but the large proportion of bone they contained was
exasperating, and was the cause of much profanity.
Sometimes bacon was issued that had really outlived its
usefulness, except, perhaps, for the manufacture of soap.
Improperly "cured," it was strong and rancid, or, occasionally, so
near a condition of putrefaction that the stench from it offended the
nostrils of the whole camp. Some times it was full of "skippers," that
tunneled their way through and through it, and grew fat with riotous
living.
Si drew the line at this point. He had an ironplated stomach, but
putrid and maggoty meat was too much for it. Whenever he got any
of this he would trade it off to the darkies for chickens. There is
nothing like pork for a Southern negro. He wants something that will
"stick to his ribs."
By a gradual process of development his appetite reached the
point when he could eat his fat pork perfectly raw. During a brief
halt when on the march he would squat in a fence corner, go down
into his haversack for supplies, cut a slice of bacon, lay it on a
hardtack, and munch them with a keen relish.
At one of the meetings of the Army of the Cumberland Gen.
Garfield told a story which may appropriately close this chapter.
One day, while the Army of the Cumberland was beleaguered in
Chattanooga and the men were almost starving on quarter rations,
Gen. Rosecrans and his staff rode out to inspect the lines. As the
brilliant cavalcade dashed by a lank, grizzled soldier growled to a
comrade:
"It'd be a darned sight better for this army if we had a little more
sowbelly and not quite so many brass buttons!"
CHAPTER VI. DETAILED AS COOK—
SI FINDS RICE ANOTHER
INNOCENT
WITH A GREAT DEAL OF CUSSEDNESS IN IT.
IT WOULD have been very strange, indeed, if Si Klegg had not
grumbled loudly and frequently about the food that was dished up to
him by the company cooks. In the first place, it was as natural for a
boy to grumble at the "grub" as it was for him to try to shirk
battalion drill or "run the guard." In the next place, the cooking done
by the company bean-boiler deserved all the abuse it received, for
as a rule the boys who sought places in the hash foundry did so
because they were too lazy to drill or do guard duty, and their
knowledge of cooking was about like that of the Irishman's of music:
"Can you play the fiddle, Pat?" he was asked. "Oi don't know, sor-
r-r—Oi niver tried."
Si's mother, like most of the well-to-do farmers' wives in Indiana,
was undoubtedly a good cook, and she trained up her daughters to
do honor to her teachings, so that Si undoubtedly knew what
properly-prepared food was. From the time he was big enough to
spank he had fared sumptuously every day. In the gush of patriotic
emotions that prompted him to enlist he scarcely thought of this
feature of the case. If it entered his mind at all, he felt that he could
safely trust all to the goodness of so beneficent a Government as
that for the preservation of which he had offered himself as a target
for the rebels to shoot at. He thought it no more than fair to the
brave soldiers that Uncle Sam should furnish professional cooks for
each company, who would serve everything up in the style of a first-
class city restaurant. So, after Si got down among the boys and
found how it really was, it was not long till his inside was a volcano
of rebellion that threatened serious results.
When, therefore, Si lifted up his voice and cried aloud, and spared
not—when he said that he could get as good coffee as that
furnished him by dipping his cup into a tan-vat; when he said that
the meat was not good soap-grease, and that the potatoes and
beans had not so much taste and nutrition in them as so much pine-
shavings, he was probably nearer right than grumblers usually are.
"Give it to 'em, Si," his comrades would Say, when he turned up
his loud bazoo on the rations question. "They ought to get it ten
times worse. When we come out we expected that some of us would
get shot by the rebels, but we didn't calculate that we were going to
be poisoned in camp by a lot of dirty, lazy potwrastlers."
One morning after roll-call the Orderly-Sergeant came up to Si and
said:
"There's been so much chin-music about this cooking-business
that the Captain's ordered the cooks to go back to duty, and after
this everybody'll have to take his regular turn at cooking. It'll be your
turn to-day, and you'll stay in camp and get dinner."
When Co. Q marched out for the forenoon drill. Si pulled off his
blouse and set down on a convenient log to think out how he should
go to work. Up to this time he had been quite certain that he knew
all about cooking that it was worth while to know. Just now none of
his knowledge seemed to be in usable shape, and the more he
thought about it the less able he seemed to be to decide upon any
way of beginning. It had always appeared very easy for his mother
and sisters to get dinner, and on more than one occasion he had
reminded them how much better times they had staying in the
house cooking dinner than he had out in the harvest field keeping up
with the reaper. At this moment he would rather have kept up with
the fastest reaper in Posey County, on the hottest of July days, than
to have cooked the coarse dinner which his 75 comrades expected
to be ready for them when they returned, tired, hot and hungry,
from the morning drill.
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
Let us accompany you on the journey of exploring knowledge and
personal growth!
ebooknice.com

More Related Content

PDF
(Ebook) Practical Web Development by kan
PDF
Practical Web Development 1st Edition Wellens Paul 2024 scribd download
PDF
Practical Web Development 1st Edition Wellens Paul
PDF
Intro to mobile web application development
PDF
Get Master Web Design with HTML CSS JavaScript and jQuery Create Stunning Int...
PDF
Master Web Design with HTML CSS JavaScript and jQuery Create Stunning Interac...
PDF
Crash Course HTML/Rails Slides
PPT
Intro to-html-backbone
(Ebook) Practical Web Development by kan
Practical Web Development 1st Edition Wellens Paul 2024 scribd download
Practical Web Development 1st Edition Wellens Paul
Intro to mobile web application development
Get Master Web Design with HTML CSS JavaScript and jQuery Create Stunning Int...
Master Web Design with HTML CSS JavaScript and jQuery Create Stunning Interac...
Crash Course HTML/Rails Slides
Intro to-html-backbone

Similar to (Ebook) Practical Web Development by kan (20)

PPTX
Web Development for Beginners: A Step-by-Step Guide
PDF
Making Of PHP Based Web Application
PPTX
PRAKHAR-Building-the-Web.pptx on web development
PDF
Hello Html5 Css3 A User Friendly Reference Guide Rob Crowther
DOCX
SIVASOFT - BEST ONLINE WEB DEVELOPMENT TRAINING COURSE
PDF
Intro to-html-backbone-angular
PPTX
025444215.pptx
PPTX
html and css . hypertextmarkuplanage and css.pptx
PPTX
"Python web development combines the simplicity of the language with powerful...
PDF
Xinzex: A Complete Web Development Guide for Beginners
PDF
ATO- Intro to Web Concepts
PPTX
Web dev-101
PPTX
HTML5 introduction for beginners
PDF
Week 05 Web, App and Javascript_Brandon, S.H. Wu
PPTX
f8db413453b33e4ffrointend development bbasics.pptx
PPTX
Website development courses
PDF
Abhilash front end ppt.pdf
PDF
Front-End Frameworks: a quick overview
PDF
Class 6: Introduction to web technology entrepreneurship
PPTX
ashish ppt webd.pptx
Web Development for Beginners: A Step-by-Step Guide
Making Of PHP Based Web Application
PRAKHAR-Building-the-Web.pptx on web development
Hello Html5 Css3 A User Friendly Reference Guide Rob Crowther
SIVASOFT - BEST ONLINE WEB DEVELOPMENT TRAINING COURSE
Intro to-html-backbone-angular
025444215.pptx
html and css . hypertextmarkuplanage and css.pptx
"Python web development combines the simplicity of the language with powerful...
Xinzex: A Complete Web Development Guide for Beginners
ATO- Intro to Web Concepts
Web dev-101
HTML5 introduction for beginners
Week 05 Web, App and Javascript_Brandon, S.H. Wu
f8db413453b33e4ffrointend development bbasics.pptx
Website development courses
Abhilash front end ppt.pdf
Front-End Frameworks: a quick overview
Class 6: Introduction to web technology entrepreneurship
ashish ppt webd.pptx
Ad

Recently uploaded (20)

PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
Anesthesia in Laparoscopic Surgery in India
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PPTX
Pharma ospi slides which help in ospi learning
PDF
Basic Mud Logging Guide for educational purpose
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
Business Ethics Teaching Materials for college
PPTX
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
O7-L3 Supply Chain Operations - ICLT Program
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
102 student loan defaulters named and shamed – Is someone you know on the list?
O5-L3 Freight Transport Ops (International) V1.pdf
Anesthesia in Laparoscopic Surgery in India
Renaissance Architecture: A Journey from Faith to Humanism
Pharma ospi slides which help in ospi learning
Basic Mud Logging Guide for educational purpose
2.FourierTransform-ShortQuestionswithAnswers.pdf
FourierSeries-QuestionsWithAnswers(Part-A).pdf
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Microbial diseases, their pathogenesis and prophylaxis
Business Ethics Teaching Materials for college
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
O7-L3 Supply Chain Operations - ICLT Program
Ad

(Ebook) Practical Web Development by kan

  • 1. (Ebook) Practical Web Development by kan download https://ebooknice.com/product/practical-web-development-50195080 Download more ebook instantly today at https://ebooknice.com
  • 2. Instant digital products (PDF, ePub, MOBI) ready for you Download now and discover formats that fit your needs... Start reading on any device today! (Ebook) Learning Django Web Development_ From idea to prototype, a learner's guide for web development with the Django application framework by kan https://ebooknice.com/product/learning-django-web-development-from-idea-to- prototype-a-learner-s-guide-for-web-development-with-the-django-application- framework-50195350 ebooknice.com (Ebook) The Complete Web Design Edition by kan https://ebooknice.com/product/the-complete-web-design-edition-50194588 ebooknice.com (Ebook) Practical Electronics for Inventors by kan https://ebooknice.com/product/practical-electronics-for-inventors-50195098 ebooknice.com (Ebook) JavaScript Cookbook, 2nd Edition_ Programming the Web by kan https://ebooknice.com/product/javascript-cookbook-2nd-edition-programming-the- web-50195402 ebooknice.com
  • 3. (Ebook) Learning LibGDX Game Development, 2nd Edition by kan https://ebooknice.com/product/learning-libgdx-game-development-2nd- edition-50195342 ebooknice.com (Ebook) Python, PyGame and Raspberry Pi Game Development by kan https://ebooknice.com/product/python-pygame-and-raspberry-pi-game- development-50196044 ebooknice.com (Ebook) Complete Vue.js 2 Web Development: Practical guide to building end-to-end web development solutions with Vue.js 2 by Mike Street, Andrea Passaglia, Paul Halliday ISBN 9781789959901, 178995990X https://ebooknice.com/product/complete-vue-js-2-web-development-practical-guide- to-building-end-to-end-web-development-solutions-with-vue-js-2-7336226 ebooknice.com (Ebook) HTML5 Game Development by Example: Beginner's Guide by kan https://ebooknice.com/product/html5-game-development-by-example-beginner-s- guide-50195518 ebooknice.com (Ebook) Practical Webix: Learn to Expedite and Improve your Web Development by Frank Zammetti ISBN 9781484233832, 1484233832 https://ebooknice.com/product/practical-webix-learn-to-expedite-and-improve- your-web-development-6981952 ebooknice.com
  • 7. Table of Contents Practical Web Development Credits About the Author Acknowledgments About the Reviewers www.PacktPub.com Support files, eBooks, discount offers, and more Why subscribe? Free access for Packt account holders Preface What this book covers What you need for this book Who this book is for Conventions Reader feedback Customer support Downloading the example code Errata Piracy Questions 1. The World Wide Web World Wide Web The Internet HTTP and HTML HTML HTTP The World Wide Web Consortium (W3C) Mosaic The first browser Netscape Internet Explorer The explosion of the Web Amazon.com and e-commerce Google and Yahoo! Social networking
  • 8. Web development HTML HTML editors and other tools Browsers and web servers CSS JavaScript PHP Data Summary 2. HTML HTML versions Semantic and presentational HTML The structure and syntax of an HTML document Doctype <html> <head> <body> Syntax for tags or elements inside the document HTML comments Links The <a> tag and attributes The href attribute The <a> name attribute The <a> target attribute Classic document elements <h1>, <h2>, <h3>, … <h6> – headings <p> – paragraph <span> – span Lists Images <img> element and attributes Image width and height Input forms Form elements Form attributes The label attribute Input attributes The name attribute The value attribute
  • 9. The checked attribute The readonly attribute Textarea Dropdown lists The disabled attribute The selected attribute Tables Table elements <table> <thead> <tbody> <tr> <th> <td> Table attributes colspan (td) rowspan (td) <div>, the "uebertag" HTML entities HTML5-specific tags Summary 3. CSS Adding styles to our documents External style sheets Internal CSS Inline styles The Document Object Model (DOM) Selectors Multiple classes Descendants Selecting children or siblings Specificity Block elements and inline elements Colors Fonts So what are fonts? Font families Serif fonts Sans-serif fonts Monospace fonts The font-family property
  • 10. Font-weight and font-style Font-size Line-height The box model Padding Border Margin Collapsing margins Positioning Float position:relative position:absolute Styling lists list-style-type list-style-image list-style-position Styling anchors – pseudo-classes Firebug Summary 4. JavaScript Programming 101 Compiled and interpreted languages compared JavaScript is not the same as Java Java JavaScript Our first JavaScript program Variables Variable declarations Values of variables Numbers Strings Converting strings to numbers Expressions and operators Arithmetic operators Addition(+) Subtraction (-) Multiplication (*) Division (/) Modulo (%)
  • 11. Relational operators Control flow if while switch Functions Scope of variables Objects JSON DOM objects, properties, methods, and events The Window object The Document object write and writeln methods Nodes and DOM traversing Events Summary 5. PHP Introduction to PHP Our first real PHP program PHP and web hosting Web hosting 101 Domain name Web hosting companies Server-side setup Additional server-side services PHP development environment PHP as a web development language Variables, values, operators, and expressions Scope of variables Local variables Global variables Static variables String operators To double quote or to single quote, that is the question Control flow Functions String functions strpos() strlen()
  • 12. substr() Date functions time() date() strtotime() Arrays Numeric arrays or indexed arrays Associative arrays Cool control statements for associative arrays Sending data back to the server – forms POST or GET, what should we get? $_POST and $_GET arrays Files include, require, and require_once Regular files File functions or f-functions fopen file_exists(), is_file(), and is_dir() fread and fwrite One line at a time – fgets() The printf family Syntax of printf family of functions Summary 6. PHP and MySQL Databases Relational databases SQL MySQL phpMyAdmin Creating databases Creating and managing users Creating and managing database tables MySQLi in PHP Connecting to the database Our first SQL query, really! Writing a MySQL query in PHP Fetching the result Obtaining data from more than one table Adding data
  • 13. Updating data Summary 7. jQuery Obtaining the jQuery library Where to place the jQuery library on your page? jQuery UI and jQuery Mobile Using jQuery selectors and methods html() text() attr() .val() show() and hide() .find() .parent() .next() .css() jQuery documentation Event handlers and jQuery preventDefault() $(this) updateNewsContent() Summary 8. Ajax XMLHttpRequest Ajax and jQuery jQuery Ajax methods $.load() method $.post() $.ajax() Summary 9. The History API – Not Forgetting Where We Are The problem we are trying to solve The self-service restaurant HTML5 History API and the history object pushState() popstate event popstate and different browsers The History plugin Bookmarking
  • 14. Summary 10. XML and JSON XML XML format Displaying XML files XML editors XML Schema SimpleXML The XML file The XML Schema file The CSS file The PHP file Creating XML files with SimpleXML Generating our HTML on the client side XSLT JSON JSON syntax JSON values JSON objects JSON strings JSON arrays JSON numbers JSON and PHP JSON with Ajax and jQuery Two useful JSON methods Summary 11. MongoDB Relational database management systems NoSQL databases MongoDB Installing MongoDB The MongoDB shell Creating databases, collections, and documents _id and ObjectIds Loading scripts Removing documents Updating documents MongoDB data types Basic data types
  • 15. Dates Embedded documents One more example MongoDB and PHP Getting our gallery data CRUD operations with MongoDB and PHP Insert documents Update documents Queries with conditions MongoDB cursor object Summary 12. Mobile First, Responsive Design with Progressive Enhancement Responsive design Déjà vu Media queries Using the media attribute Do more with less Mobile first Why mobile first? We have come a long way Mobile devices have newer capabilities Mobile devices are not only used while on the road Content first, navigation next Small means big Mobile input Mobile first recap Progressive enhancement EnhanceJS enhance.js loadStyles and loadScripts enhanced and FOUC Modernizr The Modernizr object Polyfills and Modernizr yepnope.js or Modernizr.load Summary 13. Foundation – A Responsive CSS/JavaScript Framework Our responsive toolkit – Foundation Foundation components
  • 16. The grid system Class end Visibility classes The block grid system Useful UI elements Thumbnails – for simple galleries Reveal modals – your better pop-up Dropdowns Example – a simple photo gallery Accordions Awesome Font awesome Equalizer – the hardest thing to do with two <div>s made easy Navigation Top bar – not just your regular menu bar Adding more magic Yet more magic – off-canvas, the coolest thing Summary 14. Node.js Node.js Installing node.js npm node Adding HTML Serving up static content A tale of two (JavaScript) cities node.js and MongoDB Déjà vu … once more Express Installing Express Our first Express app An example with middleware Templating and handlebars.js Creating a layout Our last Hello, World example Summary A. Bootstrap – An Alternative to Foundation Bootstrap components The Bootstrap grid system Visibility classes
  • 17. Buttons Other UI elements Thumbnails Dropdowns Modal – the Bootstrap popup Combining dropdowns and modals Collapse – an accordion for Bootstrap Navigation Summary Index
  • 19. Practical Web Development Copyright © 2015 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. First published: July 2015 Production reference: 1240715 Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK. ISBN 978-1-78217-591-9 www.packtpub.com
  • 20. Credits Author Paul Wellens Reviewers Jorge Albaladejo Elvis Boansi Adam Maus Jesús Pérez Paz Commissioning Editor Edward Gordon Acquisition Editors James Jones Sonali Vernekar Content Development Editor Ritika Singh Technical Editor Ryan Kochery Copy Editors Alpha Singh Ameesha Green Jasmine Nadar
  • 21. Jasmine Nadar Project Coordinator Milton Dsouza Proofreader Safis Editing Indexer Rekha Nair Production Coordinator Manu Joseph Cover Work Manu Joseph
  • 22. About the Author Paul Wellens has been a senior product manager for a major computer company in the Los Angeles area and Silicon Valley for over two decades. Before that, he used to install Unix systems and train companies in Europe, from his native Belgium. Later in his career, he became a web development aficionado because it brought him back to another passion of his: programming. This is not his first book. His prior publication is of a different nature. Nature is what it is all about as it is a guidebook on Eastern California, which is illustrated with his own photographs. Therefore, it should not come as a surprise to learn that, besides experimenting with new web technologies, his major hobbies are photography and hiking in the Eastern Sierra.
  • 23. Acknowledgments I have written books before and I know that the result can only be successful if there are some nice people to assist you. This is the first time that I have worked with a publisher, Packt Publishing, so these are the first people I would like to thank. I would like to thank Shivani Wala for discovering me and James Jones for working with me to figure out the right book for me to write and for you to read. I enjoyed working with Priyanka Shah, Ritika Singh, and Ryan Kochery who assisted me in bringing this cool project to completion, without a single complaint, even though I was once again late with a deliverable. Thank you for being so patient with me. I would also like to thank (yes, this is a note of cynicism) the three companies that "manage" the railroads in Belgium. Without their comedy of errors with trains—delays, cancellations, failure to depart because of mechanical problems, or trains departing from the station where you want to get to, as opposed to depart from, I would never had so much time to work on this book on my iPad. It is not in their honor, but, because for 2 years, it was the highlight of my day to safely arrive at Antwerp Central Station—which was rated by an American newspaper as the most beautiful train station in the world—that we decided to use it as the cover photo. Next, I would like to thank my web developer buddy, Björn Beheydt, for taking the time to read the early versions of the chapters of this book and providing constructive feedback. I would also like to mention Steve Drach and Bart Reunes for always being there when I needed some technical advice. Then, there are places that I would like to call a home away from home, where folks did not mind that I was typing away on my Bluetooth keyboard when inspiration kicked in. Most notably, I have to thank the folks at Trapke Op (Caro, Maressa, Evi, Klaartje and Jill) in Brecht, Belgium, where I typed these sentences. These wonderful people helped me make it to the finish line. Het Boshuisje in Zoersel, where Hendrik Conscience wrote books over a hundred years before I did, also comes to mind. I would like to thank Theo for always giving me a seat to land with my iPad, keyboard, and work. Less related to this book, but still in need of a mention, are all my friends in California that inspired me to carry on doing great things in hard times. In particular, I want to express my appreciation to the people that work(ed) at the
  • 24. particular, I want to express my appreciation to the people that work(ed) at the Gordon Biersch Restaurant in Palo Alto, which I can still proudly call my photo gallery. I thank them for their support for over 11 years and for still welcoming me when I visit them; they make me feel as if I only left last night. That also includes the patrons of the place with whom I've had numerous conversations and enjoyed every single one of them. If you read this book, or my previous book, you will notice that I have a certain affinity and passion for a particular part of California. So, I would like to thank all the wonderful folks that live in the town of June Lake, California, for always having inspired me to come back and be creative. My goal in life is to go there as often as I can. Finally, I would like to thank my mother. It has been hard for her since my father passed away and her son returned. I am dedicating this book to her, not that I expect her to read it, but I really appreciate the patience she had with me while I was writing it.
  • 25. About the Reviewers Jorge Albaladejo is a software engineer with a master's degree in information and communication technologies from HES-SO, Switzerland. With over a decade of experience building cloud, SaaS, and web applications, he considers himself to be a passionate and versatile full-stack web developer. Throughout his professional experience, he has worked with many companies in different fields, such as project management, social networks, quality assurance, weather data visualization, and video games. He devours countless books about software engineering, project management, and science fiction, and he is passionate about clean, long-lasting software architectures. He is currently working as a freelance contractor under the commercial name of CometaStudio, and he is mostly interested in start-ups and mid-sized companies that build great web experiences for great causes that make a difference. His next dream is to become a digital nomad who travels around the globe while working at the same time—and learn languages in the process! Elvis Boansi is a software developer at John Jay College. He develops and maintains custom web applications that are used by members of the college. In his spare time, he enjoys playing soccer and basketball with his friends. I'd like to thank my employers at John Jay College for all of their support. I would also like to thank my supervisors, Ana and Juan, for their feedback. I thank my friends, Sanga, Steve, and Loric, for constantly sharing their knowledge with me. Adam Maus is a software developer with a master's degree in computer science and works at the Center for Health Enhancement Systems Studies at the University of Wisconsin in Madison in the United States. His interests lie in developing web technologies that utilize data mining to create better user experiences. He primarily works on websites that help people undergoing addiction recovery support, as well as people who are aging. In his free time, he enjoys running, biking, and reading books. Jesús Pérez Paz is a full-stack web developer with experience in project
  • 26. management. He works at PepitaStore Inc. and collaborates with Mozilla. His main area of work is design, and he integrates the user interface (or frontend) of web pages / applications; however, lately, he has been diving into backend stuff and has become a full-stack web developer. He loves the open/free Internet and thinks that the Internet is a global public resource that must remain open and accessible to everyone.
  • 27. www.PacktPub.com Support files, eBooks, discount offers, and more For support files and downloads related to your book, please visit www.PacktPub.com. Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at <service@packtpub.com> for more details. At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks. https://www2.packtpub.com/books/subscription/packtlib Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can search, access, and read Packt's entire library of books.
  • 28. Why subscribe? Fully searchable across every book published by Packt Copy and paste, print, and bookmark content On demand and accessible via a web browser
  • 29. Free access for Packt account holders If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view 9 entirely free books. Simply use your login credentials for immediate access.
  • 30. Preface I am fortunate to have lived and worked in California for a long time. The majority of that time, I lived in Palo Alto, which is the center of Silicon Valley, the home of Stanford University, and the birthplace of many companies, big and small, such as Sun Microsystems, where I worked. I sat on the front row to see how the World Wide Web developed, as well as being present for the advent of social media. Facebook started on the other side of the wall of my favorite restaurant. Now, some Facebook guy or girl is sitting in what used to be my office at the bottom of the Dumbarton Bridge. As a product manager for Solaris, one of my tasks was to make sure that Netscape Navigator was included with our operating system. So, I was right at the source in which the development of the Web began. I even went to the Web 2.0 conference and bought the book of the same name. Then, I felt the need to have my own website to display my photographs and inform people about the beauty and interesting places of the parts of California that I had discovered during my many journeys travelling around the state. So, I created one. One day, I was telling a friend about it and he tried to look at it on his mobile phone. It looked terrible. So, I bought a Nokia phone (a brick compared to what we have today) so that I could test my own site to make sure that it looked good on a phone as well. This is how I caught the bug of responsive design, years before someone started calling it this. Upon my return to Belgium, I decided that it was time to learn as much as possible (I love to learn new things) about what is out there beyond creating websites and took a 6-month course on PHP web development. A lot of it looked familiar as I was previously a UNIX and C developer. There were only 12 people in the class, who were all bright minds, and I quickly discovered that there was more to learn. As the classes took place in Leuven, a major university town in Belgium, I went to the local university bookstore and bought book after book on all kinds of related topics and quickly became a jQuery fan. jQuery, by the way, was not even included in the course. I started wondering why someone needed to have 35 different books to learn about web development and that writing a single book that gave a comprehensive overview of what you need to know to engage in web development would not be a bad idea.
  • 31. Since then, web development has changed a lot; more books were needed, eBooks this time, but the concept remained the same. So, now you know why I wrote the book. This book gives you an overview of all the general aspects of web development, in a traditional way, using plain HTML to do static websites, as well as the current way, to enable you to create your web pages dynamically and make sure that they look great on mobile devices as well, by using responsive design. We conclude by giving you a hint of what is yet to come if you replace the traditional web server by writing your own using node.js.
  • 32. What this book covers Chapter 1, The World Wide Web, gives you an overview of the history of what we know today as the World Wide Web. Chapter 2, HTML, introduces HTML and gives you an overview of the most commonly used HTML tags to do web development. You will be able to create a basic website after reading this chapter. Chapter 3, CSS, explains how to use Cascading Style Sheets (CSS). This is used for the presentation part or layout of your website, from color to dimensions to typefaces. The most commonly used CSS properties are explained here. Once you are done with this chapter, you will be able to make your basic website look good. Chapter 4, JavaScript, first gives you an introduction to the world of programming and programming languages. Next, the overall syntax of JavaScript and how to use it for client-side programming is introduced. Chapter 5, PHP, explains PHP, which is another programming language. This one is used to do server-side programming. It requires a web server to do the development of your website and deploy it. You will learn how to dynamically create your web pages, rather than having to write a bunch of HTML files. Chapter 6, PHP and MySQL, introduces MySQL, an open source database. You will learn how to create a database, manage it using the phpMyAdmin tool, and perform basic CRUD (create, replace, update, delete) operations from within a PHP program. Chapter 7, jQuery, covers a popular JavaScript library. It allows you to write more compact and clean code and handles browser incompatibilities for you. With this, it is going to be a lot easier and faster for you to write JavaScript code that traverses and manipulates the web page. It does so by using selectors, which you learned to use with CSS. So, with jQuery, you can write JavaScript code without having to learn a lot of JavaScript. Chapter 8, Ajax, introduces Ajax. It represents a collection of techniques to make it easy to dynamically change only portions of a website. With this chapter, we have entered the world of what I call "modern web development". The interface
  • 33. that we use for our Ajax calls is jQuery. Chapter 9, The History API—Not Forgetting Where We Are, explains a very important piece of the web development puzzle. Once we are changing pages on the fly so they look different but actually remain the same page (URL), strange things can happen when visitors want to go back to what they think is the previous page. A solution for this is described here that will not only work for HTML5 but for HTML4 as well. Chapter 10, XML and JSON, describes XML and JSON. They are two popular formats to exchange data, for example the server and the client. Although XML is used in a variety of environments, JSON is closer to the web development community. Chapter 11, MongoDB, describes an alternative to MySQL as a database. This is a so-called NoSQL database and a document database. Documents are conveniently in the JSON format. Here, how to access a MongoDB database from within a PHP program is described. Chapter 12, Mobile First, Responsive Design with Progressive Enhancement, has the longest chapter title of the book. It explains how modern web development has to be done now that more people are using mobile devices instead of traditional computer screens to go to websites. Chapter 13, Foundation – A Responsive CSS/JavaScript Framework, describes most of the features of the Foundation framework, which helps you with your responsive design. It contains everything that I have always wanted to write myself but never had the time to do. This concludes the part of the book that covers what I call modern web development. Chapter 14, Node.js, gives an overview of what I call the avant-garde of web development. It introduces node.js, which allows you to write your server-side code in JavaScript, including your own web server, which is facilitated by using the Express framework. Appendix, Bootstrap – An Alternative to Foundation, describes the popular CSS/JavaScript framework, which is an alternative to Foundation to help you with responsive design. The main reason to include this is to point out key differences and similarities.
  • 34. The online chapter, The Mono County Site, provides a full example of a website or application where we apply most, if not all, the things we learned. It is available at https://www.packtpub.com/sites/default/files/downloads/B03816_Appendix.pdf.
  • 35. What you need for this book You will need the following software to work with the examples in this book: Software Source Firefox and Firebug http://www.mozilla.org Apache Web Server Part of the OS XAMPP (includes MySQL and PHPMyAdmin) http://www.apachefriends.org MySQL http://www.mysql.com PHPMyAdmin phpmyadmin.net jQuery http://www.jquery.com The History jQuery plugin https://github.com/browserstate/history.js MongoDB mongodb.org Foundation foundation.zurb.com Node.js nodejs.org Bootstrap getbootstrap.com
  • 36. Who this book is for This book is for anyone who wants to get to grips with the broader picture of web development today. It is perfect for beginners who want to get started and learn web development basics, such as HTML, but it also offers experienced developers a web development road map that will help them to extend their capabilities and gain a greater insight into how different technologies interact and work together.
  • 37. Conventions In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning. Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "We can include other contexts through the use of the include directive." A block of code is set as follows: <body> <div id="header"></div> <div id="container"> <div id="left"></div><div id="middle"></div><div id="right"></div> </div> <div id="footer"></div> </body> When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold: <tag class="value1 value2">text<?tag> Any command-line input or output is written as follows: { "key" : { "name":"Schwarzenegger","first":"Arnold", "profession":"governator" } } New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: " Now, not until a user clicks the Beach button, Hello, World will turn into Hello, Beach." Note Warnings or important notes appear in a box like this. Tip Tips and tricks appear like this.
  • 38. Tips and tricks appear like this.
  • 39. Reader feedback Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of. To send us general feedback, simply e-mail <feedback@packtpub.com>, and mention the book's title in the subject of your message. If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.
  • 40. Customer support Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.
  • 41. Downloading the example code You can download the example code files from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files emailed directly to you.
  • 42. Errata Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title. To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.
  • 43. Piracy Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy. Please contact us at <copyright@packtpub.com> with a link to the suspected pirated material. We appreciate your help in protecting our authors and our ability to bring you valuable content.
  • 44. Questions If you have a problem with any aspect of this book, you can contact us at <questions@packtpub.com>, and we will do our best to address the problem.
  • 45. Chapter 1. The World Wide Web This book talks about the past, present, and future of Web Development. Beginning with Chapter 2, HTML, we will walk you through all the technologies you need to know about, in order to practice web development. Before we do that, we want to set the stage, so that we all know which Web we are talking about: this would be the World Wide Web (www).
  • 46. World Wide Web I love history! So let us start with a little history about the World Wide Web. I was fortunate enough to be able to work at a company that developed the first commercial version of the UNIX Operating System. They were founded in 1977 and I joined them ten years later. UNIX is an Operating System (the thing you need to make your computer do something) that was intended to run on minicomputers (although they were called that, they could not fit into your apartment and required air-cooling). These computers were typically used as an isolated system that had quite a number of text-based terminals attached to them. Today UNIX lives on, and forms the basis of Linux, Solaris, MacOS, and others. Our company spotted an opportunity to add products that would add features and technologies that today are standard. Some of these examples are email (ability to send a mail to a person on another computer), and ftp (ability to transfer a file to another computer, or to just access another computer). Yes, you had to pay extra if you wanted to be able to send mail. Thanks to the Internet, all of this was made possible.
  • 47. The Internet The Internet is a global network that today interconnects billions of computers worldwide. Its origin dates back to research done for the US government, but today everybody can get on the Internet, using its standard set of protocols, commonly referred to as TCP/IP (the IP here being Internet Protocol). Every computer or device that is connected to the Internet will have a unique Internet address, aka IP address. It is a set of 4 numbers separated by dots, for example, 192.25.13.90. Of course, you will never tell your friend that you bought something at 192.25.13.90 but at, for instance, www.amazon.com. This is because the Internet also uses a feature that translates IP addresses into easier to remember domain names. The example I used happens to be a website you can go to and buy things from a practice that we all know has caused the www to become what it is today. The Internet and the www are, in everyday speech, treated as if they are synonyms but they are indeed not. There are a lot of different services provided on the Internet (by companies called Internet Service Providers (ISP)), and that was already the case before the www existed (for example, giving you access to electronic mail). What it took for the www to emerge was (just like in JavaScript) a series of asynchronous events. Two of those are too important to not mention.
  • 48. HTTP and HTML You have probably heard this story many times, but the World Wide Web would not have existed without it. It is the story of Tim Berners Lee, an engineer at the European Centre for Nuclear Research (CERN). The centre had many computers that were, of course, hooked up to the Internet. It also produced a tremendous amount of data and documents, and that became almost impossible to manage. Tim worked out a solution by developing a language to write these documents in, a protocol on top of the Internet to manage them, as well as a computer program for users to access them.
  • 49. HTML HTML, short for Hypertext Markup Language is the name of that language. Hypertext is text that contains hyperlinks, which in turn are those parts of a document which readers can click on to take them to a different document, using the link. You have all seen the blue underlined parts of a text, in not-so-good- looking web pages. These are hyperlinks. A document in HTML consists of tags, with text in between them. There are opening and closing tags for example, as follows: <h1>Hello, world</h1> Here, <h1> is the opening tag and </h1> the closing one. We will learn about a similar markup language: XML. HTML and XML are not the same though. One important difference is that in XML you can define your own tags, as long as you close each one you've opened. XML is used to transfer the data and the tags are used to organize the data. In HTML, tags do have a specific meaning. <h1> would be used in a document for the text of a level one header. A <a> tag—the anchor tag—is the one used to include the hyperlinks we just discussed. So the purpose of writing HTML is not to transfer data, but to present it to human users. To do so, these tags are interpreted by the computer program we mentioned earlier. Such a program is called a browser. When the reader clicks on a hyperlink, the browser will detect that as well, and send a request to yet another program, the web server, to go fetch another document.
  • 50. Random documents with unrelated content Scribd suggests to you:
  • 51. particular about a few pigs and chickens and sweet potatoes, for he was really getting hungry, and when a man is in this condition he is not in a fit mood to grapple with fine-spun theories of governmental policy. So when a fat pig came wabbling and grunting toward his post, it was to Si like a vision of manna to the children of Israel in the wilderness. A wild, uncontrollable desire to taste a fresh spare-rib took possession of him. Naturally, his first idea was to send a bullet through the animal, but on second thought he saw that wouldn't do at all. It would "give him away" at once, and, besides, he had found that a single shot on the picket-line would keep Buell's entire army in line-of-battle for a whole day. Si wrote to his mother that his bright new bayonet was stained with Southern blood, and the old lady shuddered at the awful thought. "But," added Si, "it was only a pig, and not a man, that I killed!" "I'm so glad!" she exclaimed.
  • 52. By the time Si had been in the service a year there was less zeal in the enforcement of orders of this kind, and Si had become a very skillful and successful forager. He had still been unable to reach with his bayonet the body of a single one of his misguided fellow citizens, but he had stabbed a great many pigs and sheep. In fact, Si found his bayonet a most useful auxiliary in his predatory operations. He could not well have gotten along without it. Uncle Sam generally furnished Si with plenty of coffee—roasted and unground—but did not supply him with a coffee mill. Si thought at first that the Government had forgotten something. He saw that several of the old veterans of '61 had coffee mills, but he found on inquiry that they had been obtained by confiscation only. He determined to supply himself at the first opportunity, but in the meantime he was obliged to 'use his bayonet as a substitute, just as all the rest of the soldiers did.
  • 53. We regret to say that Si, having thrown away his "Baxter's Call to the Unconverted" in his first march, and having allowed himself to forget the lessons he had learned but a few years before in Sunday- school, soon learned to play poker and other sinful games. These, at night, developed another use for the bayonet. In its capacity as a "handy" candlestick it was "equaled by few and excelled by none." The "shank" was always ready to receive the candle, while the point could be thrust into the ground in an instant, and nothing more was necessary. This was perhaps the most general sphere of usefulness found by the bayonet during the war. Barrels of candle-grease flowed down the furrowed sides of this weapon for every drop of human blood that dimmed its luster.
  • 54. CHAPTER IV. THE AWFUL HARDTACK THE HARD AND SOLID STAFF OF MILITARY LIFE. "APPETITE'S a queer thing," said Si to Shorty one day, when both were in a philosophical mood. "It's an awful bother when you haven't it, and it's a great deal worse when you have it, and can't get anything for it." "Same as money," returned sage Shorty. During the first few months of Si Klegg's service in the army the one thing that bothered him more than anything else was his appetite. It was a very robust, healthy one that Si had, for he had grown up on his father's farm in Indiana, and had never known what it was to be hungry without abundant means at hand for appeasing his desires in that direction. His mother's cupboard was never known to be in the condition of Old Mother Hubbard's, described in the nursery rhyme. The Kleggs might not have much tapestry and bric-a-brac in their home, but their smoke-house was always full, and Mrs. Klegg's kitchen could have fed a camp-meeting any time without warning. So it was that when Si enlisted his full, rosy face and his roundness of limb showed that he had been well fed, and that nature had made good use of the ample daily supplies that were provided. His digestive organs were kept in perfect condition by constant exercise. After Si had put down his name on the roll of Co. Q of the 200th Ind. he had but a few days to remain at home before his regiment was to start for Louisville. During this time his mother and sisters kept him filled up with "goodies" of every sort. In fact, it was the biggest thing in the way of a protracted picnic that Si had ever struck.
  • 55. "You must enjoy these things while you can, Si," said his mother, "for goodness knows what you'll do when you really git into the army. I've heerd 'em tell awful things about how the poor sogers don't have half enough to eat, and what they do git goes agin' any Christian stomach. Here, take another piece of this pie. A little while, and it'll be a long time, I reckon, till ye git any more." "Don't keer if I do!" said Si, for there was scarcely any limit to his capacity. And so during those days and nights the old lady and the girls cooked and cooked, and Si ate and ate, until it seemed as if he wouldn't want any more till the war was over. Si was full, and as soon as Co. Q was, it was ordered to camp, and Si had to go. They loaded him down with good things enough to last him a week. The pretty Annabel—the neighbor's daughter who had solemnly promised Si that she wouldn't go with any other fellow while he was away—came around to see Si off and brought him a rich fruit cake. "I made that for you," she said. "Bully for you!" said Si, for he felt that he must begin to talk like a soldier. The first day or two after reaching Louisville the 200th received rations of "soft bread." But that didn't last long. It was only a way they had of letting the fresh soldier down easy. Orders came to get ready to pull out after Bragg, and then Si'a regiment had its first issue of army rations. As the Orderly pried open a box of hardtack and began to distribute them to the boys, exclaimed: "Them's nice-looking soda crackers. I don't believe the grub is going to be so bad, after all." Si had never seen a hardtack before. "Better taste one and see how you like it!" said one of Buell's ragged Indiana veterans, who had come over to see the boys of the 200th and hear the latest news from "God's country."
  • 56. It happened that this lot was one of extra quality as to hardness. The baker's watch had stopped, or he had gone to sleep, and they had been left in the oven or dry-kiln too long. Si took one of them and carried it to his mouth. He first tried on it the bite which made such havoc with a quarter section of custard pie, but his incisors made no more impression upon it than if it had been a shingle. "You have to bear on hard," said the veteran, with a grim smile. "Je-ru-sa-lem!" exclaimed Si after he had made two or three attempts equally barren of results. Then he tried his "back teeth." His molars were in prime order, and his jaw power was sufficient to crack a hickory nut every time. Si crowded one corner of the hardtack as far as he could between his "grinders," where he could get a good "purchase" on it, shut his eyes and turned on a full head of steam. His teeth and jaws fairly cracked under the strain, but he couldn't even "phase" it. "If that ain't old pizen!" said Si. "It beats anything I ever seen up in the Wabash country." But his blood was up, and laying the cracker upon a log, he brought the butt of his gun down upon it like a pile-driver.
  • 57. "I thought I'd fix ye," he said, as he picked up the fragments, and tried his teeth upon the smaller ones. "Have I got to eat such stuff as that?" with a despairing look at his veteran friend. "I'd just as soon be a billy-goat and live on circus-posters, fruit-cans and old hoop-skirts." "You'll get used to it after a while, same's we did. You'll see the time when you'll be mighty glad to get even as hard a tack as that!" Si's heart sank almost into his shoes at the prospect, for the taste of his mother's pie and Annabel's fruit cake were yet fresh in his mouth. But Si was fully bent on being a loyal, obedient soldier, determined to make the best of everything without any more "kicking" than was the inalienable right of every man who wore a uniform. For the first time in his life Si went to bed hungry that night. Impelled by the gnawings of his appetite he made repeated assaults upon the hardtack, but the result was wholly insufficient to satisfy
  • 58. the longings of his stomach. His supper wasn't anything to speak of. Before going to bed he began to exercise his ingenuity on various schemes to reduce the hardtack to a condition in which it would be more gratifying to his taste and better suited to the means with which nature had provided him for disposing of his rations. Naturally Si thought that soaking in water would have a beneficial effect. So he laid five or six of them in the bottom of a camp-kettle, anchored them down with a stone, and covered them with water. He thought that with the aid of a frying-pan he would get up a breakfast that he could eat, anyway. Si felt a little blue as he lay curled up under his blanket with his head pillowed on his knapsack. He thought some about his mother, and sister Maria, and pretty Annabel, but he thought a good deal more about the beef and potatoes, the pies and the puddings, that were so plentifully spread upon the table at home. It was a long time before he got to sleep. As he lay there, thinking and thinking, there came to his mind some ether uses to which it seemed to him the hardtack might be put, which would be much more consistent with its nature than to palm it off on the soldiers as alleged food. He thought he could now understand why, when he enlisted, they examined his teeth so carefully, as if they were going to buy him for a mule. They said it was necessary to have good teeth in order to bite "cartridges" successfully, but now he knew it was with reference to his ability to eat hardtack. Si didn't want to be killed if he could help it. While he was lying there he determined to line one of his shirts with hardtacks, and he would put that on whenever there was going to be a fight. He didn't believe the bullets would go through them. He wanted to do all he could toward paralyzing the rebels, and with such a protection he could be very brave, while his comrades were being mowed down around him. The idea of having such' a shirt struck Si as being a brilliant one. Then, he thought hardtack would be excellent for half-soling his shoes. He didn't think they would ever wear out.
  • 59. If he ran short of ammunition he could ram pieces of hardtack into his gun and he had no doubt they would do terrible execution in the ranks of the enemy. All these things and many more Si thought of until finally he was lost in sleep. Then he dreamed that somebody was trying to cram stones down his throat. The company was called out at daylight, and immediately after roll-call Si went to look after the hardtacks he had put to soak the night before. He thought he had never felt so hungry in his life. He fished out the hardtack and carefully inspected them, to note the result of the submerging and to figure out the chances on his much- needed breakfast. To any old soldier it would be unnecessary to describe the condition in which Si found those hardtacks, and the effect of the soaking. For the information of any who never soaked a hardtack it may be said that Si found them transformed, to all appearances, into sole-leather. They were flexible, but as tough as the hide that was "found in the vat when the tanner died." Si tried to bite a piece off one of them to see what it was like, but he couldn't get his teeth through it. In sheer desperation he laid it on a log, seized a hatchet, and chopped off a corner. He put it in his mouth and chewed on it a while, but found it as tasteless as cold codfish. Si thought he would try the frying-pan. He chopped the hardtacks into bits, put in equal parts of water and grease, sifted over the mixture a little salt and pepper, and then gave it a thorough frying. Si's spirits rose during the gradual development of this scheme, as it seemed to offer a good prospect for his morning meal. And when it came to the eating. Si found it really good, comparatively speaking, even though it was very much like a dish compounded of the sweepings from around a shoemaker's bench. A good appetite was indispensable to a real enjoyment of this—which the soldiers called by a name that cannot be given here—but Si had the appetite, and he ate and was thankful.
  • 60. "I thought I'd get the bulge on them things some way or other," said Si, as he drank the last of his coffee and arose from his meal, feeling like a giant refreshed with new wine. For the next two or three months Si largely devoted his surplus energies to further experimenting with the hardtack. He applied every conceivable process of cookery he could think of that was possible with the meager outfit at his command in the way of utensils and materials. Nearly all of his patient and persevering efforts resulted only in vexation of spirit. He continued to eat hardtack from day to day, in these various forms, but it was only because he had to do it. He didn't hanker after it, but it was a military necessity—hardtack or starvation. It was a hard choice, but Si's love of life—and Annabel—induced him to choose the hardtack. But for a long-time Si's stomach was in a state of chronic rebellion, and on the whole he had a hard time of it getting used to this staple article of army diet. He did not become reconciled to it until after his regiment had rations of flour for a week, when the
  • 61. "cracker-line" had been cut by the guerillas and the supply of that substantial edible was exhausted. Si's experience with the flour swept away all his objections to the hardtack. Those slapjacks, so fearfully and wonderfully made, and those lumps of dough, mixed with cold water and dried on flat stones before the fire, as hard as cannon balls, played sad havoc with his internal arrangements. For the first time he was obliged to fall into the cadaverous squad at sick-call and wabble up to the doctor's shop, where he was dosed with castor-oil and blue-mass. Si was glad enough to see hardtack again. Most of the grumbling he did thereafter concerning the hardtack was because he often couldn't get enough. About six months taught Si what all the soldiers learned by experience, that the best way to eat the average hardtack was to take it "straight"—just as it came out of the box, without any soaking or frying or stewing. At meal-time he would make a quart or so of coffee, stab the end of a ramrod through three or four slices of sowbelly, and cook them over the coals, allowing some of the drippings to fall upon the hardtack for lubricating purposes, and these constituted his frugal repast.
  • 62. CHAPTER V. FAT PORK— INDISPENSABLE BODY TIMBER FOR PATRIOTISM. IT WAS told in the last chapter how the patriotic impulses of Si Klegg, of the 200th Ind., reached his stomach and digestive apparatus, and brought them under obedient subjection to hardtack. He didn't have quite so rough an experience with that other staple of army diet, which was in fact the very counterpart of the hardtack, and which took its most popular name from that part of the body of the female swine which is usually nearest the ground. Much of Si's muscle and brawn was due to the fact that meat was always plenty on his father's farm. When Si enlisted he was not entirely free from anxiety on the question of meat, for to his appetite it was not even second in importance to bread. If bread was the "staff of life" meat was life itself to Si. It didn't make much difference to him what kind it was, only so it was meat. He didn't suppose Uncle Sam would keep him supplied with quail on toast and porterhouse steaks all the time, but he did hope he would give him as much as he wanted of something in that line. "You won't get much pork, unless you're a good forager," said one of Si's friends he met at Louisville, and who had been a year in the service. Si thought he might, with practice and a little encouragement, be fairly successful in foraging on his' own hook, but at the same time he said he wouldn't grumble if he could only get plenty of pork. Fortunately for him he had not been imbued with the teachings of the Hebraic dispensation which declared "unclean" the beast that furnished the great bulk of the animal food for the American defenders of the Union.
  • 63. Co. Q of the 200th Ind. received with the first issue of army rations at Louisville a bountiful supply of bacon of prime quality, and Si was happy at the prospect. He thought it would always be that way. "I don't see anything the matter with such grub as that!" said Si. "Looks to me as though we were goin' to live like fighting-cocks." "You're just a little bit brash," said his veteran friend, who had just been through the long, hungry march from Huntsville, Ala., to Louisville. "Better eat all you can lay yer hands on now, while ye've got a chance. One o' these days ye'll git into a tight place and ye won't see enough hog's meat in a week to grease a griddle. I've bin there, myself! Jest look at me and see what short rations 'll bring you to?" But Si thought he wouldn't try to cross a bridge till he got to it, nor lie awake nights worrying over troubles that were yet in the future. Si had a philosophical streak in his mental make-up and this, by the way, was a good thing for a soldier to have. "Sufficient unto the day is the evil thereof," was an excellent rule for him to go by. So Si assimilated all the pork that fell to his share, with an extra bit now and then from a comrade whose appetite was less vigorous. He thrived under its fructifying influence, and gave good promise of military activity and usefulness. No scientific processes of cookery were necessary to prepare it for immediate use. A simple boiling or frying or toasting was all that was required.
  • 64. During the few days at Louisville fresh beef was issued occasionally. It is true that the animals slain for the soldiers were not always fat and tender, nor did each of them have four hind-quarters. This last fact was the direct cause of a good deal of inflammation in the 200th Ind., as in every other regiment. The boys who got sections of the forward part of the "critter," usually about three- quarters bone, invariably kicked, and fired peppery remarks at those who got the juicy steaks from the rear portion of the animal. Then when their turn came for a piece of hind-quarter the other fellows would growl. Four-fifths of the boys generally had to content themselves with a skinny rib or a soupshank. Si shared the common lot, and did his full quota of grumbling because his "turn" for a slice of steak didn't come every time beef was issued. The pickled pork was comparatively free from this cause of irritation. It was all alike, and was simply "Hobson's choice." Si remembered the fragrant and delicious fried ham that so often
  • 65. garnished his mother's breakfast table and wondered why there was not the same proportion of hams and sides in the Commissary that he remembered in the meathouse on the Wabash. He remarked to Shorty one day: "I wonder where all this pork comes from?" "It comes from Illinoy, I suppose," said Shorty. "I notice the barrels are all marked 'Chicago'." "Must grow funny kind o' hogs out there—a mile long each, I should say. What do you mean?" "Why, we've drawn a full mile o' sides from the Commissary, and haint struck a ham yit. I'm wonderin' jest how long that hog is!" "Well, you are green. You oughter know by this time that there are only enough hams for the officers." Now and then a few pigs' shoulders were handed round among the boys, but the large proportion of bone they contained was exasperating, and was the cause of much profanity. Sometimes bacon was issued that had really outlived its usefulness, except, perhaps, for the manufacture of soap. Improperly "cured," it was strong and rancid, or, occasionally, so near a condition of putrefaction that the stench from it offended the nostrils of the whole camp. Some times it was full of "skippers," that tunneled their way through and through it, and grew fat with riotous living.
  • 66. Si drew the line at this point. He had an ironplated stomach, but putrid and maggoty meat was too much for it. Whenever he got any of this he would trade it off to the darkies for chickens. There is nothing like pork for a Southern negro. He wants something that will "stick to his ribs." By a gradual process of development his appetite reached the point when he could eat his fat pork perfectly raw. During a brief halt when on the march he would squat in a fence corner, go down into his haversack for supplies, cut a slice of bacon, lay it on a hardtack, and munch them with a keen relish.
  • 67. At one of the meetings of the Army of the Cumberland Gen. Garfield told a story which may appropriately close this chapter. One day, while the Army of the Cumberland was beleaguered in Chattanooga and the men were almost starving on quarter rations, Gen. Rosecrans and his staff rode out to inspect the lines. As the brilliant cavalcade dashed by a lank, grizzled soldier growled to a comrade: "It'd be a darned sight better for this army if we had a little more sowbelly and not quite so many brass buttons!"
  • 68. CHAPTER VI. DETAILED AS COOK— SI FINDS RICE ANOTHER INNOCENT WITH A GREAT DEAL OF CUSSEDNESS IN IT. IT WOULD have been very strange, indeed, if Si Klegg had not grumbled loudly and frequently about the food that was dished up to him by the company cooks. In the first place, it was as natural for a boy to grumble at the "grub" as it was for him to try to shirk battalion drill or "run the guard." In the next place, the cooking done by the company bean-boiler deserved all the abuse it received, for as a rule the boys who sought places in the hash foundry did so because they were too lazy to drill or do guard duty, and their knowledge of cooking was about like that of the Irishman's of music: "Can you play the fiddle, Pat?" he was asked. "Oi don't know, sor- r-r—Oi niver tried." Si's mother, like most of the well-to-do farmers' wives in Indiana, was undoubtedly a good cook, and she trained up her daughters to do honor to her teachings, so that Si undoubtedly knew what properly-prepared food was. From the time he was big enough to spank he had fared sumptuously every day. In the gush of patriotic emotions that prompted him to enlist he scarcely thought of this feature of the case. If it entered his mind at all, he felt that he could safely trust all to the goodness of so beneficent a Government as that for the preservation of which he had offered himself as a target for the rebels to shoot at. He thought it no more than fair to the brave soldiers that Uncle Sam should furnish professional cooks for each company, who would serve everything up in the style of a first- class city restaurant. So, after Si got down among the boys and
  • 69. found how it really was, it was not long till his inside was a volcano of rebellion that threatened serious results. When, therefore, Si lifted up his voice and cried aloud, and spared not—when he said that he could get as good coffee as that furnished him by dipping his cup into a tan-vat; when he said that the meat was not good soap-grease, and that the potatoes and beans had not so much taste and nutrition in them as so much pine- shavings, he was probably nearer right than grumblers usually are. "Give it to 'em, Si," his comrades would Say, when he turned up his loud bazoo on the rations question. "They ought to get it ten times worse. When we come out we expected that some of us would get shot by the rebels, but we didn't calculate that we were going to be poisoned in camp by a lot of dirty, lazy potwrastlers." One morning after roll-call the Orderly-Sergeant came up to Si and said:
  • 70. "There's been so much chin-music about this cooking-business that the Captain's ordered the cooks to go back to duty, and after this everybody'll have to take his regular turn at cooking. It'll be your turn to-day, and you'll stay in camp and get dinner." When Co. Q marched out for the forenoon drill. Si pulled off his blouse and set down on a convenient log to think out how he should go to work. Up to this time he had been quite certain that he knew all about cooking that it was worth while to know. Just now none of his knowledge seemed to be in usable shape, and the more he thought about it the less able he seemed to be to decide upon any way of beginning. It had always appeared very easy for his mother and sisters to get dinner, and on more than one occasion he had reminded them how much better times they had staying in the house cooking dinner than he had out in the harvest field keeping up with the reaper. At this moment he would rather have kept up with the fastest reaper in Posey County, on the hottest of July days, than to have cooked the coarse dinner which his 75 comrades expected to be ready for them when they returned, tired, hot and hungry, from the morning drill.
  • 71. Welcome to our website – the ideal destination for book lovers and knowledge seekers. With a mission to inspire endlessly, we offer a vast collection of books, ranging from classic literary works to specialized publications, self-development books, and children's literature. Each book is a new journey of discovery, expanding knowledge and enriching the soul of the reade Our website is not just a platform for buying books, but a bridge connecting readers to the timeless values of culture and wisdom. With an elegant, user-friendly interface and an intelligent search system, we are committed to providing a quick and convenient shopping experience. Additionally, our special promotions and home delivery services ensure that you save time and fully enjoy the joy of reading. Let us accompany you on the journey of exploring knowledge and personal growth! ebooknice.com