| 1 | package WML::Deck; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use vars qw($VERSION); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | ▶ | use WML::Card; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 1 | $VERSION = '0.01'; | |||||||||
| 8 | |||||||||||
| 9 | |||||||||||
| 10 | 1 | ▶ | sub new{ | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 11 | 1 | my $pkg = shift; | |||||||||
| 12 | 1 | my @card = @_; | |||||||||
| 13 | 1 | my $self = bless { | |||||||||
| 14 | '_template' => undef, | ||||||||||
| 15 | '_card' => undef, | ||||||||||
| 16 | }, $pkg; | ||||||||||
| 17 | 1 | push @{$self->{'_card'}}, @card; | |||||||||
| 18 | 1 | return $self; | |||||||||
| 19 | }; | ||||||||||
| 20 | |||||||||||
| 21 | |||||||||||
| 22 | 0 | ▶ | sub _contenttype{ | ||||||||
|
Subroutine
_contenttype: not called CC=1 SCAR=6.9
| |||||||||||
| 23 | 0 | my $self = shift; | |||||||||
| 24 | 0 | return "Content-type: text/vnd.wap.wml \n\n"; | |||||||||
| 25 | } | ||||||||||
| 26 | |||||||||||
| 27 | 0 | ▶ | sub cache{ | ||||||||
|
Subroutine
cache: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 28 | 0 | my $self = shift; | |||||||||
| 29 | 0 | $self->{'cache'} = shift; | |||||||||
| 30 | } | ||||||||||
| 31 | |||||||||||
| 32 | 0 | ▶ | sub _cache{ | ||||||||
|
Subroutine
_cache: not called CC=2 SCAR=17.9
| |||||||||||
| 33 | 0 | my $self= shift; | |||||||||
| 34 | 0 | ▶ | return if !defined $self->{'cache'}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 35 | 0 | return << "EOF"; | |||||||||
| 36 | <head> | ||||||||||
| 37 | <meta http-equiv="Cache-Control" content="max-age=0"/> | ||||||||||
| 38 | </head> | ||||||||||
| 39 | EOF | ||||||||||
| 40 | } | ||||||||||
| 41 | |||||||||||
| 42 | |||||||||||
| 43 | 0 | ▶ | sub _header{ | ||||||||
|
Subroutine
_header: not called CC=1 SCAR=6.9
| |||||||||||
| 44 | 0 | my $self = shift; | |||||||||
| 45 | return << 'EOF' | ||||||||||
| 46 | <?xml version="1.0"?> | ||||||||||
| 47 | <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml"> | ||||||||||
| 48 | |||||||||||
| 49 | <wml> | ||||||||||
| 50 | EOF | ||||||||||
| 51 | 0 | } | |||||||||
| 52 | |||||||||||
| 53 | 0 | ▶ | sub template{ | ||||||||
|
Subroutine
template: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 54 | 0 | my $self = shift; | |||||||||
| 55 | 0 | my ($type, $label , $href, $target) = @_; | |||||||||
| 56 | 0 | $self->{'_wml'} .= << "EOF"; | |||||||||
| 57 | <template> | ||||||||||
| 58 | <do type="$type" label="$label"> | ||||||||||
| 59 | <go href="$target"/> | ||||||||||
| 60 | </do> | ||||||||||
| 61 | <do type="prev"> | ||||||||||
| 62 | <prev/> | ||||||||||
| 63 | </do> | ||||||||||
| 64 | </template> | ||||||||||
| 65 | EOF | ||||||||||
| 66 | } | ||||||||||
| 67 | |||||||||||
| 68 | 0 | ▶ | sub _footer{ | ||||||||
|
Subroutine
_footer: not called CC=1 SCAR=6.9
| |||||||||||
| 69 | 0 | my $self = shift; | |||||||||
| 70 | 0 | return << 'EOF'; | |||||||||
| 71 | </wml> | ||||||||||
| 72 | EOF | ||||||||||
| 73 | } | ||||||||||
| 74 | |||||||||||
| 75 | |||||||||||
| 76 | |||||||||||
| 77 | 0 | ▶ | sub return_cgi{ | ||||||||
|
Subroutine
return_cgi: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 78 | 0 | my $self =shift; | |||||||||
| 79 | 0 | print $self->_contenttype; | |||||||||
| 80 | 0 | print $self->_header; | |||||||||
| 81 | 0 | print $self->_cache; | |||||||||
| 82 | 0 | print $self->{'_template'}; | |||||||||
| 83 | 0 | for (@{$self->{'_card'}}) { | |||||||||
| 84 | 0 | $_->print; | |||||||||
| 85 | } | ||||||||||
| 86 | 0 | print $self->_footer; | |||||||||
| 87 | } | ||||||||||
| 88 | |||||||||||
| 89 | =head1 NAME | ||||||||||
| 90 | |||||||||||
| 91 | WML::Deck - Perl extension for builiding WML Decks. | ||||||||||
| 92 | |||||||||||
| 93 | =head1 SYNOPSIS | ||||||||||
| 94 | |||||||||||
| 95 | use WML::Card; | ||||||||||
| 96 | |||||||||||
| 97 | use WML::Deck; | ||||||||||
| 98 | |||||||||||
| 99 | my @cards; | ||||||||||
| 100 | |||||||||||
| 101 | my $options= [ | ||||||||||
| 102 | ['Option 1', 'http://...'], | ||||||||||
| 103 | ['Option 2', 'http://...'], | ||||||||||
| 104 | |||||||||||
| 105 | ]; | ||||||||||
| 106 | |||||||||||
| 107 | my $c = WML::Card->guess('index','Wap Site'); | ||||||||||
| 108 | $c->link_list('indice', undef, 0, $options, $options); | ||||||||||
| 109 | push @cards, $c; | ||||||||||
| 110 | |||||||||||
| 111 | # Build the deck | ||||||||||
| 112 | my $wml = WML::Deck->new(@cards); | ||||||||||
| 113 | $wml->return_cgi; | ||||||||||
| 114 | |||||||||||
| 115 | =head1 DESCRIPTION | ||||||||||
| 116 | |||||||||||
| 117 | This perl library simplifies the creation of WML decks on the fly. In combination with | ||||||||||
| 118 | WML::Card it provides functionality to build WML code for cards and decks. | ||||||||||
| 119 | |||||||||||
| 120 | =head2 Methods | ||||||||||
| 121 | |||||||||||
| 122 | =over 4 | ||||||||||
| 123 | |||||||||||
| 124 | =item $wml = WML::Deck->new(@cards); | ||||||||||
| 125 | |||||||||||
| 126 | This class method constructs a new WML::Deck object. The first argument is an array | ||||||||||
| 127 | of WML::Card objects. | ||||||||||
| 128 | |||||||||||
| 129 | =item $wml->cache($n); | ||||||||||
| 130 | |||||||||||
| 131 | This class methos specifies the max-age argument for Cache-Control | ||||||||||
| 132 | |||||||||||
| 133 | =item $wml->return_cgi; | ||||||||||
| 134 | |||||||||||
| 135 | This method prints wml code and HTTP headers for the deck. | ||||||||||
| 136 | |||||||||||
| 137 | =head1 AUTHOR | ||||||||||
| 138 | |||||||||||
| 139 | Mariana Alvaro mariana@alvaro.com.ar | ||||||||||
| 140 | |||||||||||
| 141 | Copyright 2000 Mariana Alvaro. All rights reserved. | ||||||||||
| 142 | This library is free software; you can redistribute it and/or | ||||||||||
| 143 | modify it under the same terms as Perl itself. | ||||||||||
| 144 | |||||||||||
| 145 | =head1 SEE ALSO | ||||||||||
| 146 | |||||||||||
| 147 | WML::Card | ||||||||||
| 148 | |||||||||||
| 149 | =cut | ||||||||||
| 150 | |||||||||||
| 151 | |||||||||||
| 152 | |||||||||||
| 153 | 1 | 1; | |||||||||