line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# This file is part of Plack-Middleware-iPhone |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# This software is copyright (c) 2010 by Patrick Donelan. |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# This is free software; you can redistribute it and/or modify it under |
7
|
|
|
|
|
|
|
# the same terms as the Perl 5 programming language system itself. |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
package Plack::Middleware::iPhone; |
10
|
|
|
|
|
|
|
BEGIN { |
11
|
1
|
|
|
1
|
|
52859
|
$Plack::Middleware::iPhone::VERSION = '1.102060'; |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# ABSTRACT: Make your html more iPhone friendly |
15
|
|
|
|
|
|
|
|
16
|
1
|
|
|
1
|
|
9
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
31
|
|
17
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
36
|
|
18
|
1
|
|
|
1
|
|
7
|
use parent qw( Plack::Middleware ); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
7
|
|
19
|
1
|
|
|
1
|
|
23654
|
use Plack::Util::Accessor qw( manifest icon startup_image tidy viewport statusbar ); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
4
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub new { |
22
|
1
|
|
|
1
|
1
|
184
|
my $class = shift; |
23
|
1
|
|
|
|
|
7
|
my $self = $class->SUPER::new(@_); |
24
|
|
|
|
|
|
|
|
25
|
1
|
50
|
|
|
|
23
|
$self->write_manifest if $self->manifest; |
26
|
|
|
|
|
|
|
|
27
|
1
|
|
|
|
|
97
|
return $self; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub call { |
31
|
1
|
|
|
1
|
1
|
27360
|
my $self = shift; |
32
|
1
|
|
|
|
|
3
|
my $env = shift; |
33
|
1
|
|
|
|
|
14
|
my $res = $self->app->($env); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# Buffer the entire html response (surely there's a better way..) |
36
|
1
|
|
|
|
|
16
|
my $whole_response = ''; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
$self->response_cb( |
39
|
|
|
|
|
|
|
$res, |
40
|
|
|
|
|
|
|
sub { |
41
|
1
|
|
|
1
|
|
26
|
my $res = shift; |
42
|
1
|
|
|
|
|
7
|
my $h = Plack::Util::headers( $res->[1] ); |
43
|
|
|
|
|
|
|
|
44
|
1
|
50
|
|
|
|
43
|
if ( $h->get('Content-Type') =~ m!^text/html! ) { |
45
|
|
|
|
|
|
|
return sub { |
46
|
2
|
|
|
|
|
44
|
my $chunk = shift; |
47
|
2
|
100
|
|
|
|
15
|
return unless defined $chunk; |
48
|
|
|
|
|
|
|
|
49
|
1
|
|
|
|
|
2
|
$whole_response .= $chunk; |
50
|
1
|
50
|
|
|
|
8
|
if ( $chunk =~ m{ |