Para::Frame::Site - Represents a particular website
A Paraframe server can serv many websites. (And a apache server can use any number of paraframe servers.)
One website can have several diffrent host names, like www.name1.org, www.name2.org.
The mapping of URL to file is done by Apache. Apache also give a canonical name of the webserver.
Background jobs may not be coupled to a specific site.
Information about each specific site is looked up by /get using /host as param.
Para::Frame::Site->add( \%params )
Adds a site with the given params. Should be called before startup. The params are stored as the properties of the object, to be used later.
Special params are:
webhost
= See /host
aliases
= a listref of site aliases
name
= See /name
code
= See /code
home
= See /home
home_url_path
= See /home_url_path
last_step
= See /last_step
login_page
= See /login_page
logout_page
= See /logout_page
loopback
= See /loopback
backup_host
= See /backup_host
appbase
= See /appbase
appfmly
= See /appfmly
approot
= See /approot
appback
= See /appback
params
= See /params
languages
= See /languages
htmlsrc
= See /htmlsrc
is_compiled
= See /is_compiled
send_email
= See /send_email
email
= See /email
email_domains
= See /email_domains
The site is registred under the /host, /code and all given
aliases
.
The first site registred under a given /host is the default site used for requests under that domain.
The first site registred will be the default
site, used for
background jobs when no other site are specified.
$site->clone( $hostname ) $site->clone( \%params )
Adds a site based on $site
, but for a new host.
Returns: the new site
Para::Frame::Site->get( $name )
Returns the site registred (by /add) under the given $name
.
If $name is a site object, retuns it.
Returns: A Para::Frame::Site object
Exceptions: Croaks if site nor found
Para::Frame::Site->get_by_url( $url )
Returns the site registred (by /add) under the given $url
.
Handles multiple site under the same host.
Returns: A Para::Frame::Site object
Exceptions: Croaks if site nor found
TODO: Handle other ports
Para::Frame::Site->get_by_req( $req )
Gets the site matching the req
If a site match is not found, and Para::Frame/site_auto is set,
creating a new site for the host. It will use the first match of a)
the host without the port part, b) Para::Frame/site_auto and c)
default
.
Returns: A Para::Frame::Site object
Para::Frame::Site->get_default()
Get the default site
$site->name
Returns the name
of the site.
Default to /host.
$site->desig
Returns the name
of the site.
Default to /host.
$site->code
Returns the code
of the site.
Defaults to /host.
$site->uri2file( $uri ) $site->uri2file( $uri, $file ) $site->uri2file( $uri, $file, $may_not_exist )
Same as Para::Frame::Request/uri2file, but looks up the file for the current site.
We will use the current request or create a new request if the sites doesn't match.
$site->home
Returns the Para::Frame::Dir object for the /home.
$site->home_url_path
Returns the home dir of the site as URL path, excluding the last '/'.
Should be an URL path.
TODO: rework PerlSetVar home config
This can be overridden by setting home
in dirconfig; Example
from .htaccess:
PerlSetVar home /~myuser
Important Do not end home with a /
$site->last_step
Returns the last_step
to be used if no mere steps are found in the
route. Used by Para::Frame::Route.
Should be an URL path.
Defaults to undef
.
$site->loadpage
Returns the loadpage
to be used while generatiung the result for
pages that takes more than a couple of seconds to prepare. This should
be a html page set up in the same way as the default.
Should be an URL path.
Defaults to $home/pf/loading.html
.
$site->login_page
Returns the login_page
to be used. That is, the page to go to AFTER
login.
Should be an URL path.
Defaults to /last_step if defined.
Otherwise, defaults to /home_url_path + slash.
$site->logout_page
Returns the logout_page
to be used.
Should be an URL path.
Defaults to /home + slash.
$site->host
Returns: the webhost
as a plain string
This shold be the canonical name of the host of the site. This is the main hostname of the apache virtual host. If the port is anything else than 80, the port is apended. This string does not contain 'http://'. This is the value returned by Para::Frame::Request/host.
Para::Frame::Request/http_host gives the name used in the request, and may differ from the main hostname of the site.
Example: frame.para.se
or frame.para.se:81
Defaults to the fully qualified domain name as returned by Para::Frame::Utils/fqdn.
$site->webhost
Same as /host
$site->scheme
Returns the scheme part of the URLs under this site. It's probably either http or https.
Use this in the Para::Frame::URI constructor.
$site->loopback
Returns the loopback
path to use then Para::Frame connects to
itself via Apache (for getting info from mod_perl). This should be a
lightweight page.
Should be an URL path.
Defaults to /home.
$site->backup_host
Returns the backup_host
used by
Para::Frame::Request/fallback_error_page for redirecting the user
to a backup website in cases then the site is severily broken.
$site->host_without_port
Returns the /host without the port part.
$site->howt_with_port
Returns the /host with the port part. For example
frame.para.se:80
.
$site->port
Returns the port of the /host.
$site->appbase
Returns the appbase
of the site.
This should be a prefix for Perl modules. If appbase is set to
MyProj
, the actions would have the prefix MyProj::Action::
and
be placed in lib/MyProj/Action/
.
Defaults to Para::Frame/CFG appbase
.
$site->appfmly
Returns the appfmly
for the site.
This should be a listref of elements, each to be treated ass fallbacks
for /appbase. If no actions are found under /appbase one after
one of the elements in appfmly
are tried.
Defaults to Para::Frame/CFG appfmly
.
$site->appbases
Returns a list consisting of /appbase, /appfmly and
Para::Frame
. (Not a listref)
$site->approot
Returns the path to application. This is the dir that holds the lib
and possibly the var
dirs.
Defaults to Para::Frame/CFG approot
.
$site->appback
Returns the appback
of the site.
This is a listref of server paths. Each path should bee a dir that
holds a html
dir, or a dev
dir, for compiled sites.
These dirs can hold inc
and def
dirs that will be used in
template searches.
See Para::Frame::Request/find_template and Para::Frame::Burner/paths.
Defaults to Para::Frame/CFG appback
.
$site->send_email
Returns send_email
of the site. True or false.
$site->email
Returns email
of the site. May be undef. This is the default mail
for sending or recieving.
$site->email_domains
Returns a list of domains used by the send_mail
action for
determing which domains we can send emails to from web forms. This is
for providing using the form from sending spam.
Defaults to a ref to an empty list. The send_mail action will accept reciepientson the same domain as the server.
$site->backup_redirect
Returns the backup_redirect
$site->params
The TT params to be added for each request in this site.
$site->dir( $url )
Returns a Rit::Frame::Dir object.
TODO: What is this used for?!
$site->languages
Returns a listref of languages this site supports.
Each element should be the language code as a two letter string.
Defaults to Para::Frame/CFG languages
.
$site->support_language( $langcode )
Returns true if given code is one of the supported
$site->equals( $site2 )
Returns true if $site
and $site2
is the same object.
$site->css
Returns a Para::Frame::CSS object for the site.