Para::Frame::Page - Represents the response page for a req
Represents a page on a site with a specific URL.
Inherits from Para::Frame::File
This is the superclass of <Para::Frame::Site::Page>.
During lookup or generation of the page, the URL of the page can change. We differ between the original requested URL, the resulting URL and an URL for the template used.
A Para::Frame::Request will create a Para::Frame::Page object representing the response page.
A request can also create other Page objects for representing other pages for getting information about them or for generating pages for later use, maby not specificly copupled to the current request or session.
The distinction between Para::Frame::Request and Para::Frame::Page are still a litle bit vauge. We should separate more clearly between the requested URL and the URL used for the response and the template used for the response.
Methods for generating the response page and accessing info about that page has been collected here.
A Site can answer under many hosts. The host of a Page vary with the request. The language given by the request is used also for actions and not just for the response page.
Each Request has one
response Page object. It may first be a normal
template and then change to generate an error page if action or
template throw an exception. But it is still the same object.
I may change that so that a new Page object is created if there was a redirection to a new page.
Para::Frame::Page->new( \%args )
Creates a Page object.
See Para::Frame::File/Accessors
True if this is a /index.tt
$p->template()
Returns the (current) Template::Document object for this page, as returned by /find_template given /url_path_tmpl.
The document object can be used for getting variables set in the
META
part of the template, via Template::Document/AUTOLOAD.
Example:
If the template contains [% META section="games" %] you can get that value by saying:
my $section = $p->template->section;
section
has no special meaning in paraframe. ... You can also get
the specially used variables like next_action
, et al.
Returns: The Template::Document object
$p->title()
Returns the /template otitle
or title or in the last case
just the Para::Frame::File/name.
$p->is_page()
Returns: true
$p->renderer
Returns: the renderer to be used, if not the standard renderer
$p->add_params( \%params )
$p->add_params( \%params, $keep_old_flag )
Adds template params. This can be variabls, objects, functions.
If $keep_old_flag
is true, we will not replace existing params with
the same name.
$page->precompile( \%args )
Send same args as for /new for creating the new page from thre
source $page
. Also takes:
arg type defaults to html_pre arg language defaults to undef
Returns: The new compiled page
$p->paths( $burner )
Automaticly called by Template::Provider to get the include paths for building pages from templates.
Returns: /incpath
$p->set_renderer( \&renderer )
Sets the code to run for rendering the page, if not the standard renderer.
Example renderer:
my $render_hello = sub { my( $req ) = @_; my $p = $req->page; $p->ctype("text/html"); my $out = "<h1>Hello world!</h1>"; $p->set_content(\$out); return 1; }; $p->set_renderer($render_hello);
Returns: /renderer
$p->set_content( \$content )
Sets the page to be returned to the client.
If you want an action to returns a special type of page, it should use /set_renderer since that renderer is called after all actions been sorted out.
But you could set the response page directly in the action by calling this method.
Returns: The reference to the content, stored in the page object.
The standard functions availible in templates. This is called before the page is rendered. You should not call it by yourself.
req
object.
$p->burner
Returns: the Para::Frame::Burner selected for this page
$p->set_burner_by_type( $type )
Calls Para::Frame::Burner/get_by_type and store it in the page object.
Returns: the burner
$p->set_burner_by_ext( $ext )
Calls Para::Frame::Burner/get_by_ext and store it in the page object.
Returns: the burner
$p->burn( $in, $out );
Calls Para::Frame::Burner/burn with ($in, $params, $out)
there
$params
are set by /set_tt_params.
Returns: the burner
returns ($doc, $ext) where $doc is a L<Template::Document> objetct that can be parsed to a L<Para::Frame::Burner> object.
$p->get_static( $in, $pageref )
$pageref
must be a scalar ref.
$in
must be a IO::File or a filename to be sent to
IO::File/new.
Places the content of the file in $pageref
.
Returns: $pageref
$p->render_output()
Burns the page and stores the result.
If the rendering failes, may change the template and URL. The new URL can be used for another call to this method.
This method is called by Para::Frame::Request/after_jobs.
Returns: True on success and 0 on failure
$p->set_dirsteps()
$p->set_dirsteps( $path_full )
path_full defaults to the current template dir. It must end with a /. It is a filesystem path. Not the URL path
Returns: /dirsteps
$p->dirsteps
Returns: the current dirsteps as a ref to a list of strings.
$p->set_incpath( \@incpath )
Internally used by /incpath.
The param should be a ref to an array of absolute paths (from the system root) to dirs with template include files.
Places the Para::Frame::Burner should look for templates to include.
Returns: /incpath
$p->incpath()
Internally used by /paths, that sets up the incpath. Use /paths instead of this method.
Returns: A ref to an array of absolute paths (from the system root) to dirs with template include files.
use .dir.url_path instead
use .dir.url_path_slash instead
use .parent.url_path instead
use .parent.url_path_slash instead
use .dir.sys_path instead