G-Cows

Scripting Language for Web Content Management

Andrea Sozzi

This manual is for G-Cows, a scripting language for web content management.

Updated for version 1.9, released on April 26, 2006.

Manual edition: April 26, 2006


Dedication

To the 170 billions animals killed for food each year.

Table of Contents
Preface
I. Overview of G-Cows
1 Introduction
1.1 The Cows Scripting Language
1.2 What is G-Cows
1.3 History and Release Notes
1.4 G-Cows Copying Conditions
2 Concepts
2.1 HTTP
2.2 HTML
2.3 Static and Dynamic
2.4 Applications
2.5 Features
2.6 A Concrete Example
II. Tutorial
3 Basic Features
3.1 Running Cows
3.2 Guidelines
3.3 The First Page
3.4 A Minimal Web Site
3.5 Last Modify Date
3.6 Towards an Improved Header
3.7 Improved Header
4 A Real Site
4.1 Introducing Templates
4.2 Content Organization
4.3 Layout Grids
4.4 Page Mock-ups
4.5 Writing HTML
4.6 Site Template
4.7 Creating Pages
4.8 Logo
4.9 Main Navigation Bar
4.10 Secondary Navigation Bar
4.11 Title
4.12 History
4.13 Modify Date
4.14 Separating sources
4.15 The Final Result
4.16 Publishing the site
5 Advanced Topics
5.1 Cleaning up the Project
5.2 G-Cows and CSS
5.3 Multiple Templates
5.4 Alternate Version
5.5 Multilingual Site
5.6 Printable Version
5.7 Banner
5.8 Site Map
5.9 Navigation Panel
5.10 Adding PHP
5.11 Adding PHP and MySQL
5.12 Publishing the site
5.13 Multiple Configurations
5.14 Integration with WYSIWYG editors
III. G-Cows: architecture and language
6 Cows and Cows-mkgen
6.1 Cows Input Files
6.2 Invoking Cows
6.3 G-Cows and Make
6.4 Invoking Cows-mkgen
6.5 Keeping sources separated
6.6 When Cows-mkgen needs more Hints
6.7 Excluding files and directories
6.8 Branch Sites
6.9 Multilingual Sites
6.10 Fast mode
6.11 Diagnostic Messages
6.12 Security
7 Data Types
7.1 Integers
7.2 Strings
7.3 Booleans
7.4 Array Variables
7.5 Type Conversion
7.6 Checking data types
8 Language Structure
8.1 Case Sensitive
8.2 Comments
8.3 Semicolons
8.4 Whitespaces
8.5 Literals
8.6 Identifiers
9 Variables
9.1 Use of Variables
9.2 Automatic Type Conversion
9.3 Variable Assignment
9.4 Variable Expansion
9.5 Undefining Variables
9.6 The $ Function
9.7 Variables Example
10 Expressions
11 Operators
11.1 Precedence and Associativity
11.2 Arithmetic Operators
11.3 Comparison Operators
11.4 Logical Operators
11.5 Assignment Operators
12 Arrays
12.1 Array Notation
12.2 Array Operators
12.3 Array Assignment
12.4 Array Element Assignment
12.5 Array Element Expansion
12.6 Inserting and Deleting Elements
12.7 Array Concatenation
12.8 Assignment and Concatenation
12.9 Joining Array Elements
12.10 Comparing Arrays
12.11 Array Length
12.12 Multidimensional Arrays
12.13 Undefining Arrays
12.14 Array How-to
12.15 Array Example
13 Functions
14 Output
14.1 The Echo Function
14.2 The Print Function
15 Conditional Expressions
15.1 Use of Conditional Expressions
15.2 Ifdef
15.3 Ifdef Example
15.4 Ifndef
15.5 Ifndef Example
15.6 If
15.7 If Example
15.8 Nested Conditionals
15.9 Nested Conditionals Example
16 Loops
16.1 For Loops
16.2 Foreach Loops
16.3 While Loops
17 File Inclusion
17.1 Verbatim inclusion
17.2 Including external scripts
18 String Functions
18.1 Searching into Strings
18.2 Substrings
18.3 Replacing and Inserting
18.4 Tokenizing
18.5 Trimming
18.6 Changing Case
18.7 Template strings
18.8 Examples
19 Date and Size Functions
19.1 Display current date: date
19.2 Display file date: fdate
19.3 Displaying Last Modify Dates
19.4 File Size
20 Adjusting Links
20.1 A Common Problem
20.2 Solution
20.3 The linkadjust () Function
21 Other Functions
21.1 Input File
21.2 Absolute Input File
21.3 Output File
21.4 Absolute Output File
21.5 Raising Errors
21.6 Writing to Standard Output
21.7 Random numbers
21.8 Check for file existence
22 The Type Mode
22.1 Displaying Large Amounts of HTML Code
22.2 The type Statement
22.3 Typing into a variable
23 Executing external commands, scripts and programs
23.1 The cmd Function
23.2 The evalcmd Function
23.3 The Exec Function
23.4 The evalexec Function
23.5 Security Note
24 Various Considerations
24.1 Dependencies
24.2 Optimizing Updates
IV. Appendices
A. Obtaining and Installing G-Cows
A.1 Which Package?
A.2 Installing RPM package
A.3 Installing Source Tarball
B. Migrating projects from G-Cows 0.x
C. G-Cows and Animal Rights
C.1 Animal Rights
C.2 Vegetarianism
C.3 Vivisection

This manual can be downloaded from http://www.g-cows.org/.