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.19 by root, Tue Mar 25 02:12:35 2008 UTC vs.
Revision 1.23 by root, Sun Mar 30 13:02:26 2008 UTC

25sub P_INDENT (){ 0 } 25sub P_INDENT (){ 0 }
26sub P_LEVEL (){ 1 } 26sub P_LEVEL (){ 1 }
27sub P_MARKUP (){ 2 } 27sub P_MARKUP (){ 2 }
28sub P_INDEX (){ 3 } 28sub P_INDEX (){ 3 }
29 29
30*wiki = Storable::retrieve DC::find_rcfile "docwiki.pst"; 30our %wiki;
31
32sub load_docwiki {
33 *wiki = Storable::retrieve $_[0];
34}
31 35
32sub goto_document($) { 36sub goto_document($) {
33 $goto_document->(split /\//, $_[0]); 37 $goto_document->(split /\//, $_[0]);
34} 38}
35 39
36sub is_prefix_of($@) { 40sub is_prefix_of($@) {
37 my ($node, @path) = @_; 41 my ($node, @path) = @_;
38 42
39 return 1 unless @path; 43 return 1 unless @path;
40 44
41 my $kw = lc pop @path; 45 my $kw = pop @path;
42 46
43 $node = $node->[N_PARENT] 47 $node = $node->[N_PARENT]
44 or return 0; 48 or return 0;
45 49
46 return scalar grep $_ eq $kw, @{ $node->[N_KW] }; 50 return scalar grep $_ eq $kw, @{ $node->[N_KW] };
49sub find(@) { 53sub find(@) {
50 my (@path) = @_; 54 my (@path) = @_;
51 55
52 return unless @path; 56 return unless @path;
53 57
54 my $kw = lc pop @path; 58 my $kw = pop @path;
55 59
56 # TODO: make sure results are unique 60 my %res = map +($_, $_),
57
58 grep { is_prefix_of $_, @path } 61 grep { is_prefix_of $_, @path }
59 map @$_, 62 map @$_,
60 $kw eq "*" ? @wiki{sort keys %wiki} 63 $kw eq "*" ? values %wiki
61 : $wiki{$kw} || () 64 : $wiki{$kw} || ();
65
66 values %res
62} 67}
63 68
64sub full_path_of($) { 69sub full_path_of($) {
65 my ($node) = @_; 70 my ($node) = @_;
66 71
67 my @path; 72 my @path;
68 73
69 # skip toplevel hierarchy pod/, because its not a document
70 while ($node->[N_PARENT]) { 74 while ($node) {
71 unshift @path, $node; 75 unshift @path, $node;
72 $node = $node->[N_PARENT]; 76 $node = $node->[N_PARENT];
73 } 77 }
74 78
75 @path 79 @path
118 $_[1]{$type}($_, @arg) 122 $_[1]{$type}($_, @arg)
119 }ogex; 123 }ogex;
120 } 124 }
121} 125}
122 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
123my %as_label = ( 139my %as_label = (
140 %as_common,
124 image => sub { 141 image => sub {
125 my ($par, $path) = @_; 142 my ($par, $path) = @_;
126 143
127 "<small>img</small>" 144 "<small>img</small>"
128 }, 145 },
146 163
147 $text 164 $text
148} 165}
149 166
150my %as_paragraphs = ( 167my %as_paragraphs = (
168 %as_common,
151 image => sub { 169 image => sub {
152 my ($par, $path, $flags) = @_; 170 my ($par, $path, $flags) = @_;
153 171
154 push @{ $par->{widget} }, new DC::UI::Image path => $path, 172 push @{ $par->{widget} }, new DC::UI::Image path => $path,
155 $flags & 1 ? (max_h => $::FONTSIZE) : (); 173 $flags & 1 ? (max_h => $::FONTSIZE) : ();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines