README.md
1# NAME
2
3HTML::Mason - High-performance, dynamic web site authoring system
4
5# VERSION
6
7version 1.59
8
9# SYNOPSIS
10
11 PerlModule HTML::Mason::ApacheHandler
12
13 <Location />
14 SetHandler perl-script
15 PerlHandler HTML::Mason::ApacheHandler
16 </Location>
17
18# DESCRIPTION
19
20Mason is a tool for building, serving and managing large web
21sites. Its features make it an ideal backend for high load sites
22serving dynamic content, such as online newspapers or database driven
23e-commerce sites.
24
25Actually, Mason can be used to generate any sort of text, whether for
26a web site or not. But it was originally built for web sites and
27since that's why most people are interested in it, that is the focus
28of this documentation.
29
30Mason's various pieces revolve around the notion of "components''. A
31component is a mix of HTML, Perl, and special Mason commands, one
32component per file. So-called "top-level" components represent entire
33web-pages, while smaller components typically return HTML snippets for
34embedding in top-level components. This object-like architecture
35greatly simplifies site maintenance: change a shared component, and
36you instantly changed all dependent pages that refer to it across a
37site (or across many virtual sites).
38
39Mason's component syntax lets designers separate a web page into
40programmatic and design elements. This means the esoteric Perl bits
41can be hidden near the bottom of a component, preloading simple
42variables for use above in the HTML. In our own experience, this frees
43content managers (i.e., non-programmers) to work on the layout without
44getting mired in programming details. Techies, however, still enjoy
45the full power of Perl.
46
47Mason works by intercepting innocent-looking requests (say,
48http://www.yoursite.com/index.html) and mapping them to requests for
49Mason components. Mason then compiles the component, runs it, and
50feeds the output back to the client.
51
52Consider this simple Mason component:
53
54 % my $noun = 'World';
55 Hello <% $noun %>!
56 How are ya?
57
58The output of this component is:
59
60 Hello World!
61 How are ya?
62
63In this component you see a mix of standard HTML and Mason
64elements. The bare '%' prefixing the first line tells Mason that this
65is a line of Perl code. One line below, the embedded <% ... %> tag gets replaced with the return value of its contents,
66evaluated as a Perl expression.
67
68Beyond this trivial example, components can also embed serious chunks
69of Perl code (say, to pull records from a database). They can also
70call other components, cache results for later reuse, and perform all
71the tricks you expect from a regular Perl program.
72
73# MAINTENANCE HELP NEEDED
74
75I (Dave Rolsky) am no longer using HTML::Mason and I would love to find some
76co-maintainers to help. Specifically, I'd like people to review issues and
77PRs, create new PRs, and ultimately take on the task of uploading new releases
78to CPAN. If you're interested the best way to start is to fix one or more of
79the issues in the [issue
80tracker](https://github.com/houseabsolute/HTML-Mason/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc).
81
82# WAIT - HAVE YOU SEEN MASON 2?
83
84Version 1 of Mason (this distribution) -- has been around since 1998, is in
85wide use, and is very stable. However it has not changed much in years and
86is no longer actively developed.
87
88Version 2 of Mason -- [Mason](https://metacpan.org/pod/Mason) -- was released in February of 2011. It offers
89a new syntax as well as a number of other features. See
90[https://metacpan.org/pod/distribution/Mason/lib/Mason/Manual/UpgradingFromMason1.pod](https://metacpan.org/pod/distribution/Mason/lib/Mason/Manual/UpgradingFromMason1.pod)
91for details of the differences between the two.
92
93# INSTALLATION
94
95Mason has been tested under Linux, FreeBSD, Solaris, HPUX, and
96Win32. As an all-Perl solution, it should work on any machine that has
97working versions of Perl 5.00503+, mod\_perl, and the required CPAN
98modules.
99
100Mason has a standard MakeMaker-driven installation. See the README
101file for details.
102
103# CONFIGURING MASON
104
105This section assumes that you are able to install and configure a
106mod\_perl server. Relevant documentation is available at
107http://www.apache.org (Apache) and http://perl.apache.org
108(mod\_perl). The mod\_perl mailing list, archive, and guide are also
109great resources.
110
111The simplest configuration of Mason requires a few lines in your
112httpd.conf:
113
114 PerlModule HTML::Mason::ApacheHandler
115
116 <Location />
117 SetHandler perl-script
118 PerlHandler HTML::Mason::ApacheHandler
119 </Location>
120
121The PerlModule directive simply ensures that the Mason code is loaded
122in the parent process before forking, which can save some memory when
123running mod\_perl.
124
125The <Location> section routes all requests to the Mason handler, which
126is a simple way to try out Mason. A more refined setup is discussed
127in the [Controlling Access via Filename Extension](https://metacpan.org/pod/HTML%3A%3AMason%3A%3AAdmin#Controlling-Access-via-Filename-Extension) section of the administrator's manual.
128
129Once you have added the configuration directives, restart the
130server. First, go to a standard URL on your site to make sure you
131haven't broken anything. If all goes well you should see the same page
132as before. If not, recheck your Apache config files and also tail your
133server's error log.
134
135If you are getting "404 Not Found" errors even when the files clearly
136exist, Mason may be having trouble with your document root. One
137situation that will unfortunately confuse Mason is if your document
138root goes through a symbolic link. Try expressing your document root
139in terms of the true filesystem path.
140
141Next, try adding the tag <% 2+2 %> at the top of some HTML file. If you
142reload this page and see a "4", Mason is working!
143
144# DOCUMENTATION ROADMAP
145
146Once Mason is on its feet, the next step is to write a component or
147two. The [Mason Developer's Manual](https://metacpan.org/pod/HTML%3A%3AMason%3A%3ADevel) is a
148complete tutorial for writing, using, and debugging components. A
149reference companion to the Developer's Manual is the Request API
150documentation, [HTML::Mason::Request](https://metacpan.org/pod/HTML%3A%3AMason%3A%3ARequest).
151
152Whoever is responsible for setting up and tuning Mason should read the
153[Administrator's Manual](https://metacpan.org/pod/HTML%3A%3AMason%3A%3AAdmin), though developers
154will also benefit from reading it as well. This document covers more
155advanced configuration scenarios and performance optimization. The
156reference companion to the Administrator's manual is the
157[Parameters Reference](https://metacpan.org/pod/HTML%3A%3AMason%3A%3AParams), which describes all the
158parameters you can use to configure Mason.
159
160Most of this documentation assumes that you're running Mason on top of
161mod\_perl, since that is the most common configuration. If you would
162like to run Mason via a CGI script, refer to the
163[HTML::Mason::CGIHandler](https://metacpan.org/pod/HTML%3A%3AMason%3A%3ACGIHandler) documentation.
164If you are using Mason from a standalone program, refer to
165the [Using Mason from a Standalone Script](https://metacpan.org/pod/HTML%3A%3AMason%3A%3AAdmin#Using-Mason-from-a-Standalone-Script) section of the administrator's manual.
166
167There is also a book about Mason, _Embedding Perl in HTML with
168Mason_, by Dave Rolsky and Ken Williams, published by O'Reilly and
169Associates. The book's website is at http://www.masonbook.com/. This
170book goes into detail on a number of topics, and includes a chapter of
171recipes as well as a sample Mason-based website.
172
173# GETTING HELP AND SOURCES
174
175Questions and feedback are welcome, and should be directed to the Mason
176mailing list. You must be subscribed to post.
177
178 https://lists.sourceforge.net/lists/listinfo/mason-users
179
180You can also visit us at `#mason` on [irc://irc.perl.org/#mason](irc://irc.perl.org/#mason).
181
182Bugs and feature requests will be tracked at RT:
183
184 http://rt.cpan.org/NoAuth/Bugs.html?Dist=HTML-Mason
185 bug-html-mason@rt.cpan.org
186
187# SUPPORT
188
189Bugs may be submitted at [https://github.com/houseabsolute/HTML-Mason/issues](https://github.com/houseabsolute/HTML-Mason/issues).
190
191I am also usually active on IRC as 'autarch' on `irc://irc.perl.org`.
192
193# SOURCE
194
195The source code repository for HTML-Mason can be found at [https://github.com/houseabsolute/HTML-Mason](https://github.com/houseabsolute/HTML-Mason).
196
197# AUTHORS
198
199- Jonathan Swartz <swartz@pobox.com>
200- Dave Rolsky <autarch@urth.org>
201- Ken Williams <ken@mathforum.org>
202
203# CONTRIBUTORS
204
205- Ævar Arnfjörð Bjarmason <avarab@gmail.com>
206- Alex Balhatchet <kaoru@slackwise.net>
207- Alex Vandiver <alex@chmrr.net>
208- Florian Schlichting <fsfs@debian.org>
209- John Williams <jwilliams@cpan.org>
210- Kent Fredric <kentnl@gentoo.org>
211- Kevin Falcone <falcone@bestpractical.com>
212- Patrick Kane <modus-cpan@pr.es.to>
213- Ricardo Signes <rjbs@cpan.org>
214- Shlomi Fish <shlomif@shlomifish.org>
215
216# COPYRIGHT AND LICENSE
217
218This software is copyright (c) 1998 - 2020 by Jonathan Swartz.
219
220This is free software; you can redistribute it and/or modify it under
221the same terms as the Perl 5 programming language system itself.
222
223The full text of the license can be found in the
224`LICENSE` file included with this distribution.
225