chiark / gitweb /
WIP route fixes etc.
[ypp-sc-tools.web-live.git] / yarrg / CommodsWeb.pm
index 96dde357c9bb40c31d3f7b399848ce9002d1167e..d09331d4c54e40ae91861d3abbf080187caba06a 100644 (file)
@@ -36,6 +36,7 @@ use Commods;
 use CommodsDatabase;
 
 our $self_url;
+our $base_url;
 
 BEGIN {
     use Exporter ();
@@ -43,7 +44,7 @@ BEGIN {
     $VERSION     = 1.00;
     @ISA         = qw(Exporter);
     @EXPORT      = qw($dbh &db_setocean &db_connect &db_doall
-                     $self_url);
+                     &ocean_list);
     %EXPORT_TAGS = ( );
 
     @EXPORT_OK   = qw();
@@ -56,6 +57,22 @@ for my $dir (@INC) {
     }
 }
 
-$self_url= 'http://'.$ENV{'SERVER_NAME'}.$ENV{'SCRIPT_NAME'}.$ENV{'PATH_INFO'};
+my @ocean_list;
+
+sub ocean_list () {
+    if (!@ocean_list) {
+       my $fn= "$db_datadir/master-info.txt";
+       my $f= new IO::File $fn or die $!;
+       my @r;
+       while (<$f>) {
+           next unless m/^ocean\s+(\S.*\S)\s*$/;
+           push @r, $1;
+       }
+       $f->error and die $!;
+       close $fn;
+       @ocean_list= @r;
+    }
+    return @ocean_list;
+}
 
 1;