Apache-UploadMeter

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

* Use closure to pass $hook_data
* Use output filter instead of legacy Apache::SSI
* Doc changes
* Added normal configuration
* Added simple test suite (tests sample upload handler, but not meter)
(Developer release - unstable API)
###
0.99_05 : Jan  23, 2007
* Fix XSLT URL
* Fix output filter
* Fix popup window
###
0.99_12 : Jan  23, 2007
* Added needed use for Apache2::Connection and APR::Pool
* Use handlers to serve XSL/XSD files
* RC1 for 1.00 release
###
0.99_13 : Feb  11, 2007
* Added JavaScript routines (UploadMeter object + JSON response handler)
* Docs probably still not up-to-date
* Not yet RC status for JSON - still need embedded JS example (ala Web 2.0)

javascript.pod  view on Meta::CPAN

        }
    });
    
    // Start our uploadmeter - only do this once the corresponding upload has started (or is about to start)
    um.start();
    
    // Stop (or pause) a previouslky start()ed meter
    um.stop();
    
    // Un-register the default pop-up window behavior 
    Event.stopObserving(aum_el, 'submit', aum_popup);

=head1 DESCRIPTION

Apache::UploadMeter includes several JavaScript objects to help quickly create
a customized GUI interface for Apache::UploadMeter using the JSON meter type

=head1 DOM, JavaScript and Cascading StyleSheet rules

Although we aim to give maximum customizability, in order to keep a balance between
ease of initial set-up and basic usage, and customizability, the built-in UploadMeter

javascript.pod  view on Meta::CPAN

progress bar.  If you don't want to use the built-in progress-bar, but also don't
want to muck with the UploadMeter object to get around this, just create an empty
DIV on your page, set the style to hidden (eg, display: none), and pass that to
the UploadMeter object.  If you do wish to use this built-in object, ensure that
the CSS class of this div is "uploadmeter" (and don't hide it!)

Also, it is worth noting that the default behavior looks for an element class
named "uploadform" and attempts to add to the onSubmit code for it, to trigger
the bundled default pop-up window.  If you don't want this to happen, just run:

C<Event.stopObserving(aum_el, 'submit', aum_popup);>


=head1 API Documentation

=head3 UploadMeter Object

This is where most of the action happens.  The public interface to this object
consists of a constructor, start and stop methods, and some callbacks that can 
be used to do extra stuff at various key points in the UploadMeter's lifetime.

lib/Apache/UploadMeter.pm  view on Meta::CPAN

<Location $UM/styles/js/aum.js>
    SetHandler perl-script
    PerlResponseHandler Apache::UploadMeter::Resources::JavaScript::json_js
</Location>
PerlModule Apache::UploadMeter::Resources::CSS
<Location $UM/styles/css/aum.css>
    SetHandler perl-script
    PerlResponseHandler Apache::UploadMeter::Resources::CSS::json_css
</Location>
PerlModule Apache::UploadMeter::Resources::HTML
<Location $UM/styles/aum_popup.html>
    SetHandler perl-script
    PerlResponseHandler Apache::UploadMeter::Resources::HTML::json_popup
</Location>

EOC

    $parms->server->add_config([split /\n/, $config]);
    $parms->server->log->info("Configured $namespace v$VERSION \"$val\" $UH - $UM - $UF [$TYPE]");
}

sub configure_invalid {
    my ($self, $parms, $val) = @_;

lib/Apache/UploadMeter.pm  view on Meta::CPAN


=back

=back

=head1 DATA FORMAT

Apache::UploadMeter currently provides 2 types of meters: JavaScript (JSON)
based, and XML-based.  The JSON is the new default; it's sexier, slicker, works
out-of-the-box with modern browsers, and with the magic of AJAX and DHTML, doesn't
even need a popup window.  XML is also still actively supported and is aimed at
users who wish to further customize the user-experience or provide a non-browser
based UploadMeter.  Both JSON and XML provide identical data; a formal XSL schema
can be seen at http://uploaddemo.beamartyr.net/demo/xml/meter/styles/xml/aum.xsd

=head1 BUILT-IN TYPES

Apache::UploadMeter comes pre-bundled with 2 DHTML-based graphical meters that
can be used as-is, or just as reference points for builing your own custom
meters.  Currently the 2 types can be selected by specifying I<JSON> or I<XML> in
the MeterType configuration directive.  Each of these will cause

lib/Apache/UploadMeter/Resources/HTML.pm  view on Meta::CPAN


# Static resources (CSS) for the UploadMeter widget

use strict;
use warnings;
use Apache2::RequestRec ();
use Apache2::RequestIO ();
use Apache2::Response ();
use Apache2::Const -compile=>qw(:common);

sub json_popup {
    my $r = shift;
    $r->content_type("text/html");
    $r->set_etag();
    return Apache2::Const::OK if $r->header_only();
    my $output=<<"EOF";
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<script type="text/javascript" src="js/prototype.js"></script>

lib/Apache/UploadMeter/Resources/JavaScript.pm  view on Meta::CPAN

function addMeterURL(url) {
    try {
      if (url.indexOf('?') >= 0) {
          return url + "&meter_id=" + meter_id;
      } else {
          return url + "?meter_id=" + meter_id;
      }
    } catch (e) {}
}

function aum_popup() {
    var aum = window.open(meter_url + "/styles/aum_popup.html" ,"_new","toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizeable=no,width=450,height=240");
    // Pass our info to the child window's global obj
    Object.extend(aum, {'meter_id': meter_id, 'meter_url': meter_url});
}

var rules={
    '.uploadform':function(el) {
      el.action = addMeterURL(el.action);
      aum_el = $(el); // Put this in a global so we can unregister later, if needed
      Event.observe(aum_el, 'submit', aum_popup);
    }
};
Behaviour.register(rules);

AUM-END
    $r->print($output);
    return Apache2::Const::OK;
}

1;



( run in 2.819 seconds using v1.01-cache-2.11-cpan-364913b4093 )