Now, we need a source for each page; let's create a directory for each section and, inside each directory, a file called index.cws (representing an introduction to the topic) and a source file for each page. As an example, section vegetarianism consists in four pages:
suffering
health
hunger
act
so we need the following sources:
vegetarianism/index.cws
vegetarianism/suffering.cws
vegetarianism/health.cws
vegetarianism/hunger.cws
vegetarianism/act.cws
Corresponding generated files will be:
vegetarianism/index.html
vegetarianism/suffering.html
vegetarianism/health.html
vegetarianism/hunger.html
vegetarianism/act.html
Let's create the directories:
$ mkdir vegetarianism vivisection $ mkdir furs_leather hunting entertainment
Now, the source files; for the moment, we'll only create section `vegetarianism'. I'll show you a single file: the others has the same structure and can be found within the examples archive.
File: vegetarianism/hunger.cws
<cows> type (pg.quote): Many things made me become a vegetarian, among them, the higher food yield as a solution to world hunger. endtype; pg.author = "John Denver"; type (pg.content): <p> Every day, lots of people experience hunger and die of starvation and we accept it as an unavoidable fact thinking there's not enough food for everyone. </p> <p> If you look at the data, however, our lands give us enough food for everyone. If we directly ate vegetable products, we could feed everybody in the world and free one billion people from starvation. </p> <p> But luckily we can also process natural products in order to get nice, tasty food. Rearrangement leads to a small waste of course, but there would still be enough food for everyone. </p> <p> Problems arise when we come to meat and other animal products; you need over 10 pounds of grain to produce one pound of beef ! Moreover, grain used to feed livestocks comes from poor countries, while meat is produced for the richest ones. </p> <p> That's way one billion people suffer for starvation. Estimations tell us that if 10 percent of people became vegetarian, there would be enough grain to save 60 million people from hunger and starvation. </p> <p> If you care for those people, you have another good reason to become vegetarian. </p> endtype; include ("../lib/template.cws"); </cows>
We've just used a new form of the type statement:
type (variable
):
HTML + expressions.
endtype;
This form allows to insert HTML code and Cows expressions into a variable instead of displaying it into the output file. I use it for long strings, expecially page content; for shorter variables (e.g. quotation's author) I prefer the standard variable assignment.
As you can see, every page simply consists in the definition of three variables and the inclusion of the template script. Contents and layout are completely separated.
Now, we run Cows-mkgen to create a Makefile and Make to create pages:
$ cows-mkgen $ make cows vegetarianism/suffering.cws vegetarianism/suffering.html cows vegetarianism/health.cws vegetarianism/health.html cows vegetarianism/hunger.cws vegetarianism/hunger.html cows vegetarianism/index.cws vegetarianism/index.html cows vegetarianism/act.cws vegetarianism/act.html
Let's have a look at one of source files:
vegetarianism/health.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <link rel="stylesheet" type="text/css" href="../css/style.css"> <title>Title</title> </head> <body> <div id="header"> Logo </div> <div id="menu"> <!-- Begin Main Menu --> Main menu <!-- End Main Menu --> </div> <div id="submenu"> <!-- Begin Submenu --> Submenu <!-- End Submenu --> <p> Vegetarians have the best diet. They have the lowest rates of coronary disease of any group in the country ... Some people scoff at vegetarians, but they have a fraction of our heart attack rate and they have only 40 percent of our cancer rate. They outlive other men by about six years now. --Dr.William Castelli, M.D. </p> </div> <div id="content"> <p id="stack"> History Stack </p> <h1>Title</h1> <p> Actually, vegetarians outlive other people of many years and, even more important, are much healthier. Heart attacks are very unlikely in vegetarians and cancer rate is 60% less respect to other people. </p> <p> Giving up meat and fish doesn't lead to any deficiency; if you also avoid eggs and dairy products you'll get the major benefits but this requires a small integration of Vitamin B12. There are natural B12 integrators, and using them is not less natural then following advices like `eat more fruit': you eat a natural product to improve your health. </p> <p> If you care for your health this is a really good reason to give up meat, eggs, and dairy products. </p> <p id="revision"> Revision date </p> </div> <div id="footer"> This is a sample site created with <a href="http://www.g-cows.org" target="_blank" class="menuactive">G-Cows</a>. </div> </body> </html>
Of course, these pages will completely miss navigation bars and images. We have only set up the job; now, we'll gradually fill in the blanks. Here, how it looks from the Mozilla browser:
This manual can be downloaded from http://www.g-cows.org/.