Apache2-SSI

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

        which means a human readable format such as "2.5M" for 2.5
        megabytes. Other possible value is "bytes" which would have the
        "fsize" ssi directive return the size in bytes.

        See Apache2 documentation
        <https://httpd.apache.org/docs/current/en/howto/ssi.html> for more
        information on this.

    *timefmt*
        The default way to format a date time. By default, this uses the
        display according to your locale, such as "ja_JP" (for Japan) or
        "en_GB" for the United Kingdoms. The time zone can be specified in
        the format, or it will be set to the local time zone, whatever it
        is.

        See Apache2 documentation
        <https://httpd.apache.org/docs/current/en/howto/ssi.html> for more
        information on this.

    *trunk*
        This takes a boolean value such as 0 or 1 and when enabled this

README  view on Meta::CPAN

    For example:

        Query string passed: <!--#echo var="QUERY_STRING" -->

    There are a number of standard environment variable accessible under SSI
    on top of other environment variables set. See "SSI Directives" section
    below.

  parse_echo_date_gmt
    Returns the current date with time zone set to gmt and based on the
    provided format or the format available for the current locale such as
    "ja_JP" or "en_GB".

  parse_echo_date_local
    Returns the current date with time zone set to the local time zone
    whatever that may be and on the provided format or the format available
    for the current locale such as "ja_JP" or "en_GB".

    Example:

        <!--#echo var="DATE_LOCAL" -->

  parse_echo_document_name
    Returns the document name. Under Apache, this returns the environment
    variable "DOCUMENT_NAME", if set, or the base name of the value returned
    by "filename" in Apache2::RequestRec

README  view on Meta::CPAN


    The document uri would include, if any, any path info and query string.

  parse_echo_last_modified
    This returns document last modified date. Under Apache, there is a
    standard environment variable called "LAST_MODIFIED" (see the section on
    "SSI Directives"), and if somehow absent, it will return instead the
    formatted last modification datetime for the file returned with
    "filename" in Apache2::RequestRec. The formatting of that date follows
    whatever format provided with "timefmt" or by default the datetime
    format for the current locale (e.g. "ja_JP").

    Outside of Apache, the similar result is achieved by returning the value
    of the environment variable "LAST_MODIFIED" if available, or the
    formatted datetime of the document uri as set with "document_uri"

    Example:

        <!--#echo var="LAST_MODIFIED" -->

  parse_eval_expr

README.md  view on Meta::CPAN

    megabytes. Other possible value is `bytes` which would have the
    `fsize` ssi directive return the size in bytes.

    See [Apache2
    documentation](https://httpd.apache.org/docs/current/en/howto/ssi.html){.perl-module}
    for more information on this.

*timefmt*

:   The default way to format a date time. By default, this uses the
    display according to your locale, such as `ja_JP` (for Japan) or
    `en_GB` for the United Kingdoms. The time zone can be specified in
    the format, or it will be set to the local time zone, whatever it
    is.

    See [Apache2
    documentation](https://httpd.apache.org/docs/current/en/howto/ssi.html){.perl-module}
    for more information on this.

*trunk*

README.md  view on Meta::CPAN

        Query string passed: <!--#echo var="QUERY_STRING" -->

There are a number of standard environment variable accessible under SSI
on top of other environment variables set. See [\"SSI
Directives\"](#ssi-directives){.perl-module} section below.

parse\_echo\_date\_gmt
----------------------

Returns the current date with time zone set to gmt and based on the
provided format or the format available for the current locale such as
`ja_JP` or `en_GB`.

parse\_echo\_date\_local
------------------------

Returns the current date with time zone set to the local time zone
whatever that may be and on the provided format or the format available
for the current locale such as `ja_JP` or `en_GB`.

Example:

        <!--#echo var="DATE_LOCAL" -->

parse\_echo\_document\_name
---------------------------

Returns the document name. Under Apache, this returns the environment
variable `DOCUMENT_NAME`, if set, or the base name of the value returned

README.md  view on Meta::CPAN

---------------------------

This returns document last modified date. Under Apache, there is a
standard environment variable called `LAST_MODIFIED` (see the section on
[\"SSI Directives\"](#ssi-directives){.perl-module}), and if somehow
absent, it will return instead the formatted last modification datetime
for the file returned with [\"filename\" in
Apache2::RequestRec](https://metacpan.org/pod/Apache2::RequestRec#filename){.perl-module}.
The formatting of that date follows whatever format provided with
[\"timefmt\"](#timefmt){.perl-module} or by default the datetime format
for the current locale (e.g. `ja_JP`).

Outside of Apache, the similar result is achieved by returning the value
of the environment variable `LAST_MODIFIED` if available, or the
formatted datetime of the document uri as set with
[\"document\_uri\"](#document_uri){.perl-module}

Example:

        <!--#echo var="LAST_MODIFIED" -->

lib/Apache2/SSI.pm  view on Meta::CPAN

    # and make them available for the next evaluation
    $self->{_regexp_capture}= [];
    $self->{_uri_reset}     = 0;
    # A stack reflecting the current state of if/else parser.
    # Each entry is 1 when we've seen a true condition in this if-chain,
    # 0 when we haven't. Initially it's as if we're in a big true 
    # if-block with no else.
    $self->{if_state}       = [1];
    $self->{notes}          = '';
    $self->{suspend}        = [0];
    # undef means the current locale's default
    $self->mod_perl( defined( $MOD_PERL ) ? length( $MOD_PERL ) > 0 : 0 );
    my $r = $self->apache_request;
    if( $MOD_PERL && !$r )
    {
        # NOTE: Must check if GlobalRequest is set
        if( !( $r = $self->apache_request ) )
        {
            $r = Apache2::RequestUtil->request;
            if( $r )
            {

lib/Apache2/SSI.pm  view on Meta::CPAN

sub uri { return( shift->_set_get_object( 'uri', 'Apache2::SSI::URI', @_ ) ); }

sub _format_time
{
    my( $self, $time, $format, $tzone ) = @_;
    my $env = $self->env;
    $format ||= $self->{timefmt};
    # Quotes are important as they are used to stringify overloaded $time
    my $params = { epoch => "$time" };
    $params->{time_zone} = ( $tzone || 'local' );
    $params->{locale} = $env->{lang} if( length( $env->{lang} ) );
    require DateTime;
    require DateTime::Format::Strptime;
    my $tz;
    # DateTime::TimeZone::Local will die ungracefully if the local timezeon is not set with the error:
    # "Cannot determine local time zone"
    local $@;
    # try-catch
    eval
    {
        require DateTime::TimeZone;

lib/Apache2/SSI.pm  view on Meta::CPAN

    
    # try-catch
    my $rv = eval
    {
        my $dt = DateTime->from_epoch( %$params );
        if( length( $format ) )
        {
            my $fmt = DateTime::Format::Strptime->new(
                pattern => $format,
                time_zone => ( $params->{time_zone} || $tz ),
                locale => $dt->locale->code,
            );
            $dt->set_formatter( $fmt );
            return( $dt );
        }
        else
        {
            return( $dt->format_cldr( $dt->locale->date_format_full ) );
        }
    };
    if( $@ )
    {
        $self->error( "An error occurred getting a DateTime object for time \"$time\" with format \"$format\": $@" );
        return( $self->errmsg );
    }
    return( $rv );
}

lib/Apache2/SSI.pm  view on Meta::CPAN

    <!--#endif -->

=item C<sizefmt>

The default way to format a file size. By default, this is C<abbrev>, which means a human readable format such as C<2.5M> for 2.5 megabytes. Other possible value is C<bytes> which would have the C<fsize> ssi directive return the size in bytes.

See L<Apache2 documentation|https://httpd.apache.org/docs/current/en/howto/ssi.html> for more information on this.

=item C<timefmt>

The default way to format a date time. By default, this uses the display according to your locale, such as C<ja_JP> (for Japan) or C<en_GB> for the United Kingdom. The time zone can be specified in the format, or it will be set to the local time zone...

See L<Apache2 documentation|https://httpd.apache.org/docs/current/en/howto/ssi.html> for more information on this.

=item C<trunk>

This takes a boolean value such as C<0> or C<1> and when enabled this allows the support for Apache2 experimental expressions.

See L<Regexp::Common::Apache2> for more information.

Also, see the property C<legacy> to enable legacy Apache2 expressions.

lib/Apache2/SSI.pm  view on Meta::CPAN

For example:

    Query string passed: <!--#echo var="QUERY_STRING" -->

There are a number of standard environment variable accessible under SSI on top of other environment variables set. See L<SSI Directives> section below.

=for Pod::Coverage parse_echo_query_string

=head2 parse_echo_date_gmt

Returns the current date with time zone set to gmt and based on the provided format or the format available for the current locale such as C<ja_JP> or C<en_GB>.

=head2 parse_echo_date_local

Returns the current date with time zone set to the local time zone whatever that may be and on the provided format or the format available for the current locale such as C<ja_JP> or C<en_GB>.

Example:

    <!--#echo var="DATE_LOCAL" -->

=head2 parse_echo_document_name

Returns the document name. Under Apache, this returns the environment variable C<DOCUMENT_NAME>, if set, or the base name of the value returned by L<Apache2::RequestRec/filename>

Outside of Apache, this returns the environment variable C<DOCUMENT_NAME>, if set, or the base name of the value for L</document_uri>

lib/Apache2/SSI.pm  view on Meta::CPAN

Returns the value of L</document_uri>

Example:

    <!--#echo var="DOCUMENT_URI" -->

The document uri would include, if any, any path info and query string.

=head2 parse_echo_last_modified

This returns document last modified date. Under Apache, there is a standard environment variable called C<LAST_MODIFIED> (see the section on L</SSI Directives>), and if somehow absent, it will return instead the formatted last modification datetime f...

Outside of Apache, the similar result is achieved by returning the value of the environment variable C<LAST_MODIFIED> if available, or the formatted datetime of the document uri as set with L</document_uri>

Example:

    <!--#echo var="LAST_MODIFIED" -->

=for Pod::Coverage parse_expr_args

=head2 parse_eval_expr

t/37.flastmod.t  view on Meta::CPAN

    my $dt = DateTime->now( time_zone => 'local' );
    $year = $dt->year;
    my $inc = "./t/htdocs${BASE_URI}/include.01.txt";
    ## diag( "File $inc last modified time is ", $inc->stat->mtime, " (", scalar( localtime( $inc->stat->mtime ) ), ")." );
    $inc_ts = DateTime->from_epoch( epoch => (CORE::stat( $inc ))[9], time_zone => 'local' );
    my $params =
    {
        pattern => '%A %B %d, %Y',
        time_zone => 'local',
    };
    $params->{locale} = $ENV{lang} if( length( $ENV{lang} ) );
    my $fmt = DateTime::Format::Strptime->new( %$params );
    $inc_ts->set_formatter( $fmt );
    my $me = "./t/htdocs${BASE_URI}/07.03.flastmod.html";
    $me_ts = DateTime->from_epoch( epoch => (CORE::stat( $me ))[9], time_zone => 'local' );
    my $fmt2 = DateTime::Format::Strptime->new(
        pattern => '%D',
        time_zone => 'local',
        locale => 'en_US',
    );
    $me_ts->set_formatter( $fmt2 );
    diag( __FILE__, " last modification date time is '$me_ts'." ) if( $DEBUG );
};
if( $@ )
{
    BAIL_OUT( $@ );
}

my $tests =



( run in 1.017 second using v1.01-cache-2.11-cpan-ceb78f64989 )