By now, we have only the introductory page about Animal Rights so, in order to create our site, we'll add the remaining pages.
This section will teach you
how to update a web site with Make and Cows-mkgen (complete reference: Section 6.3);
The sources described in this section can be found inside directory tutorial-2 in the examples archive downloadable from http://www.g-cows.org/.
Add the following files to the project:
File vegetarianism.cws:
<html> <head><title>Vegetarianism</title></head> <body> <cows verbatim ("lib/header_html"); /> <h1>Vegetarianism</h1> <p align="right"> When I was old enough to realize all meat was killed,<br> I saw it as an irrational way of using our power, <br> to take a weaker thing and mutilate it.<br> <em>-- River Phoenix</em> </p> <cows verbatim ("lib/footer_html"); /> </body> </html>
File vivisection.cws:
<html> <head><title>Vivisection</title></head> <body> <cows verbatim ("lib/header_html"); /> <h1>Vivisection</h1> <p align="right"> Atrocities are not less atrocities when they occur in<br> laboratories and are called medical research.<br> <em>-- George Bernard Shaw</em> </p> <cows verbatim ("lib/footer_html"); /> </body> </html>
File hunting.cws:
<html> <head><title>Hunting</title></head> <body> <cows verbatim ("lib/header_html"); /> <h1>Hunting</h1> <p align="right"> Men hunt I think maybe because they have<br> something wrong with their own equipment<br> and they need something else to shoot.<br> <em>-- Pamela Anderson</em> </p> <cows verbatim ("lib/footer_html"); /> </body> </html>
File furs.cws:
<html> <head><title>Furs & Leather</title></head> <body> <cows verbatim ("lib/header_html"); /> <h1>Furs & Leather</h1> <p align="right"> I haven't bought any leather articles for a<br> very long time. My ideal is to be able to avoid<br> all animal products, in food as well as clothing.<br> <em>-- Martina Navratilova</em> </p> <cows verbatim ("lib/footer_html"); /> </body> </html>
File entertainment.cws:
<html> <head><title>Animals in entertainment</title></head> <body> <cows verbatim ("lib/header_html"); /> <h1>Animals in entertainment</h1> <p align="right"> The zoo is a prison for animals who have been sentenced<br> without trial and I feel guilty because I do nothing about it.<br> I wanted to see an oyster-catcher, so I was no better than <br> the people who caged the oyster-catcher for me to see.<br> <em>--Russell Hoban</em> </p> <cows verbatim ("lib/footer_html"); /> </body> </html>
Every time you modify a source file, you need to run Cows on it in order to update the relative page. Moreover, you also need to run Cows on every file including the modified one. It's easy to see that if your site consists in more than a couple of files, there are many chances of an error. But don't worry: that's where the Make utility and Unix's collaborative architecture come in help.
Quoting Make's manual:
You can use it to describe any task where some files must be updated automatically from others whenever the others change.
To prepare to use make, you must write a file called the makefile that describes the relationships among files in your program and provides commands for updating each file.
Once a suitable makefile exists, each time you change some source files, this simple shell command:
makesuffices to perform all necessary recompilations.
For a complete description of these topics see Section 6.3. For the moment, you simply need to know that the cows-mkgen utility automatically generate such makefile for you. Every time you have more than a couple of files, you should use Cows-mkgen and Make to generate and update files, instead of running Cows directly.
Let's run Cows-mkgen to generate a suitable Makefile:
$ cows-mkgen $ ls -F Makefile furs.cws vegetarianism.cws Makefile.sources hunting.cws vegetarianism.html animal_rights.cws index.cws vivisection.cws
As you can see, Cows-mkgen just created two files called Makefile and Makefile.sources. If it's the first time you hear about Make, or you're reading this tutorial just to get the taste of what you can do with G-Cows, don't bother about these files. You can examine them after reading Section 6.3.
All you need to know is that Cows-mkgen just examined all your source files (descending recursively into subdirectories) and created a Makefile describing relations among them.
Now, you only need to type make at the command prompt: the Make utility will read this Makefile and run Cows as needed.
$ make cows entertainment.cws entertainment.html cows vivisection.cws vivisection.html cows furs.cws furs.html cows hunting.cws hunting.html cows vegetarianism.cws vegetarianism.html
Please notice that file index.html was already up to date so Make didn't update it.
Follows, this minimal site as seen with the Lynx text browser:
File index.html:
[ Home (Animal Rights) | Vegetarianism | Vivisection | Hunting | Furs & Leather | Animals in Entertainment ] _______________________________________________________ Animal Rights Because the heart beats under a covering of hair, of fur, feathers, or wings, it is, for that reason, to be of no account? -- Jean Paul Richter _______________________________________________________ Webmaster: webmaster@your-domain
File vegetarianism.html:
[ Home (Animal Rights) | Vegetarianism | Vivisection | Hunting | Furs & Leather | Animals in Entertainment ] _______________________________________________________ Vegetarianism When I was old enough to realize all meat was killed, I saw it as an irrational way of using our power, to take a weaker thing and mutilate it. -- River Phoenix _______________________________________________________ Webmaster: webmaster@your-domain
File vivisection.html:
[ Home (Animal Rights) | Vegetarianism | Vivisection | Hunting | Furs & Leather | Animals in Entertainment ] _______________________________________________________ Vivisection Atrocities are not less atrocities when they occur in laboratories and are called medical research. -- George Bernard Shaw _______________________________________________________ Webmaster: webmaster@your-domain
File hunting.html:
[ Home (Animal Rights) | Vegetarianism | Vivisection | Hunting | Furs & Leather | Animals in Entertainment ] _______________________________________________________ Hunting Men hunt I think maybe because they have something wrong with their own equipment and they need something else to shoot. -- Pamela Anderson _______________________________________________________ Webmaster: webmaster@your-domain
File furs.html:
[ Home (Animal Rights) | Vegetarianism | Vivisection | Hunting | Furs & Leather | Animals in Entertainment ] _______________________________________________________ Furs & Leather I haven't bought any leather articles for a very long time. My ideal is to be able to avoid all animal products, in food as well as clothing. -- Martina Navratilova _______________________________________________________ Webmaster: webmaster@your-domain
File entertainment.html:
[ Home (Animal Rights) | Vegetarianism | Vivisection | Hunting | Furs & Leather | Animals in Entertainment ] _______________________________________________________ Animals in entertainment The zoo is a prison for animals who have been sentenced without trial and I feel guilty because I do nothing about it. I wanted to see an oyster-catcher, so I was no better than the people who caged the oyster-catcher for me to see. --Russell Hoban _______________________________________________________ Webmaster: webmaster@your-domain
We have a small site, consisting in a few pages with a common layout; of course this is not a professional site but the important point is that every site, with every degree of complexity can be seen as pages consisting in:
some HTML code (header)
content
other HTML content (footer)
So this philosophy can be applied to every site. Of course in a professional site header and footer will contain graphic elements.
In general, since HTML elements flow from top to bottom and from left to right, every page can be created by including before and after content two files representing respectively:
elements located at the top and at the left of page's content;
elements located at the right and at the bottom of page's content.
The same result can be achieved with less effort by the mean of Server Side Inclusion but your web server would parse every file looking for inclusions and open three files per request. This useless server overwork would make your site slightly slower. Moreover, not every web server provide this feature. Creating standard HTML files ensures the maximum efficiency and portability.
This manual can be downloaded from http://www.g-cows.org/.