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.6 by root, Sun Aug 13 14:30:06 2006 UTC vs.
Revision 1.7 by root, Sun Aug 13 18:48:56 2006 UTC

5use Storable; 5use Storable;
6 6
7our $VERSION = 1; 7our $VERSION = 1;
8 8
9our %wiki; 9our %wiki;
10
11my $MA_BEG = "\x{fcd0}";
12my $MA_SEP = "\x{fcd1}";
13my $MA_END = "\x{fcd2}";
10 14
11*wiki = Storable::retrieve CFPlus::find_rcfile "docwiki.pst"; 15*wiki = Storable::retrieve CFPlus::find_rcfile "docwiki.pst";
12 16
13sub is_prefix_of($@) { 17sub is_prefix_of($@) {
14 my ($node, @path) = @_; 18 my ($node, @path) = @_;
56 my @res; 60 my @res;
57 61
58 do { 62 do {
59 my $p = $doc->[$par]; 63 my $p = $doc->[$par];
60 64
61 if (exists $p->{markup}) { 65 if (length $p->{markup}) {
62 my %para = ( 66 push @res, {
63 markup => $p->{markup}, 67 markup => $p->{markup},
64 indent => $p->{indent}, 68 indent => $p->{indent},
65 );
66
67 for (@{ $p->{widget} || [] }) {
68 my ($class, @args) = @$_;
69 push @{ $para{widget} }, $class->new (@args);
70 } 69 };
71
72 push @res, \%para;
73 } 70 }
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
84 my $text = 110 my $text =
85 join "\n", 111 join "\n",
86 map +("\xa0" x ($_->{indent} / 4)) . $_->{markup}, 112 map +("\xa0" x ($_->{indent} / 4)) . $_->{markup},
87 @_; 113 @_;
88 114
90 $text =~ s/\s+$//; 116 $text =~ s/\s+$//;
91 117
92 $text 118 $text
93} 119}
94 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
95sub section_label(@) { 146sub section_label(@) {
96 as_label &section 147 as_label &section
97} 148}
98 149
991 1501

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines