Book Image

Catalyst

By : Jonathan Rockway
Book Image

Catalyst

By: Jonathan Rockway

Overview of this book

<p>Many web applications are implemented in a way that makes developing them painful and repetitive. Catalyst is an open-source Perl-based Model-View-Controller framework that aims to solve this problem by reorganizing your web application to design and implement it in a natural, maintainable, and testable manner, making web development fun, fast, and rewarding.<br /><br />Everything that your web application needs to do is only written once; you connect to the database in one place, have configuration in one place, etc. Then, you just write actions for each URL that your application needs, without worrying about the database connections or HTML to produce. Catalyst will handle the details so you can worry about writing your application.<br /><br />Catalyst is designed to be reliable. There are hundreds of production applications and thousands of users. The code is well-tested, and new releases almost always maintain compatibility with applications written for older versions. You don't have to worry about Catalyst breaking your application and slowing down your development. It just works.<br /><br />Most importantly, Catalyst has a thriving community. You can ask a question on the IRC channel and get a response at almost any time of the day.<br />&nbsp;<br />This book embodies Catalyst's philosophies of Do It Yourself and Don't Repeat Yourself.</p>
Table of Contents (14 chapters)

TTSite


TTSite is a Catalyst View that wraps every TT template we use in a header and footer. This all happens transparently, so we can add some prettiness to our site without writing any CSS or HTML.

There are a few differences from the standard TT view to be aware of. First, templates are stored in /root/src instead of /root. TTSite keeps its configuration in /root/lib, so that's where you'll want to go if you want to change the look of the site. The configuration is easy to understand—the file called header contains the TT commands that will be added to the header of the page (and so on).

For this application, we do need to make a few modifications to the default setup. First, let's remove the default "message" (to display at the top of the page), so we can specify our own from a controller.

To do this, edit /root/lib/config/main, removing the block of code that looks like this:

# set defaults for variables, etc.
DEFAULT
message = 'There is no message';

Next, we'll edit the template that...