[MOBY-guts] biomoby commit
Eddie Kawas
kawas at dev.open-bio.org
Thu Jun 26 20:22:52 UTC 2008
kawas
Thu Jun 26 16:22:52 EDT 2008
Update of /home/repository/moby/moby-live/Perl
In directory dev.open-bio.org:/tmp/cvs-serv22161/Perl
Modified Files:
create_doc.pl
Log Message:
changed the layout of the documentation page
we use jquery now
we use a jquery plugin tree view
instead of a dump of modules, the modules are in a nice little tree that the user can manipulate and view the perldoc
moby-live/Perl create_doc.pl,1.3,1.4
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/create_doc.pl,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- /home/repository/moby/moby-live/Perl/create_doc.pl 2008/02/25 19:28:09 1.3
+++ /home/repository/moby/moby-live/Perl/create_doc.pl 2008/06/26 20:22:52 1.4
@@ -6,6 +6,7 @@
###########################################################
use strict;
use Pod::Html;
+use XML::LibXML;
use Pod::Find qw(pod_find);
use File::Path;
use Pod::Checker;
@@ -31,9 +32,38 @@
# create the index file
@html_files = sort(@html_files);
-my $vars = { 'worklist' => \@html_files,
- 'replace' => sub {my $text = shift; $text =~ s/\//::/g; return $text;}
-};
+
+# create the root element
+my $doc = XML::LibXML::Document->new();
+my $root = &create_root_node();
+$doc->setDocumentElement($root);
+$root->appendChild(&create_collapsable_node("MOBY"));
+foreach my $string (@html_files) {
+ my @parts = split(/\//, $string);
+ my $last_element = undef;
+ my $href = "./docs/html/MOBY-Server/lib/$string.html";
+ for (my $i = 0; $i < $#parts + 1; $i++) {
+ my $part = $parts[$i];
+ #my $e = $doc->getElementById($part);
+ my $e = &getById($part);
+ # skip if $e exists already and we are not at a leaf
+ next if $e and $i != $#parts ;#or $part eq 'MOBY');
+ if ($i == $#parts) {
+ # create leaf
+ my $leaf = &create_leaf_node($part, $href);
+ my $parent_id = $parts[$i - 1];
+ &getById($parent_id)->appendChild($leaf);
+ #$doc->getElementById($parent_id)->appendChild($leaf);
+ } else {
+ # create folder
+ my $folder = &create_collapsable_node($part);
+ my $parent_id = $parts[$i - 1];
+ &getById($parent_id)->appendChild($folder);
+ #$doc->getElementsById($parent_id)->appendChild($folder);
+ }
+ }
+}
+my $vars = { 'tree' => $doc->toStringHTML() };
my $template = Template->new( {} );
@@ -81,3 +111,53 @@
}
}
}
+
+sub getById {
+ my ($id) = @_;
+ foreach my $n ($doc->getElementsByTagName('*')) {
+ next unless $n->getAttribute('id');
+ return $n if $n->getAttribute('id') eq $id;
+ }
+ return undef;
+}
+
+sub create_root_node () {
+ #my $ul = $doc->createElement( "ul" );
+ my $ul = XML::LibXML::Element->new( "ul" );
+ $ul->setAttribute("id","browser");
+ $ul->setAttribute("class","filetree treeview");
+ return $ul;
+}
+
+sub create_collapsable_node {
+ my ($name) = @_;
+ my $li = XML::LibXML::Element->new("li");
+ $li->setAttribute("class","closed");
+ my $div = XML::LibXML::Element->new("div");
+ #$div->setAttribute("class","hitarea collapsable-hitarea");
+ my $span = XML::LibXML::Element->new("span");
+ $span->setAttribute("class","folder");
+ $span->appendText($name);
+ my $ul = XML::LibXML::Element->new("ul");
+ $ul->setAttribute("id","$name");
+
+ #$li->appendChild($div);
+ $li->appendChild($span);
+ $li->appendChild($ul);
+ return $li;
+}
+
+sub create_leaf_node {
+ my ($name, $href) = @_;
+ my $li = XML::LibXML::Element->new("li");
+ $li->setAttribute("class","last");
+ my $span = XML::LibXML::Element->new("span");
+ $span->setAttribute("class","file");
+ my $a = XML::LibXML::Element->new("a");
+ $a->appendText($name);
+ $a->setAttribute("target","_blank");
+ $a->setAttribute("href","$href");
+ $span->appendChild($a);
+ $li->appendChild($span);
+ return $li;
+}
More information about the MOBY-guts
mailing list