--- deliantra/Deliantra-Client/DC/Pod.pm 2006/08/13 18:48:56 1.7
+++ deliantra/Deliantra-Client/DC/Pod.pm 2006/08/14 18:46:07 1.12
@@ -1,11 +1,13 @@
package CFPlus::Pod;
use strict;
+use utf8;
use Storable;
our $VERSION = 1;
+our $goto_document = sub { };
our %wiki;
my $MA_BEG = "\x{fcd0}";
@@ -14,12 +16,16 @@
*wiki = Storable::retrieve CFPlus::find_rcfile "docwiki.pst";
+sub goto_document($) {
+ $goto_document->(split /\//, $_[0]);
+}
+
sub is_prefix_of($@) {
my ($node, @path) = @_;
return 1 unless @path;
- my $kw = pop @path;
+ my $kw = lc pop @path;
$node = $node->{parent}
or return 0;
@@ -32,7 +38,7 @@
return unless @path;
- my $kw = pop @path;
+ my $kw = lc pop @path;
# TODO: make sure results are unique
@@ -45,9 +51,19 @@
sub full_path_of($) {
my ($node) = @_;
- my $path = $node->{kw}[0];
- $path = "$node->{kw}[0]/$path" while $node = $node->{parent};
- $path
+ my @path;
+
+ # skip toplevel hierarchy pod/, because its not a document
+ while ($node->{parent}) {
+ unshift @path, $node;
+ $node = $node->{parent};
+ }
+
+ @path
+}
+
+sub full_path($) {
+ join "/", map $_->{kw}[0], &full_path_of
}
sub section_of($) {
@@ -98,9 +114,9 @@
"img"
},
link => sub {
- my ($par, $link) = @_;
+ my ($par, $text, $link) = @_;
- "" . (CFPlus::asxml $link) . ""
+ "↺" . (CFPlus::asxml $text) . ""
},
);
@@ -120,16 +136,29 @@
my %as_paragraphs = (
image => sub {
- my ($par, $path) = @_;
+ my ($par, $path, $flags) = @_;
- push @{ $par->{widget} }, new CFPlus::UI::Image path => $path;
+ push @{ $par->{widget} }, new CFPlus::UI::Image path => $path,
+ $flags & 1 ? (max_h => $::FONTSIZE * 0.8) : ();
- "\x{FFFC}"
+ "\x{fffc}"
},
link => sub {
- my ($par, $link) = @_;
+ my ($par, $text, $link) = @_;
+
+ push @{ $par->{widget} }, new CFPlus::UI::Label
+ markup => "↺" . (CFPlus::asxml $text) . "",
+ fontsize => 0.8,
+ can_hover => 1,
+ can_events => 1,
+ padding_x => 0,
+ padding_y => 0,
+ tooltip => "Go to " . (CFPlus::asxml $link) . "",
+ on_button_up => sub {
+ goto_document $link;
+ };
- "" . (CFPlus::asxml $link) . ""
+ "\x{fffc}"
},
);