[Codestriker-commits] CVS update: codestriker/template/en/default viewtopic.html.tmpl
Brought to you by:
sits
|
From: <si...@us...> - 2005-03-01 10:13:13
|
Created Codestriker topic at: http://codestriker.sourceforge.net/cgi-bin/codestriker.pl?topic=335572&action=view User: sits Date: 05/03/01 02:12:54 Modified: lib/Codestriker/Action EditComment.pm ListProjects.pm SubmitNewComment.pm ViewTopic.pm ViewTopicComments.pm ViewTopicFile.pm ViewTopicInfo.pm ViewTopicProperties.pm lib/Codestriker/Http Render.pm Response.pm template/en/default viewtopic.html.tmpl Log: Moved the javascript+css code for comment handling into Response.pm, so that comments are properly handled on all screens. Index: EditComment.pm =================================================================== RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Action/EditComment.pm,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- EditComment.pm 30 Jan 2005 00:47:55 -0000 1.12 +++ EditComment.pm 1 Mar 2005 10:12:49 -0000 1.13 @@ -31,6 +31,7 @@ my $mode = $http_input->get('mode'); my $tabwidth = $http_input->get('tabwidth'); my $anchor = $http_input->get('a'); + my $fview = $http_input->get('fview'); # Retrieve the appropriate topic details. my $topic = Codestriker::Model::Topic->new($topicid); @@ -42,7 +43,7 @@ my @document_description = split /\n/, $topic->{description}; # Display the header of this page. - $http_response->generate_header(topic=>$topicid, + $http_response->generate_header(topic=>$topic, topic_title=>"Edit Comment: $topic->{title}", email=>$email, mode=>$mode, @@ -55,7 +56,8 @@ $vars->{'topic_title'} = $topic->{title}; Codestriker::Action::ViewTopic::ProcessTopicHeader($vars, $topic, - $url_builder); + $url_builder, $fview, + $tabwidth, 1, 0); my $view_topic_url = $url_builder->view_url($topicid, $line, $mode); my $view_comments_url = $url_builder->view_comments_url($topicid); Index: ListProjects.pm =================================================================== RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Action/ListProjects.pm,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- ListProjects.pm 30 Sep 2004 10:27:09 -0000 1.9 +++ ListProjects.pm 1 Mar 2005 10:12:49 -0000 1.10 @@ -30,7 +30,7 @@ my @projects = Codestriker::Model::Project->list(); # Display the data, with each prject title linked to edit project page. - $http_response->generate_header(topic => -1, topic_title=>"Project List", + $http_response->generate_header(topic_title=>"Project List", reload=>0, cache=>0); # Create the hash for the template variables. Index: SubmitNewComment.pm =================================================================== RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Action/SubmitNewComment.pm,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- SubmitNewComment.pm 17 Aug 2004 22:28:46 -0000 1.5 +++ SubmitNewComment.pm 1 Mar 2005 10:12:49 -0000 1.6 @@ -77,7 +77,7 @@ # up will ensure the next editing topic will be handled quickly, as the # overhead of bringing up a new window is removed. my $reload = $query->param('submit') eq 'Submit+Refresh' ? 1 : 0; - $http_response->generate_header(topic=>$topicid, + $http_response->generate_header(topic=>$topic, topic_title=>"Comment Submitted: $topic->{title}", email=>$email, repository=>$topic->{repository}, Index: ViewTopic.pm =================================================================== RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Action/ViewTopic.pm,v retrieving revision 1.50 retrieving revision 1.51 diff -u -r1.50 -r1.51 --- ViewTopic.pm 21 Feb 2005 11:25:05 -0000 1.50 +++ ViewTopic.pm 1 Mar 2005 10:12:49 -0000 1.51 @@ -66,9 +66,11 @@ # Retrieve line-by-line versions of the data and description. my @document_description = split /\n/, $topic->{description}; - $http_response->generate_header(topic=>$topic->{topicid}, + $http_response->generate_header(topic=>$topic, + comments=>\@comments, topic_title=>"Topic Text: $topic->{title}", mode=>$mode, tabwidth=>$tabwidth, + fview=>$fview, reload=>0, cache=>1); # Retrieve the repository object, if repository functionality is enabled. @@ -214,7 +216,6 @@ my @document = split /\n/, $topic->{document}; my $max_digit_width = length($#document+1); - # Build the render which will be used to build this page. my $render = Codestriker::Http::Render->new($query, $url_builder, 1, $max_digit_width, $topicid, @@ -262,49 +263,51 @@ Codestriker::TopicListeners::Manager::topic_viewed($email, $topic); } -# This function is used by all of the three topic pages to fill out the -# common template items that are required by all three. -sub ProcessTopicHeader($$$) { +# This function is used by all of the view topic tabs to fill out the +# common template items that are required by all, in addition to the view +# topic file action. +sub ProcessTopicHeader +{ my ($vars, $topic, $url_builder) = @_; # Handle the links in the three topic tabs. $vars->{'view_topicinfo_url'} = $url_builder->view_topicinfo_url($topic->{topicid}); $vars->{'view_topic_url'} = - ## XX mode, last param + ## XX mode, last param $url_builder->view_url($topic->{topicid}, -1, 0); - + $vars->{'view_comments_url'} = $url_builder->view_comments_url($topic->{topicid}); - + $vars->{'view_topic_properties_url'} = $url_builder->view_topic_properties_url($topic->{topicid}); - + my @project_ids = ($topic->{project_id}); $vars->{'list_open_topics_in_project_url'} = $url_builder->list_topics_url("", "", "", "", "", "", "", "", "", "", [ 0 ], \@project_ids); - + # Retrieve the comment details for this topic. my @comments = $topic->read_comments(); - + # Obtains how many comments there are, and the internal link to them. $vars->{'number_comments'} = $#comments + 1; - + # Obtain the view topic summary information, the title, bugs it relates # to, and who the participants are. $vars->{'title'} = $topic->{title}; - + $vars->{'author'} = Codestriker->filter_email($topic->{author}); $vars->{'document_creation_time'} = - Codestriker->format_timestamp($topic->{creation_ts}); - + Codestriker->format_timestamp($topic->{creation_ts}); + $vars->{'topic'} = $topic->{topicid}; - + $vars->{'reviewers'} = Codestriker->filter_email($topic->{reviewers}); $vars->{'cc'} = Codestriker->filter_email($topic->{cc}); - + # Get the list of obsoleted topics. my @obsoleted_topics = (); foreach my $id (@{ $topic->{obsoleted_topics} }) { @@ -315,7 +318,7 @@ push @obsoleted_topics, $entry; } $vars->{'obsoleted_topics'} = \@obsoleted_topics; - + # Get the list of topics this has been obsoleted by. my @obsoleted_by = (); foreach my $id (@{ $topic->{obsoleted_by} }) { @@ -328,4 +331,5 @@ $vars->{'obsoleted_by'} = \@obsoleted_by; } + 1; Index: ViewTopicComments.pm =================================================================== RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Action/ViewTopicComments.pm,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- ViewTopicComments.pm 2 Feb 2005 22:18:48 -0000 1.13 +++ ViewTopicComments.pm 1 Mar 2005 10:12:49 -0000 1.14 @@ -25,6 +25,8 @@ my $topicid = $http_input->get('topic'); my $email = $http_input->get('email'); my $mode = $http_input->get('mode'); + my $fview = $http_input->get('fview'); + my $tabwidth = $http_input->get('tabwidth'); my $feedback = $http_input->get('feedback'); my $show_context = $http_input->get('scontext'); my $show_comments_from_user = $http_input->get('sauthor'); @@ -49,9 +51,11 @@ my $topic = Codestriker::Model::Topic->new($topicid); # Display the data, with each topic title linked to the view topic screen. - $http_response->generate_header(topic=>$topicid, + $http_response->generate_header(topic=>$topic, + comments=>\@comments, topic_title=>"Topic Comments: $topic->{title}", - email=>$email, + email=>$email, fview=>$fview, + tabwidth=>$tabwidth, reload=>0, cache=>0); # Create the hash for the template variables. Index: ViewTopicFile.pm =================================================================== RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Action/ViewTopicFile.pm,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- ViewTopicFile.pm 22 Feb 2005 22:06:10 -0000 1.10 +++ ViewTopicFile.pm 1 Mar 2005 10:12:49 -0000 1.11 @@ -94,9 +94,12 @@ "View File: $filename v$revision"; } - $http_response->generate_header(topic=>$topicid, topic_title=>$title, + $http_response->generate_header(topic=>$topic, + comments=>\@comments, + topic_title=>$title, mode=>$mode, tabwidth=>$tabwidth, + fview=>$fview, repository=>$topic->{repository}, reload=>0, cache=>1); @@ -198,7 +201,7 @@ $$maxline_length_ref = 0; for (my $i = 1; $i <= $#$data_array_ref; $i++) { $$data_array_ref[$i] = - Codestriker::Http::Render->tabadjust($tabwidth, + Codestriker::Http::Render::tabadjust($tabwidth, $$data_array_ref[$i], 0); my $line_length = length($$data_array_ref[$i]); if ($line_length > $$maxline_length_ref) { Index: ViewTopicInfo.pm =================================================================== RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Action/ViewTopicInfo.pm,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- ViewTopicInfo.pm 17 Aug 2004 22:28:46 -0000 1.11 +++ ViewTopicInfo.pm 1 Mar 2005 10:12:49 -0000 1.12 @@ -43,7 +43,7 @@ # Retrieve the comment details for this topic. my @topic_comments = $topic->read_comments(); - $http_response->generate_header(topic=>$topic->{topicid}, + $http_response->generate_header(topic=>$topic, topic_title=>"Topic Properties: $topic->{title}", mode=>$mode, tabwidth=>$tabwidth, reload=>0, cache=>1); Index: ViewTopicProperties.pm =================================================================== RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Action/ViewTopicProperties.pm,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- ViewTopicProperties.pm 30 Sep 2004 22:58:04 -0000 1.11 +++ ViewTopicProperties.pm 1 Mar 2005 10:12:49 -0000 1.12 @@ -40,7 +40,7 @@ # Retrieve the comment details for this topic. my @topic_comments = $topic->read_comments(); - $http_response->generate_header(topic=>$topic->{topicid}, + $http_response->generate_header(topic=>$topic, topic_title=>"Topic Properties: $topic->{title}", mode=>$mode, tabwidth=>$tabwidth, reload=>0, cache=>1); Index: Render.pm =================================================================== RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Http/Render.pm,v retrieving revision 1.48 retrieving revision 1.49 diff -u -r1.48 -r1.49 --- Render.pm 24 Feb 2005 09:41:01 -0000 1.48 +++ Render.pm 1 Mar 2005 10:12:52 -0000 1.49 @@ -151,114 +151,6 @@ $self->{idhashref} = undef; } - # Precompute the overlib HTML for each comment location. - print "\n<script language=\"JavaScript\" type=\"text/javascript\">\n"; - - # Add the reviewers for the review here. - print " var topic_reviewers = '" . $topic_obj->{reviewers} . "';\n"; - - # Now record all the comments made so far in the topic. - print " var comment_text = new Array();\n"; - print " var comment_hash = new Array();\n"; - print " var comment_metrics = new Array();\n"; - my $index; - for ($index = 0; $index <= $#comment_locations; $index++) { - - # Contains the overlib HTML text. - my $overlib_html = ""; - - # Determine what the previous and next comment locations are. - my $previous = undef; - my $next = undef; - if ($index > 0) { - $previous = $comment_locations[$index-1]; - } - if ($index < $#comment_locations) { - $next = $comment_locations[$index+1]; - } - - # Compute the previous link if required. - my $current_url = $self->{query}->self_url(); - if (defined $previous && $previous =~ /^(\-?\d+)|\-?\d+|\d+$/o) { - my $previous_fview = $1; - my $previous_index = $index - 1; - my $previous_url = $current_url; - $previous_url =~ s/fview=\d+/fview=$previous_fview/o if $self->{fview} != -1; - $previous_url .= '#' . $previous; - $overlib_html .= "<a href=\"javascript:window.location=\\'$previous_url\\'; "; - if ($self->{fview} == -1 || $self->{fview} == $previous_fview) { - $overlib_html .= "overlib(comment_text[$previous_index], STICKY, DRAGGABLE, ALTCUT, FIXX, getEltPageLeft(getElt(\\'c$previous_index\\')), FIXY, getEltPageTop(getElt(\\'c$previous_index\\'))); "; -} - $overlib_html .= "void(0);\">Previous</a>"; - } - - # Compute the next link if required. - if (defined $next && $next =~ /^(\-?\d+)|\-?\d+|\d+$/o) { - my $next_fview = $1; - $overlib_html .= " | " if defined $previous; - my $next_index = $index + 1; - my $next_url = $current_url; - $next_url =~ s/fview=\d+/fview=$next_fview/o if $self->{fview} != -1; - $next_url .= '#' . $next; - $overlib_html .= "<a href=\"javascript:window.location=\\'$next_url\\'; "; - if ($self->{fview} == -1 || $self->{fview} == $next_fview) { - $overlib_html .= "overlib(comment_text[$next_index], STICKY, DRAGGABLE, ALTCUT, FIXX, getEltPageLeft(getElt(\\'c$next_index\\')), FIXY, getEltPageTop(getElt(\\'c$next_index\\'))); "; - } - $overlib_html .= "void(0);\">Next</a>"; - } - if (defined $previous || defined $next) { - $overlib_html .= " | "; - } - - # Add an add comment link. - my $key = $comment_locations[$index]; - $key =~ /^(\-?\d+)\|(\-?\d+)\|(\d+)$/o; - $overlib_html .= "<a href=\"javascript:add_comment_tooltip($1,$2,$3)" . - "; void(0);\">Add Comment</a> | "; - - # Add a close link. - $overlib_html .= "<a href=\"javascript:hideElt(getElt(\\'overDiv\\')); void(0);\">Close</a><p>"; - - # Create the actual comment text. - my @comments = @{ $comment_hash{$key} }; - - for (my $i = 0; $i <= $#comments; $i++) { - my $comment = $comments[$i]; - - # Need to format the data appropriately for HTML display. - my $data = HTML::Entities::encode($comment->{data}); - $data =~ s/\'/\\\'/mg; - $data =~ s/\n/<br>/mg; - $data =~ s/ / /mg; - $data = tabadjust($self, $self->{tabwidth}, $data, 1); - - # Show each comment with the author and date in bold. - $overlib_html .= "<b>Comment from $comment->{author} "; - $overlib_html .= "on $comment->{date}</b><br>"; - $overlib_html .= "$data"; - - # Add a newline at the end if required. - if ($i < $#comments && - substr($overlib_html, length($overlib_html)-4, 4) ne '<br>') { - $overlib_html .= '<br>'; - } - } - - print " comment_text[$index] = '$overlib_html';\n"; - print " comment_hash['" . $comment_locations[$index] . "'] = $index;\n"; - - # Store the current metric values for this comment. - print " comment_metrics[$index] = new Array();\n"; - my $comment_metrics = $comments[0]->{metrics}; - foreach my $metric_config (@{ $Codestriker::comment_state_metrics }) { - my $value = $comment_metrics->{$metric_config->{name}}; - $value = "" unless defined $value; - print " comment_metrics[${index}]['" . - $metric_config->{name} . "'] = '" . $value . "';\n"; - } - - } - print "</script>\n"; bless $self, $type; } @@ -718,7 +610,7 @@ } # Replace spaces and tabs with the appropriate number of 's. - $data = tabadjust($self, $self->{tabwidth}, $data, 1); + $data = tabadjust($self->{tabwidth}, $data, 1); if ($self->{brmode} == $Codestriker::LINE_BREAK_ASSIST_MODE) { $data =~ s/^(\s+)/my $sp='';for(my $i=0;$i<length($1);$i++){$sp.=' '}$sp;/ge; } @@ -947,7 +839,7 @@ my $data = HTML::Entities::encode($comment->{data}); $data =~ s/\n/<br>/mg; $data =~ s/ / /mg; - $data = tabadjust($self, $self->{tabwidth}, $data, 1); + $data = tabadjust($self->{tabwidth}, $data, 1); # Show each comment with the author and date in bold. $digest .= "<b>Comment from $comment->{author} "; @@ -1247,7 +1139,7 @@ my $query = $self->{query}; # Replace the line data with spaces. - my $newdata = tabadjust($self, $self->{tabwidth}, $data, 0); + my $newdata = tabadjust($self->{tabwidth}, $data, 0); if ($class ne "") { # Add the appropriate number of spaces to justify the data to a length @@ -1324,8 +1216,8 @@ # Replace the passed in string with the correct number of spaces, for # alignment purposes. -sub tabadjust ($$$$) { - my ($type, $tabwidth, $input, $htmlmode) = @_; +sub tabadjust ($$$) { + my ($tabwidth, $input, $htmlmode) = @_; $_ = $input; if ($htmlmode) { Index: Response.pm =================================================================== RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Http/Response.pm,v retrieving revision 1.28 retrieving revision 1.29 diff -u -r1.28 -r1.29 --- Response.pm 24 Feb 2005 09:41:01 -0000 1.28 +++ Response.pm 1 Mar 2005 10:12:53 -0000 1.29 @@ -38,7 +38,7 @@ my ($self, %params) = @_; - my $topic = ""; + my $topic = undef; my $topic_title = ""; my $email = ""; my $reviewers = ""; @@ -49,6 +49,7 @@ my $projectid = ""; my $load_anchor = ""; my $topicsort = ""; + my $fview = -1; my $reload = $params{reload}; my $cache = $params{cache}; @@ -65,8 +66,8 @@ $topic = $params{topic}; $topic_title = $params{topic_title}; - # Some screens don't have $topic set, if so, set it to a blank value. - $topic = "" if ! defined($topic); + # Set the fview parameter if defined. + $fview = $params{fview} if defined $params{fview}; # Set the cookie in the HTTP header for the $email, $cc, $reviewers and # $tabwidth parameters. @@ -239,7 +240,7 @@ print "<script type=\"text/javascript\">\n"; print " var cs_load_anchor = '$load_anchor';\n"; print " var cs_reload = $reload;\n"; - print " var cs_topicid = $topic;\n" if defined $topic && $topic ne ""; + print " var cs_topicid = $topic->{topicid};\n" if defined $topic; print " var cs_email = '$email';\n" if defined $email; # Now output all of the comment metric information. @@ -261,16 +262,167 @@ } $i++; } - - print "</script>\n"; + # Output the comment declarations if the $comments array is defined. + my $comments = $params{comments}; + if (defined $comments) { + print generate_comment_declarations($topic, $comments, $query, + $fview, $tabwidth); + } + # Write an HTML comment indicating if response was sent compressed or not. $self->{output_compressed} = $output_compressed; print "\n<!-- Source was" . (!$output_compressed ? " not" : "") . " sent compressed. -->\n"; } +# Return the javascript code necessary to support viewing/modification of +# comments. +sub generate_comment_declarations +{ + my ($topic, $comments, $query, $fview, $tabwidth) = @_; + + # The output html to return. + my $html = ""; + + # Build a hash from filenumber|fileline|new -> comment array, to record + # what comments are associated with what locations. Also record the + # order of comment_locations found. + my %comment_hash = (); + my @comment_locations = (); + for (my $i = 0; $i <= $#$comments; $i++) { + my $comment = $$comments[$i]; + my $key = $comment->{filenumber} . "|" . $comment->{fileline} . "|" . + $comment->{filenew}; + if (! exists $comment_hash{$key}) { + push @comment_locations, $key; + } + push @{ $comment_hash{$key} }, $comment; + } + + # Precompute the overlib HTML for each comment location. + $html .= "\n<script language=\"JavaScript\" type=\"text/javascript\">\n"; + + # Add the reviewers for the review here. + $html .= " var topic_reviewers = '" . $topic->{reviewers} . "';\n"; + + # Now record all the comments made so far in the topic. + $html .= " var comment_text = new Array();\n"; + $html .= " var comment_hash = new Array();\n"; + $html .= " var comment_metrics = new Array();\n"; + my $index; + for ($index = 0; $index <= $#comment_locations; $index++) { + + # Contains the overlib HTML text. + my $overlib_html = ""; + + # Determine what the previous and next comment locations are. + my $previous = undef; + my $next = undef; + if ($index > 0) { + $previous = $comment_locations[$index-1]; + } + if ($index < $#comment_locations) { + $next = $comment_locations[$index+1]; + } + + # Compute the previous link if required. + my $current_url = $query->self_url(); + if (defined $previous && $previous =~ /^(\-?\d+)|\-?\d+|\d+$/o) { + my $previous_fview = $1; + my $previous_index = $index - 1; + my $previous_url = $current_url; + $previous_url =~ s/fview=\d+/fview=$previous_fview/o if $fview != -1; + $previous_url .= '#' . $previous; + $overlib_html .= "<a href=\"javascript:window.location=\\'$previous_url\\'; "; + if ($fview == -1 || $fview == $previous_fview) { + $overlib_html .= "overlib(comment_text[$previous_index], STICKY, DRAGGABLE, ALTCUT, FIXX, getEltPageLeft(getElt(\\'c$previous_index\\')), FIXY, getEltPageTop(getElt(\\'c$previous_index\\'))); "; +} + $overlib_html .= "void(0);\">Previous</a>"; + } + + # Compute the next link if required. + if (defined $next && $next =~ /^(\-?\d+)|\-?\d+|\d+$/o) { + my $next_fview = $1; + $overlib_html .= " | " if defined $previous; + my $next_index = $index + 1; + my $next_url = $current_url; + $next_url =~ s/fview=\d+/fview=$next_fview/o if $fview != -1; + $next_url .= '#' . $next; + $overlib_html .= "<a href=\"javascript:window.location=\\'$next_url\\'; "; + if ($fview == -1 || $fview == $next_fview) { + $overlib_html .= "overlib(comment_text[$next_index], STICKY, DRAGGABLE, ALTCUT, FIXX, getEltPageLeft(getElt(\\'c$next_index\\')), FIXY, getEltPageTop(getElt(\\'c$next_index\\'))); "; + } + $overlib_html .= "void(0);\">Next</a>"; + } + if (defined $previous || defined $next) { + $overlib_html .= " | "; + } + + # Add an add comment link. + my $key = $comment_locations[$index]; + $key =~ /^(\-?\d+)\|(\-?\d+)\|(\d+)$/o; + $overlib_html .= "<a href=\"javascript:add_comment_tooltip($1,$2,$3)" . + "; void(0);\">Add Comment</a> | "; + + # Add a close link. + $overlib_html .= "<a href=\"javascript:hideElt(getElt(\\'overDiv\\')); void(0);\">Close</a><p>"; + + # Create the actual comment text. + my @comments = @{ $comment_hash{$key} }; + + for (my $i = 0; $i <= $#comments; $i++) { + my $comment = $comments[$i]; + + # Need to format the data appropriately for HTML display. + my $data = HTML::Entities::encode($comment->{data}); + $data =~ s/\'/\\\'/mg; + $data =~ s/\n/<br>/mg; + $data =~ s/ / /mg; + $data = Codestriker::Http::Render::tabadjust($tabwidth, $data, 1); + + # Show each comment with the author and date in bold. + $overlib_html .= "<b>Comment from $comment->{author} "; + $overlib_html .= "on $comment->{date}</b><br>"; + $overlib_html .= "$data"; + + # Add a newline at the end if required. + if ($i < $#comments && + substr($overlib_html, length($overlib_html)-4, 4) ne '<br>') { + $overlib_html .= '<br>'; + } + } + + $html .= " comment_text[$index] = '$overlib_html';\n"; + $html .= " comment_hash['" . $comment_locations[$index] . + "'] = $index;\n"; + + # Store the current metric values for this comment. + $html .= " comment_metrics[$index] = new Array();\n"; + my $comment_metrics = $comments[0]->{metrics}; + foreach my $metric_config (@{ $Codestriker::comment_state_metrics }) { + my $value = $comment_metrics->{$metric_config->{name}}; + $value = "" unless defined $value; + $html .= " comment_metrics[${index}]['" . + $metric_config->{name} . "'] = '" . $value . "';\n"; + } + + } + $html .= "</script>\n"; + + # Now declare the CSS positional elements for each comment location. + $html .= "<style type=\"text/css\">\n"; + for (my $i = 0; $i <= $#$comments; $i++) { + $html .= '#c' . $i . ' { position: absolute; }' . "\n"; + } + $html .= "</style>\n"; + + # Return the generated HTML. + return $html; +} + + # Close the response, which only requires work if we are dealing with # compressed streams. sub generate_footer($) { Index: viewtopic.html.tmpl =================================================================== RCS file: /cvsroot/codestriker/codestriker/template/en/default/viewtopic.html.tmpl,v retrieving revision 1.31 retrieving revision 1.32 diff -u -r1.31 -r1.32 --- viewtopic.html.tmpl 21 Feb 2005 11:25:31 -0000 1.31 +++ viewtopic.html.tmpl 1 Mar 2005 10:12:53 -0000 1.32 @@ -1,13 +1,3 @@ -[%# Output the style elements for the comments which exist #%] - -<style type="text/css"> -[% SET index = 0 %] -[% WHILE index < number_comments %] -#c[% index %] { position: absolute; } -[% index = index + 1 %] -[% END %] -</style> - </head> <body charset="ISO-8859-1" vlink="purple" onload="view_topic_on_load_handler();" bgcolor="#eeeeee" link="blue"> |