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.21 by root, Sun Mar 30 10:18:16 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 #TODO: maybe get rid of lowercasing?
51 return scalar grep lc eq $kw, @{ $node->[N_KW] }; 50 return scalar grep $_ eq $kw, @{ $node->[N_KW] };
52} 51}
53 52
54sub find(@) { 53sub find(@) {
55 my (@path) = @_; 54 my (@path) = @_;
56 55
57 return unless @path; 56 return unless @path;
58 57
59 my $kw = lc pop @path; 58 my $kw = pop @path;
60 59
61 # TODO: make sure results are unique 60 my %res = map +($_, $_),
62
63 grep { is_prefix_of $_, @path } 61 grep { is_prefix_of $_, @path }
64 map @$_, 62 map @$_,
65 $kw eq "*" ? @wiki{sort keys %wiki} 63 $kw eq "*" ? values %wiki
66 : $wiki{$kw} || () 64 : $wiki{$kw} || ();
65
66 values %res
67} 67}
68 68
69sub full_path_of($) { 69sub full_path_of($) {
70 my ($node) = @_; 70 my ($node) = @_;
71 71
72 my @path; 72 my @path;
73 73
74 # skip toplevel hierarchy pod/, because its not a document
75 while ($node->[N_PARENT]) { 74 while ($node) {
76 unshift @path, $node; 75 unshift @path, $node;
77 $node = $node->[N_PARENT]; 76 $node = $node->[N_PARENT];
78 } 77 }
79 78
80 @path 79 @path
123 $_[1]{$type}($_, @arg) 122 $_[1]{$type}($_, @arg)
124 }ogex; 123 }ogex;
125 } 124 }
126} 125}
127 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
128my %as_label = ( 139my %as_label = (
140 %as_common,
129 image => sub { 141 image => sub {
130 my ($par, $path) = @_; 142 my ($par, $path) = @_;
131 143
132 "<small>img</small>" 144 "<small>img</small>"
133 }, 145 },
151 163
152 $text 164 $text
153} 165}
154 166
155my %as_paragraphs = ( 167my %as_paragraphs = (
168 %as_common,
156 image => sub { 169 image => sub {
157 my ($par, $path, $flags) = @_; 170 my ($par, $path, $flags) = @_;
158 171
159 push @{ $par->{widget} }, new DC::UI::Image path => $path, 172 push @{ $par->{widget} }, new DC::UI::Image path => $path,
160 $flags & 1 ? (max_h => $::FONTSIZE) : (); 173 $flags & 1 ? (max_h => $::FONTSIZE) : ();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines