This file is indexed.

/usr/share/perl5/Jifty/Plugin/Chart/Dispatcher.pm is in libjifty-plugin-chart-perl 1.01+dfsg-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
use strict;
use warnings;

package Jifty::Plugin::Chart::Dispatcher;
use Jifty::Dispatcher -base;

use Jifty::YAML;

=head1 NAME

Jifty::Plugin::Chart::Dispatcher - Dispatcher for the chart API plugin

=cut

my %classes = (
    chart       => 'Chart::$TYPE',
    gd_graph    => 'GD::Graph::$TYPE',
    xmlswf      => 'XML::Simple',
);

=head1 RULES

=head2 chart/*/*

Grabs the chart configuration stored in the key indicated in C<$1> and unpacks it using L<YAML>. It then passes it to the correct L<Jifty::Plugin::Chart::View> template.

=cut

on 'chart/*/*' => run {
    my $renderer = $1;

    # No renderer?  Act like a 404.
    last_rule if not defined $classes{$renderer};

    # Create a session ID to lookup the chart configuration
    my $session_id = 'chart_' . $2;

    # Unpack the data and then clear it from the session
    my $args = Jifty::YAML::Load( Jifty->web->session->get( $session_id ) );

    # XXX if there are a lot of charts, this could asplode
    #Jifty->web->session->remove( $session_id );

    # No data? Act like a 404
    last_rule unless defined $args;

    # Request might override width/height:
    $args->{width}  = get 'width'  if get 'width';
    $args->{height} = get 'height' if get 'height';

    # XXX TODO Is there a better way to guess the pixel heights when using CSS
    # heights initially?

    # Remove 'px' from width/height and set to 400/300 if not in pixels
    ($args->{width}  =~ s/px$//) or ($args->{width}  = 400);
    ($args->{height} =~ s/px$//) or ($args->{height} = 300);

    # No zeroes! Ba Ba Blacksheep.
    $args->{width}  ||= 400;
    $args->{height} ||= 300;

    if (my $class = $classes{$renderer}) {
        # Use the "type" to determine which class to use
        $class =~ s/\$TYPE/$args->{type}/g;

        # Load that class or die if it does not exist
        $class->require;

        # Remember the class name for the view
        $args->{class} = $class;
    }

    # Send them on to chart the chart
    set 'args' => $args;
    show "chart/$renderer";
};

=head1 SEE ALSO

L<Jifty::Plugin::Chart::View>

=head1 AUTHOR

Andrew Sterling Hanenkamp C<< <andrew.hanenkamp@boomer.com> >>

=head1 COPYRIGHT AND LICENSE

Copyright 2007 Boomer Consulting, Inc.

This is free software and may be modified and redistributed under the same terms as Perl itself.

=cut

1;