#!usr/local/bin/perl use CGI::Carp qw(fatalsToBrowser); use lib "cgi"; use Nova; require "cgi-lib.pl"; ReadParse(); # Harvest chapter, scene, and page number information from image ID. # #--------------------------------------------------------------------# $id = $in{'id'}; unless (-e "../htdocs/pages/nova$id.jpg") { print "Location: ../archive.html\n\n"; exit; } $chapter = substr($id, 0, 2); $scene = substr($id, 2, 2); $page = substr($id, 4, 2); my $nova = new Nova; # Deduce previous/next page IDs and create links. # #-------------------------------------------------# my $prev = $nova->prev_page($id); my $next = $nova->next_page($id); $prev_link = $prev ? qq|\< previous| : qq|beginning of story!|; $next_link = $next ? qq|\> next| : qq|\> archive|; # Create sidebar link listing. # #------------------------------# my $scenes = @{$nova->{chapters}}[$chapter]->{scene_pages}; my $total_scenes = scalar(@$scenes) - 1; my $total_pages = @{$scenes}[$scene]; my $top = sprintf("

Chapter %d:

\n", $chapter); my @link_list = ($top); # Iterate through all scenes. for (1..$total_scenes) { unless ($_ == $scene) { # Not current scene; just print a link to the first page of the scene. my $link = sprintf("%02d%02d01", $chapter, $_); push(@link_list, qq|

\> Scene $_

\n|); } else { push(@link_list, " Scene $_
\n"); for (1..$total_pages) { unless ($_ == $page) { my $link = sprintf("%02d%02d%02d", $chapter, $scene, $_); push(@link_list, qq| Page $_
\n|); } else { push(@link_list, " Page $_
\n"); } } } } my $link = sprintf("archive.cgi?chapter=%d&scene=%d", $chapter, $scene); push (@link_list, qq|

Chapter
Archive

|); # Begin printing out the page. # #------------------------------# my $niceName = $nova->niceName($id); print "Content-type: text/html\n\n"; print < $niceName
$prev_link $next_link
HEADER print $_ foreach @link_list; print qq|
$prev_link $next_link
$niceName
  < home
|; exit; # End of view.cgi.