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.20 by root, Sun Mar 30 00:25:11 2008 UTC vs.
Revision 1.23 by root, Sun Mar 30 13:02:26 2008 UTC

40sub is_prefix_of($@) { 40sub is_prefix_of($@) {
41 my ($node, @path) = @_; 41 my ($node, @path) = @_;
42 42
43 return 1 unless @path; 43 return 1 unless @path;
44 44
45 my $kw = lc pop @path; 45 my $kw = pop @path;
46 46
47 $node = $node->[N_PARENT] 47 $node = $node->[N_PARENT]
48 or return 0; 48 or return 0;
49 49
50 return scalar grep $_ eq $kw, @{ $node->[N_KW] }; 50 return scalar grep $_ eq $kw, @{ $node->[N_KW] };
53sub find(@) { 53sub find(@) {
54 my (@path) = @_; 54 my (@path) = @_;
55 55
56 return unless @path; 56 return unless @path;
57 57
58 my $kw = lc pop @path; 58 my $kw = pop @path;
59 59
60 # TODO: make sure results are unique 60 my %res = map +($_, $_),
61
62 grep { is_prefix_of $_, @path } 61 grep { is_prefix_of $_, @path }
63 map @$_, 62 map @$_,
64 $kw eq "*" ? @wiki{sort keys %wiki} 63 $kw eq "*" ? values %wiki
65 : $wiki{$kw} || () 64 : $wiki{$kw} || ();
65
66 values %res
66} 67}
67 68
68sub full_path_of($) { 69sub full_path_of($) {
69 my ($node) = @_; 70 my ($node) = @_;
70 71
71 my @path; 72 my @path;
72 73
73 # skip toplevel hierarchy pod/, because its not a document
74 while ($node->[N_PARENT]) { 74 while ($node) {
75 unshift @path, $node; 75 unshift @path, $node;
76 $node = $node->[N_PARENT]; 76 $node = $node->[N_PARENT];
77 } 77 }
78 78
79 @path 79 @path
122 $_[1]{$type}($_, @arg) 122 $_[1]{$type}($_, @arg)
123 }ogex; 123 }ogex;
124 } 124 }
125} 125}
126 126
127my %as_common = (
128 h1 => sub {
129 "\n\n<span foreground='#ffff00' size='x-large'>$_[1]</span>\n"
130 },
131 h2 => sub {
132 "\n\n<span foreground='#ccccff' size='large'>$_[1]</span>\n"
133 },
134 h3 => sub {
135 "\n\n<span size='large'>$_[1]</span>\n"
136 },
137);
138
127my %as_label = ( 139my %as_label = (
140 %as_common,
128 image => sub { 141 image => sub {
129 my ($par, $path) = @_; 142 my ($par, $path) = @_;
130 143
131 "<small>img</small>" 144 "<small>img</small>"
132 }, 145 },
150 163
151 $text 164 $text
152} 165}
153 166
154my %as_paragraphs = ( 167my %as_paragraphs = (
168 %as_common,
155 image => sub { 169 image => sub {
156 my ($par, $path, $flags) = @_; 170 my ($par, $path, $flags) = @_;
157 171
158 push @{ $par->{widget} }, new DC::UI::Image path => $path, 172 push @{ $par->{widget} }, new DC::UI::Image path => $path,
159 $flags & 1 ? (max_h => $::FONTSIZE) : (); 173 $flags & 1 ? (max_h => $::FONTSIZE) : ();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines