line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package YAML::YuyuPress; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
177408
|
use strict; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
77
|
|
4
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
232
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
YAML::YuyuPress - Tool for making presentations out of YAML files. |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 SYNOPSIS |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
use YAML::YuyuPress; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my $yuyu = new YAML::YuyuPress( { path => $path, #to templates dir |
16
|
|
|
|
|
|
|
plantilla => 'plantilla.tmpl', #template |
17
|
|
|
|
|
|
|
contenido => 'contenido.yaml', #slides |
18
|
|
|
|
|
|
|
staticdir => '/path/to/dir' # static dir |
19
|
|
|
|
|
|
|
); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
$yuyu->run(); # Runs in port 8080 by default |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
$yuyu->port(13432); # Set the server port |
24
|
|
|
|
|
|
|
my $pid=$yuyu->background(); # or |
25
|
|
|
|
|
|
|
$yuyu->run(); # Both inherited from HTML::Server::Simple::CGI |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
The presentation can then be run from http://localhost:13432/, slides |
28
|
|
|
|
|
|
|
accessed via http://localhost:13432/?slide=1 or, REST-style, |
29
|
|
|
|
|
|
|
http://localhost:13432/slide/1, |
30
|
|
|
|
|
|
|
index via http://localhost:13432/?indice=1 or |
31
|
|
|
|
|
|
|
http://localhost:13432/index |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 DESCRIPTION |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
Program for making presentations out of YAML files. Can be used as a |
36
|
|
|
|
|
|
|
module or from the C script |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
Inherits from L and L for serving pages. Use C for a quick presentation of the things that can be done, and how to do them; the presentation itself is contained in the C directory of the distro under the name C. C, in the C dir, are examples also of correct presentations. |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 METHODS |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=cut |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
our $VERSION="0.07_2"; |
45
|
|
|
|
|
|
|
our ($CVSVERSION) = ( '$Revision: 1.23 $' =~ /(\d+\.\d+)/ ) ; |
46
|
|
|
|
|
|
|
|
47
|
2
|
|
|
2
|
|
12
|
use base qw/HTTP::Server::Simple::CGI/; |
|
2
|
|
|
|
|
14
|
|
|
2
|
|
|
|
|
2091
|
|
48
|
2
|
|
|
2
|
|
62727
|
use HTTP::Server::Simple::Static; # for serve_static |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
use YAML::Yuyu; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head2 new |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Creates a new copy of the object |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=cut |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub new { |
58
|
|
|
|
|
|
|
my $class = shift; |
59
|
|
|
|
|
|
|
my ($opts ) = shift; |
60
|
|
|
|
|
|
|
my $self = $class->SUPER::new(); |
61
|
|
|
|
|
|
|
$self->{'staticdir'} = $opts->{'staticdir'}; |
62
|
|
|
|
|
|
|
my $yuyu = YAML::Yuyu->new(path => $opts->{'path'}, |
63
|
|
|
|
|
|
|
plantilla => $opts->{'plantilla'}, |
64
|
|
|
|
|
|
|
contenido => $opts->{'contenido'} ); |
65
|
|
|
|
|
|
|
$self->{'_yuyu'} = $yuyu; |
66
|
|
|
|
|
|
|
return $self; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head2 handle_request CGI |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Overrides default to return the main presentation page |
72
|
|
|
|
|
|
|
('portada'), index or any of the slides. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=cut |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub handle_request { |
78
|
|
|
|
|
|
|
my ( $self, $cgi ) = @_; |
79
|
|
|
|
|
|
|
my $path = $cgi->path_info(); |
80
|
|
|
|
|
|
|
my $yuyu = $self->{'_yuyu'}; |
81
|
|
|
|
|
|
|
if ( $path ne "/" and (-e $self->{'staticdir'}."/$path") ) { # First of all, static stuff |
82
|
|
|
|
|
|
|
$self->serve_static( $cgi, $self->{'staticdir'}); |
83
|
|
|
|
|
|
|
} else { |
84
|
|
|
|
|
|
|
print "HTTP/1.0 200 OK\r\n", |
85
|
|
|
|
|
|
|
$cgi->header(); |
86
|
|
|
|
|
|
|
if ( $path eq '/' ) { |
87
|
|
|
|
|
|
|
if ( !$cgi->param() ) { |
88
|
|
|
|
|
|
|
print $yuyu->portada; |
89
|
|
|
|
|
|
|
return 1; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
if ( $cgi->param('indice') ){ |
92
|
|
|
|
|
|
|
print $yuyu->indice; |
93
|
|
|
|
|
|
|
return 1; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
if ( $cgi->param('slide') ne '' ) { |
96
|
|
|
|
|
|
|
print $yuyu->slide( $cgi->param('slide') ); |
97
|
|
|
|
|
|
|
return 1; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
} else { |
100
|
|
|
|
|
|
|
$self->process_REST( $cgi, $path ); |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub process_REST( ) { |
106
|
|
|
|
|
|
|
my $self = shift; |
107
|
|
|
|
|
|
|
my $cgi = shift; |
108
|
|
|
|
|
|
|
my $path = shift; |
109
|
|
|
|
|
|
|
my $yuyu = $self->{'_yuyu'}; |
110
|
|
|
|
|
|
|
my ($foo, $command, @args) = split("/", $path ); |
111
|
|
|
|
|
|
|
if ( $command eq 'index' ) { |
112
|
|
|
|
|
|
|
print $yuyu->indice; |
113
|
|
|
|
|
|
|
} elsif ( $command eq 'slide' ) { |
114
|
|
|
|
|
|
|
print $yuyu->slide( $args[0] ); |
115
|
|
|
|
|
|
|
} else { |
116
|
|
|
|
|
|
|
print "HTTP/1.0 404 Not found\r\n"; |
117
|
|
|
|
|
|
|
print $cgi->start_html('Not found'), |
118
|
|
|
|
|
|
|
$cgi->h1("$path Not found"), |
119
|
|
|
|
|
|
|
$cgi->end_html; |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 Copyright |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
This file is released under the GPL. See the LICENSE file included in this distribution, |
127
|
|
|
|
|
|
|
or go to http://www.fsf.org/licenses/gpl.txt |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
CVS Info: $Date: 2008/02/11 13:04:30 $ |
130
|
|
|
|
|
|
|
$Header: /home/jmerelo/repos/yuyupress/lib/YAML/YuyuPress.pm,v 1.23 2008/02/11 13:04:30 jmerelo Exp $ |
131
|
|
|
|
|
|
|
$Author: jmerelo $ |
132
|
|
|
|
|
|
|
$Revision: 1.23 $ |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=cut |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
'Tostodo'; |