package CatalystX::CMS::Tutorial; our $VERSION = '0.011'; =pod =head1 NAME CatalystX::CMS::Tutorial - drop-in content management system =head1 DESCRIPTION CatalystX::CMS (CXCMS) is a set of Catalyst base classes that enable web-based editing and revision history of your application templates. The impetus behind the project is simple: sometimes you need to give non-programmers an easy way to manage your application templates, or to allow them to extend the application with new content. This tutorial provides an overview of the project and offers examples of CatalystX::CMS in use. =head1 OVERVIEW The basic premise is simple: any URL in your Catalyst application can be made edit-able by making your controller class a subclass of CatalystX::CMS::Controller. This magic is achieved through CatalystX::CMS::Action, which evaluates every action for the presence of the C request parameter. If that parameter is present and true, then the appropriate CMS method is called. Otherwise, your normal action chain is executed. The CMS editor interface pulls up the raw Template Toolkit file and allows the user to edit it in a text box. The TT files are then stored in a Subversion repository, so you get all the Subversion features for your templates: revision history, diff, blame, etc. =head1 TEMPLATE STRUCTURE CXCMS assumes the following template structure: The C file calls the other three. In addition to the four-part template, CXCMS supports two levels of abstraction: B and B. The B is intended to be used like a MIME type. The default B is C. The B is intended to be used like a theme or skin designation. The template directory structure is assumed to be: type/flavour/ type/flavour/ type/flavour/ type/flavour/ This structure supports the idea of multiple flavours for each type. =head1 A NEW PROJECT This example looks at creating a new application designed specifically for managing mostly raw HTML files. Look at the example app in the distribution t/ dir for an example. Bootstrap your app: % MyCMS % cd MyCMS % script/ controller CMS CMS % script/ model CMS CMS % script/ view CMS CMS Add the config to lib/ __PACKAGE__->config( cms => { use_editor => 1, use_layout => 1, root => { r => [ __PACKAGE__->path_to('root') ], rw => ['/tmp/mycms/work'] }, }, ); Get your css and js files served for free by the Static::Simple plugin. Edit lib/ to include: use Class::Inspector; use Path::Class::Dir; use CatalystX::CMS; my $cms_base = Class::Inspector->loaded_filename( 'CatalystX::CMS' ); $cms_base =~ s/\.pm$//; __PACKAGE__->config( static => { include_path => [ __PACKAGE__->path_to( 'root' ), Path::Class::dir( $cms_base, 'tt' ) ], } ); Create your local svn repos and workdir: % mkdir /tmp/mycms % svnadmin create /tmp/mycms/repos % cd /tmp/mycms % svn co file:///tmp/mycms/repos work % cd - Start up the test server: % script/ Point your browser at a URL that doesn't yet exist: http://localhost:3000/cms/foo You should be prompted to create the file. If you click on the file name B you should be redirected to the CMS editor. Change the default text: [ this is a new page ] to something more meaningful and click C. You should be redirected to the new URL. See the section on L