|Home||Android Apps||Web Projects||Webmaster Tools||Software||Andrew's Blog||
XAO::Web - XAO Web Developer, dynamic content building suite
XAO::Web is a part of XAO open source web services suite. It allows to build dynamic web content using data, templates and external input (for an overview of the templating system please refer to XAO::DO::Web::Page description).
The distinguishing feature of XAO::Web is in its modular design where almost every aspect of functionality can be altered and alterations can be re-used. No complex code is embedded in the templates which allows to upgrade code and templates separately or maintain multiple visual representations of the same functionality at the same time.
Aside from that most interesting features of XAO::Web are:
perl Makefile.PL make make test sudo make installSaying "install XAO::Web" from the CPAN shell is a good way too:
perl -MCPAN -eshell install XAO::WebUsing CPAN shell is usually the best way because all dependencies will be resolved automatically. If you do manual installation then XAO::Web depends on at least the following modules (look into Makefile.PL or just watch closely the output of `perl Makefile.PL' for additional dependencies):
XAO::Base XAO::FS Digest::MD5 Error MIME::Lite Test::UnitWhen you run "perl Makefile.PL" you will be asked for XAO::Web test database. That database is only used when you do `make test' and it have to exist. It does not matter what is inside the database, it will be completely wiped out for each test case. Normally the database should be the same that you have used for XAO::FS tests and in case of MySQL is usually 'test' or 'test_fs'.
The directory where templates get installed is the same that you gave to XAO::Base when you installed it. Normally that directory is /usr/local/xao -- we will assume that for the rest of the document.
FIRST-TIME RUNNING AND TESTING
You are almost there. Now is the time to try it!
In addition to reading this manual (or instead of reading it if you feel too adventurous today) you can look at the generic site setup in the misc/samplesite/ directory of the distribution archive. The sample site also provides a very useful template to start any project with!
Configure your Apache server so that it would execute /usr/local/xao/handlers/xao-apache.pl when someone types URL like http://test.company.com/cgi-bin/xao-apache.pl. Here is an example of a virtual host configuration for that (or you can simply sym-link xao-apache.pl to your existing cgi-bin directory if you have one):
<VirtualHost 10.0.0.1:80> ServerName test.company.com ScriptAlias /cgi-bin/ /usr/local/xao/handlers/ </VirtualHost>After you configure and re-start your web-server point your browser at http://test.company.com/cgi-bin/xao-apache.pl/mysite/ -- you should be able to see the default page template processed by XAO::Web. If you do not see it -- you might want to look into apache error log, usually there is some additional information there.
In the URL you used to look at the default page includes 'mysite' as a site name. In this case it can be anything you want, nothing depends on the name because your site does not yet have any specific templates, objects or configuration. We will get back to customizing your site later.
Now let us look into the URL - it does not look good, does it? It includes cgi-bin, site name and generally looks ugly, we agree. The way to deal with it currently is to use mod_rewrite to hide that into Apache configuration. We are working on the real mod_perl module that will not require mod_rewrite, you should expect it with the next release of XAO::Web.
Here is how to configure Apache with mod_rewrite in the meantime:
<VirtualHost 10.0.0.1:80> ServerName test.company.com ServerAlias test.company.com <Directory /usr/local/xao/handlers> Options ExecCGI SetHandler cgi-script </Directory> RewriteEngine on RewriteRule ^/images/(.*)$ \ /usr/local/xao/projects/mysite/images/$1 \ [L] RewriteRule ^/(.*)$ \ /usr/local/xao/handlers/xao-apache.pl/mysite/$1 \ [L] </VirtualHost>That leaves everything in /images/ to be processed by the web server in the usual way and maps everything else to XAO::Web handler. Restart Apache and try going to just http://test.company.com/ now -- you should see the same default page as before.
And finally, here is an example of mod_perl configuration, you should use it for production grade sites. The only difference is in <Directory> block.
<VirtualHost 10.0.0.1:80> ServerName test.company.com ServerAlias test.company.com <Directory /usr/local/xao/handlers> Options ExecCGI SetHandler perl-script PerlHandler Apache::Registry PerlSendHeader Off </Directory> RewriteEngine on RewriteRule ^/images/(.*)$ \ /usr/local/xao/projects/mysite/images/$1 \ [L] RewriteRule ^/(.*)$ \ /usr/local/xao/handlers/xao-apache.pl/mysite/$1 \ [L] </VirtualHost>That is it, if you got so far your installation of XAO::Web works fine and you can move on to actually building a custom web site.
Before you go any further it is recommended that you keep cgi-bin configuration sample from the examples above as opposed to mod_perl. Mod_perl development has its own peculiarities related to caching of modules and content and you can get back to that later. Cgi-bin based configurations are usually much easier to develop and debug.
Here is a couple of steps to start the development of a new site.
Copyright © 2005 Andrew Maltsev
Copyright © 2001-2004 Andrew Maltsev, XAO Inc.
<email@example.com> -- http://ejelta.com/xao/
XAO::Web was created and is maintained by Andrew Maltsev. Creating of XAO::Web would not be possible without valuable comments and ideas from everybody on our team and especially from Marcos Alves, Bil Drury, Brian Despain and Jason Shupe.
Recommended reading: XAO::DO::Web::Page (for templates language), XAO::Objects (for object loading details), XAO::DO::Config (for site config details), XAO::FS (for OO database interface), XAO::DO::FS::Config, XAO::Web.