Apache2-SSI

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

            $ssi->throw;
        };
        print( $result );

    Inside Apache, in the VirtualHost configuration, for example:

        PerlModule Apache2::SSI
        PerlOptions +GlobalRequest
        PerlSetupEnv On
        <Directory "/home/joe/www">
            Options All +Includes +ExecCGI -Indexes -MultiViews
            AllowOverride All
            SetHandler modperl
            # You can choose to set this as a response handler or a output filter, whichever works.
            # PerlResponseHandler Apache2::SSI
            PerlOutputFilterHandler Apache2::SSI
            # If you do not set this to On, path info will not work, example:
            # /path/to/file.html/path/info
            # See: <https://httpd.apache.org/docs/current/en/mod/core.html#acceptpathinfo>
            AcceptPathInfo On
            # To enable no-caching (see no_cache() in Apache2::RequestUtil:
            PerlSetVar Apache2_SSI_NO_CACHE On
            # This is required for exec cgi to work:
            # <https://httpd.apache.org/docs/current/en/mod/mod_include.html#element.exec>
            <Files ~ "\.pl$">
                SetHandler perl-script
                AcceptPathInfo On
                PerlResponseHandler ModPerl::PerlRun
                ## Even better for stable cgi scripts:
                ## PerlResponseHandler ModPerl::Registry
                ## Change this in mod_perl1 PerlSendHeader On to the following:
                ## <https://perl.apache.org/docs/2.0/user/porting/compat.html#C_PerlSendHeader_>
                PerlOptions +ParseHeaders
            </Files>
            <Files ~ "\.cgi$">
                SetHandler cgi-script
                AcceptPathInfo On
            </Files>
            # To enable debugging output in the Apache error log
            # PerlSetVar Apache2_SSI_DEBUG 3
            # To set the default echo message
            # PerlSetVar Apache2_SSI_Echomsg 
            # To Set the default error message
            # PerlSetVar Apache2_SSI_Errmsg "Oops, something went wrong"
            # To Set the default size format: bytes or abbrev
            # PerlSetVar Apache2_SSI_Sizefmt "bytes"
            # To Set the default date time format
            # PerlSetVar Apache2_SSI_Timefmt ""
            # To enable legacy mode:
            # PerlSetVar Apache2_SSI_Expression "legacy"
            # To enable trunk mode:
            # PerlSetVar Apache2_SSI_Expression "trunk"
        </Directory>

VERSION
        v0.2.0

DESCRIPTION
    Apache2::SSI implements Apache Server Side Include
    <https://httpd.apache.org/docs/current/en/howto/ssi.html>, a.k.a. SSI,
    within and outside of Apache2/mod_perl2 framework.

    Apache2::SSI is inspired from the original work of Apache::SSI with the
    main difference that Apache2::SSI works well when called from within
    Apache mod_perl2 as well as when called outside of Apache if you want to
    simulate SSI <https://httpd.apache.org/docs/current/en/howto/ssi.html>.

    Apache2::SSI also implements all of Apache SSI features, including
    functions, encoding and decoding and old style variables such as
    "${QUERY_STRING}" as well as modern style such as "v('QUERY_STRING')"
    and variants such as "%{REQUEST_URI}".

    See below details in this documentation and in the section on "SSI
    Directives"

    Under Apache mod_perl, you would implement it like this in your
    "apache2.conf" or "httpd.conf"

        <Files *.phtml>
            SetHandler modperl
            PerlOutputFilterHandler Apache2::SSI
        </Files>

    This would enable Apache2::SSI for files whose extension is ".phtml".
    You can also limit this by location, such as:

        <Location /some/web/path>
            <Files *.html>
                SetHandler modperl
                PerlOutputFilterHandler Apache2::SSI
            </Files>
        </Location>

    In the example above, we enable it in files with extensions ".phtml",
    but you can, of course, enable it for all html by setting extension
    ".html" or whatever extension you use for your html files.

    As pointed out by Ken Williams, the original author of Apache::SSI, the
    benefit for using Apache2::SSI is:

    1. You want to subclass Apache2::SSI and have granular control on how to
    render ssi
    2. You want to "parse the output of other mod_perl handlers, or send the
    SSI output through another handler"
    3. You want to imitate SSI without activating them or without using
    Apache (such as in command line) or within your perl/cgi script

  INSTALLATION
        perl Makefile.PL
        make
        make test
        sudo make install

    This will detect if you have Apache installed and run the Apache
    mod_perl2 tests by starting a separate instance of Apache on a
    non-standard port like 8123 under your username just for the purpose of
    testing. This is all handled automatically by Apache::Test

    If you do not have Apache or mod_perl installed, it will still install,
    but obviously not start an instance of Apache/mod_perl, nor perform any
    of the Apache mod_perl tests.

README  view on Meta::CPAN

  parse_func_osenv
    Lookup operating system environment variable

        <!--#if expr="env('LANG') =~ /en(_(GB|US))/" -->
        Showing English language
        <!--#endif -->

  parse_func_replace
    replace(string, "from", "to") replaces all occurrences of "from" in the
    string with "to".

    Example:

        <!--#if expr="replace( 'John is in Tokyo', 'John', 'Jack' ) == 'Jack is in Tokyo'" -->
        This worked!
        <!--#else -->
        Nope, it failed.
        <!--#endif -->

  parse_func_req
    See "parse_func_http"

  parse_func_reqenv
    Lookup request environment variable (as a shortcut, v can also be used
    to access variables).

    This is only different from "parse_func_env" under Apache.

    See "parse_func_env"

    Example:

        <!--#if expr="reqenv('ProcessId') == '$$'" -->
        This worked!
        <!--#else -->
        Nope, it failed.
        <!--#endif -->

    Or using the Apache SSI "v" shortcut:

        <!--#if expr="v('ProcessId') == '$$'" -->

  parse_func_req_novary
    Same as "parse_func_req", but header names will not be added to the Vary
    header.

  parse_func_resp
    Get HTTP response header.

    Example:

        <!--#if expr="resp('X-ProcessId') == '$$'" -->
        This worked!
        <!--#else -->
        Nope, it failed.
        <!--#endif -->

    An important note here:

    First, there is obviously no response header available for perl scripts
    running outside of Apache2/mod_perl2 framework.

    If the script runs under mod_perl, not all response header will be
    available depending on whether you are using Apache2::SSI in your Apache
    configuration as an output filter handler ("PerlOutputFilterHandler") or
    a response handler ("PerlResponseHandler").

    If it is running as an output filter handler, then some headers, such as
    "Content-Type" will not be available, unless they have been set by a
    script in a previous phase. Only basic headers will be available. For
    more information, check the Apache/mod_perl2 documentation on each
    phase.

  parse_func_sha1
    Hash the string using SHA1, then encode the hash with hexadecimal
    encoding.

    Example:

        <!--#if expr="sha1('Tous les êtres humains naissent libres et égaux en dignité et en droits.') == '8c244078c64a51e8924ecf646df968094a818d59'" -->
        This worked!
        <!--#else -->
        Nope, it failed.
        <!--#endif -->

  parse_func_tolower
    Convert string to lower case.

    Example:

        <!--#if expr="tolower('Tous les êtres humains naissent libres et égaux en dignité et en droits.') == 'tous les êtres humains naissent libres et égaux en dignité et en droits.'" -->
        This worked!
        <!--#else -->
        Nope, it failed.
        <!--#endif -->

  parse_func_toupper
    Convert string to upper case.

    Example:

        <!--#if expr="toupper('Tous les êtres humains naissent libres et égaux en dignité et en droits.') == 'TOUS LES ÊTRES HUMAINS NAISSENT LIBRES ET ÉGAUX EN DIGNITÉ ET EN DROITS.'" -->
        This worked!
        <!--#else -->
        Nope, it failed.
        <!--#endif -->

  parse_func_unbase64
    Decode base64 encoded string, return truncated string if 0x00 is found.

    Example:

        <!--#if expr="unbase64('VG91cyBsZXMgw6p0cmVzIGh1bWFpbnMgbmFpc3NlbnQgbGlicmVzIGV0IMOpZ2F1eCBlbiBkaWduaXTDqSBldCBlbiBkcm9pdHMu') == 'Tous les êtres humains naissent libres et égaux en dignité et en droits.'" -->
        This worked!
        <!--#else -->
        Nope, it failed.
        <!--#endif -->

  parse_func_unescape
    Unescape %hex encoded string, leaving encoded slashes alone; return
    empty string if %00 is found.



( run in 0.718 second using v1.01-cache-2.11-cpan-df04353d9ac )