=head1 NAME

Parse::Template::Web - 

=head1 SYNOPSIS



=head1 EXPORTS

Nothing exported by default

=over



=back

=head1 DEPENDENCIES

This module requires these other modules and libraries:

    Data::Format::Nml::Document
    WWW::Misc::Image
    Parse::Template::Directives::ContentEditable
    Error::Logical
    Perl::Module
    Data::Hub::Util
    Parse::Template::BBCode
    WWW::Livesite::Args
    Carp
    Parse::Template::Directives::Color
    Parse::Template::Directives::HTML
    HTML::Entities
    Parse::Template::Directives::JS
    Parse::Template::Directives::URI
    Parse::Template::Directives::Encode

=head1 DESCRIPTION




=head1 PUBLIC INTERFACE

=head2 defang

=over

=item Remove characters that would otherwise cause parser evaluation.



Also perform lightweight killing of HTML characters: C<\>\<'"&>


This example will B<not> abort:


  use Parse::Template::Web;



This example will B<not> abort:


  use Data::Hub;



This example:


  my $p = Parse::Template::Web->new(Data::Hub->new());
  $p->defang('a[#b]c');



I<will return>:

  abc


This example:


  my $p = Parse::Template::Web->new(Data::Hub->new());
  my $r = $p->defang(['a[#b]c', 'a<b>c</d>e']);
  join('', @$r);



I<will return>:

  abcabc/de



=back


=head2 http:header

=over

=item Add an HTTP header for output




  [#:http:header 'Name' 'Definition']
  [#:http:header 'Name' 'Definition' -override]

When -override is given, existing headers with the same name
are removed.



=back


=head2 is_editing

=over

=item Is the page being rendered for an authorized editor






=back


=head1 PACKAGE INTERNALS

=head2 _mk_url

=over

=item Given a relative path or URI, return an escaped URL for use in HTML




Spaces and ampersands will be encoded corretly:


  http://www.example.com/a b & c/c?a=b&c=1 2&d=%20;e="q"

becomes:


  http://www.example.com/a%20b%20&amp;%20c/c?a=b&amp;c=1%202&amp;d=%20&amp;e=%22q%22




=back


=head2 _elem_attrs

=over

=item Format arguments as element attributes






=back


=head2 _mk_image

=over

=item Create attributes for an image and possibly a wrapping anchor




where:


  $src              image url (src attribute)
  %attrs            image attributes which invoke special behavior
    $attrs{src}     image url (src attribute)
    $attrs{resize}  requests the image be resized to WxH/wxh
    $attrs{href}    the image is wrapped in an anchor
    $attrs{target}  that anchor has a target

options:


  -resize     => $WxH/wxh
  -max_width  => $num
  -max_height => $num
  -min_width  => $num
  -min_height => $num

Resize format is C<WxH/wxh> (read as max-width by max-height over min-width by
min-height) in pixels.

  100           width <= 100
  100x          width <= 100
  100x99        width <= 100, height <= 99
  100x99/       width <= 100, height <= 99
  100x99/10     10 <= width <= 100, height <= 99
  100x99/10x    10 <= width <= 100, height <= 99
  100x99/10x9   10 <= width <= 100, 9 <= height <= 99
  /10           10 <= width
  /10x          10 <= width
  /10x9         10 <= width, 9 <= height

Template options should take precedence over data options so that one may
lock-down the flow of the page.

The Livesite responder for images allows one to specify the resize parameter
in the URL:


  http://www.example.com/images/laura.jpg?resize=50x50

However the server simply resizes the image to the nearest reasonable size, 
Which means the image tag must include the exact width and height.



=back



=head1 AUTHORS

    Ryan Gies <ryangies@cpan.org>

=head1 COPYRIGHT

    Copyright (C) 2014-2016 by Ryan Gies. All rights reserved.
    Copyright (C) 2006-2013 by Livesite Networks, LLC. All rights reserved.
    Copyright (C) 2000-2005 by Ryan Gies. All rights reserved.
    Redistribution and use in source and binary forms, with or without 
    modification, are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright notice, 
    this list of conditions and the following disclaimer.
    * The origin of this software must not be misrepresented; you must not 
    claim that you wrote the original software. If you use this software in a 
    product, an acknowledgment in the product documentation would be 
    appreciated but is not required.
    * Altered source versions must be plainly marked as such, and must not be 
    misrepresented as being the original software.
    * The name of the author may not be used to endorse or promote products 
    derived from this software without specific prior written permission.

    THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED 
    WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
    MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 
    EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
    EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
    OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
    INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
    CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
    IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
    OF SUCH DAMAGE.
    To the best of our knowledge, no patented algorithms have been used. However, we
    do not have the resources to carry out a patent search, and therefore cannot 
    give any guarantee of the above statement.

=cut

