IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 23, 2016, 9:17:22 AM (10 years ago)
Author:
bills
Message:

committing several data store scripts that have been in production
for quite a while but never committed to the source tree

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/DataStoreServer/web/cgi/dsgetindex

    r25366 r39658  
    2020my $PS_EXIT_CONFIG_ERROR = 3;
    2121my $PS_EXIT_DATA_ERROR = 5;
     22
     23my $redirect_root_to_pstamp = 0;
    2224
    2325my $uri = shift;
     
    132134            print @$stdout_buf;
    133135        }
     136        $error_code = 0 if !defined $error_code;
    134137    } else {
    135138        if (0 && $html_mode) {
     
    199202
    200203        # return link
    201         print a({-href=>"./index.txt"}, "Text Version");
     204        if (!$redirect_root_to_pstamp || $program ne "dsrootindex") {
     205            print a({-href=>"./index.txt"}, "Text Version");
     206        }
    202207
    203208        if ($#path >= 1) {
    204             print "&nbsp&nbsp&nbsp&nbsp\n";
    205 
    206             my $up = join('/', @path[0..$#path-1]);
    207             print a({-href=>".."}, "Up to $up");
    208 
     209            # including the up links in the data store display causes
     210            # wget -r to follow them up which makes a mess
     211            # Turn them off if the user agent looks like wget
     212            my $display_up_links = (lc($ENV{HTTP_USER_AGENT}) =~ /wget/) ? 0 : 1;
     213            if ($display_up_links) {
     214                print "&nbsp&nbsp&nbsp&nbsp\n";
     215                my $up = join('/', @path[0..$#path-1]);
     216                if ($redirect_root_to_pstamp and $program eq "dsprodindex") {
     217                    print a({-href=>"http://pstamp.ipp.ifa.hawaii.edu/dsroot.php"}, "Up to $up");
     218                } elsif ($program eq 'dsrootindex') {
     219                    # no up link in dsroot
     220                } else {
     221                    print a({-href=>".."}, "Up to $up");
     222                }
     223            }
    209224        }
    210225        print "</p>\n";
     
    244259    if ($nolink) {
    245260       print $toks[0];
    246     }
    247 
    248     else {
    249                 # assumes id is always first field
    250             my $wpath = "./$toks[0]";
    251 
    252             # if this is a file request, use a download cgi
    253             if ($wpath =~ /\.fits\s*$/) {
    254                 # This doesn't work through the proxy
    255                 # The /ds-cgi gets tried on alala
    256                 #    $wpath = '/ds-cgi/dsfits.cgi?'.substr($wpath, 4); # strip' /ds/'
     261    } else {
     262         # First column is link to an entity down one level in data store (product, fileset, file)
     263         # assumes id is always first field
     264         my $wpath = "./$toks[0]";
     265
     266         # if this is a file request, use a download cgi
     267         my $fits = 0;
     268         if ($wpath =~ /\.fits\s*$/) {
     269             # This doesn't work through the proxy
     270             # The /ds-cgi gets tried on alala
     271             #    $wpath = '/ds-cgi/dsfits.cgi?'.substr($wpath, 4); # strip' /ds/'
     272             $fits = 1;
     273         }
     274
     275        if ($fits) {
     276            print a({-href=>$wpath, -type=>'image/x-fits'}, $toks[0]);
     277        } else {
     278            print a({-href=>$wpath}, $toks[0]);
     279        }
     280
     281        if ($program eq 'dsrootindex') {
     282            # for root listing make most recent fileset a link as well unless there are no filesets
     283            my $fileset = $toks[1];
     284            $fileset =~ s/^\s+//;
     285            $fileset =~ s/\s+$//;
     286            if ($fileset ne 'none') {
     287                print "</$celltag>";
     288                print "<$celltag>";
     289                # drop the product from the list of tokens
     290                my $product = shift @toks;
     291                # elmiminate any whitesapace
     292                $product =~ s/^\s+//;
     293                $product =~ s/\s+$//;
     294                print a({-href=>"./$product/$fileset"}, $fileset);
    257295            }
    258 
    259         print a({-href=>$wpath, -type=>'image/x-fits'}, $toks[0]);
    260     }
     296        }
     297    }
     298    shift @toks;
    261299
    262300    print "</$celltag>";
    263301
    264     foreach my $val (@toks[1..$#toks]) {
     302    # foreach my $val (@toks[1..$#toks]) {
     303    foreach my $val (@toks) {
    265304                print "<$celltag>";
    266305                print $val;
Note: See TracChangeset for help on using the changeset viewer.