#!/usr/local/bin/perl # display_issue.cgi # Display an issue filed for SV-BC ########################################################################### # # This program # # Valid Inputs: Issue number to be displayed # ########################################################################### ########################################################################### # External Dependancies ########################################################################### BEGIN { push(@INC,'/u/seedlings/public_html/cgi-bin/lib')}; use CGI; # Form Handling Module require "./lib/site-config.ph"; require "./lib/cgi-lib.pl"; #require "Site_Config.ph"; # Program Defaults #require "HTML-lib.pl"; # General Purpose HTML routines ########################################################################### # Globals ########################################################################### $APP = $ENV{'SCRIPT_NAME'}; # Name of this program $Client = new CGI; # CGI Form Object ########################################################################### # # M A I N # ########################################################################### MAIN: { if (defined($Client->param('issue_num'))) { $issue_num = $Client->param('issue_num'); &set_release_variables; &create_report; } else { print &PrintHeader, "No data has been submitted. Please reload the form " . "and resubmit your request or notify " . "" . "$CGI_OWNER that a problem has occurred.\n"; } } ################################################################################ # # SUBROUTINE: set_release_variables # # ARGUMENTS: # # GLOBAL VARIABLES USED: %input, $URL_BASE, $DIR_BASE # # RETURNS: $url, $path, $body, $issue_number # # ABSTRACT: Sets $url, $path, $issue_number, $body global variables for # the write_file subroutine. These global variables could be # used for other purposes. # ################################################################################ sub set_release_variables{ $url = $URL_BASE . "/issues"; $path = $DIR_BASE . "/issues"; $body = ""; } ########################################################################### # # Subroutine: create_report # # Description: This routine will read the issue_description, format the # report using HTML formatting, and print to stdout. # # Inputs: # # Return Values: # # Globals Read: $issue_num # # Globals Written: # ########################################################################### # Implementation Notes: # # Each page is composed by putting 6 elements together # 1. page_start # 2. banner # 3. the real stuff # 4. footer # 5. symon footer # 6. page_end # # The output is constructed entirely in memory first in the String $Page # and output when completely constructed. # ########################################################################### sub create_report { # Local Variable Declarations my($Page) =' 'x 50000; # String which will contain all the HTML # I have preallocated 50000 bytes for # run-time efficiency my($Page_Title) = "SV-BC Issue " . $issue_num; # # Create the front matter. # print $Client->header; $Page = $Client->start_html( -title=>$Page_Title, -author=>"SV-BC Page Creation", -BGCOLOR=>'White'); $Page .= "
\n"; $Page .= "\n"; # # Find the last proposal # $file = $path . "/" . $issue_num . "_issue.html"; open(FILE, "<" . $file) || &CgiError($!); $proposal_count = 0; $assignee = "None"; while () { if (/^

Proposal description:<\/b>

(.*)<\/pre>/) {
	  $issue_proposal = $1;
   	  $proposal_count = $proposal_count + 1;
      } elsif (/^Issue Status:<\/b> <\/td>(.*)<\/td><\/tr>/) {
          $issue_status = $1;
      } elsif (/^Issue Type:<\/b> <\/td>(.*)<\/td><\/tr>/) {
          $issue_type = $1;
      } elsif (/^Assignee:<\/b> <\/td>(.*)<\/td><\/tr>/) {
          $assignee = $1;
      }
  }
  close(FILE);

  #
  # Here is the body
  #
  open(FILE, "<" . $file) || &CgiError($!);
  $todo_status = 1;
  $todo_type = 1;
  while () {
      if (/^Issue Status:<\/b> <\/td>(.*)<\/td><\/tr>/) {
          if ($todo_status) {
	      $Page .= "Issue Status:";
  	      $Page .= "<\/td>\n";
	      $Page .= "Password:\n";
	      $Page .= "\n";
	      $Page .= "<\/tr>\n";
          }
	  $todo_status = 0;
      } elsif (/^Issue Type:<\/b> <\/td>(.*)<\/td><\/tr>/) {
          if ($todo_type) {
	      $Page .= "Issue Type:";
  	      $Page .= "<\/td><\/tr>\n";
          }
	  $todo_type = 0;
	  $Page .= "Assignee:\n";
	  $Page .= "\n";
	  $Page .= "<\/tr>\n";
      } elsif (/^

Problem description:<\/b>

(.*)<\/pre>/) {
	  $_ =~ s/\\n/\n/g;
	  $Page .= $_;
	  $Page .= "Current Proposal:\n";
	  if ($proposal_count == 0) {
  	      $Page .= "

\n"; } else { $issue_proposal =~ s/\\n/\n/g; $issue_proposal =~ s/^

\[(.*)\]<\/b>

 //g;
	      $issue_proposal =~ s/<\/pre>$//g;
  	      $Page .= "

\n"; } $Page .= "

Commentary History:\n"; } elsif (/^

Proposal description:<\/b>

(.*)<\/pre>/) {
	  $line = $1;
	  $line =~ s/\\n/\n/g;
	  $Page .= $line;
      } elsif (/^

Commentary description:<\/b>

(.*)<\/pre>/) {
	  $line = $1;
	  $line =~ s/\\n/\n/g;
	  $Page .= $line;
      } elsif (/^Submission Date:<\/b> <\/td>(.*)<\/td><\/tr>/) {
	  $Page .= $_;
      } elsif (/^Submittor's Email:<\/b> <\/td>(.*)<\/td><\/tr>/) {
	  $Page .= $_;
      } elsif (/^SV-BC Issue (.*)<\/h2>/) {
	  $Page .= $_;
      }
  } 

  $Page .= "

Add Commentary:\n"; $Page .= "

\n"; $Page .= "

\n"; $Page .= "\n"; $Page .= "

\n"; $Page .= "\n"; # # And finally, print the page # print $Page; }
Email Address (Required):