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.24 by root, Sat Apr 3 02:58:25 2010 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines