Acme-ReturnValue
view release on metacpan or search on metacpan
t/pms/Envolve.pm view on Meta::CPAN
has secret => (
is => 'rw',
);
has site_id => (
is => 'rw',
);
sub get_tags {
my ($self, $first_name, %options) = @_;
my $command = ($first_name) ? $self->get_login_command($first_name, %options) : $self->get_logout_command;
my $html = q{
<script type="text/javascript">
envoSn=%s;
env_commandString="%s";
</script>
<script type="text/javascript" src="//d.envolve.com/env.nocache.js"></script>
};
return sprintf $html, $self->site_id, $command;
}
sub get_login_command {
my ($self, $first_name, %options) = @_;
my %params = ( fn => $first_name );
$params{ln} = $options{last_name} if exists $options{last_name};
$params{pic} = $options{picture_url} if exists $options{picture_url};
$params{admin} = 't' if exists $options{is_admin} && $options{is_admin};
return $self->sign_command_string(
$self->generate_command_string('login', %params)
);
}
sub get_logout_command {
my ($self) = @_;
return $self->sign_command_string(
$self->generate_command_string('logout')
);
}
sub generate_command_string {
my ($self, $command, %params) = @_;
my $command_string = (time() * 1000)
.';v=0.2'
.',c='.$command;
foreach my $key (keys %params) {
my $value = ($key eq 'admin') ? $params{$key} : encode_base64url(encode("UTF-8",$params{$key}));
t/pms/Envolve.pm view on Meta::CPAN
version 1.0007
=head1 SYNOPSIS
my $chat = Chat::Envolve->new(
api_key => $key,
);
my $html = $chat->get_tags('Joe');
my $command = $chat->get_login_command('Joe');
=head1 DESCRIPTION
This is a Perl API for the Envolve L<http://www.envolve.com> chat system. If you'd like to see it in use, check out The Lacuna Expanse L<http://www.lacunaexpanse.com>. Currently Envolve has not exposed much functionality, but using this API will allo...
=head1 METHODS
=head2 new ( api_key => '111-xxx' )
Constructor. Requires both params.
=over
=item api_key
The API key provided by Envolve.
=back
=head2 get_login_command ( first_name , [ options ] )
Returns a signed login command string that can be used to log a user into a chat by calling some javascript.
<script type="text/javascript">
env_executeCommand(command_string_goes_here);
</script>
If you prefer you can just inline it into the web page using the C<get_tags> method.
=over
=item first_name
t/pms/Envolve.pm view on Meta::CPAN
=item is_admin
If set to 1, the user will gain admin privileges, which currently means that if enabled in the Envolve settings they'll be able to create and close chats administratively.
=back
=back
=head2 get_logout_command ( )
Returns a signed logout command string that can be used to log a user out of a chat by calling some javascript.
<script type="text/javascript">
env_executeCommand(command_string_goes_here);
</script>
If you prefer you can just inline it into the web page using the C<get_tags> method and pass no params to it.
=head2 get_tags ( [ first_name, login_options, ] )
Returns some HTML tags that can be inlined into your web page to start the chat. If no parameters are passed in, then the user will be anonymous. If C<first_name> is passed in then the user will be authenticated.
=over
=item first_name
See C<get_login_command>
=item login_options
See C<get_login_command>
=back
=head1 EXCEPTIONS
Currently this module doesn't throw any exceptions.
t/pms/RayApp.pm view on Meta::CPAN
my $dsd = $rayapp->load_dsd('structure.dsd');
print $dsd->serialize_data( $data );
=head1 INTRODUCTION
The B<RayApp> provides a framework for data-centric Web applications.
Instead of writing Perl code that prints HTML, or a code that calls
functions that print HTML, or embedding the code inside of HTML
markup, the Web applications only process and return Perl data.
No markup handling is done in the code of individual applications,
thus application code can focus on the business logic. This reduces
the presentation noise in individual applications, increases
maintainability and speeds development.
The data returned by the application is then serialized to XML and
can be postprocessed by XSLT to desired output format, which may be
HTML, XHTML, WML or anything else. In order to provide all parties
involved (analysts, application programmers, Web designers, ...) with
a common specification of the data format, data structure description
(DSD) file is a mandatory part of the applications. The DSD describes
what parameters the application expects and what data it will return,
t/pms/RayApp.pm view on Meta::CPAN
}
my $dbh = DBI->connect('dbi:Oracle:prod',
'scott', 'tiger',
{ RaiseError => 1, AutoCommit => 0 });
my $q = new RayApp::Request($r);
return ($dbh, $q);
}
1;
Here we first validate parameters against DSD (you can optionally
die or just log an error, depending on how strict you want to be),
we connect to the database, so that the applications get connection
to their database backend, and we use B<RayApp::Request> to get
uniform (for mod_perl and CGI) query object. The values B<$dbh> and
B<$q> are returned and will be passed as argument to the application
B<handler>.
=item RayAppStyleParamModule / RAYAPP_STYLE_PARAM_MODULE
There are often additional data except the core data of the
application that you might like to process in your XSLT
stylesheets -- id of the authenticated user, the full and
relative URLs of the currently running application, some sticky
preferences of the user. They are more related to the presentation
than to the business logic of the application, so you do not want to
have them in your DSD and have all your applications generate them and
return them.
The option B<RayAppStyleParamModule> specifies a module name from
which a B<handler> function will be called for every request that goes
to the postprocessing stage. It will be passed the DSD object and the
same arguments as the application B<handler> (those returned by
B<RayAppInputModule>) and it should return a list of key => value
pairs that will be passed to the stylesheet.
( run in 1.403 second using v1.01-cache-2.11-cpan-5735350b133 )