Ace::Browser::AceSubs(3pm) | User Contributed Perl Documentation | Ace::Browser::AceSubs(3pm) |
Ace::Browser::AceSubs - Subroutines for AceBrowser
use Ace; use Ace::Browser::AceSubs; use CGI qw(:standard); use CGI::Cookie; my $obj = GetAceObject() || AceNotFound(); PrintTop($obj); print $obj->asHTML; PrintBottom();
Ace::Browser::AceSubs exports a set of routines that are useful for creating search pages and displays for AceBrowser CGI pages. See http://stein.cshl.org/AcePerl/AceBrowser.
The following subroutines are exported by default:
AceError AceMissing AceNotFound Configuration DoRedirect GetAceObject Object2URL ObjectLink OpenDatabase PrintTop PrintBottom Url
The following subroutines are exported if explicitly requested:
AceAddCookie AceInit AceHeader AceMultipleChoices AceRedirect DB_Name Footer Header ResolveUrl Style Toggle TypeSelector
To load the default subroutines load the module with:
use Ace::Browser::AceSubs;
To bring in a set of optionally routines, load the module with:
use Ace::Browser::AceSubs qw(AceInit AceRedirect);
To bring in all the default subroutines, plus some of the optional ones:
use Ace::Browser::AceSubs qw(:DEFAULT AceInit AceRedirect);
There are two main types of AceBrowser scripts:
To retrieve the parameters, use the CGI.pm param() method:
$name = param('name'); $class = param('class');
The following sections describe the exported subroutines.
The three arguments are:
$symbol The keyword or query string the user was searching on, undef if none. $report The symbolic name of the current display, or undef if none. $objects An array reference containing the Ace objects in question.
This subroutine is not exported by default.
$obj = GetAceObject(); if ($obj->CDS) { my $protein = $obj->Corresponding_protein; AceRedirect('protein',$protein); }
AceRedirect must be called b<before> PrintTop() or AceHeader(). It invokes exit(), so it will not return.
This subroutine is not exported by default. It differs from DoRedirect() in that it displays a message to the user for two seconds before it generates the new page. It also allows the display to be set explicitly, rather than determined automatically by the AceBrowser system.
This function is not exported by default.
If a single object is found, the function returns it as the function result. If no objects are found, it returns undef. If more than one object is found, the function invokes AceMultipleChoices() and exits the script.
It is also possible to pass Object2URL an object name and class, in the case that an AceDB object isn't available.
The return value is a URL.
This function is used extensively to create cross references between Ace::Objects on AceBrowser pages.
Example:
my $author = $db->fetch(Author => 'Sulston JE'); print ObjectLink($author,$author->Full_name);
This will print out a link to a page that will display details on the author page. The text of the link will be the value of the Full_name tag.
This function is not exported by default.
Call it with one or more arguments. The arguments are:
$object An AceDB object. The navigation bar and title will be customized for the object. $class If no AceDB object is available, then you can pass a string containing the AceDB class that this page is designed to display. $title A title to use for the HTML page and the first level-one header. If not provided, a generic title "Report for Object" is generated. @html_headers Additional HTML headers to pass to the the CGI.pm start_html.
{ -src => '/ace/stylesheets/current_stylesheet.css' }
This hash is suitable for passing to the -style argument of CGI.pm's start_html() function, or for use as an additional header in PrintTop(). You may add locally-defined stylesheet elements to the hash before calling start_html(). See the pic script for an example of how this is done this.
This function is not exported by default.
A typical call is:
$url = ResolveUrl('/cgi-bin/ace/generic/tree','name=fred;class=Author');
This function is not exported by default.
Toggle() can be used to manage multiple collapsible HTML sections, but each section must have a unique name. The required first argument is the section name. Optional arguments are:
$label The text of the generated link, for example "sequence" $object_count The number of objects that opening the section will reveal $add_plural If true, the label will be pluralized when appropriate $add_count If true, the label will have the object count added when appropriate
In a scalar context, Toggle() prints the link HTML and returns a boolean flag. A true result indicates that the section is expanded and should be generated. A false result indicates that the section is collapsed.
In a list context, Toggle() returns a two-element list. The first element is the HTML link that expands and contracts the section. The second element is a boolean that indicates whether the section is currently open or closed.
This example indicates typical usage:
my $sequence = GetAceObject(); print "sequence name = ",$sequence,"\n"; print "sequence clone = ",$sequence->Clone,"\n"; if (Toggle('dna','Sequence DNA')) { print $sequence->asDNA; }
An alternative way to do the same thing:
my $sequence = GetAceObject(); print "sequence name = ",$sequence,"\n"; print "sequence clone = ",$sequence->Clone,"\n"; my ($link,$open) = Toggle('dna','Sequence DNA'); print $link; print $sequence->asDNA if $open;
When hard-coding relative URLs into AceBrowser scripts, it is important to pass them through Url(). The reason for this is that AceBrowser may need to attach the database name to the URL in order to identify it.
Example:
my $url = Url('../sequence_dump',"name=$name;long_dump=yes"); print a({-href=>$url},'Dump this sequence');
Please report them.
Ace::Object, Ace::Browser::SiteDefs, Ace::Browsr::SearchSubs, the README.ACEBROWSER file.
Lincoln Stein <lstein@cshl.org>.
Copyright (c) 2001 Cold Spring Harbor Laboratory
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See DISCLAIMER.txt for disclaimers of warranty.
2021-02-20 | perl v5.32.1 |