ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/DC/Pod.pm
(Generate patch)

Comparing deliantra/Deliantra-Client/DC/Pod.pm (file contents):
Revision 1.1 by root, Sun Jul 23 16:11:12 2006 UTC vs.
Revision 1.2 by root, Mon Jul 24 08:23:28 2006 UTC

5use Pod::POM; 5use Pod::POM;
6 6
7use CFClient; 7use CFClient;
8use CFClient::UI; 8use CFClient::UI;
9 9
10our $VERSION = 1; # bump if resultant formatting changes 10our $VERSION = 1.02; # bump if resultant formatting changes
11 11
12our @result; 12our @result;
13our $indent; 13our $indent;
14 14
15package CFClient::Pod::AsXML; 15package CFClient::Pod::AsMarkup;
16 16
17use strict; 17use strict;
18 18
19use base "Pod::POM::View::Text"; 19use base "Pod::POM::View::Text";
20 20
21*view_seq_file =
21*view_seq_code = 22*view_seq_code =
22*view_seq_bold = sub { "<b>$_[1]</b>" }; 23*view_seq_bold = sub { "<b>$_[1]</b>" };
23*view_seq_italic = sub { "<i>$_[1]</i>" }; 24*view_seq_italic = sub { "<i>$_[1]</i>" };
24*view_seq_space = 25*view_seq_space =
25*view_seq_link =
26*view_seq_index = sub { CFClient::asxml $_[1] }; 26*view_seq_link = sub { CFClient::asxml $_[1] };
27*view_seq_zero =
28*view_seq_index = sub { };
27 29
28sub view_seq_text { 30sub view_seq_text {
29 my $text = $_[1]; 31 my $text = $_[1];
30 $text =~ s/\s+/ /g; 32 $text =~ s/\s+/ /g;
31 CFClient::asxml $text 33 CFClient::asxml $text
44 split /\n/, CFClient::asxml $_[1]) 46 split /\n/, CFClient::asxml $_[1])
45 . "\n" 47 . "\n"
46} 48}
47 49
48sub view_textblock { 50sub view_textblock {
49 ("\t" x ($indent / 2)) . "$_[1]\n\n" 51 ("\t" x ($indent / 2)) . "$_[1]\n"
50} 52}
51 53
52sub view_head1 { 54sub view_head1 {
53 "\n\n<span foreground='#ffff00' size='x-large'>" . $_[1]->title->present ($_[0]) . "</span>\n\n" 55 "\n\n<span foreground='#ffff00' size='x-large'>" . $_[1]->title->present ($_[0]) . "</span>\n\n"
54 . $_[1]->content->present ($_[0]) 56 . $_[1]->content->present ($_[0])
73 75
74use strict; 76use strict;
75 77
76use base "Pod::POM::View"; 78use base "Pod::POM::View";
77 79
80*view_seq_file =
78*view_seq_code = 81*view_seq_code =
79*view_seq_bold = sub { "<b>$_[1]</b>" }; 82*view_seq_bold = sub { "<b>$_[1]</b>" };
80*view_seq_italic = sub { "<i>$_[1]</i>" }; 83*view_seq_italic = sub { "<i>$_[1]</i>" };
81*view_seq_space = 84*view_seq_zero = sub { };
82*view_seq_link = 85*view_seq_space = sub { my $text = $_[1]; $text =~ s/ /&#160;/g; $text };
83*view_seq_index = sub { CFClient::asxml $_[1] }; 86*view_seq_index = sub { warn "index<@_>\n"; $result[-1]{index}{$_[1]} = undef };
84 87
85sub view_seq_text { 88sub view_seq_text {
86 my $text = $_[1]; 89 my $text = $_[1];
87 $text =~ s/\s+/ /g; 90 $text =~ s/\s+/ /g;
88 CFClient::asxml $text 91 CFClient::asxml $text
89} 92}
90 93
94sub view_seq_link {
95 my (undef, $link) = @_;
96
97 # TODO:
98 # http://...
99 # ref
100 # pod/ref
101
102 "<u>" . (CFClient::asxml $_[1]) . "</u>";
103}
104
91sub view_item { 105sub view_item {
92 push @result, { 106 push @result, {
93 indent => $indent * 8, 107 indent => $indent * 8,
94 text => $_[1]->title->present ($_[0]) . "\n\n", 108 markup => $_[1]->title->present ($_[0]) . "\n\n",
95 }; 109 };
96 $_[1]->content->present ($_[0]); 110 $_[1]->content->present ($_[0]);
97 () 111 ()
98} 112}
99 113
100sub view_verbatim { 114sub view_verbatim {
101 push @result, { 115 push @result, {
102 indent => $indent * 16, 116 indent => $indent * 16,
103 text => "<tt>" . (CFClient::asxml $_[1]) . "</tt>", 117 markup => "<tt>" . (CFClient::asxml $_[1]) . "</tt>\n",
104 }; 118 };
105 () 119 ()
106} 120}
107 121
108sub view_textblock { 122sub view_textblock {
109 push @result, { 123 push @result, {
110 indent => $indent * 16, 124 indent => $indent * 16,
111 text => "$_[1]\n", 125 markup => "$_[1]\n",
112 }; 126 };
113 () 127 ()
114} 128}
115 129
116sub view_head1 { 130sub view_head1 {
117 push @result, { 131 push @result, {
118 indent => $indent * 16, 132 indent => $indent * 16,
119 text => "\n\n<span foreground='#ffff00' size='x-large'>" . $_[1]->title->present ($_[0]) . "</span>\n", 133 markup => "\n\n<span foreground='#ffff00' size='x-large'>" . $_[1]->title->present ($_[0]) . "</span>\n",
120 }; 134 };
121 $_[1]->content->present ($_[0]); 135 $_[1]->content->present ($_[0]);
122 () 136 ()
123}; 137};
124 138
125sub view_head2 { 139sub view_head2 {
126 push @result, { 140 push @result, {
127 indent => $indent * 16, 141 indent => $indent * 16,
128 text => "\n\n<span foreground='#ccccff' size='large'>" . $_[1]->title->present ($_[0]) . "</span>\n", 142 markup => "\n\n<span foreground='#ccccff' size='large'>" . $_[1]->title->present ($_[0]) . "</span>\n",
129 }; 143 };
130 $_[1]->content->present ($_[0]); 144 $_[1]->content->present ($_[0]);
131 () 145 ()
132}; 146};
133 147
134sub view_head3 { 148sub view_head3 {
135 push @result, { 149 push @result, {
136 indent => $indent * 16, 150 indent => $indent * 16,
137 text => "\n\n<span size='large'>" . $_[1]->title->present ($_[0]) . "</span>\n", 151 markup => "\n\n<span size='large'>" . $_[1]->title->present ($_[0]) . "</span>\n",
138 }; 152 };
139 $_[1]->content->present ($_[0]); 153 $_[1]->content->present ($_[0]);
140 () 154 ()
141}; 155};
142 156
149 163
150sub view_for { 164sub view_for {
151 if ($_[1]->format eq "image") { 165 if ($_[1]->format eq "image") {
152 push @result, { 166 push @result, {
153 indent => $indent * 16, 167 indent => $indent * 16,
154 text => "\x{fffc}", 168 markup => "\x{fffc}",
155 obj => [new CFClient::UI::Image path => "pod/" . $_[1]->text], 169 widget => [new CFClient::UI::Image path => "pod/" . $_[1]->text],
156 }; 170 };
157 } 171 }
158 () 172 ()
159} 173}
160 174
174 stat $path 188 stat $path
175 or die "$path: $!"; 189 or die "$path: $!";
176 190
177 my $phash = join ",", $filterversion, $VERSION, (stat _)[7,9]; 191 my $phash = join ",", $filterversion, $VERSION, (stat _)[7,9];
178 192
193 my ($chash, $pom) = eval {
194 local $SIG{__DIE__};
179 my ($chash, $pom) = eval { @{ Storable::thaw $pod_cache->get ("$path/$filtertype") } }; 195 @{ Storable::thaw $pod_cache->get ("$path/$filtertype") }
196 };
180 197
181 return $pom if $chash eq $phash; 198 return $pom if $chash eq $phash;
182 199
183 my $pod = do { 200 my $pod = do {
184 local $/; 201 local $/;
194 $pod_cache->put ("$path/$filtertype" => Storable::nfreeze [$phash, $pom]); 211 $pod_cache->put ("$path/$filtertype" => Storable::nfreeze [$phash, $pom]);
195 212
196 $pom 213 $pom
197} 214}
198 215
216sub section($$) {
217 my ($pod, $section) = @_;
218}
219
199sub as_xml($) { 220sub as_markup($) {
200 my ($pom) = @_; 221 my ($pom) = @_;
201 222
202 local $indent = 0; 223 local $indent = 0;
203 224
204 $pom->present ("CFClient::Pod::AsXML") 225 $pom->present ("CFClient::Pod::AsMarkup")
205} 226}
206 227
207sub as_paragraphs($) { 228sub as_paragraphs($) {
208 my ($pom) = @_; 229 my ($pom) = @_;
209 230
210 local @result = ( { } ); 231 local @result = ( { } );
211 local $indent = 0; 232 local $indent = 0;
212 233
213 $pom->present ("CFClient::Pod::AsParagraphs"); 234 $pom->present ("CFClient::Pod::AsParagraphs");
214 235
215 [grep exists $_->{text}, @result] 236 [grep exists $_->{markup}, @result]
216} 237}
217 238
239sub pod_paragraphs($) {
240 load CFClient::find_rcfile "pod/$_[0].pod",
241 pod_paragraphs => 1, sub { as_paragraphs $_[0] };
242}
243

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines