Mason

来自开放百科 - 灰狐
(版本间的差异)
跳转到: 导航, 搜索
第18行: 第18行:
 
  vi /etc/apache-perl/conf.d/libhtml-mason-perl-examples.conf
 
  vi /etc/apache-perl/conf.d/libhtml-mason-perl-examples.conf
 
  PerlModule HTML::Mason::ApacheHandler
 
  PerlModule HTML::Mason::ApacheHandler
  <Directory /home/www/vhosts/xxx.com/html>
+
  <Directory /var/www/mason/html>
 
         SetHandler perl-script
 
         SetHandler perl-script
 
         PerlHandler HTML::Mason::ApacheHandler
 
         PerlHandler HTML::Mason::ApacheHandler
 
  </Directory>
 
  </Directory>
 
Using Mason from a CGI Script
 
Using Mason from a CGI Script
  #!/usr/bin/perl
+
  touch hello.html
use HTML::Mason::CGIHandler;
+
  % my $ planet = "world";
  my $h = HTML::Mason::CGIHandler->new
+
  Hello, <% $planet %
  (
+
  http://localhost/mason/html/hello.html :)
  data_dir => '/home/jethro/code/mason_data',
+
  );
+
$h->handle_request;
+
  
 
The relevant portions of the httpd.conf file look like:
 
The relevant portions of the httpd.conf file look like:

2007年2月20日 (二) 00:52的版本

Masonhq logo.gif

Mason - High-performance, dynamic web site authoring system

HTML中的Mason组件是基于开放Perl,用来创建维护网站的一个平台。最早是为了克服CGI的一些局限而开发的,CGI(Common Gateway Interface)是HTTP服务器与你的或其它机器上的程序进行“交谈”的一种工具,其程序须运行在网络服务器上。Mason的出现使得开发和管理大型网页的工作变得相对简单起来。其后Mason不断完善,目前已经是一个完整的开发工具了。1998年,基于Perl Artistic License的第一个HTML::Mason版本正式发行。  

Mason是一个结构化的可复用的组件库,包括HTML,Perl代码以及Mason命令。一个完整的网站首先要包括一个主要组件(父组件),在主要组件之中包括各种小型组件(子组件)。这种面向对象的机制,保证了当组件有所改变时,所有引用此组件的网页都会有所改变。这样网页设计人员(这些人通常都对组件编程不太精通)就可以忽略组件的内部机制问题,专心致志将精力放到整个网页的内容之上了。  

Mason支持的其他功能有:利用缓存构件进行回复;可以利用目录或分层结构十分轻松的创建模板;具有模拟不同环境下网页真实显示效果的能力。Mason特意针对Apache服务器和mod_perl做了优化。当然,Mason也可以作为CGI的标准模块被使用。

目录

安装指南

前提是安装了 mod_perl

Debian用户

#apt-get install libhtml-mason-perl libhtml-mason-perl-examples 
// mason install to /usr/share/perl5/HTML/Mason

vi /etc/apache-perl/conf.d/libhtml-mason-perl-examples.conf
PerlModule HTML::Mason::ApacheHandler
<Directory /var/www/mason/html>
       SetHandler perl-script
       PerlHandler HTML::Mason::ApacheHandler
</Directory>

Using Mason from a CGI Script

touch hello.html
% my $ planet = "world";
Hello, <% $planet %
http://localhost/mason/html/hello.html :)

The relevant portions of the httpd.conf file look like:

DocumentRoot /path/to/comp/root
ScriptAlias /cgi-bin/ /path/to/cgi-bin/
<LocationMatch "\.html$">
  Action html-mason /cgi-bin/mason_handler.cgi
  AddHandler html-mason .html
</LocationMatch>
 <LocationMatch "^/cgi-bin/">
     RemoveHandler .html
 </LocationMatch>
<FilesMatch "(autohandler|dhandler)$">
    Order allow,deny
    Deny from all
</FilesMatch>

Linux用户

wget http://cpan.linuxforum.net/authors/id/D/DR/DROLSKY/HTML-Mason-1.35.tar.gz
tar HTML-Mason-1.35.tar.gz
cd HTML-Mason-1.35
#perl Build.PL
#./Build
#./Build instal

CGI and Mason Example Programs - http://mnementh.csi.cam.ac.uk/mason-course-examples/

Related Links

MasonPoweredSites

http://www.masonhq.com/?MasonPoweredSites

MasonPoweredApps

分享您的观点
个人工具
名字空间

变换
操作
导航
工具箱