Daizu::Preview

Daizu::Preview is a Perl module that offers functions for generating preview versions of output content.
Download

Daizu::Preview Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Geoff Richards
  • Publisher web site:
  • http://search.cpan.org/~geoffr/Daizu-0.3/lib/Daizu/Preview.pm

Daizu::Preview Tags


Daizu::Preview Description

Daizu::Preview is a Perl module that offers functions for generating preview versions of output content. Daizu::Preview is a Perl module that offers functions for generating preview versions of output content.This code is used by the CGI script preview.cgi to filter output so that links refer back to the preview. It is this code which makes it possible to preview not only an HTML page, but also get preview versions of all the CSS, images, and linked pages which it references.FUNCTIONSThe following functions are available for export from this module. None of them are exported by default.output_preview($cms, $url, $file, $generator, $method, $argument, $type, $fh) Generate the output for $file (a Daizu::File object) which is meant to be published at $url (a simple string or URI object). The output will be generated by calling $method on the $generator object, and using $argument. The output will sometimes (depending on the expected MIME type given by $type) be filtered to adjust embedded links so that they point to preview versions instead of the live site. Links will be adjusted if they point to known URLs for the working copy. Other URLs will be made absolute, based on $url. %PREVIEW_FILTER is used to determine whether the files need to be filtered, and which function to use for the filtering. The finished (possibly filtered) output is printed to $fh. The file handle will be adjusted with binmode to expect raw or utf8 output, depending on whether the content type is a text or binary one.adjust_preview_links_html($cms, $wc_id, $base_url, $html, $fh) Given a string containing HTML in $html, parse it and adjust any attributes which are meant to contain URIs to use the correct for of links for a preview. The output is written to $fh. Exactly which attributes are adjusted depends on the contents of %HTML_URL_ATTR. In addition, inline CSS code in style elements is filtered though the CSS filtering function described below, so that CSS links are adjusted as well.adjust_preview_links_css($cms, $wc_id, $base_url, $css, $fh) Filter CSS (cascading style sheet) code in $css replacing links with ones which point to the preview (if appropriate) or are absolute. This means that if your CSS file references background images, or includes other stylesheets, it will still work while previewing output. The filtering is done with a simple lexical analyser, which looks for url() values and @import commands. It knows enough to skip over string literals and comments which happen to contain things which might look like these, but it doesn't make any great effort to understand the CSS syntax.adjust_link_for_preview($cms, $wc_id, $base_url, $urls, $value_type) Called by the filtering functions above to adjust a link. $value_type should be either uri if $urls is expected to contain a single URI, or uri-list if it might contain a whitespace-separated list of URIs. Returns a replacement for the value in $urls, which can be substituted back into the filtered content.script_link($cms, $wc_id, %args) Return a properly encoded URL with query parameters which refers to the current CGI script (based on the SCRIPT_NAME environment variable). The keys and values in %args will be given as CGI parameters. If $wc_id is provided, and there is no wc argument in %args, then a wc argument may be added automatically. It's assumed that this argument will default to the live working copy ID, so it isn't added if $wc_id is the same as that. Requirements: · Perl


Daizu::Preview Related Software