This how-to describes the basics of gestalt.
For the purposes of this how-to, lets build a demo application called 'My CD Collection'.
First of all, create a postgreSQL database called 'my_cd_collection' with the following tables:
CREATE TABLE artist
(
id serial UNIQUE NOT NULL,
name varchar(64) UNIQUE,
description TEXT,
PRIMARY KEY (id)
);
# We use comments in PostgreSQL to describe the various parts:
# Tables have "singular,plural" descriptions, so no assumptions are made
COMMENT ON TABLE artist IS 'Artist,Artists';
COMMENT ON COLUMN artist.id IS 'Artist ID';
COMMENT ON COLUMN artist.description IS 'Description and Comments';
CREATE TABLE album
(
id serial UNIQUE NOT NULL,
artist int NOT NULL REFERENCES artist(id),
album_title varchar(64) NOT NULL,
description TEXT,
PRIMARY KEY (id)
);
COMMENT ON TABLE album IS 'Album,Albums';
COMMENT ON COLUMN album.id IS 'Album ID';
COMMENT ON COLUMN album.artist IS 'Artist';
COMMENT ON COLUMN album.album_title IS 'Title';
COMMENT ON COLUMN album.description IS 'Description and Comments';
CREATE TABLE song
(
id serial UNIQUE NOT NULL,
album int NOT NULL REFERENCES album(id),
name varchar(64) NOT NULL,
PRIMARY KEY (id)
);
COMMENT ON TABLE song IS 'Song,Songs';
COMMENT ON COLUMN song.id IS 'Song ID';
COMMENT ON COLUMN song.album IS 'Album';
COMMENT ON COLUMN song.name IS 'Song Title';
OK, so we have 3 tables to store Artists, Albums, and Songs. Now we need to generate the application:
bradley $ gestalt --database my_cd_collection --username ABC --password DEF --app-name 'cd-collection' \
--email-address 'your@email.address.com'
The output will look like this:
Processing Templates... collection/DB/Makefile.PL collection/DB/Table/Makefile.PL collection/DB/Table/Row/Makefile.PL collection/Apache/Makefile.PL collection/Apache/Request/Makefile.PL collection/Apache/Request/Controller/Makefile.PL collection/DB/Table/Album/Makefile.PL collection/DB/Table/Row/Album/Makefile.PL collection/Apache/Request/Controller/Album/Makefile.PL collection/DB/Table/Row/Album/Makefile.am collection/DB/Table/Album/Makefile.am collection/Apache/Request/Controller/Album/Makefile.am collection/templates/Album/Makefile.am collection/DB/Table/Album/Album.pm collection/DB/Table/Row/Album/Album.pm collection/Apache/Request/Controller/Album/Album.pm collection/DB/Table/Artist/Makefile.PL collection/DB/Table/Row/Artist/Makefile.PL collection/Apache/Request/Controller/Artist/Makefile.PL collection/DB/Table/Row/Artist/Makefile.am collection/DB/Table/Artist/Makefile.am collection/Apache/Request/Controller/Artist/Makefile.am collection/templates/Artist/Makefile.am collection/DB/Table/Artist/Artist.pm collection/DB/Table/Row/Artist/Artist.pm collection/Apache/Request/Controller/Artist/Artist.pm collection/DB/Table/Song/Makefile.PL collection/DB/Table/Row/Song/Makefile.PL collection/Apache/Request/Controller/Song/Makefile.PL collection/DB/Table/Row/Song/Makefile.am collection/DB/Table/Song/Makefile.am collection/Apache/Request/Controller/Song/Makefile.am collection/templates/Song/Makefile.am collection/DB/Table/Song/Song.pm collection/DB/Table/Row/Song/Song.pm collection/Apache/Request/Controller/Song/Song.pm collection/configure.in collection/Makefile.am collection/DB/Makefile.am collection/Apache/Makefile.am collection/Apache/Request/Makefile.am collection/DB/Table/Row/Makefile.am collection/DB/Table/Makefile.am collection/Apache/Request/Controller/Makefile.am collection/templates/Makefile.am collection/collection.cfg.in collection/collection.spec.in collection/collection.apache.conf.in collection/collection.pl.in collection/NEWS collection/README collection/AUTHORS collection/ChangeLog collection/bootstrap bradley $
As you can see, a lot of files for your project have been generated. It may look complicated, but its actually OK because most of the files are just project-related build files and the rest dont actually contain much code because they inherit from the core modules which are supplied with Gestalt.
Now, lets get your application up and running:
bradley $ cd collection bradley $ ./bootstrap bradley $ ./configure && make && make install [output snipped]
You should just have to restart apache and point your browser to: http://127.0.0.1/collection/ You should see something like this:
http://www.kitefamily.co.uk/images/album_list.jpg
You should be able to navigate between artists, albums, and songs and add/delete/modify your entries as you see fit.
