[Bio] / FigWebServices / link.cgi Repository:
ViewVC logotype

View of /FigWebServices/link.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (download) (annotate)
Mon Oct 2 03:03:08 2006 UTC (13 years, 2 months ago) by parrello
Branch: MAIN
Added to support external linking to protein pages.

#!/usr/bin/perl -w

=head1 Protein Page Link

This is a simple redirection script that takes a feature name as input and opens
the appropriate protein page. The feature name can be a FIG feature ID or
an external alias.

This script supports the following CGI query parameters.

=over 4

=item id

ID of the desired feature. This can be a FIG ID or an alias.

=item Trace

Trace level and list of trace modules to turn on, space-delimited. The
default is no tracing.

=item TF

C<1> to trace to a file, C<0> to trace to the web page itself. The
default is C<0>.

=back

=cut

use strict;
use Tracer;
use CGI;
use Sprout;
use URI::Escape;

my ($cgi, $varHash) = ScriptSetup();
eval {
    # Get the protein ID.
    my $pegID = $cgi->param('id');
    if (! $pegID) {
        # No protein ID, so we fail.
        Confess("No ID specified.");
    } else {
        # Escape the incoming ID.
        my $protID = uri_escape($pegID);
        # Determine the correct mode (seed or SPROUT).
        my $mode = $cgi->param('SPROUT');
        if (! defined $mode) {
            $mode = ($FIG_Config::sproutDB ? 1 : 0);
        }
        my $url = "protein.cgi?SPROUT=1;prot=$protID;SPROUT=$mode";
        # Redirect to the protein page.
        print $cgi->redirect(-uri => $url);
    }
};
if ($@) {
    # Get the error message.
    my $errorMessage = $@;
    Trace("Script Error: $errorMessage") if T(0);
    # Display the error message. Note that unlike most situations,
    # we have to write a content header. This is because we have a
    # redirection script ratherh than a standard CGI script.
    $varHash->{results} = $cgi->h3("Script Error: $errorMessage");
    print "CONTENT-TYPE: text/html\n\n";
    ScriptFinish("Simple_tmpl.php", $varHash);
}

1;

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3