ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/lib/cf/pod.pm
(Generate patch)

Comparing deliantra/server/lib/cf/pod.pm (file contents):
Revision 1.18 by root, Thu Sep 11 22:18:46 2008 UTC vs.
Revision 1.31 by root, Wed Nov 21 12:47:04 2012 UTC

1#
2# This file is part of Deliantra, the Roguelike Realtime MMORPG.
3#
4# Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5#
6# Deliantra is free software: you can redistribute it and/or modify it under
7# the terms of the Affero GNU General Public License as published by the
8# Free Software Foundation, either version 3 of the License, or (at your
9# option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the Affero GNU General Public License
17# and the GNU General Public License along with this program. If not, see
18# <http://www.gnu.org/licenses/>.
19#
20# The authors can be reached via e-mail to <support@deliantra.net>
21#
22
1package cf::pod; 23package cf::pod;
24
25use common::sense;
2 26
3use Pod::POM; 27use Pod::POM;
4 28
5our $indent; 29our $indent;
6our $level; 30our $level;
7our @result; 31our @result;
8 32
9package cf::pod::AsParagraphs; 33package cf::pod::AsParagraphs;
10 34
11use strict; 35use common::sense;
12 36
13use base "Pod::POM::View"; 37use base "Pod::POM::View";
14 38
15my %E = ( 39my %E = (
16 "<" => "E<lt>", 40 "<" => "E<lt>",
37 61
38*view_seq_file = sub { "C<$_[1]>" }; 62*view_seq_file = sub { "C<$_[1]>" };
39*view_seq_code = sub { "C<$_[1]>" }; 63*view_seq_code = sub { "C<$_[1]>" };
40*view_seq_bold = sub { "B<$_[1]>" }; 64*view_seq_bold = sub { "B<$_[1]>" };
41*view_seq_italic = sub { "I<$_[1]>" }; 65*view_seq_italic = sub { "I<$_[1]>" };
66*view_seq_T = sub { "T<$_[1]>" };
67*view_seq_G = sub { "G<$_[1]>" };
42*view_seq_zero = sub { "Z<>" }; 68*view_seq_zero = sub { "Z<>" };
43*view_seq_space = sub { my $text = $_[1]; $text =~ s/ /\xa0/g; $text }; 69*view_seq_space = sub { my $text = $_[1]; $text =~ s/ /\xa0/g; $text };
44*view_seq_index = sub { push @{ $result[-1]{index} }, $_[1]; "" }; 70*view_seq_index = sub { push @{ $result[-1]{index} }, $_[1]; "" };
71#view_seq_entity
45 72
46sub view_seq_text { 73sub view_seq_text {
47 my $text = $_[1]; 74 my $text = $_[1];
48 $text =~ s/\s+/ /g; 75 $text =~ s/\s+/ /g;
49 aspod $text 76 aspod $text
55 my $text = $link =~ s/^(.*)\|// ? $1 : $link; 82 my $text = $link =~ s/^(.*)\|// ? $1 : $link;
56 83
57 if ($link =~ /http:/) { 84 if ($link =~ /http:/) {
58 "U<" . (aspod $link) . ">" 85 "U<" . (aspod $link) . ">"
59 } else { 86 } else {
60 () 87 aspod $text
61 } 88 }
62} 89}
63 90
64sub view_item { 91sub view_item {
65 push @result, { 92 push @result, {
166 193
167############################################################################# 194#############################################################################
168 195
169package cf::pod; 196package cf::pod;
170 197
171sub pom_as_paragraphs($) { 198sub pom_as_paragraphs_ng($) {
172 my ($pom) = @_; 199 my ($pom) = @_;
173 200
174 # we suckers use global variables, unfortunately. 201 # we suckers use global variables, unfortunately.
175 my $guard = cf::lock_acquire "cf::pod::as_paragraphs";
176
177 local $indent = 0; 202 local $indent = 0;
178 local $level = 1; 203 local $level = 1;
179 local @result = ( { } ); 204 local @result = ( { } );
180 205
181 $pom->present ("cf::pod::AsParagraphs"); 206 $pom->present ("cf::pod::AsParagraphs");
182 207
183 [grep $_->{index} || exists $_->{markup}, @result] 208 [grep $_->{index} || exists $_->{markup}, @result]
184} 209}
185 210
211sub pom_as_paragraphs($) {
212 my ($pom) = @_;
213
214 my $guard = cf::lock_acquire "cf::pod::as_paragraphs";
215
216 $pom->pom_as_paragraphs_ng
217}
218
186sub load_pod($) { 219sub load_pod($) {
187 my ($path) = @_; 220 my ($path) = @_;
188 221
189 Coro::Storable::thaw cf::cache "cf::pod::as_paragraphs/$path" => [$path], 222 Coro::Storable::thaw cf::cache "cf::pod::as_paragraphs/$path" => [$path],
190 7 => sub { 223 9 => sub {
191 my ($src) = @_; 224 my ($src) = @_;
192 225
193 cf::fork_call { 226 cf::fork_call {
194 my $pod = $src->[0]; 227 Coro::Storable::blocking_nfreeze
195 utf8::decode $pod; 228 pom_as_paragraphs_ng
196 Coro::Storable::blocking_nfreeze pom_as_paragraphs +(Pod::POM->new->parse_text ($pod)) 229 +(Pod::POM->new->parse_text ($src->[0]))
197 } 230 }
198 }; 231 };
199} 232}
200 233
201# format as cfpod-style text 234# format as cfpod-style text

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines