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.4 by root, Sun Aug 13 02:43:22 2006 UTC vs.
Revision 1.7 by root, Sun Aug 13 18:48:56 2006 UTC

2 2
3use strict; 3use strict;
4 4
5use Storable; 5use Storable;
6 6
7use CFPlus::UI;
8
9our $VERSION = 1; 7our $VERSION = 1;
10 8
11our %wiki; 9our %wiki;
10
11my $MA_BEG = "\x{fcd0}";
12my $MA_SEP = "\x{fcd1}";
13my $MA_END = "\x{fcd2}";
12 14
13*wiki = Storable::retrieve CFPlus::find_rcfile "docwiki.pst"; 15*wiki = Storable::retrieve CFPlus::find_rcfile "docwiki.pst";
14 16
15sub is_prefix_of($@) { 17sub is_prefix_of($@) {
16 my ($node, @path) = @_; 18 my ($node, @path) = @_;
58 my @res; 60 my @res;
59 61
60 do { 62 do {
61 my $p = $doc->[$par]; 63 my $p = $doc->[$par];
62 64
63 my %para = ( 65 if (length $p->{markup}) {
66 push @res, {
64 markup => $p->{markup}, 67 markup => $p->{markup},
65 indent => $p->{indent}, 68 indent => $p->{indent},
66 ); 69 };
67
68 for (@{ $p->{widget} || [] }) {
69 my ($class, @args) = @$_;
70 push @{ $para{widget} }, $class->new (@args);
71 } 70 }
72
73 push @res, \%para;
74 } while $doc->[++$par]{level} > $lvl; 71 } while $doc->[++$par]{level} > $lvl;
75 72
76 @res 73 @res
77} 74}
78 75
79sub section(@) { 76sub section(@) {
80 map section_of $_, &find 77 map section_of $_, &find
81} 78}
82 79
80sub thaw_section(\@\%) {
81 for (@{$_[0]}) {
82 $_->{markup} =~ s{
83 $MA_BEG
84 ([^$MA_END]+)
85 $MA_END
86 }{
87 my ($type, @arg) = split /$MA_SEP/o, $1;
88
89 $_[1]{$type}($_, @arg)
90 }ogex;
91 }
92}
93
94my %as_label = (
95 image => sub {
96 my ($par, $path) = @_;
97
98 "<small>img</small>"
99 },
100 link => sub {
101 my ($par, $link) = @_;
102
103 "<big>" . (CFPlus::asxml $link) . "</big>"
104 },
105);
106
83sub as_label(@) { 107sub as_label(@) {
108 thaw_section @_, %as_label;
109
110 my $text =
84 join "\n", 111 join "\n",
85 map +("\xa0" x ($_->{indent} / 4)) . $_->{markup}, 112 map +("\xa0" x ($_->{indent} / 4)) . $_->{markup},
86 @_ 113 @_;
114
115 $text =~ s/^\s+//;
116 $text =~ s/\s+$//;
117
118 $text
119}
120
121my %as_paragraphs = (
122 image => sub {
123 my ($par, $path) = @_;
124
125 push @{ $par->{widget} }, new CFPlus::UI::Image path => $path;
126
127 "\x{FFFC}"
128 },
129 link => sub {
130 my ($par, $link) = @_;
131
132 "<big>" . (CFPlus::asxml $link) . "</big>"
133 },
134);
135
136sub as_paragraphs(@) {
137 thaw_section @_, %as_paragraphs;
138
139 @_
140}
141
142sub section_paragraphs(@) {
143 as_paragraphs &section
144}
145
146sub section_label(@) {
147 as_label &section
87} 148}
88 149
891 1501

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines