Thread: [Codestriker-commits] CVS update: codestriker/template/en/default viewtopiccomments.html.tmpl
                
                Brought to you by:
                
                    sits
                    
                
            
            
        
        
        
    | 
      
      
      From: <si...@us...> - 2005-01-30 00:48:33
       | 
| Created Codestriker topic at: http://codestriker.sourceforge.net/cgi-bin/codestriker.pl?topic=1715961&action=view User: sits Date: 05/01/29 16:48:13 Modified: . CHANGELOG lib/Codestriker/Action EditComment.pm SubmitEditCommentsState.pm ViewTopicComments.pm lib/Codestriker/Http Render.pm lib/Codestriker/Model Comment.pm lib/Codestriker/TopicListeners Email.pm template/en/default viewtopiccomments.html.tmpl Log: * It is now possible to create a comment associated with a specific file, or the topic itself, rather than being associated with a specific line. This allows reviewers to create file-level or topic-level comments. Index: CHANGELOG =================================================================== RCS file: /cvsroot/codestriker/codestriker/CHANGELOG,v retrieving revision 1.160 retrieving revision 1.161 diff -u -r1.160 -r1.161 --- CHANGELOG 28 Jan 2005 00:59:04 -0000 1.160 +++ CHANGELOG 30 Jan 2005 00:47:51 -0000 1.161 @@ -3,6 +3,11 @@ Version 1.8.6 +* It is now possible to create a comment associated with a specific + file, or the topic itself, rather than being associated with a + specific line. This allows reviewers to create file-level or + topic-level comments. + * Extra options are now available in the codestriker.conf file in regards to when emails are sent out. It is now possible to control whether emails are sent to the topic author and/or the comment Index: EditComment.pm =================================================================== RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Action/EditComment.pm,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- EditComment.pm 23 Jan 2005 21:05:28 -0000 1.11 +++ EditComment.pm 30 Jan 2005 00:47:55 -0000 1.12 @@ -41,10 +41,6 @@ # Retrieve line-by-line versions of the description. my @document_description = split /\n/, $topic->{description}; - # Retrieve the diff hunk for this file and line number. - my $delta = Codestriker::Model::Delta->get_delta($topicid, $fn, - $line, $new); - # Display the header of this page. $http_response->generate_header(topic=>$topicid, topic_title=>"Edit Comment: $topic->{title}", @@ -80,7 +76,14 @@ $dec_context, $anchor, ""); $vars->{'inc_context_url'} = $inc_context_url; $vars->{'dec_context_url'} = $dec_context_url; - $vars->{'context'} = $query->pre( + $vars->{'context'} = ""; + if ($line != -1) { + # Retrieve the context for a comment made against a specific line. + my $delta = Codestriker::Model::Delta->get_delta($topicid, $fn, + $line, $new); + + $vars->{'context'} = + $query->pre( Codestriker::Http::Render->get_context($line, $context, 1, $delta->{old_linenumber}, @@ -88,6 +91,7 @@ $delta->{text}, $new)) . $query->p . "\n"; + } # Display the comments which have been made for this line number # in chronological order. Index: SubmitEditCommentsState.pm =================================================================== RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Action/SubmitEditCommentsState.pm,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- SubmitEditCommentsState.pm 17 Aug 2004 22:28:46 -0000 1.5 +++ SubmitEditCommentsState.pm 30 Jan 2005 00:48:08 -0000 1.6 @@ -51,7 +51,7 @@ foreach my $metric (@{$Codestriker::comment_state_metrics}) { my $metric_name = $metric->{name}; my $prefix = "comment_state_metric\\|$metric_name"; - if ($param_name =~ /^($prefix\|\d+\|\d+\|\d+)\|(\d+)$/) { + if ($param_name =~ /^($prefix\|\-?\d+\|\-?\d+\|\d+)\|(\d+)$/) { $comment_state_version_map{$1} = $2; $comment_state_new_map{$1} = $query->param($param_name); } Index: ViewTopicComments.pm =================================================================== RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Action/ViewTopicComments.pm,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- ViewTopicComments.pm 18 Sep 2004 00:54:19 -0000 1.11 +++ ViewTopicComments.pm 30 Jan 2005 00:48:08 -0000 1.12 @@ -79,8 +79,8 @@ # Go through all the comments and make them into an appropriate form for # displaying. - my $last_filenumber = -1; - my $last_fileline = -1; + my $last_filenumber = -999; + my $last_fileline = -999; my $index = 0; for (my $i = 0; $i <= $#comments; $i++) { my $comment = $comments[$i]; Index: Render.pm =================================================================== RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Http/Render.pm,v retrieving revision 1.39 retrieving revision 1.40 diff -u -r1.39 -r1.40 --- Render.pm 9 Nov 2004 21:01:15 -0000 1.39 +++ Render.pm 30 Jan 2005 00:48:09 -0000 1.40 @@ -368,6 +368,11 @@ . "#$$filenames[$bwd_index]"; } + # Generate the text for the link to add a file-level comment. + my $add_file_level_comment_link = "javascript:eo('$cfi','-1','1')"; + my $add_file_level_comment_text = + $query->a({href=>$add_file_level_comment_link}, "[Add comment]"); + if ($repmatch && $revision ne $Codestriker::ADDED_REVISION && $revision ne $Codestriker::PATCH_REVISION) { # File matches something in the repository. Link it to @@ -398,12 +403,13 @@ $revision_text); } - # Output the "back to contents" link - # and some browsing links for visiting - # the previous and next file (<<, >>). - + # Output the "back to contents" link and some browsing links + # for visiting the previous and next file (<<, >>), in + # addition to the "add file-level comment" link. + print $query->Tr($cell, # = file header $query->td({-class=>'file', align=>'right'}, + "$add_file_level_comment_text ", ($bwd_url ne "" ? $query->a({href=>$bwd_url},"[<<]") : ""), $query->a({href=>$contents_url},"[Top]"), ($fwd_url ne "" ? $query->a({href=>$fwd_url},"[>>]") : ""))); @@ -413,6 +419,7 @@ "File ", $query->a({name=>$filename},$filename)), $query->td({-class=>'file', align=>'right'}, + "$add_file_level_comment_text ", ($bwd_url ne "" ? $query->a({href=>$bwd_url},"[<<]") : ""), $query->a({href=>$contents_url},"[Top]"), ($fwd_url ne "" ? $query->a({href=>$fwd_url},"[>>]") : ""))); @@ -963,7 +970,10 @@ } } print $query->end_table() . "\n"; - $self->print_coloured_table(); + + # Render the "Add comment to topic" link. + print $query->p($query->a({href=>"javascript:eo('-1','-1',1)"}, + "Add comment") . " to topic."); } # Render the initial start of the coloured table, with an empty row setting @@ -997,6 +1007,11 @@ } print "</TABLE>\n"; + + # Render the "Add comment to topic" link. + my $query = $self->{query}; + print $query->p($query->a({href=>"javascript:eo('-1','-1',1)"}, + "Add comment") . " to topic."); } # Display a line for a single file view. Index: Comment.pm =================================================================== RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Model/Comment.pm,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- Comment.pm 28 Sep 2004 22:15:18 -0000 1.18 +++ Comment.pm 30 Jan 2005 00:48:10 -0000 1.19 @@ -143,7 +143,7 @@ $self->{metrics}->{$metric->{name}} = $metric->{value}; } - # get the filename, for the new comment. + # Get the filename, for the new comment. my $get_filename = $dbh->prepare_cached('SELECT filename ' . 'FROM topicfile ' . 'WHERE topicid = ? AND ' . @@ -153,8 +153,8 @@ ( $self->{filename} ) = $get_filename->fetchrow_array(); - $select_commentstate = undef; - $get_filename = undef; + $select_commentstate->finish(); + $get_filename->finish(); Codestriker::DB::DBI->release_connection($dbh, $success); die $dbh->errstr if !$success; @@ -256,6 +256,9 @@ # Obtain a database connection. my $dbh = Codestriker::DB::DBI->get_connection(); + # Determine if we are using Oracle, since it can't handle LEFT OUTER JOINs. + my $using_oracle = $Codestriker::db =~ /^DBI:Oracle/i; + # Store the results into an array of objects. my @results = (); @@ -272,11 +275,17 @@ 'commentstate.id, ' . 'commentstate.creation_ts, ' . 'commentstate.modified_ts ' . - 'FROM commentdata, commentstate, topicfile ' . - 'WHERE commentstate.topicid = ? ' . - 'AND commentstate.id = commentdata.commentstateid ' . - 'AND topicfile.topicid = commentstate.topicid ' . - 'AND topicfile.sequence = commentstate.filenumber ' . + 'FROM commentdata, commentstate ' . + ($using_oracle ? + (', topicfile WHERE commentstate.topicid = ? ' . + 'AND commentstate.id = commentdata.commentstateid ' . + 'AND topicfile.topicid = commentstate.topicid(+) ' . + 'AND topicfile.sequence = commentstate.filenumber(+) ') : + ('LEFT OUTER JOIN topicfile ON ' . + 'commentstate.topicid = topicfile.topicid AND ' . + 'commentstate.filenumber = topicfile.sequence ' . + 'WHERE commentstate.topicid = ? ' . + 'AND commentstate.id = commentdata.commentstateid ')) . 'ORDER BY ' . 'commentstate.filenumber, ' . 'commentstate.fileline, ' . @@ -379,7 +388,7 @@ return @comments; } -# Update the specified metriuc for the specified commentstate. The version +# Update the specified metric for the specified commentstate. The version # parameter indicates what version of the commentstate the user was operating # on. sub change_state { Index: Email.pm =================================================================== RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/TopicListeners/Email.pm,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- Email.pm 21 Dec 2004 22:44:25 -0000 1.13 +++ Email.pm 30 Jan 2005 00:48:11 -0000 1.14 @@ -315,13 +315,6 @@ $comment->{topicid}, "", "", $query->url()); - # Retrieve the diff hunk for this file and line number. - my $delta = Codestriker::Model::Delta->get_delta( - $comment->{topicid}, - $comment->{filenumber}, - $comment->{fileline}, - $comment->{filenew}); - # Retrieve the comment details for this topic. my @comments = $topic->read_comments(); @@ -350,23 +343,41 @@ $bcc = $comment->{author}; } - my $subject = "[REVIEW] Topic \"$topic->{title}\" comment added by $comment->{author}"; + my $subject = "[REVIEW] Topic \"$topic->{title}\" " . + "comment added by $comment->{author}"; my $body = - "$comment->{author} added a comment to Topic \"$topic->{title}\".\n\n" . + "$comment->{author} added a comment to " . + "Topic \"$topic->{title}\".\n\n" . "URL: $edit_url\n\n"; - $body .= "File: " . $delta->{filename} . " line $comment->{fileline}.\n\n"; + if (defined $comment->{filename} && $comment->{filename} ne '') { + $body .= "File: " . $comment->{filename}; + } + + if ($comment->{fileline} != -1) { + $body .= " line $comment->{fileline}.\n\n"; - $body .= "Context:\n$EMAIL_HR\n\n"; - my $email_context = $Codestriker::EMAIL_CONTEXT; - $body .= Codestriker::Http::Render->get_context($comment->{fileline}, + # Only show the context for a comment made against a specific line. + $body .= "Context:\n$EMAIL_HR\n\n"; + my $email_context = $Codestriker::EMAIL_CONTEXT; + + # Retrieve the diff hunk for this file and line number. + my $delta = + Codestriker::Model::Delta->get_delta($comment->{topicid}, + $comment->{filenumber}, + $comment->{fileline}, + $comment->{filenew}); + $body .= + Codestriker::Http::Render->get_context($comment->{fileline}, $email_context, 0, $delta->{old_linenumber}, $delta->{new_linenumber}, $delta->{text}, $comment->{filenew}) . "\n"; - $body .= "$EMAIL_HR\n\n"; + $body .= "$EMAIL_HR"; + } + $body .= "\n\n"; # Now display the comments that have already been submitted. for (my $i = $#comments; $i >= 0; $i--) { Index: viewtopiccomments.html.tmpl =================================================================== RCS file: /cvsroot/codestriker/codestriker/template/en/default/viewtopiccomments.html.tmpl,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- viewtopiccomments.html.tmpl 24 Nov 2004 11:18:09 -0000 1.16 +++ viewtopiccomments.html.tmpl 30 Jan 2005 00:48:12 -0000 1.17 @@ -104,8 +104,8 @@ <TABLE CELLPADDING="1" CELLSPACING="3" BORDER="0" WIDTH="100%"> -[% last_fileline = -1 %] -[% last_filenumber = -1 %] +[% last_fileline = -999 %] +[% last_filenumber = -999 %] [% FOREACH comment = comments %] [% FLUSH IF loop.count() % 10 == 1 %] @@ -115,8 +115,10 @@ [%# Display the comment thread information #%] <TD> [% IF comment.filename != '' %] - <A HREF="[% comment.view_file %]">[% comment.filename %]:[% comment.fileline %]</A> + <A HREF="[% comment.view_file %]">[% comment.filename %][% IF comment.fileline != -1 %]:[% comment.fileline %][% END %]</A> [% IF allow_repositories != 0 %] | <A HREF="[% comment.view_parallel %]">Parallel</A> [% END %] + [% ELSIF comment.fileline == -1 && comment.filenumber == -1 %] + Topic-level [% ELSE %] Line: [% comment.line %] [% END %] | 
| 
      
      
      From: <si...@us...> - 2005-07-27 04:13:36
       | 
| Created Codestriker topic at: http://codestriker.sourceforge.net/cgi-bin/codestriker.pl?topic=4563205&action=view User: sits Date: 05/07/26 21:13:11 Modified: template/en/default viewtopiccomments.html.tmpl Log: Fix formatting issues when displaying comment context Index: viewtopiccomments.html.tmpl =================================================================== RCS file: /cvsroot/codestriker/codestriker/template/en/default/viewtopiccomments.html.tmpl,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- viewtopiccomments.html.tmpl 19 Jun 2005 11:26:52 -0000 1.24 +++ viewtopiccomments.html.tmpl 27 Jul 2005 04:13:09 -0000 1.25 @@ -166,7 +166,7 @@ [% IF comment.context != '' %] <TR CLASS="commentc"> - <TD> [% comment.context %]</TD> + <TD><PRE>[% comment.context %]</PRE></TD> </TR> [% END %] [% last_fileline = comment.fileline %] |