line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package YAML::Yuyu; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
50126
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
84
|
|
4
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
55
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
9
|
use Carp; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
196
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
YAML::Yuyu - Easily create presentations from a YAML file. |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 SYNOPSIS |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my $yuyu = new YAML::Yuyu( path => $path, |
15
|
|
|
|
|
|
|
plantilla => 'plantilla.tmpl', |
16
|
|
|
|
|
|
|
contenido => 'contenido.yaml' ); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# From an array of pre-loaded or programatically created slides |
19
|
|
|
|
|
|
|
use YAML qw(LoadFile); |
20
|
|
|
|
|
|
|
@slides = LoadFile('yourslides.yaml'); |
21
|
|
|
|
|
|
|
my $yuyu = new YAML::Yuyu( path => $path, |
22
|
|
|
|
|
|
|
plantilla => 'plantilla.tmpl', |
23
|
|
|
|
|
|
|
contenido => \@slides ); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# From a glob; v. gr. data behind the __END__ marker |
26
|
|
|
|
|
|
|
my $yuyu3 = YAML::Yuyu->new( path => $path, |
27
|
|
|
|
|
|
|
plantilla => $plantilla, |
28
|
|
|
|
|
|
|
contenido => \*main::DATA ); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
my $nth_slide = $yuyu->slide( $n ); |
31
|
|
|
|
|
|
|
my $front_page = $yuyu->portada(); |
32
|
|
|
|
|
|
|
my $index = $yuyu->index(); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=cut |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 DESCRIPTION |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
Derived from L, which is a way cool module, this module |
39
|
|
|
|
|
|
|
loads a YAML from which it derives a presentation: index, slides, and |
40
|
|
|
|
|
|
|
so on. It can be used from another module, but you'll usually want to |
41
|
|
|
|
|
|
|
do it from the scripts for standalone presentations (with its own web |
42
|
|
|
|
|
|
|
server, no less) or to generate a single or several HTML pages you'll |
43
|
|
|
|
|
|
|
want to present from somewhere else or upload to a website. |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 USAGE |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
Stand-alone presentation tool. It will use default templates, if none |
48
|
|
|
|
|
|
|
is indicated |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
bash$ yuyupress presentation.yaml [path-to-templates] [template(s)] |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Generate a web page with the presentation |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
bash$ yuyugen presentation.yaml [path-to-templates] [template(s)] |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 METHODS |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=cut |
59
|
|
|
|
|
|
|
|
60
|
2
|
|
|
2
|
|
1780
|
use YAML qw(LoadFile Load); # Para configuración |
|
2
|
|
|
|
|
26125
|
|
|
2
|
|
|
|
|
130
|
|
61
|
2
|
|
|
2
|
|
2874
|
use Template; |
|
2
|
|
|
|
|
67815
|
|
|
2
|
|
|
|
|
143
|
|
62
|
2
|
|
|
2
|
|
20
|
use Exporter; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
218
|
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
our ($CVSVERSION) = ( '$Revision: 1.15 $' =~ /(\d+\.\d+)/ ) ; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
#Declaración de propiedades |
67
|
2
|
|
|
2
|
|
3279
|
use Object::props qw( path plantilla contenido ); |
|
2
|
|
|
|
|
7091
|
|
|
2
|
|
|
|
|
20
|
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
use Class::constr { |
70
|
|
|
|
|
|
|
init => sub { |
71
|
1
|
|
|
|
|
613
|
my $template = Template->new( {INCLUDE_PATH => $_[0]->path } ); |
72
|
1
|
|
|
|
|
29854
|
$_[0]->{_template} = $template; |
73
|
1
|
|
|
|
|
4
|
my @stream; |
74
|
1
|
50
|
|
|
|
9
|
if ( ref $_[0]->contenido eq '' ) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
75
|
1
|
|
|
|
|
26
|
@stream = LoadFile( $_[0]->contenido ); |
76
|
|
|
|
|
|
|
} elsif ( ref $_[0]->contenido eq 'ARRAY' ) { |
77
|
0
|
|
|
|
|
|
@stream = @{$_[0]->contenido}; |
|
0
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
} elsif ( ref $_[0]->contenido eq 'GLOB' ) { |
79
|
0
|
|
|
|
|
|
my $glob = $_[0]->contenido; |
80
|
0
|
|
|
|
|
|
my $stream = join('',<$glob>); |
81
|
0
|
|
|
|
|
|
@stream = Load($stream); |
82
|
|
|
|
|
|
|
} |
83
|
0
|
0
|
|
|
|
|
carp "Bad content stream" if !@stream; |
84
|
0
|
|
|
|
|
|
$_[0]->{_portada} = shift @stream; |
85
|
0
|
|
|
|
|
|
$_[0]->{_slides} = \@stream; |
86
|
0
|
|
|
|
|
|
$_[0]->{_doc} = $_[0]->plantilla; |
87
|
0
|
|
|
|
|
|
$_[0]->{_size } = scalar @stream - 1; |
88
|
|
|
|
|
|
|
} |
89
|
2
|
|
|
2
|
|
2838
|
}; |
|
2
|
|
|
|
|
1800
|
|
|
2
|
|
|
|
|
40
|
|
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head2 portada |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
C is the main page; it returns the title and general front matter for the presentation |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=cut |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub portada { |
98
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
99
|
0
|
|
|
|
|
|
my %data = %{$self->{_portada}->[0]}; |
|
0
|
|
|
|
|
|
|
100
|
0
|
|
|
|
|
|
my $contenido=<
|
101
|
|
|
|
|
|
|
$data{'autor'} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
$data{'email'} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
$data{'sitio'} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
EIF |
109
|
0
|
|
|
|
|
|
my $salida; |
110
|
0
|
0
|
|
|
|
|
$self->{_template}->process( $self->plantilla, |
111
|
|
|
|
|
|
|
{ titulo => $data{'titulo'}, |
112
|
|
|
|
|
|
|
contenido => $contenido }, |
113
|
|
|
|
|
|
|
\$salida ) |
114
|
|
|
|
|
|
|
|| die $self->{_template}->error(), "\n"; ; |
115
|
0
|
|
|
|
|
|
return $salida; |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head2 slide |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
C( $slide_number) returns the $slide_number'th slide from the presentation |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=cut |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
sub slide { |
126
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
127
|
0
|
|
0
|
|
|
|
my $nr = shift || 0; |
128
|
0
|
0
|
0
|
|
|
|
die if ($nr > $self->{_size}) || ($nr < 0); |
129
|
0
|
|
|
|
|
|
my @slide = @{$self->{_slides}[$nr]}; |
|
0
|
|
|
|
|
|
|
130
|
0
|
|
|
|
|
|
my $salida; |
131
|
0
|
|
|
|
|
|
my $titulo = shift @slide; |
132
|
0
|
|
|
|
|
|
my $contenido; |
133
|
0
|
|
|
|
|
|
$contenido = procesa(\@slide ); |
134
|
0
|
|
|
|
|
|
my $navegacion; |
135
|
0
|
0
|
|
|
|
|
if ( $nr ) { |
136
|
0
|
|
|
|
|
|
$navegacion .= "Anterior "; |
137
|
|
|
|
|
|
|
} |
138
|
0
|
|
|
|
|
|
$navegacion .= "Índice "; |
139
|
0
|
0
|
|
|
|
|
if ( $nr < $self->{_size} ) { |
140
|
0
|
|
|
|
|
|
$navegacion .= "Siguiente "; |
141
|
|
|
|
|
|
|
} |
142
|
0
|
0
|
|
|
|
|
$self->{_template}->process( $self->plantilla, |
143
|
|
|
|
|
|
|
{ titulo => $titulo, |
144
|
|
|
|
|
|
|
contenido => $contenido, |
145
|
|
|
|
|
|
|
navegacion => $navegacion, |
146
|
|
|
|
|
|
|
number => $nr+1 |
147
|
|
|
|
|
|
|
}, |
148
|
|
|
|
|
|
|
\$salida ) |
149
|
|
|
|
|
|
|
|| die $self->{_template}->error(), "\n"; ; |
150
|
0
|
|
|
|
|
|
return $salida; |
151
|
|
|
|
|
|
|
}; |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head2 indice |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
Returns the presentation index |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=cut |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
sub indice { |
160
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
161
|
0
|
|
|
|
|
|
my $i; |
162
|
0
|
|
|
|
|
|
my $contenido="". |
163
|
|
|
|
|
|
|
join("\n", |
164
|
0
|
|
|
|
|
|
map("".$_->[0]."", @{$self->{_slides}} ) ).""; |
165
|
|
|
|
|
|
|
|
166
|
0
|
|
|
|
|
|
my $salida; |
167
|
0
|
0
|
|
|
|
|
$self->{_template}->process( $self->plantilla, |
168
|
|
|
|
|
|
|
{ titulo => 'Indice', |
169
|
|
|
|
|
|
|
contenido => $contenido |
170
|
|
|
|
|
|
|
}, |
171
|
|
|
|
|
|
|
\$salida ) |
172
|
|
|
|
|
|
|
|| die $self->{_template}->error(), "\n"; ; |
173
|
0
|
|
|
|
|
|
return $salida; |
174
|
|
|
|
|
|
|
} |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
sub procesa { |
178
|
0
|
|
|
0
|
0
|
|
my $yref = shift; |
179
|
0
|
|
|
|
|
|
my $contenido=''; |
180
|
0
|
0
|
|
|
|
|
if (@$yref > 0 ) { |
181
|
0
|
|
|
|
|
|
$contenido = "".procesaArray( $yref )." "; |
182
|
|
|
|
|
|
|
} else { |
183
|
0
|
|
|
|
|
|
$contenido = procesaItem( $yref ); |
184
|
|
|
|
|
|
|
} |
185
|
0
|
|
|
|
|
|
return $contenido; |
186
|
|
|
|
|
|
|
} |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
sub procesaArray { |
189
|
0
|
|
|
0
|
0
|
|
my $yref = shift; |
190
|
0
|
|
|
|
|
|
my $contenido=''; |
191
|
0
|
|
|
|
|
|
for ( @$yref ) { |
192
|
0
|
|
|
|
|
|
$contenido .= procesaItem( $_ )."\n"; |
193
|
|
|
|
|
|
|
} |
194
|
0
|
|
|
|
|
|
return $contenido; |
195
|
|
|
|
|
|
|
} |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
sub procesaHash { |
198
|
0
|
|
|
0
|
0
|
|
my $yref = shift; |
199
|
0
|
|
|
|
|
|
my $contenido=''; |
200
|
0
|
|
|
|
|
|
for ( keys %$yref ) { |
201
|
0
|
|
|
|
|
|
$contenido .= "$_\n"; |
202
|
0
|
|
|
|
|
|
for my $i ( @{$yref->{$_}} ) { |
|
0
|
|
|
|
|
|
|
203
|
0
|
|
|
|
|
|
$contenido .= procesaItem( $i ); |
204
|
|
|
|
|
|
|
} |
205
|
0
|
|
|
|
|
|
$contenido .="\n"; |
206
|
|
|
|
|
|
|
} |
207
|
0
|
|
|
|
|
|
$contenido .= ""; |
208
|
0
|
|
|
|
|
|
return $contenido; |
209
|
|
|
|
|
|
|
} |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
sub procesaItem { |
212
|
0
|
|
|
0
|
0
|
|
my $yref = shift; |
213
|
0
|
|
|
|
|
|
my $contenido=''; |
214
|
0
|
0
|
|
|
|
|
if ( ref $yref eq '' ) { |
215
|
0
|
|
|
|
|
|
$contenido.= "$yref"; |
216
|
|
|
|
|
|
|
} else { |
217
|
0
|
|
|
|
|
|
my $tag = ref $yref; |
218
|
0
|
0
|
|
|
|
|
if ( $tag eq 'ARRAY' ) { |
|
|
0
|
|
|
|
|
|
219
|
0
|
|
|
|
|
|
$contenido = procesaArray( $yref ); |
220
|
|
|
|
|
|
|
} elsif ( $tag eq 'HASH' ) { |
221
|
0
|
|
|
|
|
|
$contenido = procesaHash( $yref ); |
222
|
|
|
|
|
|
|
} else { |
223
|
0
|
|
|
|
|
|
$contenido = "<$tag"; |
224
|
0
|
|
|
|
|
|
for ( keys %$yref ) { |
225
|
0
|
0
|
|
|
|
|
if ( $_ ne 'body' ) { |
226
|
0
|
|
|
|
|
|
$contenido .= " $_='$yref->{$_}'"; |
227
|
|
|
|
|
|
|
} |
228
|
|
|
|
|
|
|
} |
229
|
0
|
0
|
|
|
|
|
if ( $yref->{'body'} ) { |
230
|
0
|
|
|
|
|
|
$contenido.=">".$yref->{'body'}."$tag>"; |
231
|
|
|
|
|
|
|
} else { |
232
|
0
|
|
|
|
|
|
$contenido.=">"; |
233
|
|
|
|
|
|
|
} |
234
|
|
|
|
|
|
|
} |
235
|
|
|
|
|
|
|
} |
236
|
0
|
|
|
|
|
|
return $contenido; |
237
|
|
|
|
|
|
|
} |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
=head1 Copyright |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
This file is released under the GPL. See the LICENSE file included in this distribution, |
242
|
|
|
|
|
|
|
or go to http://www.fsf.org/licenses/gpl.txt |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
CVS Info: $Date: 2008/02/11 13:03:55 $ |
245
|
|
|
|
|
|
|
$Header: /home/jmerelo/repos/yuyupress/lib/YAML/Yuyu.pm,v 1.15 2008/02/11 13:03:55 jmerelo Exp $ |
246
|
|
|
|
|
|
|
$Author: jmerelo $ |
247
|
|
|
|
|
|
|
$Revision: 1.15 $ |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
=cut |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
'Sacabó'; |