line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::Dthumb::Data; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
=head1 NAME |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
App::Dthumb::Data - Retrieve installed data (like lightbox images) |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 SYNOPSIS |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
use App::Dthumb::Data; |
11
|
|
|
|
|
|
|
my $data = App::Dthumb::Data->new(); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
$data->set_vars( |
14
|
|
|
|
|
|
|
title => 'Something funky', |
15
|
|
|
|
|
|
|
); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
print $data->get('html_start.dthumb'); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
open(my $fh, '>', 'close.png'); |
20
|
|
|
|
|
|
|
print {$fh} $data->get('close.png'); |
21
|
|
|
|
|
|
|
close($fh); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 VERSION |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
This manual documents B version 0.2 |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=cut |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
4
|
|
|
4
|
|
507634
|
use strict; |
|
4
|
|
|
|
|
18
|
|
|
4
|
|
|
|
|
267
|
|
31
|
4
|
|
|
4
|
|
25
|
use warnings; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
433
|
|
32
|
4
|
|
|
4
|
|
93
|
use base 'Exporter'; |
|
4
|
|
|
|
|
16
|
|
|
4
|
|
|
|
|
631
|
|
33
|
|
|
|
|
|
|
|
34
|
4
|
|
|
4
|
|
5001
|
use Data::Section -setup; |
|
4
|
|
|
|
|
221552
|
|
|
4
|
|
|
|
|
39
|
|
35
|
4
|
|
|
4
|
|
8482
|
use MIME::Base64 qw(decode_base64); |
|
4
|
|
|
|
|
3716
|
|
|
4
|
|
|
|
|
2081
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
our @EXPORT_OK = (); |
38
|
|
|
|
|
|
|
our $VERSION = '0.2'; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 METHODS |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head2 new |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Returns a new B object. Does not take any arguments. |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=cut |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub new { |
51
|
1
|
|
|
1
|
1
|
3523
|
my ($obj) = @_; |
52
|
1
|
|
|
|
|
4
|
my $ref = {}; |
53
|
1
|
|
|
|
|
5
|
return bless($ref, $obj); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head2 set_vars(%vars) |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Set replacement variables. For each hash key, when outputting data using the |
60
|
|
|
|
|
|
|
B function, dthumb will replace occurences of "" or "/* $key |
61
|
|
|
|
|
|
|
*/" (the dollar sign is literal) with its value. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=cut |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub set_vars { |
67
|
0
|
|
|
0
|
1
|
0
|
my ($self, %vars) = @_; |
68
|
0
|
|
|
|
|
0
|
$self->{replace} = \%vars; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head2 list_archived |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Returns an array of all saved data. That is, all files which do not end in |
75
|
|
|
|
|
|
|
".dthumb". |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=cut |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub list_archived { |
81
|
0
|
|
|
0
|
1
|
0
|
my ($self) = @_; |
82
|
0
|
|
|
|
|
0
|
return grep { ! /\.dthumb$/ } $self->section_data_names(); |
|
0
|
|
|
|
|
0
|
|
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head2 get($filename) |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Returns the exact content of share/$filename. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=cut |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub get { |
94
|
8
|
|
|
8
|
1
|
11810
|
my ($self, $name) = @_; |
95
|
8
|
|
|
|
|
32
|
my $data = $self->section_data($name); |
96
|
|
|
|
|
|
|
|
97
|
8
|
50
|
|
|
|
30349
|
if (not $data) { |
98
|
0
|
|
|
|
|
0
|
die("No such data: ${name}\n"); |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
8
|
|
|
|
|
13
|
$data = ${$data}; |
|
8
|
|
|
|
|
32
|
|
102
|
|
|
|
|
|
|
|
103
|
8
|
|
|
|
|
32
|
chomp($data); |
104
|
|
|
|
|
|
|
|
105
|
8
|
100
|
|
|
|
67
|
if ($name =~ qr{ \. (png | gif) $ }ox) { |
106
|
3
|
|
|
|
|
47
|
return decode_base64($data); |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
5
|
|
|
|
|
12
|
while (my ($key, $value) = each %{$self->{replace}}) { |
|
5
|
|
|
|
|
31
|
|
110
|
0
|
|
|
|
|
0
|
$data =~ s{ |
111
|
|
|
|
|
|
|
( \<\!-- | /\* ) |
112
|
|
|
|
|
|
|
\s+ \$ $key \s+ |
113
|
|
|
|
|
|
|
( --\> | \*/ ) |
114
|
|
|
|
|
|
|
}{$value}gx; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
5
|
|
|
|
|
39
|
return $data; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
1; |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=over |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=item * Data::Section |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=back |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head1 AUTHOR |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Copyright (C) 2011 by Daniel Friesel Ederf@chaosdorf.deE |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 LICENSE |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
0. You just DO WHAT THE FUCK YOU WANT TO. |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=cut |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
__DATA__ |