line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Rest::HtmlVis::Key; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
2150
|
use 5.006; |
|
1
|
|
|
|
|
3
|
|
4
|
1
|
|
|
1
|
|
3
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
16
|
|
5
|
1
|
|
|
1
|
|
3
|
use warnings FATAL => 'all'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
315
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Rest::HtmlVis::Key - Base class for easy-to-use html vis |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 VERSION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Version 0.01 |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=cut |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our $VERSION = '0.13'; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 SYNOPSIS |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
All you have to do is to inherit from Rest::HtmlVis::Key and then implement the callback html. |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
Example: |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
package Rest::HtmlVis::MyGraph; |
27
|
|
|
|
|
|
|
use parent qw( Rest::HtmlVis::Key ); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
use YAML::Syck; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub html { |
32
|
|
|
|
|
|
|
my ($self) = @_; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
local $Data::Dumper::Indent=1; |
35
|
|
|
|
|
|
|
local $Data::Dumper::Quotekeys=0; |
36
|
|
|
|
|
|
|
local $Data::Dumper::Terse=1; |
37
|
|
|
|
|
|
|
local $Data::Dumper::Sortkeys=1; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
return ' '.Dump($self->getStruct).' '; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head2 new |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=cut |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub new { |
49
|
0
|
|
|
0
|
1
|
|
my ($class, $baseurl) = @_; |
50
|
0
|
|
|
|
|
|
return bless {baseurl => $baseurl}, $class; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head2 baseurl |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=cut |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub baseurl { |
58
|
0
|
|
|
0
|
1
|
|
return $_[0]->{baseurl}; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head2 setHeader |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=cut |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub setHeader{ |
66
|
0
|
|
|
0
|
1
|
|
my ($self, $header) = @_; |
67
|
0
|
|
|
|
|
|
my %hash = @{$header}; |
|
0
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
$self->{header} = \%hash; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head2 getHeader |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=cut |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub getHeader { |
76
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
77
|
0
|
|
|
|
|
|
return $self->{header}; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head2 setStruct |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=cut |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub setStruct { |
85
|
0
|
|
|
0
|
1
|
|
my ($self, $key, $struct, $env) = @_; |
86
|
0
|
0
|
0
|
|
|
|
if ($struct && ref $struct eq 'HASH' && exists $struct->{$key}){ |
|
|
|
0
|
|
|
|
|
87
|
0
|
|
|
|
|
|
$self->{struct} = $struct->{$key}; |
88
|
0
|
|
|
|
|
|
$self->{env} = $env; |
89
|
0
|
|
|
|
|
|
return 1; |
90
|
|
|
|
|
|
|
}else{ |
91
|
0
|
|
|
|
|
|
$self->{struct} = undef; |
92
|
|
|
|
|
|
|
} |
93
|
0
|
|
|
|
|
|
return undef; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head2 getStruct |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Return html hash with input structure. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=cut |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub getStruct { |
103
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
104
|
0
|
|
|
|
|
|
return $self->{struct}; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head2 getEnv |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Return env variables. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=cut |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub getEnv { |
114
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
115
|
0
|
|
|
|
|
|
return $self->{env}; |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head2 getOrder |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Return wight on elemnt on html page. Default 1 means in middle; |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=cut |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
sub getOrder { |
125
|
0
|
|
|
0
|
1
|
|
return 1; |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head2 blocks |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Number of blocks in row. Max 12. (ala bootstrap) |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Default is 12; |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=cut |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
sub blocks { |
137
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
138
|
0
|
|
|
|
|
|
return 12; |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head2 newRow |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Define if element is on new row or is the part of previous row. |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Default is 0 - no new row; |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=cut |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
sub newRow { |
150
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
151
|
0
|
|
|
|
|
|
return 0; |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head2 head |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
Return head of page as HTML string. |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
Default empty. |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=cut |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
sub head { |
163
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
164
|
0
|
|
|
|
|
|
return; |
165
|
|
|
|
|
|
|
} |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=head2 head |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
Return footer of page as HTML string. |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
Default empty. |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=cut |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
sub footer { |
176
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
177
|
0
|
|
|
|
|
|
return; |
178
|
|
|
|
|
|
|
} |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=head2 onload |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
Return onload javascript function of onload attr in body. It must ends with ; |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
Default empty. |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=cut |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
sub onload { |
189
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
190
|
0
|
|
|
|
|
|
return; |
191
|
|
|
|
|
|
|
} |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=head2 html |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
Return body part of HTML. |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
Default empty. |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
=cut |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
sub html { |
202
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
203
|
0
|
|
|
|
|
|
return; |
204
|
|
|
|
|
|
|
} |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=encoding utf-8 |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
=head1 AUTHOR |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
Václav Dovrtěl Evaclav.dovrtel@gmail.comE |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=head1 BUGS |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
Please report any bugs or feature requests to github repository. |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
Inspired by L |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
=head1 REPOSITORY |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
L |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
Copyright 2015 Vaclav Dovrtel. |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
229
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
230
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
See L for more information. |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
=cut |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
1; # End of Rest::HtmlVis::Key |