Alien-GvaScript
view release on metacpan or search on metacpan
GvaScript_Builder.pm view on Meta::CPAN
# destination for wiki files
my $dir = "blib/wiki";
-d $dir or mkdir $dir or die "mkdir $dir: $!";
# list of source files
my @podfiles = glob ("lib/Alien/GvaScript/*.pod");
# convert each file
foreach my $podfile (@podfiles) {
my $parser = Pod::Simple::Wiki->new('googlecode');
$podfile =~ m[^lib/Alien/GvaScript/(.*)\.pod];
my $wikifile = "$dir/$1.wiki";
open my $fh, ">$wikifile" or die "open >$wikifile: $!";
print STDERR "converting $podfile ==> $wikifile\n";
$parser->output_fh($fh);
$parser->parse_file($podfile);
}
return 1;
}
1;
#======================================================================
package Pod::POM::View::HTML::GvaScript;
#======================================================================
use strict;
use warnings;
use base 'Pod::POM::View::HTML';
sub _title_to_id {
my $title = shift;
$title =~ s/<.*?>//g; # no tags
$title =~ s/\W+/_/g;
return $title;
}
sub view_pod {
my ($self, $pod) = @_;
my $doc_title = ($pod->head1)[0]->content->present($self);
$doc_title =~ s/<.*?>//g; # no tags
my ($name, $description) = split /\s+-\s+/, $doc_title;
my $content = $pod->content->present($self);
my $toc = $self->make_toc($pod, 0);
return <<__EOHTML__
<html>
<head>
<script src="../../lib/Alien/GvaScript/lib/prototype.js"></script>
<script src="../../lib/Alien/GvaScript/lib/GvaScript.js"></script>
<link href="GvaScript_doc.css" rel="stylesheet" type="text/css">
<script>
document.observe('dom:loaded', function() { new GvaScript.TreeNavigator('TN_tree'); });
function jumpto_href(event) {
var label = event.controller.label(event.target);
if (label && label.tagName == "A") {
label.focus();
return Event.stopNone;
}
}
</script>
</head>
<body>
<div id='TN_tree'>
<div class="TN_node">
<h1 class="TN_label">$name</h1>
<div class="TN_content">
<p><em>$description</em></p>
<div class="TN_node" onPing="jumpto_href">
<h3 class="TN_label">Table of contents</h3>
<div class="TN_content">
$toc
</div>
</div>
<hr/>
</div>
</div>
$content
</div>
</body>
</html>
__EOHTML__
}
# installing same method for view_head1, view_head2, etc.
BEGIN {
for my $num (1..6) {
no strict 'refs';
*{"view_head$num"} = sub {
my ($self, $item) = @_;
my $title = $item->title->present($self);
my $id = _title_to_id($title);
my $content = $item->content->present($self);
my $h_num = $num + 1;
return <<__EOHTML__
<div class="TN_node" id="$id">
<h$h_num class="TN_label">$title</h$h_num>
<div class="TN_content">
$content
</div>
</div>
__EOHTML__
}
}
}
sub make_toc_orig {
my ($self, $item, $level) = @_;
( run in 0.710 second using v1.01-cache-2.11-cpan-119454b85a5 )