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.18 by root, Tue Mar 25 01:46:36 2008 UTC vs.
Revision 1.22 by root, Sun Mar 30 11:31:09 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
38 42
39 return 1 unless @path; 43 return 1 unless @path;
40 44
41 my $kw = lc pop @path; 45 my $kw = lc pop @path;
42 46
43 $node = $node->{parent} 47 $node = $node->[N_PARENT]
44 or return 0; 48 or return 0;
45 49
50 #TODO: maybe get rid of lowercasing?
46 return scalar grep $_ eq $kw, @{ $node->{kw} }; 51 return scalar grep lc eq $kw, @{ $node->[N_KW] };
47} 52}
48 53
49sub find(@) { 54sub find(@) {
50 my (@path) = @_; 55 my (@path) = @_;
51 56
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 74 # skip toplevel hierarchy pod/, because its not a document
70 while ($node->{parent}) { 75 while ($node->[N_PARENT]) {
71 unshift @path, $node; 76 unshift @path, $node;
72 $node = $node->{parent}; 77 $node = $node->[N_PARENT];
73 } 78 }
74 79
75 @path 80 @path
76} 81}
77 82
78sub full_path($) { 83sub full_path($) {
79 join "/", map $_->{kw}[0], &full_path_of 84 join "/", map $_->[N_KW][0], &full_path_of
80} 85}
81 86
82sub section_of($) { 87sub section_of($) {
83 my ($node) = @_; 88 my ($node) = @_;
84 89
85 my $doc = $node->{doc}; 90 my $doc = $node->[N_DOC];
86 my $par = $node->{par}; 91 my $par = $node->[N_PAR];
87 my $lvl = $node->{level}; 92 my $lvl = $node->[N_LEVEL];
88 93
89 my @res; 94 my @res;
90 95
91 do { 96 do {
92 my $p = $doc->[$par]; 97 my $p = $doc->[$par];
118 $_[1]{$type}($_, @arg) 123 $_[1]{$type}($_, @arg)
119 }ogex; 124 }ogex;
120 } 125 }
121} 126}
122 127
128my %as_common = (
129 h1 => sub {
130 "\n\n<span foreground='#ffff00' size='x-large'>$_[1]</span>\n"
131 },
132 h2 => sub {
133 "\n\n<span foreground='#ccccff' size='large'>$_[1]</span>\n"
134 },
135 h3 => sub {
136 "\n\n<span size='large'>$_[1]</span>\n"
137 },
138);
139
123my %as_label = ( 140my %as_label = (
141 %as_common,
124 image => sub { 142 image => sub {
125 my ($par, $path) = @_; 143 my ($par, $path) = @_;
126 144
127 "<small>img</small>" 145 "<small>img</small>"
128 }, 146 },
146 164
147 $text 165 $text
148} 166}
149 167
150my %as_paragraphs = ( 168my %as_paragraphs = (
169 %as_common,
151 image => sub { 170 image => sub {
152 my ($par, $path, $flags) = @_; 171 my ($par, $path, $flags) = @_;
153 172
154 push @{ $par->{widget} }, new DC::UI::Image path => $path, 173 push @{ $par->{widget} }, new DC::UI::Image path => $path,
155 $flags & 1 ? (max_h => $::FONTSIZE) : (); 174 $flags & 1 ? (max_h => $::FONTSIZE) : ();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines