[Bio] / FigKernelPackages / HTML.pm Repository:
ViewVC logotype

Diff of /FigKernelPackages/HTML.pm

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

revision 1.35, Sun Mar 13 00:55:21 2005 UTC revision 1.41, Thu Apr 28 20:56:37 2005 UTC
# Line 5  Line 5 
5  use Data::Dumper;  use Data::Dumper;
6  use LWP::UserAgent;  use LWP::UserAgent;
7  use LWP::Simple;  use LWP::Simple;
8    use URI::Escape;  # uri_escape()
9  use URI::URL;  use URI::URL;
10  use HTTP::Request::Common;  use HTTP::Request::Common;
11  use POSIX;  use POSIX;
# Line 65  Line 66 
66  sub show_page {  sub show_page {
67      #warn "SHOWPAGE: cgi=", Dumper(@_);      #warn "SHOWPAGE: cgi=", Dumper(@_);
68      shift if UNIVERSAL::isa($_[0],__PACKAGE__);      shift if UNIVERSAL::isa($_[0],__PACKAGE__);
69      my($cgi,$html,$no_home, $alt_header, $css) = @_;      my($cgi,$html,$no_home, $alt_header, $css, $javasrc) = @_;
70      my $i;      my $i;
71    
72    
# Line 77  Line 78 
78      #     $css is a reference to a hash. The key is the name of the CSS sheet and the value is the URL of that sheet. Note the usual rules about relative css urls      #     $css is a reference to a hash. The key is the name of the CSS sheet and the value is the URL of that sheet. Note the usual rules about relative css urls
79      #               the sheet named "Default" is considered to be the default style sheet, and if this is not set it points at $FIG_Config::HTML/css/default.css      #               the sheet named "Default" is considered to be the default style sheet, and if this is not set it points at $FIG_Config::HTML/css/default.css
80      #               the sheet named "Sans Serif" is considered to the the first alternate, and if this is not set it points at $FIG_Config::HTML/css/sanserif.css      #               the sheet named "Sans Serif" is considered to the the first alternate, and if this is not set it points at $FIG_Config::HTML/css/sanserif.css
81        #     $javasrc is a reference to an array of URLs to javascripts to be included (e.g. "/FIG/Html/css/styleswitcher.js")
82      #      #
83      # Find the HTML header      # Find the HTML header
84      #      #
# Line 90  Line 91 
91    
92      my $user = $cgi->param('user') || "";      my $user = $cgi->param('user') || "";
93      my @html_hdr;      my @html_hdr;
94      if ($alt_header)      if ($alt_header && ref($alt_header) eq "ARRAY")
95      {      {
96         @html_hdr = @$alt_header;         @html_hdr = @$alt_header;
97      }      }
# Line 250  Line 251 
251    
252      # RAE:      # RAE:
253      # Add css here      # Add css here
254      # Note that at the moment I define these two sheets here. I think this should be moved out, but I want to try it and see what happens      # Note that at the moment I define these two sheets here. I think this should
255      # css has the format      # be moved out, but I want to try it and see what happens.  css has the format:
256        #
257      # <link rel='stylesheet' title='default' href='/css/default.css' type='text/css'>      # <link rel='stylesheet' title='default' href='/css/default.css' type='text/css'>
258    
259      # convert the default key to the right case. and eliminate dups      # convert the default key to the right case. and eliminate dups
# Line 271  Line 273 
273      foreach my $k (keys %$css)      foreach my $k (keys %$css)
274      {      {
275         next if (lc($k) eq "default" || lc($k) eq "sans serif");         next if (lc($k) eq "default" || lc($k) eq "sans serif");
276         $csstext .= "<link rel='stylesheet' title='$k' href='".$css->{$k}."' type='text/css'>\n";         $csstext .= "<link rel='alternate stylesheet' title='$k' href='".$css->{$k}."' type='text/css'>\n";
277        }
278    
279    
280        # RAE: also added support for external javascripts here.
281        # we are cluttering the HTML code with all the javascripts when they could easily be in external files
282        # this solution allows us to source other files
283    
284        # $javasrc must be a ref to an array with urls (absolute or relative) to the javascripts
285        if ($javasrc && ref($javasrc) eq "ARRAY") {
286         foreach my $script (@$javasrc) {
287          $csstext .= "<script src=\"$script\" type=\"text/javascript\"></script>\n";
288      }      }
289        }
290    
291    
292    
293      splice( @$html, $head_end_line, 1, "$csstext</HEAD>\n" );  # note here I am replacing the </head> line. Could be bad...? But it doesn't increment everything else.      splice( @$html, $head_end_line, 1, "$csstext</HEAD>\n" );  # note here I am replacing the </head> line. Could be bad...? But it doesn't increment everything else.
294    
295      #      #
# Line 374  Line 391 
391          splice( @$html, $i, 0, @tags );          splice( @$html, $i, 0, @tags );
392      }      }
393    
394      print join "\n", @$html;      # RAE the chomp will return any new lines at the ends of elements in the array,
395        # and then we can join  with a "\n". This is because somethings put newlines in,
396        # and others don't. This should make nicer looking html
397        #
398        # chomp(@$html);
399        # print join "\n", @$html;
400        #
401        # Apparently the above still breaks things. This is the correct code:
402    
403        print @$html;
404  }  }
405    
406  sub make_table {  sub make_table {
# Line 408  Line 434 
434    
435      $tag = "td" unless $tag;      $tag = "td" unless $tag;
436      my $endtag=$tag;      my $endtag=$tag;
437      # RAE modified this so that you can pass in a reference to an array where the first element is the data to  
438      # display and the second element is optional things like colspan and align. Note that in this case you need to include the td      # RAE modified this so that you can pass in a reference to an array where
439        # the first element is the data to display and the second element is optional
440        # things like colspan and align. Note that in this case you need to include the td
441      # use something like ["some data to appear", "td colspan=4 bgcolor=gray"]      # use something like ["some data to appear", "td colspan=4 bgcolor=gray"]
442    
443      if (ref($x) eq "ARRAY") {($x, $tag)=@$x; if ($tag =~ /td/) {$endtag = "td"}}      if (ref($x) eq "ARRAY") {($x, $tag)=@$x; if ($tag =~ /td/) {$endtag = "td"}}
444    
445      if ($x =~ /^\@([^:]+)\:(.*)$/)      if ($x =~ /^\@([^:]+)\:(.*)$/)
# Line 521  Line 550 
550      return $family;      return $family;
551  }  }
552    
 use URI::Escape;  
553    
554  sub get_html {  sub get_html {
555      shift if UNIVERSAL::isa($_[0],__PACKAGE__);      shift if UNIVERSAL::isa($_[0],__PACKAGE__);
# Line 852  Line 880 
880      my $user = $cgi->param('user');      my $user = $cgi->param('user');
881      if ($user)      if ($user)
882      {      {
883          $sub_link = "<a href=./subsys.cgi?ssa_name=$sub&request=show_ssa&user=$user>$sub</a>";          my $esc_sub = uri_escape( $sub );
884            $sub_link = "<a href=./subsys.cgi?ssa_name=$esc_sub&request=show_ssa&user=$user>$sub</a>";
885      }      }
886      else      else
887      {      {

Legend:
Removed from v.1.35  
changed lines
  Added in v.1.41

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3