… | |
… | |
5 | |
5 | |
6 | use Storable; |
6 | use Storable; |
7 | |
7 | |
8 | our $VERSION = 1; |
8 | our $VERSION = 1; |
9 | |
9 | |
10 | our $on_link = sub { }; |
10 | our $goto_document = sub { }; |
11 | our %wiki; |
11 | our %wiki; |
12 | |
12 | |
13 | my $MA_BEG = "\x{fcd0}"; |
13 | my $MA_BEG = "\x{fcd0}"; |
14 | my $MA_SEP = "\x{fcd1}"; |
14 | my $MA_SEP = "\x{fcd1}"; |
15 | my $MA_END = "\x{fcd2}"; |
15 | my $MA_END = "\x{fcd2}"; |
16 | |
16 | |
17 | *wiki = Storable::retrieve CFPlus::find_rcfile "docwiki.pst"; |
17 | *wiki = Storable::retrieve CFPlus::find_rcfile "docwiki.pst"; |
|
|
18 | |
|
|
19 | sub goto_document($) { |
|
|
20 | $goto_document->(split /\//, $_[0]); |
|
|
21 | } |
18 | |
22 | |
19 | sub is_prefix_of($@) { |
23 | sub is_prefix_of($@) { |
20 | my ($node, @path) = @_; |
24 | my ($node, @path) = @_; |
21 | |
25 | |
22 | return 1 unless @path; |
26 | return 1 unless @path; |
… | |
… | |
45 | } |
49 | } |
46 | |
50 | |
47 | sub full_path_of($) { |
51 | sub full_path_of($) { |
48 | my ($node) = @_; |
52 | my ($node) = @_; |
49 | |
53 | |
50 | my $path = $node->{kw}[0]; |
54 | my @path; |
51 | $path = "$node->{kw}[0]/$path" while $node = $node->{parent}; |
55 | |
|
|
56 | # skip toplevel hierarchy pod/, because its not a document |
|
|
57 | while ($node->{parent}) { |
|
|
58 | unshift @path, $node; |
|
|
59 | $node = $node->{parent}; |
|
|
60 | } |
|
|
61 | |
52 | $path |
62 | @path |
|
|
63 | } |
|
|
64 | |
|
|
65 | sub full_path($) { |
|
|
66 | join "/", map $_->{kw}[0], &full_path_of |
53 | } |
67 | } |
54 | |
68 | |
55 | sub section_of($) { |
69 | sub section_of($) { |
56 | my ($node) = @_; |
70 | my ($node) = @_; |
57 | |
71 | |
… | |
… | |
136 | size => 0.8, |
150 | size => 0.8, |
137 | can_hover => 1, |
151 | can_hover => 1, |
138 | can_events => 1, |
152 | can_events => 1, |
139 | padding_x => 0, |
153 | padding_x => 0, |
140 | padding_y => 0, |
154 | padding_y => 0, |
|
|
155 | tooltip => "Go to <i>" . (CFPlus::asxml $link) . "</i>", |
141 | on_button_up => sub { |
156 | on_button_up => sub { |
142 | $on_link->(split /\//, $link); |
157 | goto_document $link; |
143 | }; |
158 | }; |
144 | |
159 | |
145 | "\x{fffc}" |
160 | "\x{fffc}" |
146 | }, |
161 | }, |
147 | ); |
162 | ); |