A Holiday Gantry Web Applicationby Phil Crow
Nearly 10 years ago, a small Internet and cable service provider in Kansas began serving applications via the Web. Almost two years ago, the third incarnation of our Perl-based web framework was released as an open source project called Gantry (under the same license as Perl). While Gantry is easy to use, we felt the need for even more laziness. Thus, we also developed Bigtop to generate code, SQL, configuration files, and other things for Gantry applications.
Bigtop is not only a code generator, it is a regenerator. As you'll see in the short story below, even after you have a running application, you can still use Bigtop to regenerate parts of the application. There is no risk of losing custom code you've written.
With Bigtop and Gantry, the core of a simple app can be ready in a few minutes. The start of a complex app can be generated in a short time as well. Then, the inevitable changes requested by users and developers can be incorporated into the application by regeneration. Only custom code needs to be updated manually.
To show the power of our tools, I've written a short story. Though it is set around Christmas time, I hope you'll find its meaning is timeless.
'Twas the Friday before Christmas, and all through the office, not a creature was stirring, except for my boss. At the door to the bat cave he made a request, "My wife needs an app to keep up with grandkids. Think about that while I order our lunch. After lunch, when you're done, you can leave for vacation."
From the corner of my ear I heard the boss order pizza from a place close at hand. Visions of pizza slices danced not in my head, but rather of the app, which I built in a flash.
"It should be here in half an hour," the boss said as he sat.
"You'll have to dine alone. I'm done."
"Now, that can't be."
Despite my protests, the boss wouldn't believe. When I showed him the app, he accused me of thievery. So, I replied, "I'll start again." And this is what he saw.
I typed at my keyboard, fingers in a whirl:
bigtop --new GrandKids 'child->family child(name,birth_day:date) family(parent,address,city,state,zip)'
This created a new two table application by the name of "GrandKids." The first table called child, having a foreign key to the second called family. Children keeping track of name and birth date. Families storing addresses for the boss to send toys.
When Bigtop finished, it told me on my screen:
I have generated your "GrandKids" application. To run the application:
cd GrandKids sqlite app.db < docs/schema.sqlite ./app.server [ port ]
The app.server runs on port 8080 by default.
Once the app.server starts, it will print a list of the URLs it can serve. Point your browser to one of those and enjoy.
If you prefer to run the app with Postgres or MySQL type one of these:
bigtop --pg_help bigtop --mysql_help
So, I followed instructions to the GrandKids directory and built my db with SQLite3:
sqlite3 app.db < docs/schema.sqlite
Then started the app with a bit of a flare:
Which gave me this list of where I could go:
Available urls: http://localhost:8080/ http://localhost:8080/child http://localhost:8080/family
I chose family.
Clicking Add, I put in some data to save. Then chose Child from navigation links and added one kid.
Having named one child, entered the date of her birth, and picked her parents from the pull down; I saved triumphantly and looked to the boss.
"Why," was all he could spout.
I rose from my chair to retrieve my long coat, but was stopped short by the boss fearing lunch all alone. "What about gifts?"
"Gifts?" I asked unsure.
"Yes, Mrs. Boss has long feared double gifting a child, after the trauma of giving one girl a 'My Little Pony Castle' two years in a row."
Pages: 1, 2