/[gnump3d]/gnump3d/lib/gnump3d/plugins/random.pm
ViewVC logotype

Diff of /gnump3d/lib/gnump3d/plugins/random.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by skx, Wed Aug 20 19:57:16 2003 UTC revision 1.3 by skx, Sun Oct 12 00:59:57 2003 UTC
# Line 81  sub handlePath( ) Line 81  sub handlePath( )
81      else      else
82      {      {
83          #          #
84            #  We weren't, so we must choose some random tracks and
85            # present them to the user for inspection.
86            #
87    
88            #
89          # The HTML template we use for output.          # The HTML template we use for output.
90          # And the text we build up to send.          # And the text we build up to send.
91          #          #
# Line 121  sub handlePath( ) Line 126  sub handlePath( )
126          my @rand = ( );          my @rand = ( );
127          while( $count > 0 )          while( $count > 0 )
128          {          {
129              #              # Pick a random line from the database.
             # Pick a random track.  
130              my $r = $lines[ rand @lines ];              my $r = $lines[ rand @lines ];
131    
132              if ( $r =~ /([^\t]+)\t(.*)/ )              if ( $r =~ /([^\t]+)\t(.*)/ )
133              {              {
134                    # Save the filename.
135                  push @rand, $1;                  push @rand, $1;
136                  $count -= 1;                  $count -= 1;
137              }              }
# Line 159  sub handlePath( ) Line 164  sub handlePath( )
164              #              #
165              my $tag = &getSongDisplay( $file, $format );              my $tag = &getSongDisplay( $file, $format );
166    
             print "$file -> $tag\n";  
   
167              #              #
168              # Get the containing directory.              # Get the containing directory.
169              my $dir = $file;              my $dir = $file;
# Line 170  sub handlePath( ) Line 173  sub handlePath( )
173              }              }
174    
175              my $link = $dir;              my $link = $dir;
176              $link = &urlEncode( $link );              $link    = &urlEncode( $link );
177              $link .= $suffix;              $link   .= $suffix;
178    
179              if ($dir =~ /(.*)\/(.*)$/ )              if ($dir =~ /(.*)\/(.*)$/ )
180              {              {
181                  $dir = $1;                  $dir = $1;
182                    $dir = &urlEncode( $dir );
183              }              }
184              $dir = &urlEncode( $dir );  
185              $output .= "<li>[<a href='$dir/'>+</a>] &middot; <a href='$link'>$tag</a></li>\n";              # Add the entry to the output.
186                $output .= "<li>[<a href=\"$dir/\" title=\"Visit the directory containing this track.\">+</a>] &middot; <a href=\"$link\">$tag</a></li>\n";
187    
188          }          }
189          $output .= "</ul>\n";          $output .= "</ul>\n";
190    
191          #          #
192          #  Add a hidden form to contain the selections.          #  Add a hidden form to contain the selections.
193          #          #
194          my $form = "<table><tr><td><form action='/random/play' method='get'>\n";          my $form = "<table><tr><td><form action=\"/random/play\" method=\"get\">\n";
195    
196          $count = 0;          $count = 0;
197          foreach my $file ( @rand )          foreach my $file ( @rand )
# Line 198  sub handlePath( ) Line 204  sub handlePath( )
204              # Escape the link to the songs.              # Escape the link to the songs.
205              $file = &urlEncode( $file );              $file = &urlEncode( $file );
206    
207              $form .= "<input type='hidden' name='track$count'  value='$file'>\n";              $form .= "<input type=\"hidden\" name=\"track$count\"  value=\"$file\">\n";
208              $count ++;              $count ++;
209          }          }
210          $form .= "<input type='Submit' name='submit' value='Play'>\n";          $form .= "<input type=\"submit\" name=\"submit\" value=\"Play\">\n";
211          $form .= "</form></td>\n";          $form .= "</form></td>\n";
212    
213    
# Line 220  sub handlePath( ) Line 226  sub handlePath( )
226          $form   .= "<option value=\"40\">40</option>\n";          $form   .= "<option value=\"40\">40</option>\n";
227          $form   .= "<option value=\"50\">50</option>\n";          $form   .= "<option value=\"50\">50</option>\n";
228          $form   .= "</select>\n";          $form   .= "</select>\n";
229          $form   .= "<input type='Submit' name='submit' value='Try Again'>\n";          $form   .= "<input type=\"submit\" name=\"submit\" value=\"Try Again\">\n";
230          $form   .= "</form></td></tr></table>\n";          $form   .= "</form></td></tr></table>\n";
231          $output .= $form;          $output .= $form;
232    
# Line 297  sub handlePlaylist( ) Line 303  sub handlePlaylist( )
303    
304      #      #
305      # If we have songs      # If we have songs
306        #
307      if ( ($#songs+1) > 0 )      if ( ($#songs+1) > 0 )
308      {      {
309          # Send playlist header.          # Send playlist header.
# Line 322  sub handlePlaylist( ) Line 329  sub handlePlaylist( )
329          close( $data );          close( $data );
330          exit;          exit;
331      }      }
332      else  
333      {      # Send error
334          # Send error      my $header   = &getHTTPHeader( 200, "text/html" );
335          my $header   = &getHTTPHeader( 200, "text/html" );      &sendData( $data, $header );
336          &sendData( $data, $header );      my $text = &getErrorPage( $ARGUMENTS{'theme'},
337          my $text = &getErrorPage( $ARGUMENTS{'theme'},                                "Error - No tracks sent." );
338                                    "Error - No tracks sent." );      &sendData( $data, $text );
339          &sendData( $data, $text );      close( $data );
340          close( $data );      exit;
         exit;  
     }  
341  }  }

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26