codestriker-commits Mailing List for Codestriker: collaborative code reviewer (Page 7)
Brought to you by:
sits
You can subscribe to this list here.
| 2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(58) |
Dec
(14) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2005 |
Jan
(12) |
Feb
(53) |
Mar
(2) |
Apr
|
May
(36) |
Jun
(59) |
Jul
(69) |
Aug
(47) |
Sep
(54) |
Oct
(45) |
Nov
|
Dec
|
| 2006 |
Jan
(20) |
Feb
(3) |
Mar
|
Apr
(6) |
May
(13) |
Jun
(18) |
Jul
(9) |
Aug
(12) |
Sep
|
Oct
|
Nov
(1) |
Dec
|
| 2007 |
Jan
|
Feb
(1) |
Mar
(4) |
Apr
(1) |
May
(2) |
Jun
(7) |
Jul
(7) |
Aug
(6) |
Sep
(5) |
Oct
(2) |
Nov
(1) |
Dec
|
| 2008 |
Jan
(7) |
Feb
(13) |
Mar
(9) |
Apr
|
May
|
Jun
(50) |
Jul
(22) |
Aug
(58) |
Sep
(28) |
Oct
|
Nov
|
Dec
|
User: sits
Date: 08/06/16 04:32:07
Modified: lib/Codestriker/Http HtmlEntityLineFilter.pm
DeltaRenderer.pm TabToNbspLineFilter.pm
LineBreakLineFilter.pm LineFilter.pm
Added: lib/Codestriker/Http HighlightLineFilter.pm
Log:
Initial refactoring of line filtering, so that it can accept text in chunks rather than line-by-line so that external highlighting can be performed.
Index: HtmlEntityLineFilter.pm
===================================================================
RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Http/HtmlEntityLineFilter.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- HtmlEntityLineFilter.pm 10 Mar 2008 23:18:03 -0000 1.1
+++ HtmlEntityLineFilter.pm 16 Jun 2008 11:32:05 -0000 1.2
@@ -25,9 +25,10 @@
# Escape all HTML entities so that they are displayed correctly.
sub filter {
- my ($self, $text) = @_;
+ my ($self, $delta) = @_;
- return HTML::Entities::encode($text);
+ $delta->{diff_old_lines} = HTML::Entities::encode($delta->{diff_old_lines});
+ $delta->{diff_new_lines} = HTML::Entities::encode($delta->{diff_new_lines});
}
1;
Index: DeltaRenderer.pm
===================================================================
RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Http/DeltaRenderer.pm,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- DeltaRenderer.pm 13 Jun 2008 05:55:12 -0000 1.6
+++ DeltaRenderer.pm 16 Jun 2008 11:32:05 -0000 1.7
@@ -59,10 +59,10 @@
@{$self->{line_filters}} = ();
push @{$self->{line_filters}}, Codestriker::Http::HtmlEntityLineFilter->new();
push @{$self->{line_filters}}, Codestriker::Http::TabToNbspLineFilter->new($tabwidth);
- push @{$self->{line_filters}}, Codestriker::Http::LineBreakLineFilter->new($brmode);
- if (defined $lxr_config) {
- push @{$self->{line_filters}}, Codestriker::Http::LxrLineFilter->new($lxr_config);
- }
+ #push @{$self->{line_filters}}, Codestriker::Http::LineBreakLineFilter->new($brmode);
+ #if (defined $lxr_config) {
+ # push @{$self->{line_filters}}, Codestriker::Http::LxrLineFilter->new($lxr_config);
+ #}
bless $self, $type;
}
@@ -131,9 +131,34 @@
foreach my $delta (@{ $self->{deltas} }) {
- # Now process the text so that the display code has minimal work to do.
- # Also apply appropriate transformations to the line as required.
+ # Split the delta into the left and right side so that text filtering
+ # can be applied.
my @diff_lines = split /\n/, $delta->{text};
+ for (my $i = 0; $i <= $#diff_lines; $i++) {
+ my $data = $diff_lines[$i];
+
+ if ($data =~ /^\-(.*)$/o) {
+ # Line corresponding to old code.
+ $delta->{diff_old_lines} .= "$1\n";
+ } elsif ($data =~ /^\+(.*)$/o) {
+ # Line corresponding to new code.
+ $delta->{diff_new_lines} .= "$1\n";
+ } elsif ($data =~ /^\\/) {
+ # A diff comment such as "No newline at end of file" - ignore it.
+ } else {
+ # Line corresponding to both sides. Strip the first space off
+ # the diff for proper alignment.
+ $data =~ s/^\s//;
+ $delta->{diff_old_lines} .= "$data\n";
+ $delta->{diff_new_lines} .= "$data\n";
+ }
+ }
+
+ # Apply the line filters through the delta text.
+ $self->_apply_line_filters($delta);
+
+ # Now go through the delta text again to determine what lines are to be
+ # rendered.
my $old_linenumber = $delta->{old_linenumber};
my $new_linenumber = $delta->{new_linenumber};
@{$self->{lines}} = ();
@@ -142,25 +167,29 @@
@{$self->{diff_new_lines}} = ();
@{$self->{diff_new_lines_numbers}} = ();
$self->{current_filename} = "";
+ my $old_index = 0;
+ my $new_index = 0;
+ my @filtered_old_lines = split /\n/, $delta->{diff_old_lines};
+ my @filtered_new_lines = split /\n/, $delta->{diff_new_lines};
for (my $i = 0; $i <= $#diff_lines; $i++) {
my $data = $diff_lines[$i];
- if ($data =~ /^\-(.*)$/o) {
+ if ($data =~ /^\-/o) {
# Line corresponding to old code.
- push @{ $self->{diff_old_lines} }, $1;
+ push @{ $self->{diff_old_lines} }, $filtered_old_lines[$old_index++];
push @{ $self->{diff_old_lines_numbers} }, $old_linenumber;
$old_linenumber++;
} elsif ($data =~ /^\+(.*)$/o) {
# Line corresponding to new code.
- push @{ $self->{diff_new_lines} }, $1;
+ push @{ $self->{diff_new_lines} }, $filtered_new_lines[$new_index++];
push @{ $self->{diff_new_lines_numbers} }, $new_linenumber;
$new_linenumber++;
} elsif ($data =~ /^\\/) {
# A diff comment such as "No newline at end of file" - ignore it.
} else {
- # Line corresponding to both sides. Strip the first space off
- # the diff for proper alignment.
- $data =~ s/^\s//;
+ # Line corresponding to both sides.
+ $data = $filtered_old_lines[$old_index++];
+ $new_index++;
# Render what has been currently recorded.
$self->_render_changes($delta->{filenumber});
@@ -173,7 +202,6 @@
# Now render the line which is present on both sides.
my $line = {};
- $data = $self->_apply_line_filters($data);
my $data_class =
$self->{mode} == $Codestriker::COLOURED_MODE ? "n" : "msn";
$line->{old_data} = $data;
@@ -189,7 +217,7 @@
push @{$self->{lines}}, $line;
$old_linenumber++;
$new_linenumber++;
- }
+ }
# Check if the delta corresponds to a new file. This is true
# if there is only one delta for the whole file, there are no
@@ -200,8 +228,8 @@
if ($delta->{new_file}) {
$delta->{new_file_class} =
$self->{mode} == $Codestriker::COLOURED_MODE ? "n" : "msn";
- }
- }
+ }
+ }
# Render any remaining diff segments.
$self->_render_changes($delta->{filenumber});
@@ -213,7 +241,7 @@
# Keep track of the current filename being processed.
$self->{current_filename} = $delta->{filename};
}
- }
+}
}
# Annotate any accumlated diff changes.
@@ -296,13 +324,13 @@
my $line = {};
if (defined $old_data) {
- $line->{old_data} = $self->_apply_line_filters($old_data);
+ $line->{old_data} = $old_data;
$line->{old_data_line} =
$self->comment_link($filenumber, $old_data_line, 0, $old_data_line);
}
$line->{old_data_class} = $render_old_colour;
if (defined $new_data) {
- $line->{new_data} = $self->_apply_line_filters($new_data);
+ $line->{new_data} = $new_data;
$line->{new_data_line} =
$self->comment_link($filenumber, $new_data_line, 1, $new_data_line);
}
@@ -312,16 +340,16 @@
# Apply all of the line filters to the line of text supplied.
sub _apply_line_filters {
- my ($self, $text) = @_;
+ my ($self, $delta) = @_;
# TODO: perform syntax highlighting.
foreach my $line_filter (@{$self->{line_filters}}) {
- $text = $line_filter->filter($text);
+ $line_filter->filter($delta);
}
# Unconditionally add a at the start for better alignment.
# Fix so count isn't stuffed.
- return " " . $text;
+ # return " " . $text;
}
}
Index: TabToNbspLineFilter.pm
===================================================================
RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Http/TabToNbspLineFilter.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TabToNbspLineFilter.pm 10 Mar 2008 23:18:04 -0000 1.1
+++ TabToNbspLineFilter.pm 16 Jun 2008 11:32:05 -0000 1.2
@@ -28,9 +28,9 @@
}
# Convert tabs to the appropriate number of entities.
-sub filter {
+sub _filter {
my ($self, $text) = @_;
-
+
my $tabwidth = $self->{tabwidth};
1 while $text =~ s/\t+/' ' x
(length($&) * $tabwidth - length($`) % $tabwidth)/eo;
@@ -38,4 +38,12 @@
return $text;
}
+# Convert tabs to the appropriate number of entities.
+sub filter {
+ my ($self, $delta) = @_;
+
+ $delta->{diff_old_lines} = $self->_filter($delta->{diff_old_lines});
+ $delta->{diff_new_lines} = $self->_filter($delta->{diff_new_lines});
+}
+
1;
Index: LineBreakLineFilter.pm
===================================================================
RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Http/LineBreakLineFilter.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- LineBreakLineFilter.pm 10 Mar 2008 23:18:04 -0000 1.1
+++ LineBreakLineFilter.pm 16 Jun 2008 11:32:05 -0000 1.2
@@ -28,17 +28,25 @@
}
# Convert the spaces appropriately for line-breaking.
-sub filter {
+sub _filter {
my ($self, $text) = @_;
if ($self->{brmode} == $Codestriker::LINE_BREAK_ASSIST_MODE) {
$text =~ s/^(\s+)/my $sp='';for(my $i=0;$i<length($1);$i++){$sp.=' '}$sp;/ge;
}
else {
- $text =~ s/\s/ /g;
+ $text =~ s/ / /g;
}
return $text;
}
+# Convert the spaces appropriately for line-breaking.
+sub filter {
+ my ($self, $delta) = @_;
+
+ $delta->{diff_old_lines} = $self->_filter($delta->{diff_old_lines});
+ $delta->{diff_new_lines} = $self->_filter($delta->{diff_new_lines});
+}
+
1;
Index: LineFilter.pm
===================================================================
RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Http/LineFilter.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- LineFilter.pm 10 Mar 2008 23:18:04 -0000 1.1
+++ LineFilter.pm 16 Jun 2008 11:32:05 -0000 1.2
@@ -19,10 +19,9 @@
}
sub filter {
- my ($self, $text) = @_;
+ my ($self, $delta) = @_;
# Default is a no-op.
- return $text;
}
1;
Index: HighlightLineFilter.pm
===================================================================
RCS file: HighlightLineFilter.pm
diff -N HighlightLineFilter.pm
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ HighlightLineFilter.pm 16 Jun 2008 11:32:05 -0000 1.1
@@ -0,0 +1,47 @@
+###############################################################################
+# Codestriker: Copyright (c) 2001, 2002 David Sitsky. All rights reserved.
+# si...@us...
+#
+# This program is free software; you can redistribute it and modify it under
+# the terms of the GPL.
+
+# Line filter for converting tabs to the appropriate number of
+# entities.
+
+package Codestriker::Http::HighlightLineFilter;
+
+use strict;
+
+use Codestriker::Http::LineFilter;
+
+@Codestriker::Http::HighlightLineFilter::ISA =
+ ("Codestriker::Http::LineFilter");
+
+# Take the desired tabwidth as a parameter.
+sub new {
+ my ($type, $highlight) = @_;
+
+ my $self = Codestriker::Http::LineFilter->new();
+ $self->{highlight} = $highlight;
+
+ return bless $self, $type;
+}
+
+# Convert tabs to the appropriate number of entities.
+sub _filter {
+ my ($self, $text) = @_;
+
+
+
+ return $text;
+}
+
+# Convert tabs to the appropriate number of entities.
+sub filter {
+ my ($self, $delta) = @_;
+
+ $delta->{diff_old_lines} = $self->_filter($delta->{diff_old_lines});
+ $delta->{diff_new_lines} = $self->_filter($delta->{diff_new_lines});
+}
+
+1;
|
|
From: <si...@us...> - 2008-06-16 07:37:09
|
User: sits
Date: 08/06/16 00:37:07
Modified: . CHANGELOG
Log:
Updated to reflect new LXR rendering code.
Index: CHANGELOG
===================================================================
RCS file: /cvsroot/codestriker/codestriker/CHANGELOG,v
retrieving revision 1.227
retrieving revision 1.228
diff -u -r1.227 -r1.228
--- CHANGELOG 13 Jun 2008 05:55:13 -0000 1.227
+++ CHANGELOG 16 Jun 2008 07:37:07 -0000 1.228
@@ -37,7 +37,8 @@
* Added support for LXR 0.9.5, which renamed the database tables to
contain an lxr_ prefix by default. Support for older LXR databases
- will still work by default.
+ will still work by default. LXR entities are now rendered in black text,
+ the same as program code, but an underline is shown when hovered over.
Version 1.9.4
|
|
From: <si...@us...> - 2008-06-16 06:01:05
|
User: sits
Date: 08/06/15 23:01:04
Modified: lib/Codestriker/Action ViewTopic.pm
Log:
Make sure the previous/next links for all delta objects are recorded so that the various views are rendered correctly.
Index: ViewTopic.pm
===================================================================
RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Action/ViewTopic.pm,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -r1.60 -r1.61
--- ViewTopic.pm 11 Jun 2008 12:00:31 -0000 1.60
+++ ViewTopic.pm 16 Jun 2008 06:01:04 -0000 1.61
@@ -247,9 +247,9 @@
# Set the per-delta URL links, such as adding a file-level comment,
# and links to the previous/next file.
- my $filenumber = 0;
my $current_filename = "";
foreach my $delta (@deltas) {
+ my $filenumber = $delta->{filenumber};
$delta->{add_file_comment_element} =
$delta_renderer->comment_link($filenumber, -1, 1, "[Add File Comment]");
@@ -276,8 +276,7 @@
}
# Create the next/previous file URL links.
- if ($current_filename ne $delta->{filename}) {
- if ($filenumber > 0) {
+ if ($filenumber > 0) {
$delta->{previous_file_url} =
$url_builder->view_url($topicid, -1, $mode, $brmode,
$filenumber-1) . "#" . $filenames[$filenumber-1];
@@ -288,10 +287,7 @@
$filenumber+1) . "#" . $filenames[$filenumber+1];
}
- # Keep track of the current filename being processed.
- $filenumber++;
$current_filename = $delta->{filename};
- }
}
# Annotate the deltas appropriately so that they can be easily rendered.
|
|
From: <si...@us...> - 2008-06-13 07:16:25
|
User: sits
Date: 08/06/13 00:16:22
Modified: html codestriker.css
Log:
Keep LXR entities in black, but draw an underline when hover over.
Index: codestriker.css
===================================================================
RCS file: /cvsroot/codestriker/codestriker/html/codestriker.css,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- codestriker.css 11 Mar 2008 06:01:12 -0000 1.16
+++ codestriker.css 13 Jun 2008 07:16:21 -0000 1.17
@@ -113,7 +113,11 @@
TR.tl2 {background-color: #eeeeee; font-family: Helvetica, Arial}
/* Colour to use for matching identifier */
-A.fid {color: #777777; text-decoration: none}
+/* A.fid {color: #777777; text-decoration: none} */
+A.fid:link { color: inherit; text-decoration: none }
+A.fid:visited { color: inherit; text-decoration: none }
+A.fid:visited:hover { text-decoration: underline; }
+A.fid:link:hover { text-decoration: underline; }
/* Style comment listings. */
TR.comments {background-color: #aaffaa; font-family: Helvetica, Arial} /* space */
|
|
From: <si...@us...> - 2008-06-13 05:55:17
|
User: sits
Date: 08/06/12 22:55:14
Modified: lib/Codestriker/Http DeltaRenderer.pm LxrLineFilter.pm
. CHANGELOG
lib/Codestriker/Repository Subversion.pm
Log:
* Added support for LXR 0.9.5, which renamed the database tables to
contain an lxr_ prefix by default. Support for older LXR databases
will still work by default.
Index: DeltaRenderer.pm
===================================================================
RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Http/DeltaRenderer.pm,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- DeltaRenderer.pm 11 Jun 2008 12:00:31 -0000 1.5
+++ DeltaRenderer.pm 13 Jun 2008 05:55:12 -0000 1.6
@@ -58,11 +58,11 @@
@{$self->{line_filters}} = ();
push @{$self->{line_filters}}, Codestriker::Http::HtmlEntityLineFilter->new();
+ push @{$self->{line_filters}}, Codestriker::Http::TabToNbspLineFilter->new($tabwidth);
+ push @{$self->{line_filters}}, Codestriker::Http::LineBreakLineFilter->new($brmode);
if (defined $lxr_config) {
push @{$self->{line_filters}}, Codestriker::Http::LxrLineFilter->new($lxr_config);
}
- push @{$self->{line_filters}}, Codestriker::Http::TabToNbspLineFilter->new($tabwidth);
- push @{$self->{line_filters}}, Codestriker::Http::LineBreakLineFilter->new($brmode);
bless $self, $type;
}
@@ -315,7 +315,6 @@
my ($self, $text) = @_;
# TODO: perform syntax highlighting.
- # TODO: perform LXR linking.
foreach my $line_filter (@{$self->{line_filters}}) {
$text = $line_filter->filter($text);
}
Index: LxrLineFilter.pm
===================================================================
RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Http/LxrLineFilter.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- LxrLineFilter.pm 11 Jun 2008 12:00:31 -0000 1.1
+++ LxrLineFilter.pm 13 Jun 2008 05:55:13 -0000 1.2
@@ -16,6 +16,8 @@
@Codestriker::Http::LxrLineFilter::ISA =
("Codestriker::Http::LineFilter");
+
+# TODO: close the database handle correctly.
# Take the LXR configuration as a parameter and create a connection to the LXR database
# for symbol lookup.
@@ -32,21 +34,25 @@
$lxr_config->{password} : $lxr_config->{passwd};
$self->{dbh} = DBI->connect($lxr_config->{db}, $lxr_config->{user},
$password,
- {AutoCommit=>0, RaiseError=>1})
+ {AutoCommit=>0, RaiseError=>0, PrintError=>0})
|| die "Couldn't connect to LXR database: " . DBI->errstr;
# Create the appropriate prepared statement for retrieving LXR symbols.
# Depending on the LXR deployment, the table name is either "symbols"
- # or "lxr_symbols".
- eval
- {
- $self->{select_ids} =
+ # or "lxr_symbols". Try to determine this silently.
+ $self->{select_ids} =
$self->{dbh}->prepare_cached('SELECT count(symname) FROM symbols where symname = ?');
- };
- if ($@) {
+ my $success = defined $self->{select_ids};
+ $success &&= $self->{select_ids}->execute('test');
+ $success &&= $self->{select_ids}->finish;
+ if (! $success) {
$self->{select_ids} =
$self->{dbh}->prepare_cached('SELECT count(symname) FROM lxr_symbols where symname = ?');
- }
+ }
+
+ # Re-enable error reporting again.
+ $self->{dbh}->{RaiseError} = 1;
+ $self->{dbh}->{PrintError} = 1;
# Cache for storing which IDs have been found.
$self->{idhash} = {};
@@ -79,7 +85,7 @@
# Check if the id has been found in lxr.
if ($count > 0) {
- return '<a href=\"' . $self->{url} . $id . '\" class=\"fid\">' . $id . '</a>';
+ return '<a href="' . $self->{url} . $id . '" class="fid">' . $id . '</a>';
} else {
return $id;
}
@@ -123,6 +129,7 @@
$newdata .= $token;
} elsif ($token eq "nbsp" || $token eq "quot" || $token eq "amp" ||
$token eq "lt" || $token eq "gt") {
+ # TODO: is this still needed?
# HACK - ignore potential HTML entities. This needs to be
# done in a smarter fashion later.
$newdata .= $token;
@@ -147,4 +154,15 @@
return $newdata;
}
+# Ensure the prepared statements and database connection to LXR is closed.
+sub DESTROY {
+ my ($self) = @_;
+
+ $self->SUPER::DESTROY if $self->can("SUPER::DESTROY");
+
+ $self->{select_ids}->finish;
+ $self->{dbh}->disconnect;
+}
+
+
1;
Index: CHANGELOG
===================================================================
RCS file: /cvsroot/codestriker/codestriker/CHANGELOG,v
retrieving revision 1.226
retrieving revision 1.227
diff -u -r1.226 -r1.227
--- CHANGELOG 11 Jun 2008 07:05:22 -0000 1.226
+++ CHANGELOG 13 Jun 2008 05:55:13 -0000 1.227
@@ -33,7 +33,11 @@
rob...@us....
* The edit comment page has been updated so that the topic name is
- linked back to the associated view topic page.
+ linked back to the associated view topic page.
+
+* Added support for LXR 0.9.5, which renamed the database tables to
+ contain an lxr_ prefix by default. Support for older LXR databases
+ will still work by default.
Version 1.9.4
Index: Subversion.pm
===================================================================
RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Repository/Subversion.pm,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- Subversion.pm 24 Oct 2007 10:09:36 -0000 1.19
+++ Subversion.pm 13 Jun 2008 05:55:13 -0000 1.20
@@ -108,7 +108,7 @@
# Return a string representation of this repository.
sub toString ($) {
my ($self) = @_;
- return "svn:" . $self->getRoot();
+ return $self->{repository_string};
}
# Given a Subversion URL, determine if it refers to a directory or a file.
|
|
From: <si...@us...> - 2008-06-11 12:00:35
|
User: sits
Date: 08/06/11 05:00:33
Modified: lib/Codestriker/Http DeltaRenderer.pm
lib/Codestriker/Action ViewTopic.pm ViewTopicFile.pm
html-docs index.html
Added: lib/Codestriker/Http LxrLineFilter.pm
Log:
Integration of the LXR text filter. Untested, but should newer versions of LXR which use a different table name. See https://sourceforge.net/tracker/index.php?func=detail&aid=1878650&group_id=41136&atid=429860 for more information.
Index: DeltaRenderer.pm
===================================================================
RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Http/DeltaRenderer.pm,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DeltaRenderer.pm 11 Jun 2008 07:52:04 -0000 1.4
+++ DeltaRenderer.pm 11 Jun 2008 12:00:31 -0000 1.5
@@ -14,11 +14,12 @@
use Codestriker::Http::HtmlEntityLineFilter;
use Codestriker::Http::TabToNbspLineFilter;
use Codestriker::Http::LineBreakLineFilter;
+use Codestriker::Http::LxrLineFilter;
# Constructor.
sub new {
my ($type, $topic, $comments, $deltas, $query, $mode, $brmode,
- $tabwidth) = @_;
+ $tabwidth, $repository) = @_;
my $self = {};
$self->{topic} = $topic;
@@ -52,8 +53,14 @@
# Record list of line filter objects to apply to each line of code.
# Setup some default filters.
+ my $lxr_config = defined $repository ?
+ $Codestriker::lxr_map->{$repository->toString()} : undef;
+
@{$self->{line_filters}} = ();
push @{$self->{line_filters}}, Codestriker::Http::HtmlEntityLineFilter->new();
+ if (defined $lxr_config) {
+ push @{$self->{line_filters}}, Codestriker::Http::LxrLineFilter->new($lxr_config);
+ }
push @{$self->{line_filters}}, Codestriker::Http::TabToNbspLineFilter->new($tabwidth);
push @{$self->{line_filters}}, Codestriker::Http::LineBreakLineFilter->new($brmode);
@@ -126,8 +133,6 @@
# Now process the text so that the display code has minimal work to do.
# Also apply appropriate transformations to the line as required.
- # TODO: put this into a proper module/plugin framework to make it easier
- # to extend/modify.
my @diff_lines = split /\n/, $delta->{text};
my $old_linenumber = $delta->{old_linenumber};
my $new_linenumber = $delta->{new_linenumber};
Index: LxrLineFilter.pm
===================================================================
RCS file: LxrLineFilter.pm
diff -N LxrLineFilter.pm
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ LxrLineFilter.pm 11 Jun 2008 12:00:31 -0000 1.1
@@ -0,0 +1,150 @@
+###############################################################################
+# Codestriker: Copyright (c) 2001, 2002 David Sitsky. All rights reserved.
+# si...@us...
+#
+# This program is free software; you can redistribute it and modify it under
+# the terms of the GPL.
+
+# Line filter for converting tabs to the appropriate number of
+# entities.
+
+package Codestriker::Http::LxrLineFilter;
+
+use strict;
+
+use Codestriker::Http::LineFilter;
+
+@Codestriker::Http::LxrLineFilter::ISA =
+ ("Codestriker::Http::LineFilter");
+
+# Take the LXR configuration as a parameter and create a connection to the LXR database
+# for symbol lookup.
+sub new {
+ my ($type, $lxr_config) = @_;
+
+ my $self = Codestriker::Http::LineFilter->new();
+
+ # Store the LXR-specific configuration.
+ $self->{url} = $lxr_config->{url};
+
+ # Create a connection to the LXR database.
+ my $password = defined $lxr_config->{password} ?
+ $lxr_config->{password} : $lxr_config->{passwd};
+ $self->{dbh} = DBI->connect($lxr_config->{db}, $lxr_config->{user},
+ $password,
+ {AutoCommit=>0, RaiseError=>1})
+ || die "Couldn't connect to LXR database: " . DBI->errstr;
+
+ # Create the appropriate prepared statement for retrieving LXR symbols.
+ # Depending on the LXR deployment, the table name is either "symbols"
+ # or "lxr_symbols".
+ eval
+ {
+ $self->{select_ids} =
+ $self->{dbh}->prepare_cached('SELECT count(symname) FROM symbols where symname = ?');
+ };
+ if ($@) {
+ $self->{select_ids} =
+ $self->{dbh}->prepare_cached('SELECT count(symname) FROM lxr_symbols where symname = ?');
+ }
+
+ # Cache for storing which IDs have been found.
+ $self->{idhash} = {};
+
+ return bless $self, $type;
+}
+
+# Given an identifier, wrap it within the appropriate <a href> tag if it
+# is a known identifier to LXR, otherwise just return the id. To avoid
+# excessive crap, only consider those identifiers which are at least 4
+# characters long.
+sub lxr_ident($$) {
+ my ($self, $id) = @_;
+
+ my $count = 0;
+ if (length($id) >= 4) {
+ # Check if the id has not yet been found in lxr.
+ if (! exists $self->{idhash}->{$id}) {
+ # Initialise this entry.
+ $self->{idhash}->{$id} = 0;
+
+ # Fetch ids from lxr and store the result.
+ $self->{select_ids}->execute($id);
+ ($count) = $self->{select_ids}->fetchrow_array();
+ $self->{idhash}->{$id} = $count;
+ } else {
+ $count = $self->{idhash}->{$id};
+ }
+ }
+
+ # Check if the id has been found in lxr.
+ if ($count > 0) {
+ return '<a href=\"' . $self->{url} . $id . '\" class=\"fid\">' . $id . '</a>';
+ } else {
+ return $id;
+ }
+}
+
+# Parse the line and produce the appropriate hyperlinks to LXR.
+# Currently, this is very Java/C/C++ centric, but it will do for now.
+sub filter {
+ my ($self, $text) = @_;
+
+ # If the line is a comment, don't do any processing. Note this code
+ # isn't bullet-proof, but its good enough most of the time.
+ $_ = $text;
+ return $text if (/^(\s| )*\/\// ||
+ /^(\s| ){0,10}\*/ ||
+ /^(\s| ){0,10}\/\*/ ||
+ /^(\s| )*\*\/(\s| )*$/);
+
+ # Handle package Java statements.
+ if ($text =~ /^(package(\s| )+)([\w\.]+)(.*)$/) {
+ return $1 . $self->lxr_ident($3) . $4;
+ }
+
+ # Handle Java import statements.
+ if ($text =~ /^(import(\s| )+)([\w\.]+)\.(\w+)((\s| )*)(.*)$/) {
+ return $1 . $self->lxr_ident($3) . "." . $self->lxr_ident($4) . "$5$7";
+ }
+
+ # Break the string into potential identifiers, and look them up to see
+ # if they can be hyperlinked to an LXR lookup.
+ my $idhash = $self->{idhash};
+ my @data_tokens = split /([A-Za-z][\w]+)/, $text;
+ my $newdata = "";
+ my $in_comment = 0;
+ my $eol_comment = 0;
+ for (my $i = 0; $i <= $#data_tokens; $i++) {
+ my $token = $data_tokens[$i];
+ if ($token =~ /^[A-Za-z]/) {
+ if ($eol_comment || $in_comment) {
+ # Currently in a comment, don't LXRify.
+ $newdata .= $token;
+ } elsif ($token eq "nbsp" || $token eq "quot" || $token eq "amp" ||
+ $token eq "lt" || $token eq "gt") {
+ # HACK - ignore potential HTML entities. This needs to be
+ # done in a smarter fashion later.
+ $newdata .= $token;
+ } else {
+ $newdata .= $self->lxr_ident($token);
+ }
+ } else {
+ $newdata .= $token;
+ $token =~ s/(\s| )//g;
+
+ # Check if we are entering or exiting a comment.
+ if ($token =~ /\/\//) {
+ $eol_comment = 1;
+ } elsif ($token =~ /\*+\//) {
+ $in_comment = 0;
+ } elsif ($token =~ /\/\*/) {
+ $in_comment = 1;
+ }
+ }
+ }
+
+ return $newdata;
+}
+
+1;
Index: ViewTopic.pm
===================================================================
RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Action/ViewTopic.pm,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -r1.59 -r1.60
--- ViewTopic.pm 13 Mar 2008 22:39:07 -0000 1.59
+++ ViewTopic.pm 11 Jun 2008 12:00:31 -0000 1.60
@@ -239,7 +239,7 @@
my $delta_renderer =
Codestriker::Http::DeltaRenderer->new($topic, \@comments, \@deltas, $query,
- $mode, $brmode, $tabwidth);
+ $mode, $brmode, $tabwidth, $repository);
# Set the add general comment URL.
$vars->{'add_general_comment_element'} =
Index: ViewTopicFile.pm
===================================================================
RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Action/ViewTopicFile.pm,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- ViewTopicFile.pm 14 Mar 2008 01:30:52 -0000 1.14
+++ ViewTopicFile.pm 11 Jun 2008 12:00:31 -0000 1.15
@@ -137,7 +137,7 @@
my $delta_renderer =
Codestriker::Http::DeltaRenderer->new($topic, \@comments,
\@merged_deltas, $query,
- $mode, $brmode, $tabwidth);
+ $mode, $brmode, $tabwidth, $repository);
$delta_renderer->annotate_deltas();
my $vars = {};
Index: index.html
===================================================================
RCS file: /cvsroot/codestriker/codestriker/html-docs/index.html,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- index.html 7 Aug 2006 01:52:32 -0000 1.36
+++ index.html 11 Jun 2008 12:00:32 -0000 1.37
@@ -67,7 +67,7 @@
under the GPL.
</p>
<p>
- <a href="http://codestriker.sourceforge.net/cgi-bin/codestriker.pl?topic=7063366&action=view">View</a>
+ <a href="http://codestriker.sourceforge.net/cgi-bin/codestriker.pl?topic=7759043&action=view">View</a>
an example code review, <a href="http://codestriker.sourceforge.net/cgi-bin/codestriker.pl">list</a>
open topics,
read the <a href="codestriker.html">manual</a>,
|
|
From: <si...@us...> - 2008-06-11 07:52:06
|
User: sits
Date: 08/06/11 00:52:05
Modified: lib/Codestriker/Http DeltaRenderer.pm
template/en/default viewdeltas.html.tmpl viewtopic.html.tmpl
Log:
Generate the comment links correctly with the right filenumber.
Index: DeltaRenderer.pm
===================================================================
RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Http/DeltaRenderer.pm,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DeltaRenderer.pm 14 Mar 2008 01:30:52 -0000 1.3
+++ DeltaRenderer.pm 11 Jun 2008 07:52:04 -0000 1.4
@@ -136,7 +136,6 @@
@{$self->{diff_old_lines_numbers}} = ();
@{$self->{diff_new_lines}} = ();
@{$self->{diff_new_lines_numbers}} = ();
- $self->{filenumber} = 0;
$self->{current_filename} = "";
for (my $i = 0; $i <= $#diff_lines; $i++) {
my $data = $diff_lines[$i];
@@ -159,7 +158,7 @@
$data =~ s/^\s//;
# Render what has been currently recorded.
- $self->_render_changes();
+ $self->_render_changes($delta->{filenumber});
# Now that the diff changeset has been rendered, remove the state data.
@{$self->{diff_old_lines}} = ();
@@ -174,12 +173,12 @@
$self->{mode} == $Codestriker::COLOURED_MODE ? "n" : "msn";
$line->{old_data} = $data;
$line->{old_data_line} =
- $self->comment_link($self->{filenumber}, $old_linenumber,
+ $self->comment_link($delta->{filenumber}, $old_linenumber,
0, $old_linenumber);
$line->{old_data_class} = $data_class;
$line->{new_data} = $data;
$line->{new_data_line} =
- $self->comment_link($self->{filenumber}, $new_linenumber,
+ $self->comment_link($delta->{filenumber}, $new_linenumber,
1, $new_linenumber);
$line->{new_data_class} = $data_class;
push @{$self->{lines}}, $line;
@@ -200,14 +199,13 @@
}
# Render any remaining diff segments.
- $self->_render_changes();
+ $self->_render_changes($delta->{filenumber});
# Store the processed lines with the delta object for rendering.
@{$delta->{lines}} = @{$self->{lines}};
if ($self->{current_filename} ne $delta->{filename}) {
# Keep track of the current filename being processed.
- $self->{filenumber}++;
$self->{current_filename} = $delta->{filename};
}
}
@@ -216,7 +214,7 @@
# Annotate any accumlated diff changes.
sub _render_changes
{
- my ($self) = @_;
+ my ($self, $filenumber) = @_;
# Determine the class to use for displaying the comments.
my ($old_col, $old_notpresent_col, $new_col, $new_notpresent_col);
@@ -295,13 +293,13 @@
if (defined $old_data) {
$line->{old_data} = $self->_apply_line_filters($old_data);
$line->{old_data_line} =
- $self->comment_link($self->{filenumber}, $old_data_line, 0, $old_data_line);
+ $self->comment_link($filenumber, $old_data_line, 0, $old_data_line);
}
$line->{old_data_class} = $render_old_colour;
if (defined $new_data) {
$line->{new_data} = $self->_apply_line_filters($new_data);
$line->{new_data_line} =
- $self->comment_link($self->{filenumber}, $new_data_line, 1, $new_data_line);
+ $self->comment_link($filenumber, $new_data_line, 1, $new_data_line);
}
$line->{new_data_class} = $render_new_colour;
push @{$self->{lines}}, $line;
Index: viewdeltas.html.tmpl
===================================================================
RCS file: /cvsroot/codestriker/codestriker/template/en/default/viewdeltas.html.tmpl,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- viewdeltas.html.tmpl 14 Mar 2008 01:30:53 -0000 1.5
+++ viewdeltas.html.tmpl 11 Jun 2008 07:52:04 -0000 1.6
@@ -1,7 +1,6 @@
[%# HTML for rendering a set of deltas. #%]
[% SET diff_current_filename = "" %]
-[% SET filenumber = 0 %]
[% FOREACH delta = deltas %]
[% FLUSH IF loop.count() % 10 == 1 %]
[%# Check if a heading for the current diff needs to be output. #%]
@@ -24,7 +23,6 @@
</tr>
[% END %]
</table>
- [% filenumber = filenumber + 1 %]
[%# Make sure all the diffs are aligned in the same table. #%]
<table width="100%" cellspacing="0" cellpadding="0" border="0">
Index: viewtopic.html.tmpl
===================================================================
RCS file: /cvsroot/codestriker/codestriker/template/en/default/viewtopic.html.tmpl,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -r1.45 -r1.46
--- viewtopic.html.tmpl 13 Mar 2008 22:39:07 -0000 1.45
+++ viewtopic.html.tmpl 11 Jun 2008 07:52:04 -0000 1.46
@@ -1,11 +1,6 @@
</head>
<body onload="view_topic_on_load_handler();">
-[%# Screen for displaying the heading information of a topic. The
- actual view topic data is still generated directly from the perl
- script, as it is complex HTML that doesn't need to be
- customised. #%]
-
[% PROCESS viewtopicheader.html.tmpl version = version
help = "x504.html#VIEW-TOPIC" topicview = 1 topicproperties = 0
topiccomments = 0 topicinfo = 0 closehead = 0 %]
|
|
From: <si...@us...> - 2008-06-11 07:05:26
|
User: sits
Date: 08/06/11 00:05:22
Modified: . CHANGELOG
template/en/default editcomment.html.tmpl
Log:
The edit comment page has been updated so that the topic name is linked back to the associated view topic page.
Index: CHANGELOG
===================================================================
RCS file: /cvsroot/codestriker/codestriker/CHANGELOG,v
retrieving revision 1.225
retrieving revision 1.226
diff -u -r1.225 -r1.226
--- CHANGELOG 26 Feb 2008 08:32:17 -0000 1.225
+++ CHANGELOG 11 Jun 2008 07:05:22 -0000 1.226
@@ -31,6 +31,9 @@
* Make sure very long filenames don't move the diff display far to the
right of the view topic page. Fix suggested by
rob...@us....
+
+* The edit comment page has been updated so that the topic name is
+ linked back to the associated view topic page.
Version 1.9.4
Index: editcomment.html.tmpl
===================================================================
RCS file: /cvsroot/codestriker/codestriker/template/en/default/editcomment.html.tmpl,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- editcomment.html.tmpl 10 Aug 2006 11:29:04 -0000 1.23
+++ editcomment.html.tmpl 11 Jun 2008 07:05:22 -0000 1.24
@@ -122,7 +122,7 @@
<table border="0" cellpadding="5" cellspacing="0" width="100%">
<tr class="tlh">
- <td>Topic title: <b>[% topic_title | html_entity %]</b>.</td>
+ <td>Topic title: <b><a href="[% view_topic_url %]">[% topic_title | html_entity %]</a></b>.</td>
<td align=right>[% document_creation_time | html_entity %]</td>
</tr>
</table>
|
|
From: <si...@us...> - 2008-03-14 01:30:54
|
User: sits
Date: 08/03/13 18:30:53
Modified: lib Codestriker.pm
lib/Codestriker/Action DownloadTopic.pm EditComment.pm
SubmitNewComment.pm SubmitNewTopic.pm
ViewTopicComments.pm ViewTopicFile.pm
ViewTopicInfo.pm ViewTopicProperties.pm
lib/Codestriker/Http DeltaRenderer.pm Response.pm
lib/Codestriker/Model Delta.pm
lib/Codestriker/Template/Plugin FormatWhitespace.pm
lib/Codestriker/TopicListeners Email.pm
template/en/default viewdeltas.html.tmpl
Removed: lib/Codestriker/Http Render.pm
Log:
Remove Render.pm from the system.
Index: Codestriker.pm
===================================================================
RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker.pm,v
retrieving revision 1.106
retrieving revision 1.107
diff -u -r1.106 -r1.107
--- Codestriker.pm 9 Jan 2008 04:08:52 -0000 1.106
+++ Codestriker.pm 14 Mar 2008 01:30:52 -0000 1.107
@@ -627,5 +627,22 @@
$stderr_fh->flush;
}
+# Replace the passed in string with the correct number of spaces, for
+# alignment purposes.
+sub tabadjust ($$$) {
+ my ($tabwidth, $input, $htmlmode) = @_;
+
+ $_ = $input;
+ if ($htmlmode) {
+ 1 while s/\t+/' ' x
+ (length($&) * $tabwidth - length($`) % $tabwidth)/eo;
+ }
+ else {
+ 1 while s/\t+/' ' x
+ (length($&) * $tabwidth - length($`) % $tabwidth)/eo;
+ }
+ return $_;
+}
+
1;
Index: DownloadTopic.pm
===================================================================
RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Action/DownloadTopic.pm,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- DownloadTopic.pm 19 May 2006 00:40:15 -0000 1.13
+++ DownloadTopic.pm 14 Mar 2008 01:30:52 -0000 1.14
@@ -11,7 +11,6 @@
use strict;
-use Codestriker::Http::Render;
use Codestriker::Model::Topic;
# If the input is valid, display the topic.
Index: EditComment.pm
===================================================================
RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Action/EditComment.pm,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- EditComment.pm 15 Jan 2006 21:20:05 -0000 1.14
+++ EditComment.pm 14 Mar 2008 01:30:52 -0000 1.15
@@ -11,7 +11,6 @@
use strict;
use Codestriker::Model::Topic;
-use Codestriker::Http::Render;
# Create an appropriate form for adding a comment to a topic.
sub process($$$) {
@@ -83,16 +82,17 @@
# 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},
- $delta->{new_linenumber},
- $delta->{text},
- $new)) .
- $query->p . "\n";
+
+ my @text = ();
+ my $offset = $delta->retrieve_context($line, $new, $context, \@text);
+ for (my $i = 0; $i <= $#text; $i++) {
+ $text[$i] = HTML::Entities::encode($text[$i]);
+ if ($i == $offset) {
+ $text[$i] = "<font color=\"red\">" . $text[$i] . "</font>";
+ }
+ }
+
+ $vars->{'context'} = $query->pre(join '\n', @text) . $query->p;
}
# Display the comments which have been made for this line number
Index: SubmitNewComment.pm
===================================================================
RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Action/SubmitNewComment.pm,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- SubmitNewComment.pm 11 Jun 2006 08:29:11 -0000 1.12
+++ SubmitNewComment.pm 14 Mar 2008 01:30:52 -0000 1.13
@@ -15,7 +15,6 @@
use Codestriker::Model::Comment;
use Codestriker::Model::File;
use Codestriker::Model::Topic;
-use Codestriker::Http::Render;
# If the input is valid, create the appropriate topic into the database.
sub process($$$) {
Index: SubmitNewTopic.pm
===================================================================
RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Action/SubmitNewTopic.pm,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- SubmitNewTopic.pm 22 Feb 2008 00:32:05 -0000 1.32
+++ SubmitNewTopic.pm 14 Mar 2008 01:30:52 -0000 1.33
@@ -15,7 +15,6 @@
use FileHandle;
use Codestriker::Model::Topic;
-use Codestriker::Http::Render;
use Codestriker::Repository::RepositoryFactory;
use Codestriker::Repository::ScmBug;
use Codestriker::FileParser::Parser;
Index: ViewTopicComments.pm
===================================================================
RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Action/ViewTopicComments.pm,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- ViewTopicComments.pm 22 May 2006 23:19:05 -0000 1.17
+++ ViewTopicComments.pm 14 Mar 2008 01:30:52 -0000 1.18
@@ -12,7 +12,6 @@
use strict;
use Codestriker::Http::Template;
-use Codestriker::Http::Render;
use Codestriker::Model::Comment;
use Codestriker::Model::File;
@@ -121,13 +120,16 @@
$comment->{fileline} ,
$comment->{filenew});
- $comment->{context} = Codestriker::Http::Render->get_context(
- $comment->{fileline} ,
- $show_context, 1,
- $delta->{old_linenumber},
- $delta->{new_linenumber},
- $delta->{text},
- $comment->{filenew});
+ my @text = ();
+ my $offset = $delta->retrieve_context($comment->{fileline}, $comment->{filenew},
+ $show_context, \@text);
+ for (my $i = 0; $i <= $#text; $i++) {
+ $text[$i] = HTML::Entities::encode($text[$i]);
+ if ($i == $offset) {
+ $text[$i] = "<font color=\"red\">" . $text[$i] . "</font>";
+ }
+ }
+ $comment->{context} = $offset == -1 ? "" : (join "\n", @text);
}
}
Index: ViewTopicFile.pm
===================================================================
RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Action/ViewTopicFile.pm,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- ViewTopicFile.pm 12 Mar 2008 08:29:14 -0000 1.13
+++ ViewTopicFile.pm 14 Mar 2008 01:30:52 -0000 1.14
@@ -13,7 +13,6 @@
use Codestriker::Model::File;
use Codestriker::Model::Comment;
-use Codestriker::Http::Render;
use Codestriker::Repository::RepositoryFactory;
# If the input is valid, display the topic.
@@ -58,10 +57,8 @@
my @comments = $topic->read_comments();
# Load the appropriate original form of this file into memory.
- my ($filedata_max_line_length, @filedata);
- if (!_read_repository_file($filename, $revision, $tabwidth,
- $repository, \@filedata,
- \$filedata_max_line_length)) {
+ my @filedata;
+ if (!$repository->retrieve($filename, $revision, \@filedata)) {
$http_response->error("Couldn't get repository data for $filename " .
"$revision: $!");
}
@@ -153,27 +150,4 @@
Codestriker::TopicListeners::Manager::topic_viewed($email, $topic);
}
-# Read the specified repository file and revision into memory. Return true if
-# successful, false otherwise.
-sub _read_repository_file ($$$$$$) {
- my ($filename, $revision, $tabwidth, $repository, $data_array_ref,
- $maxline_length_ref) = @_;
-
- # Read the file data.
- $repository->retrieve($filename, $revision, $data_array_ref);
-
- # Determine the maximum line length, and replace tabs with spaces.
- $$maxline_length_ref = 0;
- for (my $i = 1; $i <= $#$data_array_ref; $i++) {
- $$data_array_ref[$i] =
- Codestriker::Http::Render::tabadjust($tabwidth,
- $$data_array_ref[$i], 0);
- my $line_length = length($$data_array_ref[$i]);
- if ($line_length > $$maxline_length_ref) {
- $$maxline_length_ref = $line_length;
- }
- }
- return 1;
-}
-
1;
Index: ViewTopicInfo.pm
===================================================================
RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Action/ViewTopicInfo.pm,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- ViewTopicInfo.pm 1 Mar 2005 10:12:49 -0000 1.12
+++ ViewTopicInfo.pm 14 Mar 2008 01:30:52 -0000 1.13
@@ -14,7 +14,6 @@
use Codestriker::Model::Topic;
use Codestriker::Model::Comment;
use Codestriker::Http::UrlBuilder;
-use Codestriker::Http::Render;
use Codestriker::Repository::RepositoryFactory;
use HTML::Entities ();
Index: ViewTopicProperties.pm
===================================================================
RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Action/ViewTopicProperties.pm,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- ViewTopicProperties.pm 23 Feb 2008 02:30:14 -0000 1.15
+++ ViewTopicProperties.pm 14 Mar 2008 01:30:52 -0000 1.16
@@ -14,7 +14,6 @@
use Codestriker::Model::Topic;
use Codestriker::Model::Comment;
use Codestriker::Http::UrlBuilder;
-use Codestriker::Http::Render;
use Codestriker::Repository::RepositoryFactory;
use HTML::Entities ();
Index: DeltaRenderer.pm
===================================================================
RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Http/DeltaRenderer.pm,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DeltaRenderer.pm 10 Mar 2008 23:18:03 -0000 1.2
+++ DeltaRenderer.pm 14 Mar 2008 01:30:52 -0000 1.3
@@ -169,14 +169,15 @@
# Now render the line which is present on both sides.
my $line = {};
+ $data = $self->_apply_line_filters($data);
my $data_class =
$self->{mode} == $Codestriker::COLOURED_MODE ? "n" : "msn";
- $line->{old_data} = $self->_apply_line_filters($data);
+ $line->{old_data} = $data;
$line->{old_data_line} =
$self->comment_link($self->{filenumber}, $old_linenumber,
0, $old_linenumber);
$line->{old_data_class} = $data_class;
- $line->{new_data} = $self->_apply_line_filters($data);
+ $line->{new_data} = $data;
$line->{new_data_line} =
$self->comment_link($self->{filenumber}, $new_linenumber,
1, $new_linenumber);
@@ -185,6 +186,17 @@
$old_linenumber++;
$new_linenumber++;
}
+
+ # Check if the delta corresponds to a new file. This is true
+ # if there is only one delta for the whole file, there are no
+ # old lines, and the diff strarts at 0,1.
+ $delta->{new_file} =
+ $delta->{only_delta_in_file} && $old_linenumber == 0 &&
+ $delta->{old_linenumber} == 0 && $delta->{new_linenumber} == 1;
+ if ($delta->{new_file}) {
+ $delta->{new_file_class} =
+ $self->{mode} == $Codestriker::COLOURED_MODE ? "n" : "msn";
+ }
}
# Render any remaining diff segments.
@@ -280,13 +292,17 @@
}
my $line = {};
- $line->{old_data} = $self->_apply_line_filters($old_data);
- $line->{old_data_line} =
- $self->comment_link($self->{filenumber}, $old_data_line, 0, $old_data_line);
+ if (defined $old_data) {
+ $line->{old_data} = $self->_apply_line_filters($old_data);
+ $line->{old_data_line} =
+ $self->comment_link($self->{filenumber}, $old_data_line, 0, $old_data_line);
+ }
$line->{old_data_class} = $render_old_colour;
- $line->{new_data} = $self->_apply_line_filters($new_data);
- $line->{new_data_line} =
- $self->comment_link($self->{filenumber}, $new_data_line, 1, $new_data_line);
+ if (defined $new_data) {
+ $line->{new_data} = $self->_apply_line_filters($new_data);
+ $line->{new_data_line} =
+ $self->comment_link($self->{filenumber}, $new_data_line, 1, $new_data_line);
+ }
$line->{new_data_class} = $render_new_colour;
push @{$self->{lines}}, $line;
}
Index: Response.pm
===================================================================
RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Http/Response.pm,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -r1.42 -r1.43
--- Response.pm 24 Sep 2007 21:15:08 -0000 1.42
+++ Response.pm 14 Mar 2008 01:30:52 -0000 1.43
@@ -403,7 +403,7 @@
$data =~ s/\'/\\\'/mgo;
$data =~ s/\n/<br>/mgo;
$data =~ s/ \s+/' ' x (length($&)-1)/emgo;
- $data = Codestriker::Http::Render::tabadjust($tabwidth, $data, 1);
+ $data = Codestriker::tabadjust($tabwidth, $data, 1);
# Show each comment with the author and date in bold.
$overlib_html .= "<b>Comment from $comment->{author} ";
Index: Render.pm
===================================================================
RCS file: Render.pm
diff -N Render.pm
--- Render.pm 28 Feb 2008 11:01:58 -0000 1.56
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,1148 +0,0 @@
-###############################################################################
-# Codestriker: Copyright (c) 2001, 2002 David Sitsky. All rights reserved.
-# si...@us...
-#
-# This program is free software; you can redistribute it and modify it under
-# the terms of the GPL.
-
-# Collection of routines for rendering HTML output.
-
-package Codestriker::Http::Render;
-
-use strict;
-use DBI;
-use CGI::Carp 'fatalsToBrowser';
-use HTML::Entities ();
-
-# Colour to use when displaying the line number that a comment is being made
-# against.
-my $CONTEXT_COLOUR = "red";
-
-sub _coloured_mode_finish( $ );
-
-# New lines within a diff block.
-my @diff_new_lines = ();
-
-# The corresponding lines they refer to.
-my @diff_new_lines_numbers = ();
-
-# The corresponding offsets they refer to.
-my @diff_new_lines_offsets = ();
-
-# Old lines within a diff block.
-my @diff_old_lines = ();
-
-# The corresponding lines they refer to.
-my @diff_old_lines_numbers = ();
-
-# A record of added and removed lines for a given diff block when displaying a
-# file in a popup window, along with their offsets.
-my @view_file_minus = ();
-my @view_file_plus = ();
-my @view_file_minus_offset = ();
-my @view_file_plus_offset = ();
-
-# What colour a line should appear if it has a comment against it.
-my $COMMENT_LINE_COLOUR = "red";
-
-# Constructor for rendering complex data.
-sub new ($$$$$$$\%\@$$\@\@\@\@$$) {
- my ($type, $query, $url_builder, $parallel, $max_digit_width, $topic,
- $mode, $comments, $tabwidth, $repository, $filenames_ref,
- $revisions_ref, $binaries_ref, $numchanges_ref, $max_line_length,
- $brmode, $fview) = @_;
-
- # Record all of the above parameters as instance variables, which remain
- # constant while we render code lines.
- my $self = {};
- $self->{query} = $query;
- $self->{url_builder} = $url_builder;
- $self->{parallel} = $parallel;
- $self->{max_digit_width} = $max_digit_width;
- $self->{topic} = $topic;
- $self->{mode} = $mode;
- if (! defined $brmode) {
- $brmode = $Codestriker::default_topic_br_mode;
- }
- if (! defined $fview) {
- $fview = $Codestriker::default_file_to_view;
- }
- $self->{brmode} = $brmode;
- $self->{fview} = $fview;
- $self->{comments} = $comments;
- $self->{tabwidth} = $tabwidth;
- $self->{repository} = $repository;
- $self->{filenames_ref} = $filenames_ref;
- $self->{revisions_ref} = $revisions_ref;
- $self->{binaries_ref} = $binaries_ref;
- $self->{numchanges_ref} = $numchanges_ref;
- $self->{max_line_length} = $max_line_length;
- $self->{old_linenumber} = 1;
- $self->{new_linenumber} = 1;
-
- # Get the main entry to the database
- my $topic_obj = Codestriker::Model::Topic->new($self->{topic});
- # Check for readonly
- $self->{topic_state} = $topic_obj->{topic_state};
-
- # Build a hash from filenumber|fileline|new -> comment array, so that
- # when rendering, lines can be coloured appropriately. Also build a list
- # of what points in the review have a comment. Also record a mapping
- # from filenumber|fileline|new -> the comment number.
- my %comment_hash = ();
- my @comment_locations = ();
- my %comment_location_map = ();
- 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;
- $comment_location_map{$key} = $#comment_locations;
- }
- push @{ $comment_hash{$key} }, $comment;
- }
- $self->{comment_hash} = \%comment_hash;
- $self->{comment_locations} = \@comment_locations;
- $self->{comment_location_map} = \%comment_location_map;
-
- # Also have a number of additional private variables which need to
- # be initialised.
- $self->{diff_current_filename} = "";
- $self->{diff_current_revision} = "";
- $self->{diff_current_repmatch} = 0;
-
- # Check if the repository has an associated LXR mapping, and if so,
- # setup a db connection and prepare a select statement.
- if (defined $repository) {
- my $value = $Codestriker::lxr_map->{$repository->toString()};
- if (defined $value) {
- my %lxr = %{ $value };
-
- my $passwd = $lxr{password};
- if (! defined $passwd) {
- # For backwards compatibility.
- $passwd = $lxr{passwd};
- }
- my $dbh = DBI->connect($lxr{db}, $lxr{user}, $passwd,
- {AutoCommit=>0, RaiseError=>1})
- || die "Couldn't connect to database: " . DBI->errstr;
- my $select_ids =
- $dbh->prepare_cached('SELECT count(symname) FROM symbols where symname = ?');
- $self->{idhashref} = {};
- $self->{idhashsth} = $select_ids;
- $self->{idhashdbh} = $dbh;
- $self->{lxr_base_url} = $lxr{url};
- }
- else {
- # No LXR mapping defined for this repository.
- $self->{idhashref} = undef;
- }
- }
- else {
- # Topic has no repository, so no LXR mapping.
- $self->{idhashref} = undef;
- }
-
- bless $self, $type;
-}
-
-# cleanup, disconnect from the lxr database if connected
-sub DESTROY {
- my $self = shift;
- $self->{idhashdbh}->disconnect() if exists $self->{idhashdbh};
-}
-
-
-# Given an identifier, wrap it within the appropriate <A HREF> tag if it
-# is a known identifier to LXR, otherwise just return the id. To avoid
-# excessive crap, only consider those identifiers which are at least 4
-# characters long.
-sub lxr_ident($$) {
- my ($self, $id) = @_;
-
- my $idhashref = $self->{idhashref};
-
- if (length($id) >= 4) {
-
- # Check if the id has not yet been found in lxr.
- if (not exists $idhashref->{$id}) {
- $idhashref->{$id} = 0; # By default not found.
- my $sth = $self->{idhashsth}; # DB statement handle.
-
- # Fetch ids from lxr and store in hash.
- $sth->execute($id);
- ($idhashref->{$id}) = $sth->fetchrow_array();
- }
- }
-
- # Check if the id has been found in lxr.
- if ($$idhashref{$id}) {
- return "<A HREF=\"" . $self->{lxr_base_url} . "$id\" " .
- "CLASS=\"fid\">$id</A>";
- } else {
- return $id;
- }
-}
-
-# Parse the line and product the appropriate hyperlinks to LXR.
-# Currently, this is very Java/C/C++ centric, but it will do for now.
-sub lxr_data($$) {
- my ($self, $data) = @_;
-
- # Don't do anything if LXR is not enabled for this topic.
- return $data if ! defined $self->{idhashref};
-
- # If the line is just a comment, don't do any processing. Note this code
- # isn't bullet-proof, but its good enough most of the time.
- $_ = $data;
- return $data if (/^(\s| )*\/\// || /^(\s| ){0,10}\*/ ||
- /^(\s| ){0,10}\/\*/ ||
- /^(\s| )*\*\/(\s| )*$/);
-
- # Handle package Java statements.
- if ($data =~ /^(package(\s| )+)([\w\.]+)(.*)$/) {
- return $1 . $self->lxr_ident($3) . $4;
- }
-
- # Handle Java import statements.
- if ($data =~ /^(import(\s| )+)([\w\.]+)\.(\w+)((\s| )*)(.*)$/) {
- return $1 . $self->lxr_ident($3) . "." . $self->lxr_ident($4) . "$5$7";
- }
-
- # Handle #include statements. Note, these aren't identifier lookups, but
- # need to be mapped to http://localhost.localdomain/lxr/xxx/yyy/incfile.h
- # Should include the current filename in the object for matching purposes.
-# if (/^(\#\s*include\s+[\"<])(.*?)([\">].*)$/) {
-# return $1 . $self->lxr_ident($2) . $3;
-# }
-
- # Break the string into potential identifiers, and look them up to see
- # if they can be hyperlinked to an LXR lookup.
- my $idhashref = $self->{idhashref};
- my @data_tokens = split /([A-Za-z][\w]+)/, $data;
- my $newdata = "";
- my $in_comment = 0;
- my $eol_comment = 0;
- for (my $i = 0; $i <= $#data_tokens; $i++) {
- my $token = $data_tokens[$i];
- if ($token =~ /^[A-Za-z]/) {
- if ($eol_comment || $in_comment) {
- # Currently in a comment, don't LXRify.
- $newdata .= $token;
- } elsif ($token eq "nbsp" || $token eq "quot" || $token eq "amp" ||
- $token eq "lt" || $token eq "gt") {
- # HACK - ignore potential HTML entities. This needs to be
- # done in a smarter fashion later.
- $newdata .= $token;
- } else {
- $newdata .= $self->lxr_ident($token);
- }
- } else {
- $newdata .= $token;
- $token =~ s/(\s| )//g;
-
- # Check if we are entering or exiting a comment.
- if ($token =~ /\/\//) {
- $eol_comment = 1;
- } elsif ($token =~ /\*+\//) {
- $in_comment = 0;
- } elsif ($token =~ /\/\*/) {
- $in_comment = 1;
- }
- }
- }
-
- return $newdata;
-}
-
-# Render a delta. If the filename has changed since the last delta, output the
-# appropriate file headers. Pass in the delta object you want to render.
-sub delta ($$$$$$$$$$) {
- my ($self, $delta) = @_;
-
- my $filename = $delta->{filename};
- my $filenumber = $delta->{filenumber},
- my $revision = $delta->{revision};
- my $old_linenumber = $delta->{old_linenumber};
- my $new_linenumber = $delta->{new_linenumber};
- my $text = $delta->{text};
- my $description = $delta->{description};
- my $binary = $delta->{binary};
- my $repmatch = $delta->{repmatch};
-
- # Don't do anything for binary files.
- return if $binary;
-
- my $query = $self->{query};
-
- if ($delta->is_delta_new_file() == 0)
- {
- # Check if the file heading needs to be output.
- if ($self->{diff_current_filename} ne $filename) {
- $self->delta_file_header($filename, $revision, $repmatch);
- }
-
- # Display the delta heading.
- $self->delta_heading($filenumber, $revision, $old_linenumber,
- $new_linenumber, $description, $repmatch);
-
- # Now render the actual diff text itself.
- $self->delta_text($filename, $filenumber, $revision, $old_linenumber,
- $new_linenumber, $text, $repmatch, 1, 1);
- }
- else
- {
- # Special formatting for full file upload that is not a diff.
- # If it not a diff, show the entire delta (actually the file
- # contents) in a single column.
- $self->delta_file_header($filename, $revision, $repmatch);
-
- print $query->Tr($query->td(" "), $query->td(" "),"\n");
-
- my @lines = split /\n/, $text;
- for (my $i = 0; $i <= $#lines; $i++) {
- my $line = $lines[$i];
-
- my $rendered_left_linenumber =
- $self->render_linenumber($i+1, $filenumber,1,1);
-
- # Removed the delta text, where + is added to the start of each
- # line. Also make sure the line is suitably escaped.
- $line =~ s/^\+//;
- $line = HTML::Entities::encode($line);
-
- my $cell = $self->render_coloured_cell($line);
- my $cell_class =
- $self->{mode} == $Codestriker::COLOURED_MODE ? "n" : "msn";
-
- print $query->Tr($query->td($rendered_left_linenumber),
- $query->td({-class=>$cell_class}, $cell),
- "\n");
- }
- }
-}
-
-# Output the header for a series of deltas for a specific file.
-sub delta_file_header ($$$$) {
- my ($self, $filename, $revision, $repmatch) = @_;
-
- my $query = $self->{query};
-
- # We need the file names for building the forward and backward
- # url Strings.
- my $filenames = $self->{filenames_ref};
-
- # Close the table, update the current filename, and open a new table.
- print $query->end_table();
- $self->{diff_current_filename} = $filename;
- $self->{diff_current_revision} = $revision;
- $self->{diff_current_repmatch} = $repmatch;
- $self->print_coloured_table();
-
- # Url to the table of contents on the same page.
- my $contents_url =
- $self->{url_builder}->view_url($self->{topic}, -1,
- $self->{mode}, $self->{brmode},
- $self->{fview})
- . "#contents";
-
- # Variables to store the navigation Urls.
- my $fwd_index = "";
- my $bwd_index = "";
- my $fwd_url = "";
- my $bwd_url = "";
-
- # Get the current file index.
- my $cfi = $self->{fview};
-
- # Store the current view mode, single view = 0, all files = -1.
- my $vmode = $self->{fview} == -1 ? -1 : 0;
-
- # No better idea how I can get the array index of the current file. In the
- # single display mode you got it through fview - but in multi mode?
- if ($cfi == -1) {
- for (my $i = 0; $i <= $#$filenames; $i++) {
- if ($$filenames[$i] eq $filename) {
- $cfi = $i;
- last;
- }
- }
- }
-
- # Check the bounds for the previous and next browser. A value of -1
- # indicates there it is not a valid link.
- $fwd_index = ($cfi+1 > $#$filenames ? -1 : $cfi+1);
- $bwd_index = ($cfi-1 < 0 ? -1 : $cfi-1);
-
- # Build the urls for next and previous file. Differ through $vmode
- # between all and single file review.
- if ($fwd_index != -1) {
- $fwd_url = $self->{url_builder}->view_url($self->{topic}, -1,
- $self->{mode},
- $self->{brmode},
- $vmode == -1 ? -1 : $fwd_index)
- . "#$$filenames[$fwd_index]";
- }
- if ($bwd_index != -1) {
- $bwd_url = $self->{url_builder}->view_url($self->{topic}, -1,
- $self->{mode},
- $self->{brmode},
- $vmode == -1 ? -1 : $bwd_index)
- . "#$$filenames[$bwd_index]";
- }
-
- # Generate the text for the link to add a file-level comment.
- my $add_file_level_comment_text =
- $self->render_comment_link($cfi, -1, 1, "[Add File Comment]",
- "file_comment", undef);
-
- if ($repmatch && $revision ne $Codestriker::ADDED_REVISION &&
- $revision ne $Codestriker::PATCH_REVISION) {
- # File matches something in the repository. Link it to
- # the repository viewer if it is defined.
- my $cell = "";
- my $revision_text = "revision $revision";
- my $file_url = "";
- if (defined $self->{repository}) {
- $file_url = $self->{repository}->getViewUrl($filename);
- }
-
- if ($file_url eq "") {
- # Output the header without hyperlinking the filename.
- $cell = "Diff for " .
- $query->a({name=>$filename},
- $filename) .
- $revision_text;
- }
- else {
- # Link the filename to the repository system with more information
- # about it.
- $cell = "Diff for " .
- $query->a({href=>$file_url,
- name=>$filename},
- $filename) .
- $revision_text;
- }
-
- # 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($query->td({-class=>'file', -colspan=>'4'},
- $query->table({-width=>'100%'},
- $query->Tr(
- $query->td({align=>'left'}, $cell),
- $query->td({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},"[>>]") : ""))))));
- } else {
- # No match in repository, or a new file.
- print $query->Tr($query->td({-class=>'file', -colspan=>'4'},
- $query->table({-width=>'100%'},
- $query->Tr(
- $query->td({align=>'left'},
- "File ",
- $query->a({name=>$filename},
- $filename)),
- $query->td({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},"[>>]") : ""))))));
- }
-
-}
-
-# Output the delta heading, which consists of links to view the old and new
-# file in its entirety.
-sub delta_heading ($$$$$$$) {
- my ($self, $filenumber, $revision, $old_linenumber, $new_linenumber,
- $description, $repmatch) = @_;
-
- my $query = $self->{query};
-
- # Create some blank space.
- print $query->Tr($query->td(" "), $query->td(" "),
- $query->td(" "), $query->td(" "), "\n");
-
- # Output a diff block description if one is available, in a separate
- # row.
- if ($description ne "") {
- my $description_escaped = HTML::Entities::encode($description);
- print $query->Tr($query->td({-class=>'line', -colspan=>'2'},
- $description_escaped),
- $query->td({-class=>'line', -colspan=>'2'},
- $description_escaped));
- }
-
- if ($repmatch && $revision ne $Codestriker::ADDED_REVISION &&
- $revision ne $Codestriker::PATCH_REVISION) {
- # Display the line numbers corresponding to the patch, with links
- # to the entire file.
- my $url_builder = $self->{url_builder};
- my $topic = $self->{topic};
- my $mode = $self->{mode};
- my $url_old_full =
- $url_builder->view_file_url($topic, $filenumber, 0,
- $old_linenumber, $mode, 0);
- my $url_old = "javascript: myOpen('$url_old_full','CVS')";
-
- my $url_old_both_full =
- $url_builder->view_file_url($topic, $filenumber, 0,
- $old_linenumber, $mode, 1);
- my $url_old_both =
- "javascript: myOpen('$url_old_both_full','CVS')";
-
- my $url_new_full =
- $url_builder->view_file_url($topic, $filenumber, 1,
- $new_linenumber, $mode, 0);
- my $url_new = "javascript: myOpen('$url_new_full','CVS')";
-
- my $url_new_both_full =
- $url_builder->view_file_url($topic, $filenumber, 1,
- $new_linenumber, $mode, 1);
- my $url_new_both = "javascript: myOpen('$url_new_both_full','CVS')";
-
- print $query->Tr($query->td({-class=>'line', -colspan=>'2'},
- $query->a({href=>$url_old}, "Line " .
- $old_linenumber) .
- " | " .
- $query->a({href=>$url_old_both},
- "Parallel")),
- $query->td({-class=>'line', -colspan=>'2'},
- $query->a({href=>$url_new}, "Line " .
- $new_linenumber) .
- " | " .
- $query->a({href=>$url_new_both},
- "Parallel"))),
- "\n";
- } else {
- # No match in the repository - or a new file. Just display
- # the headings.
- print $query->Tr($query->td({-class=>'line', -colspan=>'2'},
- "Line $old_linenumber"),
- $query->td({-class=>'line', -colspan=>'2'},
- "Line $new_linenumber")),
- "\n";
- }
-}
-
-# Output the delta text chunk in the coloured format.
-sub delta_text ($$$$$$$$$$$) {
- my ($self, $filename, $filenumber, $revision, $old_linenumber,
- $new_linenumber, $text, $repmatch, $new, $link) = @_;
-
- my $query = $self->{query};
-
- # Split up the lines, and display them, with the appropriate links.
- my @lines = split /\n/, $text;
- $self->{old_linenumber} = $old_linenumber;
- $self->{new_linenumber} = $new_linenumber;
- for (my $i = 0; $i <= $#lines; $i++) {
- my $line = $lines[$i];
- if ($self->{parallel}) {
- $self->display_coloured_data($filenumber, $line, $link);
- } else {
- $self->display_single_filedata($filenumber, $line, $new, $link);
- }
- }
-
- # Render the diff blocks.
- if ($self->{parallel}) {
- $self->render_changes($filenumber, $link);
- } else {
- $self->flush_monospaced_lines($filenumber, $self->{max_line_length},
- $new, $link);
- }
-}
-
-# Display a line for coloured data. Note special handling is done for
-# unidiff formatted text, to output it in the "coloured-diff" style. This
-# requires storing state when retrieving each line.
-sub display_coloured_data ($$$$) {
- my ($self, $filenumber, $data, $link) = @_;
-
- my $query = $self->{query};
-
- # Escape the data.
- $data = HTML::Entities::encode($data);
-
- my $leftline = $self->{old_linenumber};
- my $rightline = $self->{new_linenumber};
- if ($data =~ /^\-(.*)$/) {
- # Line corresponds to something which has been removed.
- add_old_change($1, $leftline);
- $leftline++;
- } elsif ($data =~ /^\+(.*)$/) {
- # Line corresponds to something which has been removed.
- add_new_change($1, $rightline);
- $rightline++;
- } elsif ($data =~ /^\\/) {
- # A diff comment such as "No newline at end of file" - ignore it.
- } else {
- # Strip the first space off the diff for proper alignment.
- $data =~ s/^\s//;
-
- # Render the previous diff changes visually.
- $self->render_changes($filenumber, $link);
-
- # Render the current line for both cells.
- my $celldata = $self->render_coloured_cell($data);
-
- # Determine the appropriate classes to render.
- my $cell_class =
- $self->{mode} == $Codestriker::COLOURED_MODE ? "n" : "msn";
-
- my $rendered_left_linenumber =
- $self->render_linenumber($leftline, $filenumber, 0, $link);
- my $rendered_right_linenumber =
- ($leftline == $rightline && !$self->{parallel}) ?
- $rendered_left_linenumber :
- $self->render_linenumber($rightline, $filenumber, 1, $link);
-
- print $query->Tr($query->td($rendered_left_linenumber),
- $query->td({-class=>$cell_class}, $celldata),
- $query->td($rendered_right_linenumber),
- $query->td({-class=>$cell_class}, $celldata),
- "\n");
-
- $leftline++;
- $rightline++;
- }
-
- # Update the left and right line nymber state variables.
- $self->{old_linenumber} = $leftline;
- $self->{new_linenumber} = $rightline;
-}
-
-# Render a cell for the coloured diff.
-sub render_coloured_cell($$)
-{
- my ($self, $data) = @_;
-
- if (! defined $data || $data eq "") {
- return " ";
- }
-
- # Replace spaces and tabs with the appropriate number of 's.
- $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;
- }
- else {
- $data =~ s/\s/ /g;
- }
-
- # Add LXR links to the output.
- $data = $self->lxr_data($data);
-
- # Unconditionally add a at the start for better alignment.
- return " $data";
-}
-
-# Indicate a line of data which has been removed in the diff.
-sub add_old_change($$) {
- my ($data, $linenumber) = @_;
- push @diff_old_lines, $data;
- push @diff_old_lines_numbers, $linenumber;
-}
-
-# Indicate that a line of data has been added in the diff.
-sub add_new_change($$) {
- my ($data, $linenumber) = @_;
- push @diff_new_lines, $data;
- push @diff_new_lines_numbers, $linenumber;
-}
-
-# Render the current diff changes, if there is anything.
-sub render_changes($$$) {
- my ($self, $filenumber, $link) = @_;
-
- return if ($#diff_new_lines == -1 && $#diff_old_lines == -1);
-
- my ($arg1, $arg2, $arg3, $arg4);
- my $mode = $self->{mode};
- if ($#diff_new_lines != -1 && $#diff_old_lines != -1) {
- # Lines have been added and removed.
- if ($mode == $Codestriker::COLOURED_MODE) {
- $arg1 = "c"; $arg2 = "cb"; $arg3 = "c"; $arg4 = "cb";
- } else {
- $arg1 = "msc"; $arg2 = "mscb"; $arg3 = "msc"; $arg4 = "mscb";
- }
- } elsif ($#diff_new_lines != -1 && $#diff_old_lines == -1) {
- # New lines have been added.
- if ($mode == $Codestriker::COLOURED_MODE) {
- $arg1 = "a"; $arg2 = "ab"; $arg3 = "a"; $arg4 = "ab";
- } else {
- $arg1 = "msa"; $arg2 = "msab"; $arg3 = "msa"; $arg4 = "msab";
- }
- } else {
- # Lines have been removed.
- if ($mode == $Codestriker::COLOURED_MODE) {
- $arg1 = "r"; $arg2 = "rb"; $arg3 = "r"; $arg4 = "rb";
- } else {
- $arg1 = "msr"; $arg2 = "msrb"; $arg3 = "msr"; $arg4 = "msrb";
- }
- }
- $self->render_inplace_changes($arg1, $arg2, $arg3, $arg4, $filenumber,
- $link);
-
- # Now that the diff changeset has been rendered, remove the state data.
- @diff_new_lines = ();
- @diff_new_lines_numbers = ();
- @diff_old_lines = ();
- @diff_old_lines_numbers = ();
-}
-
-# Render the inplace changes in the current diff change set.
-sub render_inplace_changes($$$$$$$)
-{
- my ($self, $old_col, $old_notpresent_col, $new_col,
- $new_notpresent_col, $filenumber, $link) = @_;
-
- my $old_data;
- my $new_data;
- my $old_data_line;
- my $new_data_line;
- while ($#diff_old_lines != -1 || $#diff_new_lines != -1) {
-
- # Retrieve the next lines which were removed (if any).
- if ($#diff_old_lines != -1) {
- $old_data = shift @diff_old_lines;
- $old_data_line = shift @diff_old_lines_numbers;
- } else {
- undef($old_data);
- undef($old_data_line);
- }
-
- # Retrieve the next lines which were added (if any).
- if ($#diff_new_lines != -1) {
- $new_data = shift @diff_new_lines;
- $new_data_line = shift @diff_new_lines_numbers;
- } else {
- undef($new_data);
- undef($new_data_line);
- }
-
- my $render_old_data = $self->render_coloured_cell($old_data);
- my $render_new_data = $self->render_coloured_cell($new_data);
-
- # Set the colours to use appropriately depending on what is defined.
- my $render_old_colour = $old_col;
- my $render_new_colour = $new_col;
- if (defined $old_data && ! defined $new_data) {
- $render_new_colour = $new_notpresent_col;
- } elsif (! defined $old_data && defined $new_data) {
- $render_old_colour = $old_notpresent_col;
- }
-
- my $parallel = $self->{parallel};
-
- my $query = $self->{query};
- print $query->Tr($query->td($self->render_linenumber($old_data_line,
- $filenumber,
- 0, $link)),
- $query->td({-class=>"$render_old_colour"},
- $render_old_data),
- $query->td($self->render_linenumber($new_data_line,
- $filenumber,
- 1, $link)),
- $query->td({-class=>"$render_new_colour"},
- $render_new_data), "\n");
- }
-}
-
-# Render a linenumber as a hyperlink. If the line already has a
-# comment made against it, render it with $comment_line_colour. The
-# title of the link should be set to the comment digest, and the
-# status line should be set if the mouse moves over the link.
-# Clicking on the link will take the user to the add comment page.
-sub render_linenumber($$$$$) {
- my ($self, $line, $filenumber, $new, $link) = @_;
-
- if (! defined $line) {
- return " ";
- }
-
- # Determine what class to use when rendering the number.
- my ($comment_class, $no_comment_class);
- if ($self->{mode} == $Codestriker::COLOURED_MODE) {
- $comment_class = "com";
- $no_comment_class = "nocom";
- } else {
- $comment_class = "smscom";
- $no_comment_class = "smsnocom";
- }
-
- # Check if the linenumber is outside the review.
- if ($link == 0) {
- return $line;
- }
-
- # Now render the line.
- return $self->render_comment_link($filenumber, $line, $new, $line,
- $comment_class, $no_comment_class);
-}
-
-# Render the supplied text within a edit comment link.
-sub render_comment_link {
- my ($self, $filenumber, $line, $new, $text,
- $comment_class, $no_comment_class) = @_;
-
- # Determine the anchor and edit URL for this line number.
- my $anchor = "$filenumber|$line|$new";
- my $edit_url = "javascript:eo('$filenumber','$line','$new')";
-
- # Set the anchor to this line number.
- my $params = {};
- $params->{name} = $anchor;
-
- # Only set the href attribute if the comment is in open state.
- if (!Codestriker::topic_readonly($self->{topic_state})) {
- $params->{href} = $edit_url;
- }
-
- # If a comment exists on this line, set span and the overlib hooks onto
- # it.
- my $query = $self->{query};
- my %comment_hash = %{ $self->{comment_hash} };
- my %comment_location_map = %{ $self->{comment_location_map} };
- my $comment_number = undef;
- if (exists $comment_hash{$anchor}) {
- # Determine what comment number this anchor refers to.
- $comment_number = $comment_location_map{$anchor};
-
- if (defined $comment_class) {
- $text = $query->span({-id=>"c$comment_number"}, "") .
- $query->span({-class=>$comment_class}, $text);
- }
-
- # Determine what the next comment in line is.
- my $index = -1;
- my @comment_locations = @{ $self->{comment_locations} };
- for ($index = 0; $index <= $#comment_locations; $index++) {
- last if $anchor eq $comment_locations[$index];
- }
-
- $params->{onmouseover} = "return overlib(comment_text[$index],STICKY,DRAGGABLE,ALTCUT);";
- $params->{onmouseout} = "return nd();";
- } else {
- if (defined $no_comment_class) {
- $text = $query->span({-class=>$no_comment_class}, $text);
- }
- }
-
- return $query->a($params, $text);
-}
-
-# Finished hook called when finished rendering to a page.
-sub finish($) {
- my ($self) = @_;
- if ($self->{mode} == $Codestriker::NORMAL_MODE) {
- $self->_normal_mode_finish();
- } else {
- $self->_coloured_mode_finish();
- }
-
- $self->_print_legend();
-}
-
-# Private functon to print the diff legend out at the bottom of the topic text page.
-sub _print_legend($) {
- my ($self) = @_;
-
- my $query = $self->{query};
- my $topic = $self->{topic};
- my $mode = $self->{mode};
-
- print $query->start_table({-cellspacing=>'0', -cellpadding=>'0',
- -border=>'0'}), "\n";
- print $query->Tr($query->td(" "), $query->td(" "));
- print $query->Tr($query->td({-colspan=>'2'}, "Legend:"));
- print $query->Tr($query->td({-class=>'rf'},
- "Removed"),
- $query->td({-class=>'rb'}, " "));
- print $query->Tr($query->td({-class=>'cf',
- -align=>"center", -colspan=>'2'},
- "Changed"));
- print $query->Tr($query->td({-class=>'ab'}, " "),
- $query->td({-class=>'af'},
- "Added"));
- print $query->end_table(), "\n";
-}
-
-# Render the initial start of the coloured table, with an empty row setting
-# the widths.
-sub print_coloured_table($)
-{
- my ($self) = @_;
-
- my $query = $self->{query};
- print $query->start_table({-width=>'100%',
- -border=>'0',
- -cellspacing=>'0',
- -cellpadding=>'0'}), "\n";
- print $query->Tr($query->td({-width=>'2%'}, " "),
- $query->td({-width=>'48%'}, " "),
- $query->td({-width=>'2%'}, " "),
- $query->td({-width=>'48%'}, " "), "\n");
-}
-
-
-# Finish topic view display hook for coloured mode.
-sub _coloured_mode_finish ($) {
- my ($self) = @_;
-
- if ($self->{fview} != -1) {
- # Show the current file header again for navigation purposes when
- # viewing a single file at a time.
- $self->delta_file_header($self->{diff_current_filename},
- $self->{diff_current_revision},
- $self->{diff_current_repmatch});
- }
-
- print "</TABLE>\n";
-
- # Render the "Add comment to topic" link.
- my $query = $self->{query};
- print $query->p;
- print $self->render_comment_link(-1, -1, 1, "Add General Comment",
- "general_comment", undef);
- print " to topic.";
- print $query->p;
-}
-
-# Display a line for a single file view.
-sub display_single_filedata ($$$$$) {
- my ($self, $filenumber, $data, $new, $link) = @_;
-
- my $leftline = $self->{old_linenumber};
- my $rightline = $self->{new_linenumber};
- my $max_line_length = $self->{max_line_length};
-
- # Handling of either an old or new view.
- if ($data =~ /^\-(.*)$/o) {
- # A removed line.
- $self->add_minus_monospace_line($1, $leftline++);
- } elsif ($data =~ /^\+(.*)$/o) {
- # An added line.
- $self->add_plus_monospace_line($1, $rightline++);
- } else {
- # An unchanged line, output it and anything pending, and remove
- # the leading space for alignment reasons.
- $data =~ s/^\s//;
- $self->flush_monospaced_lines($filenumber, $max_line_length, $new,
- $link);
-
- my $linenumber = $new ? $rightline : $leftline;
- print $self->render_monospaced_line($filenumber, $linenumber, $new,
- $data, $link,
- $max_line_length, "");
- $leftline++;
- $rightline++;
- }
-
- # Update the left and right line nymber state variables.
- $self->{old_linenumber} = $leftline;
- $self->{new_linenumber} = $rightline;
-}
-
-# Print out a line of data with the specified line number suitably aligned,
-# and with tabs replaced by spaces for proper alignment.
-sub render_monospaced_line ($$$$$$$$) {
- my ($self, $filenumber, $linenumber, $new, $data, $link,
- $max_line_length, $class) = @_;
-
- # Convert any identifier to their LXR links.
- $data = $self->lxr_data(HTML::Entities::encode($data));
-
- my $prefix = "";
- my $digit_width = length($linenumber);
- my $max_digit_width = $self->{max_digit_width};
- for (my $i = 0; $i < ($max_digit_width - $digit_width); $i++) {
- $prefix .= " ";
- }
-
- # Determine what class to use when rendering the number.
- my ($comment_class, $no_comment_class);
- if ($self->{parallel} == 0) {
- $comment_class = "mscom";
- $no_comment_class = "msnocom";
- } else {
- if ($self->{mode} == $Codestriker::COLOURED_MODE) {
- $comment_class = "com";
- $no_comment_class = "nocom";
- } else {
- $comment_class = "smscom";
- $no_comment_class = "smsnocom";
- }
- }
-
- my $line_cell = "";
- if ($link == 0) {
- # A line outside of the review. Just render the line number, as
- # the "name" of the linenumber should not be used.
- $line_cell = "$prefix$linenumber";
- } else {
- $line_cell = $prefix .
- $self->render_comment_link($filenumber, $linenumber, $new,
- $linenumber, $comment_class,
- $no_comment_class);
- }
-
- # Render the line data. If the user clicks on a topic line, the
- # edit window is focused to the appropriate line.
- my $query = $self->{query};
-
- # Replace the line data with spaces.
- my $newdata = tabadjust($self->{tabwidth}, $data, 0);
-
- if ($class ne "") {
- # Add the appropriate number of spaces to justify the data to a length
- # of $max_line_length, and render it within a SPAN to get the correct
- # background colour.
- my $padding = $max_line_length - length($data);
- for (my $i = 0; $i < ($padding); $i++) {
- $newdata .= " ";
- }
- return "$line_cell " .
- $query->span({-class=>"$class"}, $newdata) . "\n";
- }
- else {
- return "$line_cell $newdata\n";
- }
-}
-
-# Record a plus line.
-sub add_plus_monospace_line ($$$) {
- my ($self, $linedata, $offset) = @_;
- push @view_file_plus, $linedata;
- push @view_file_plus_offset, $offset;
-}
-
-# Record a minus line.
-sub add_minus_monospace_line ($$$) {
- my ($self, $linedata, $offset) = @_;
- push @view_file_minus, $linedata;
- push @view_file_minus_offset, $offset;
-}
-
-# Flush the current diff chunk. Note if the original file is being rendered,
-# the minus lines are used, otherwise the plus lines.
-sub flush_monospaced_lines ($$$$$) {
- my ($self, $filenumber, $max_line_length, $new, $link) = @_;
-
- my $class = "";
- if ($#view_file_plus != -1 && $#view_file_minus != -1) {
- # This is a change chunk.
- $class = "msc";
- }
- elsif ($#view_file_plus != -1) {
- # This is an add chunk.
- $class = "msa";
- }
- elsif ($#view_file_minus != -1) {
- # This is a remove chunk.
- $class = "msr";
- }
-
- if ($new) {
- for (my $i = 0; $i <= $#view_file_plus; $i++) {
- print $self->render_monospaced_line($filenumber,
- $view_file_plus_offset[$i],
- $new,
- $view_file_plus[$i], $link,
- $max_line_length, $class);
- }
- }
- else {
- for (my $i = 0; $i <= $#view_file_minus; $i++) {
- print $self->render_monospaced_line($filenumber,
- $view_file_minus_offset[$i],
- $new,
- $view_file_minus[$i], $link,
- $max_line_length, $class);
- }
- }
- $#view_file_minus = -1;
- $#view_file_minus_offset = -1;
- $#view_file_plus = -1;
- $#view_file_plus_offset = -1;
-}
-
-# Replace the passed in string with the correct number of spaces, for
-# alignment purposes.
-sub tabadjust ($$$) {
- my ($tabwidth, $input, $htmlmode) = @_;
-
- $_ = $input;
- if ($htmlmode) {
- 1 while s/\t+/' ' x
- (length($&) * $tabwidth - length($`) % $tabwidth)/eo;
- }
- else {
- 1 while s/\t+/' ' x
- (length($&) * $tabwidth - length($`) % $tabwidth)/eo;
- }
- return $_;
-}
-
-# Retrieve the data that forms the "context" when submitting a comment.
-sub get_context ($$$$$$$$$) {
- my ($type, $targetline, $context, $html_view, $old_startline,
- $new_startline, $text, $new) = @_;
-
- # Break the text into lines.
- my @document = split /\n/, $text;
-
- # Calculate the location of the target line within the diff chunk.
- my $offset;
- my $old_linenumber = $old_startline;
- my $new_linenumber = $new_startline;
- for ($offset = 0; $offset <= $#document; $offset++) {
-
- my $data = $document[$offset];
-
- # Check if the target line as been found.
- if ($data =~ /^ /o) {
- last if ($new && $new_linenumber == $targetline);
- last if ($new == 0 && $old_linenumber == $targetline);
- $old_linenumber++;
- $new_linenumber++;
- } elsif ($data =~ /^\+/o) {
- last if ($new && $new_linenumber == $targetline);
- $new_linenumber++;
- } elsif ($data =~ /^\-/o) {
- last if ($new == 0 && $old_linenumber == $targetline);
- $old_linenumber++;
- }
- }
-
- # Get the minimum and maximum line numbers for this context, and return
- # the data. The line of interest will be rendered appropriately.
- my $min_line = ($offset - $context < 0 ? 0 : $offset - $context);
- my $max_line = $offset + $context;
- my $context_string = "";
- for (my $i = $min_line; $i <= $max_line && $i <= $#document; $i++) {
- my $linedata = $document[$i];
- if ($html_view) {
- if ($i == $offset) {
- $context_string .=
- "<font color=\"$CONTEXT_COLOUR\">" .
- HTML::Entities::encode($linedata) . "</font>\n";
- } else {
- $context_string .= HTML::Entities::encode("$linedata") ."\n";
- }
- } else {
- # This is the context for emails.
- $context_string .= ($i == $offset) ? "* " : " ";
- $context_string .= $linedata . "\n";
- }
- }
- return $context_string;
-}
-
-1;
Index: Delta.pm
===================================================================
RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Model/Delta.pm,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- Delta.pm 30 May 2006 07:18:09 -0000 1.11
+++ Delta.pm 14 Mar 2008 01:30:53 -0000 1.12
@@ -169,31 +169,66 @@
return @results;
}
+# Determine the offset of $target_line within the delta text. or -1
+# if it can't be located.
+sub find_line_offset {
+ my ($self, $targetline, $new) = @_;
-# This function looks at the delta, and will return 1 if the delta looks like
-# it is a delta for a completly new file. This happens when a new file is added
-# to SCM system, or the user updated a plain old text document to be reviewed
-# without diffs. We need this function because we want to format this case
-# special.
-sub is_delta_new_file
-{
- my $self = shift;
-
- # All of the following must be true:
- # - one delta for the entire file
- # - delta must start at line 1 (0ld, and new)
- my $is_new_file = 0;
- if ($self->{only_delta_in_file} &&
- $self->{old_linenumber} == 0 &&
- $self->{new_linenumber} == 1) {
- # All of the delta text lines must start with +.
- my @lines = split '\n', $self->{text};
- if ( scalar( grep !/^\+/, @lines ) == 0) {
- $is_new_file = 1;
+ # Break the text into lines.
+ my @document = split /\n/, $self->{text};
+
+ # Calculate the location of the target line within the diff chunk.
+ my $offset;
+ my $old_linenumber = $self->{old_linenumber};
+ my $new_linenumber = $self->{new_linenumber};
+ for ($offset = 0; $offset <= $#document; $offset++) {
+
+ my $data = $document[$offset];
+
+ # Check if the target line as been found.
+ if ($data =~ /^ /o) {
+ last if ($new && $new_linenumber == $targetline);
+ last if ($new == 0 && $old_linenumber == $targetline);
+ $old_linenumber++;
+ $new_linenumber++;
+ } elsif ($data =~ /^\+/o) {
+ last if ($new && $new_linenumber == $targetline);
+ $new_linenumber++;
+ } elsif ($data =~ /^\-/o) {
+ last if ($new == 0 && $old_linenumber == $targetline);
+ $old_linenumber++;
}
}
-
- return $is_new_file;
+
+ if (($new && $new_linenumber == $targetline) ||
+ ($new == 0 && $old_linenumber == $targetline)) {
+ return $offset;
+ } else {
+ # No match was found.
+ return -1;
+ }
+}
+
+# Retrieve the textual context for the delta at the specified line and
+# context width.
+sub retrieve_context {
+ my ($self, $targetline, $new, $context, $text) = @_;
+
+ my $offset = $self->find_line_offset($targetline, $new);
+ if ($offset == -1) {
+ return -1;
+ }
+
+ # Get the minimum and maximum line numbers for this context, and return
+ # the data.
+ my @document = split /\n/, $self->{text};
+ my $min_line = ($offset - $context < 0 ? 0 : $offset - $context);
+ my $max_line = $offset + $context;
+ for (my $i = $min_line; $i <= $max_line && $i <= $#document; $i++) {
+ push @{ $text }, $document[$i];
+ }
+
+ return $offset - $min_line;
}
1;
Index: FormatWhitespace.pm
===================================================================
RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Template/Plugin/FormatWhitespace.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- FormatWhitespace.pm 2 Jun 2005 11:31:01 -0000 1.1
+++ FormatWhitespace.pm 14 Mar 2008 01:30:53 -0000 1.2
@@ -22,7 +22,7 @@
$text =~ s/ \s+/' ' x (length($&)-1)/emgo;
# Replace tabs.
- $text = Codestriker::Http::Render::tabadjust($tabwidth, $text, 1);
+ $text = Codestriker::tabadjust($tabwidth, $text, 1);
return $text;
}
Index: Email.pm
===================================================================
RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/TopicListeners/Email.pm,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- Email.pm 9 Jan 2008 06:16:05 -0000 1.25
+++ Email.pm 14 Mar 2008 01:30:53 -0000 1.26
@@ -370,14 +370,18 @@
$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";
+ my @text = ();
+ my $offset = $delta->retrieve_context($comment->{fileline}, $comment->{filenew},
+ $email_context, \@text);
+ for (my $i = 0; $i <= $#text; $i++) {
+ if ($i == $offset) {
+ $text[$i] = "* " . $text[$i];
+ } else {
+ $text[$i] = " " . $text[$i];
+ }
+ }
+ $body .= join "\n", @text;
+ $body .= "\n\n";
$body .= "$EMAIL_HR";
}
$body .= "\n\n";
Index: viewdeltas.html.tmpl
===================================================================
RCS file: /cvsroot/codestriker/codestriker/template/en/default/viewdeltas.html.tmpl,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- viewdeltas.html.tmpl 13 Mar 2008 22:39:07 -0000 1.4
+++ viewdeltas.html.tmpl 14 Mar 2008 01:30:53 -0000 1.5
@@ -30,14 +30,15 @@
<table width="100%" cellspacing="0" cellpadding="0" border="0">
[% END %]
- [%# Now output the delta header. #%]
+ [%# Now output the delta header if its not a new file. #%]
[% SET diff_current_filename = delta.filename %]
<tr>
<td colspan="4"> </td>
</tr>
<tr>
- [% IF delta.view_old_full_url != "" %]
- [%# Display heading with links to retrieve the entire file #%]
+ [% IF !delta.new_file %]
+ [% IF delta.view_old_full_url != "" %]
+ [%# Display heading with links to retrieve the entire file #%]
<td class="line" colspan="2">
<a href="javascript: myOpen('[% delta.view_old_full_url %]', 'Codestriker')">
Line [% delta.old_linenumber %]
@@ -56,10 +57,11 @@
Parallel
</a>
</td>
- [% ELSE %]
- [%# Just display the line numbers for the delta without any links. #%]
+ [% ELSE %]
+ [%# Just display the line numbers for the delta without any links. #%]
<td class="line" colspan="2">Line [% delta.old_linenumber %]</td>
<td class="line" colspan="2">Line [% delta.new_linenumber ...
[truncated message content] |
|
From: <si...@us...> - 2008-03-13 22:39:09
|
User: sits
Date: 08/03/13 15:39:07
Modified: lib/Codestriker/Action ViewTopic.pm
template/en/default viewdeltaheader.html.tmpl
viewdeltas.html.tmpl viewtopic.html.tmpl
Log:
Support named anchors again for filenames
Index: ViewTopic.pm
===================================================================
RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Action/ViewTopic.pm,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -r1.58 -r1.59
--- ViewTopic.pm 13 Mar 2008 00:56:02 -0000 1.58
+++ ViewTopic.pm 13 Mar 2008 22:39:07 -0000 1.59
@@ -209,9 +209,6 @@
$filerow->{href_filename_url} =
$url_builder->view_url($topicid, -1, $mode, $brmode, $i) .
"#" . $filename;
- $filerow->{anchor_filename_url} =
- $url_builder->view_url($topicid, -1, $mode, $brmode, -1) .
- "#" . $filename;
$filerow->{binary} = $binary[$i];
my $revision = $revisions[$i];
Index: viewdeltaheader.html.tmpl
===================================================================
RCS file: /cvsroot/codestriker/codestriker/template/en/default/viewdeltaheader.html.tmpl,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- viewdeltaheader.html.tmpl 13 Mar 2008 06:11:34 -0000 1.1
+++ viewdeltaheader.html.tmpl 13 Mar 2008 22:39:07 -0000 1.2
@@ -2,13 +2,13 @@
<tr>
<td class="file" align="left">
+ [% IF render_anchor %]<a name="[% delta.filename %]">File</a> [% ELSE %]File [% END %]
[% IF delta.repository_file_view_url != "" %]
- File
<a href="[% delta.repository_file_view_url %]">
[% delta.filename | html_entity %]
</a>
[% ELSE %]
- File [% delta.filename | html_entity %]
+ [% delta.filename | html_entity %]
[% END %]
(Revision [% delta.revision %])
</td>
Index: viewdeltas.html.tmpl
===================================================================
RCS file: /cvsroot/codestriker/codestriker/template/en/default/viewdeltas.html.tmpl,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- viewdeltas.html.tmpl 13 Mar 2008 06:11:34 -0000 1.3
+++ viewdeltas.html.tmpl 13 Mar 2008 22:39:07 -0000 1.4
@@ -14,7 +14,7 @@
<table width="100%" cellspacing="0" cellpadding="0" border="0">
- [% PROCESS viewdeltaheader.html.tmpl delta = delta %]
+ [% PROCESS viewdeltaheader.html.tmpl delta = delta render_anchor = 1 %]
[%# Output the diff description if it is present. #%]
[% IF delta.description != "" %]
@@ -82,6 +82,6 @@
[% IF render_header_in_footer %]
<table width="100%" cellspacing="0" cellpadding="0" border="0">
-[% PROCESS viewdeltaheader.html.tmpl delta = delta %]
+[% PROCESS viewdeltaheader.html.tmpl delta = delta render_anchor = 0 %]
</table>
[% END %]
Index: viewtopic.html.tmpl
===================================================================
RCS file: /cvsroot/codestriker/codestriker/template/en/default/viewtopic.html.tmpl,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -r1.44 -r1.45
--- viewtopic.html.tmpl 13 Mar 2008 06:11:34 -0000 1.44
+++ viewtopic.html.tmpl 13 Mar 2008 22:39:07 -0000 1.45
@@ -65,7 +65,7 @@
[%# Display the jump to link in the case when all files are displayed. #%]
[% IF fview == -1 %]
- [<a href="[% file.anchor_filename_url %]">Jump to</a>]
+ [<a href="#[% file.filename %]">Jump to</a>]
[% END %]
[%# Display the filename with an internal link if its not binary. #%]
|
|
From: <si...@us...> - 2008-03-13 06:11:37
|
User: sits
Date: 08/03/12 23:11:34
Modified: template/en/default viewdeltas.html.tmpl viewtopic.html.tmpl
Added: template/en/default viewdeltaheader.html.tmpl
Log:
Render the delta header in the footer if only one file is being viewed.
Index: viewdeltas.html.tmpl
===================================================================
RCS file: /cvsroot/codestriker/codestriker/template/en/default/viewdeltas.html.tmpl,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- viewdeltas.html.tmpl 12 Mar 2008 08:29:15 -0000 1.2
+++ viewdeltas.html.tmpl 13 Mar 2008 06:11:34 -0000 1.3
@@ -13,30 +13,8 @@
[% END %]
<table width="100%" cellspacing="0" cellpadding="0" border="0">
- <tr>
- <td class="file" align="left">
- [% IF delta.repository_file_view_url != "" %]
- File
- <a href="[% delta.repository_file_view_url %]">
- [% delta.filename | html_entity %]
- </a>
- [% ELSE %]
- File [% delta.filename | html_entity %]
- [% END %]
- (Revision [% delta.revision %])
- </td>
-
- <td class="file" align="right">
- [% delta.add_file_comment_element %]
- [% IF delta.previous_file_url != "" %]
- <a href="[% delta.previous_file_url %]">[<<]</a>
- [% END %]
- <a href="#contents">[Top]</a>
- [% IF delta.next_file_url != "" %]
- <a href="[% delta.next_file_url %]">[>>]</a>
- [% END %]
- </td>
- </tr>
+
+ [% PROCESS viewdeltaheader.html.tmpl delta = delta %]
[%# Output the diff description if it is present. #%]
[% IF delta.description != "" %]
@@ -55,7 +33,7 @@
[%# Now output the delta header. #%]
[% SET diff_current_filename = delta.filename %]
<tr>
- <td> </td><td> </td><td> </td><td> </td>
+ <td colspan="4"> </td>
</tr>
<tr>
[% IF delta.view_old_full_url != "" %]
@@ -95,7 +73,15 @@
<td class="[% line.new_data_class %]">[% line.new_data %]</td>
</tr>
[% END %]
+ <tr><td colspan="4"> </td></tr>
+
[% END %]
[%# Close off the table from the last file's delta set. #%]
</table>
+
+[% IF render_header_in_footer %]
+<table width="100%" cellspacing="0" cellpadding="0" border="0">
+[% PROCESS viewdeltaheader.html.tmpl delta = delta %]
+</table>
+[% END %]
Index: viewtopic.html.tmpl
===================================================================
RCS file: /cvsroot/codestriker/codestriker/template/en/default/viewtopic.html.tmpl,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -r1.43 -r1.44
--- viewtopic.html.tmpl 13 Mar 2008 00:56:03 -0000 1.43
+++ viewtopic.html.tmpl 13 Mar 2008 06:11:34 -0000 1.44
@@ -102,7 +102,8 @@
<span class="general_comment">[% add_general_comment_element %] to topic.</span>
<p>
-[% PROCESS viewdeltas.html.tmpl deltas = deltas %]
+[%# Render the delta header in the footer if only one file is being viewed. #%]
+[% PROCESS viewdeltas.html.tmpl deltas = deltas render_header_in_footer = fview != -1 %]
[%# Output the legend at the bottom. #%]
Index: viewdeltaheader.html.tmpl
===================================================================
RCS file: viewdeltaheader.html.tmpl
diff -N viewdeltaheader.html.tmpl
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ viewdeltaheader.html.tmpl 13 Mar 2008 06:11:34 -0000 1.1
@@ -0,0 +1,26 @@
+[%# HTML for rendering a delta header. #%]
+
+ <tr>
+ <td class="file" align="left">
+ [% IF delta.repository_file_view_url != "" %]
+ File
+ <a href="[% delta.repository_file_view_url %]">
+ [% delta.filename | html_entity %]
+ </a>
+ [% ELSE %]
+ File [% delta.filename | html_entity %]
+ [% END %]
+ (Revision [% delta.revision %])
+ </td>
+
+ <td class="file" align="right">
+ [% delta.add_file_comment_element %]
+ [% IF delta.previous_file_url != "" %]
+ <a href="[% delta.previous_file_url %]">[<<]</a>
+ [% END %]
+ <a href="#contents">[Top]</a>
+ [% IF delta.next_file_url != "" %]
+ <a href="[% delta.next_file_url %]">[>>]</a>
+ [% END %]
+ </td>
+ </tr>
|
|
From: <si...@us...> - 2008-03-13 00:56:06
|
User: sits
Date: 08/03/12 17:56:03
Modified: lib/Codestriker/Action ViewTopic.pm
template/en/default viewtopic.html.tmpl
Log:
Remove the old Render references from ViewTopic
Index: ViewTopic.pm
===================================================================
RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Action/ViewTopic.pm,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -r1.57 -r1.58
--- ViewTopic.pm 11 Mar 2008 09:06:50 -0000 1.57
+++ ViewTopic.pm 13 Mar 2008 00:56:02 -0000 1.58
@@ -16,7 +16,6 @@
use Codestriker::Model::Topic;
use Codestriker::Model::Comment;
use Codestriker::Http::UrlBuilder;
-use Codestriker::Http::Render;
use Codestriker::Http::DeltaRenderer;
use Codestriker::Repository::RepositoryFactory;
use Codestriker::TopicListeners::Manager;
@@ -306,43 +305,6 @@
# Fire the template for generating the view topic screen.
my $template = Codestriker::Http::Template->new("viewtopic");
$template->process($vars);
-
- # The rest of the output is non-template driven, as it is quite
- # complex.
-
- print $query->p if ($mode == $Codestriker::NORMAL_MODE);
-
- # Number of characters the line number should take, need the real lines
- # not the number of changed lines.
- 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,
- $mode, \@comments, $tabwidth,
- $repository, \@filenames,
- \@revisions, \@binary,
- \@numchanges, -1,
- $brmode, $fview);
-
- # Retrieve the delta set comprising this review.
- my $old_filename = "";
-
- # Now render the selected deltas.
- for (my $i = 0; $i <= $#deltas; $i++) {
- my $delta = $deltas[$i];
- $render->delta($delta);
- }
-
- $render->finish();
-
- # Render the HTML trailer.
- my $trailer = Codestriker::Http::Template->new("trailer");
- $trailer->process();
-
- print $query->end_html();
-
$http_response->generate_footer();
# Fire the topic listener to indicate that the user has viewed the topic.
Index: viewtopic.html.tmpl
===================================================================
RCS file: /cvsroot/codestriker/codestriker/template/en/default/viewtopic.html.tmpl,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -r1.42 -r1.43
--- viewtopic.html.tmpl 11 Mar 2008 06:01:13 -0000 1.42
+++ viewtopic.html.tmpl 13 Mar 2008 00:56:03 -0000 1.43
@@ -99,7 +99,8 @@
mode = mode %]
<p>
-<span class="general_comment">[% add_general_comment_element %]</span>
+<span class="general_comment">[% add_general_comment_element %] to topic.</span>
+<p>
[% PROCESS viewdeltas.html.tmpl deltas = deltas %]
@@ -116,7 +117,11 @@
<p>
<span class="general_comment">[% add_general_comment_element %] to topic.</span>
-[%# The perl script takes control from here, rendering the topic data. #%]
+[% PROCESS trailer.html.tmpl %]
+
+</body>
+</html>
+
|
|
From: <si...@us...> - 2008-03-12 08:29:16
|
User: sits
Date: 08/03/12 01:29:15
Modified: lib/Codestriker/Action ViewTopicFile.pm
template/en/default viewdeltas.html.tmpl
Added: template/en/default viewtopicfile.html.tmpl
Log:
Reuse the templates for the view topic file action.
Index: ViewTopicFile.pm
===================================================================
RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Action/ViewTopicFile.pm,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- ViewTopicFile.pm 15 Jan 2006 21:20:05 -0000 1.12
+++ ViewTopicFile.pm 12 Mar 2008 08:29:14 -0000 1.13
@@ -42,7 +42,7 @@
# Retrieve the corresponding repository object.
my $repository =
- Codestriker::Repository::RepositoryFactory->get($topic->{repository});
+ Codestriker::Repository::RepositoryFactory->get($topic->{repository});
# Retrieve the deltas corresponding to this file.
my @deltas = Codestriker::Model::Delta->get_deltas($topicid, $fn);
@@ -66,25 +66,6 @@
"$revision: $!");
}
- # This could be done more efficiently, but for now, read through the
- # file, and determine the longest line length for the resulting
- # data that is to be viewed. Note it is not 100% accurate, but it will
- # do for now, to reduce the resulting page size.
- my $max_line_length = $filedata_max_line_length;
- for (my $d = 0; $d <= $#deltas; $d++) {
- my @difflines = split /\n/, $deltas[$d]->{text};
- for (my $i = 0; $i <= $#difflines; $i++) {
- my $line = $difflines[$i];
- if ($line =~ /^\s(.*)$/o || $line =~ /^\+(.*)$/o ||
- $line =~ /^\-(.*)$/o) {
- my $line_length = length($1);
- if ($line_length > $max_line_length) {
- $max_line_length = $line_length;
- }
- }
- }
- }
-
# Output the new file, with the deltas applied.
my $title;
if ($parallel) {
@@ -103,85 +84,69 @@
repository=>$Codestriker::repository_name_map->{$topic->{repository}},
reload=>0, cache=>1);
- # Render the HTML header.
- my $vars = {};
- $vars->{'closehead'} = 1;
-
- my $header = Codestriker::Http::Template->new("header");
- $header->process($vars);
-
- my $max_digit_width = length($#filedata);
-
- # Create a new render object to perform the line rendering.
- my @toc_filenames = ();
- my @toc_revisions = ();
- my @toc_binaries = ();
- my $url_builder = Codestriker::Http::UrlBuilder->new($query);
- my $render =
- Codestriker::Http::Render->new($query, $url_builder, $parallel,
- $max_digit_width, $topicid, $mode,
- \@comments, $tabwidth,
- $repository, \@toc_filenames,
- \@toc_revisions, \@toc_binaries,
- undef, $max_line_length, $brmode,
- $fview);
- # Prepare the output.
-
- if ($parallel) {
- $render->print_coloured_table();
- }
- else {
- print "<PRE class=\"ms\">\n";
+ # Need to create a single delta object that combines all of the deltas
+ # together.
+ my $merged_delta = {};
+ if (@deltas > 0) {
+ my $delta = $deltas[0];
+ $merged_delta->{filename} = $delta->{filename};
+ $merged_delta->{revision} = $delta->{revision};
+ $merged_delta->{binary} = $delta->{binary};
+ $merged_delta->{filenumber} = $delta->{filenumber};
+ $merged_delta->{repmatch} = $delta->{repmatch};
+ $merged_delta->{old_linenumber} = 1;
+ $merged_delta->{new_linenumber} = 1;
+ $merged_delta->{only_delta_in_file} = 1;
}
-
- # Read through all the deltas, and apply them to the original form of the
- # file.
- my $delta = undef;
+
+ # Now compute the delta text of all the merged deltas.
+ my $delta_text = "";
+ my $old_linenumber = 1;
for (my $delta_index = 0; $delta_index <= $#deltas; $delta_index++) {
- $delta = $deltas[$delta_index];
+ my $delta = $deltas[$delta_index];
# Output those lines leading up to the start of the next delta.
# Build up a delta with no changes, and render it.
- my $delta_text = "";
my $next_delta_linenumber = $delta->{old_linenumber};
- for (my $i = $render->{old_linenumber};
- $i < $next_delta_linenumber; $i++) {
+ for (my $i = $old_linenumber; $i < $next_delta_linenumber; $i++) {
$delta_text .= " $filedata[$i]\n";
+ $old_linenumber++;
+ }
+
+ # Keep track of the old linenumber so the blanks between the
+ # deltas can be filled in.
+ my @diff_lines = split /\n/, $delta->{text};
+ foreach my $line (@diff_lines) {
+ if ($line =~ /^\-/o || $line =~ /^\s/o) {
+ $old_linenumber++;
+ }
}
- $render->delta_text($filename, $fn, $revision,
- $render->{old_linenumber},
- $render->{new_linenumber},
- $delta_text, 0, $new, 0);
-
- # Render the actual change delta.
- $render->delta_text($filename, $fn, $revision,
- $delta->{old_linenumber},
- $delta->{new_linenumber}, $delta->{text}, 1,
- $new, 1);
+
+ # Add the text of this delta to the final text.
+ $delta_text .= $delta->{text};
}
- # Render the tail part of the file, again by building up a delta.
- my $delta_text = "";
- for (my $i = $render->{old_linenumber}; $i <= $#filedata; $i++) {
+ # Add the text from the tail-end of the file.
+ for (my $i = $old_linenumber; $i <= $#filedata; $i++) {
$delta_text .= " $filedata[$i]\n";
}
- $render->delta_text($filename, $fn, $revision, $render->{old_linenumber},
- $render->{new_linenumber}, $delta_text, 0, $new, 0);
-
- # Close off the rendering.
- if ($parallel) {
- print $query->end_table();
- }
- else {
- print "</PRE>\n";
- }
- # Render the HTML trailer.
- my $trailer = Codestriker::Http::Template->new("trailer");
- $trailer->process();
+ # Now update the merged delta with this text.
+ $merged_delta->{text} = $delta_text;
- print $query->end_html();
+ # Render this delta.
+ my @merged_deltas = ();
+ push @merged_deltas, $merged_delta;
+ my $delta_renderer =
+ Codestriker::Http::DeltaRenderer->new($topic, \@comments,
+ \@merged_deltas, $query,
+ $mode, $brmode, $tabwidth);
+ $delta_renderer->annotate_deltas();
+ my $vars = {};
+ $vars->{'deltas'} = \@merged_deltas;
+ my $template = Codestriker::Http::Template->new("viewtopicfile");
+ $template->process($vars);
$http_response->generate_footer();
# Fire the topic listener to indicate that the user has viewed the topic.
Index: viewdeltas.html.tmpl
===================================================================
RCS file: /cvsroot/codestriker/codestriker/template/en/default/viewdeltas.html.tmpl,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- viewdeltas.html.tmpl 9 Mar 2008 19:57:08 -0000 1.1
+++ viewdeltas.html.tmpl 12 Mar 2008 08:29:15 -0000 1.2
@@ -23,6 +23,7 @@
[% ELSE %]
File [% delta.filename | html_entity %]
[% END %]
+ (Revision [% delta.revision %])
</td>
<td class="file" align="right">
Index: viewtopicfile.html.tmpl
===================================================================
RCS file: viewtopicfile.html.tmpl
diff -N viewtopicfile.html.tmpl
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ viewtopicfile.html.tmpl 12 Mar 2008 08:29:15 -0000 1.1
@@ -0,0 +1,6 @@
+[%# Screen for displaying a complete file from a topic. #%]
+
+[% PROCESS header.html.tmpl version = version displaymenu = 1
+ closehead = 1 %]
+
+[% PROCESS viewdeltas.html.tmpl deltas = deltas %]
|
|
From: <si...@us...> - 2008-03-11 09:06:52
|
User: sits
Date: 08/03/11 02:06:50
Modified: lib/Codestriker/Action ViewTopic.pm
Log:
Minor fixes for parallel mode to work again
Index: ViewTopic.pm
===================================================================
RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Action/ViewTopic.pm,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -r1.56 -r1.57
--- ViewTopic.pm 10 Mar 2008 23:18:03 -0000 1.56
+++ ViewTopic.pm 11 Mar 2008 09:06:50 -0000 1.57
@@ -268,13 +268,13 @@
$delta->{view_old_full_url} =
$url_builder->view_file_url($topicid, $filenumber, 0, $delta->{old_linenumber},
$mode, 0);
- $delta->{view_old_both_full_url} =
+ $delta->{view_old_full_both_url} =
$url_builder->view_file_url($topicid, $filenumber, 0, $delta->{old_linenumber},
$mode, 1);
$delta->{view_new_full_url} =
$url_builder->view_file_url($topicid, $filenumber, 1, $delta->{new_linenumber},
$mode, 0);
- $delta->{view_new_both_full_url} =
+ $delta->{view_new_full_both_url} =
$url_builder->view_file_url($topicid, $filenumber, 1, $delta->{new_linenumber},
$mode, 1);
}
|
|
From: <si...@us...> - 2008-03-11 06:01:19
|
User: sits
Date: 08/03/10 23:01:13
Modified: html codestriker.css
template/en/default viewtopic.html.tmpl
Log:
Add legend to the bottom of the template
Index: codestriker.css
===================================================================
RCS file: /cvsroot/codestriker/codestriker/html/codestriker.css,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- codestriker.css 28 Feb 2008 06:26:18 -0000 1.15
+++ codestriker.css 11 Mar 2008 06:01:12 -0000 1.16
@@ -96,7 +96,7 @@
SPAN.file_comment {background-color: #cccccc; font-family: Helvetica, Arial; font-size: medium; color: #ff0000}
/* General heading */
-SPAN.general_comment {color: #ff0000}
+SPAN.general_comment {color: #000000; font-family: Helvetica, Arial}
/* Style used for rendering data within popup window */
PRE.ms {font-family: monospace; font-size: medium}
Index: viewtopic.html.tmpl
===================================================================
RCS file: /cvsroot/codestriker/codestriker/template/en/default/viewtopic.html.tmpl,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -r1.41 -r1.42
--- viewtopic.html.tmpl 9 Mar 2008 19:57:08 -0000 1.41
+++ viewtopic.html.tmpl 11 Mar 2008 06:01:13 -0000 1.42
@@ -103,6 +103,19 @@
[% PROCESS viewdeltas.html.tmpl deltas = deltas %]
+[%# Output the legend at the bottom. #%]
+
+<table cellspacing="0" cellpadding="0" border="0">
+ <tr><td> </td><td> </td></tr>
+ <tr><td colspan="2">Legend:</td></tr>
+ <tr><td class="rf">Removed</td><td class="rb"> </td></tr>
+ <tr><td colspan="2" align="center" class="cf">Changed</td></tr>
+ <tr><td class="ab"> </td><td class="af">Added</td></tr>
+</table>
+
+<p>
+<span class="general_comment">[% add_general_comment_element %] to topic.</span>
+
[%# The perl script takes control from here, rendering the topic data. #%]
|
|
From: <si...@us...> - 2008-03-10 23:18:05
|
User: sits
Date: 08/03/10 16:18:04
Modified: lib/Codestriker/Action ViewTopic.pm
lib/Codestriker/Http DeltaRenderer.pm
Added: lib/Codestriker/Http HtmlEntityLineFilter.pm
LineBreakLineFilter.pm LineFilter.pm
TabToNbspLineFilter.pm
Log:
Introduced the notion of a LineFilter when rendering lines within a delta.
This nicely separates out potentially complex line rendering code into
separate modules, and will hopefully make customisations easier to
accomplish. Will need to implement the LxrLineFilter, and then
the SyntaxHighlightingLineFilter.
Index: ViewTopic.pm
===================================================================
RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Action/ViewTopic.pm,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -r1.55 -r1.56
--- ViewTopic.pm 9 Mar 2008 19:57:07 -0000 1.55
+++ ViewTopic.pm 10 Mar 2008 23:18:03 -0000 1.56
@@ -242,8 +242,8 @@
}
my $delta_renderer =
- Codestriker::Http::Delta->new($topic, \@comments, \@deltas, $query,
- $mode, $brmode);
+ Codestriker::Http::DeltaRenderer->new($topic, \@comments, \@deltas, $query,
+ $mode, $brmode, $tabwidth);
# Set the add general comment URL.
$vars->{'add_general_comment_element'} =
Index: DeltaRenderer.pm
===================================================================
RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Http/DeltaRenderer.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DeltaRenderer.pm 9 Mar 2008 19:57:08 -0000 1.1
+++ DeltaRenderer.pm 10 Mar 2008 23:18:03 -0000 1.2
@@ -7,15 +7,18 @@
# Object for handling the computation of a delta for displaying to HTML.
-package Codestriker::Http::Delta;
+package Codestriker::Http::DeltaRenderer;
use strict;
-use HTML::Entities ();
+use Codestriker::Http::HtmlEntityLineFilter;
+use Codestriker::Http::TabToNbspLineFilter;
+use Codestriker::Http::LineBreakLineFilter;
# Constructor.
sub new {
- my ($type, $topic, $comments, $deltas, $query, $mode, $brmode) = @_;
+ my ($type, $topic, $comments, $deltas, $query, $mode, $brmode,
+ $tabwidth) = @_;
my $self = {};
$self->{topic} = $topic;
@@ -24,6 +27,7 @@
$self->{query} = $query;
$self->{mode} = $mode;
$self->{brmode} = $brmode;
+ $self->{tabwidth} = $tabwidth;
# Build a hash from filenumber|fileline|new -> comment array, so that
# when rendering, lines can be coloured appropriately. Also build a list
@@ -46,9 +50,24 @@
$self->{comment_locations} = \@comment_locations;
$self->{comment_location_map} = \%comment_location_map;
+ # Record list of line filter objects to apply to each line of code.
+ # Setup some default filters.
+ @{$self->{line_filters}} = ();
+ push @{$self->{line_filters}}, Codestriker::Http::HtmlEntityLineFilter->new();
+ push @{$self->{line_filters}}, Codestriker::Http::TabToNbspLineFilter->new($tabwidth);
+ push @{$self->{line_filters}}, Codestriker::Http::LineBreakLineFilter->new($brmode);
+
bless $self, $type;
}
+# Add a line filter to this delta-renderer, which will be called for each
+# line that is to be rendered.
+sub add_line_filter
+{
+ my ($self, $line_filter) = @_;
+ push @{$self->{line_filters}}, $line_filter;
+}
+
# Render $text with the appropriate anchor attributes set for
# displaying any existing comments and a link for adding new ones.
sub comment_link
@@ -122,14 +141,6 @@
for (my $i = 0; $i <= $#diff_lines; $i++) {
my $data = $diff_lines[$i];
- # TODO: make these text transformations as plugins.
- # TODO: perform syntax highlighting.
- # TODO: perform LXR linking.
- # TODO: tab adjust.
- # TODO: line breaking.
- # Escape the data.
- $data = HTML::Entities::encode($data);
-
if ($data =~ /^\-(.*)$/o) {
# Line corresponding to old code.
push @{ $self->{diff_old_lines} }, $1;
@@ -160,12 +171,12 @@
my $line = {};
my $data_class =
$self->{mode} == $Codestriker::COLOURED_MODE ? "n" : "msn";
- $line->{old_data} = $data;
+ $line->{old_data} = $self->_apply_line_filters($data);
$line->{old_data_line} =
$self->comment_link($self->{filenumber}, $old_linenumber,
0, $old_linenumber);
$line->{old_data_class} = $data_class;
- $line->{new_data} = $data;
+ $line->{new_data} = $self->_apply_line_filters($data);
$line->{new_data_line} =
$self->comment_link($self->{filenumber}, $new_linenumber,
1, $new_linenumber);
@@ -269,16 +280,31 @@
}
my $line = {};
- $line->{old_data} = $old_data;
+ $line->{old_data} = $self->_apply_line_filters($old_data);
$line->{old_data_line} =
$self->comment_link($self->{filenumber}, $old_data_line, 0, $old_data_line);
$line->{old_data_class} = $render_old_colour;
- $line->{new_data} = $new_data;
+ $line->{new_data} = $self->_apply_line_filters($new_data);
$line->{new_data_line} =
$self->comment_link($self->{filenumber}, $new_data_line, 1, $new_data_line);
$line->{new_data_class} = $render_new_colour;
push @{$self->{lines}}, $line;
}
+
+ # Apply all of the line filters to the line of text supplied.
+ sub _apply_line_filters {
+ my ($self, $text) = @_;
+
+ # TODO: perform syntax highlighting.
+ # TODO: perform LXR linking.
+ foreach my $line_filter (@{$self->{line_filters}}) {
+ $text = $line_filter->filter($text);
+ }
+
+ # Unconditionally add a at the start for better alignment.
+ # Fix so count isn't stuffed.
+ return " " . $text;
+ }
}
1;
Index: HtmlEntityLineFilter.pm
===================================================================
RCS file: HtmlEntityLineFilter.pm
diff -N HtmlEntityLineFilter.pm
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ HtmlEntityLineFilter.pm 10 Mar 2008 23:18:03 -0000 1.1
@@ -0,0 +1,34 @@
+###############################################################################
+# Codestriker: Copyright (c) 2001, 2002 David Sitsky. All rights reserved.
+# si...@us...
+#
+# This program is free software; you can redistribute it and modify it under
+# the terms of the GPL.
+
+# Line filter for encoding HTML entities correctly.
+
+package Codestriker::Http::HtmlEntityLineFilter;
+
+use strict;
+
+use Codestriker::Http::LineFilter;
+
+@Codestriker::Http::HtmlEntityLineFilter::ISA =
+ ("Codestriker::Http::LineFilter");
+
+sub new {
+ my $type = shift;
+
+ my $self = Codestriker::Http::LineFilter->new();
+ return bless $self, $type;
+}
+
+# Escape all HTML entities so that they are displayed correctly.
+sub filter {
+ my ($self, $text) = @_;
+
+ return HTML::Entities::encode($text);
+}
+
+1;
+
Index: LineBreakLineFilter.pm
===================================================================
RCS file: LineBreakLineFilter.pm
diff -N LineBreakLineFilter.pm
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ LineBreakLineFilter.pm 10 Mar 2008 23:18:04 -0000 1.1
@@ -0,0 +1,44 @@
+###############################################################################
+# Codestriker: Copyright (c) 2001, 2002 David Sitsky. All rights reserved.
+# si...@us...
+#
+# This program is free software; you can redistribute it and modify it under
+# the terms of the GPL.
+
+# Line filter for handling line-breaks.
+# entities.
+
+package Codestriker::Http::LineBreakLineFilter;
+
+use strict;
+
+use Codestriker::Http::LineFilter;
+
+@Codestriker::Http::LineBreakLineFilter::ISA =
+ ("Codestriker::Http::LineFilter");
+
+# Take the linebreak mode as a parameter.
+sub new {
+ my ($type, $brmode) = @_;
+
+ my $self = Codestriker::Http::LineFilter->new();
+ $self->{brmode} = $brmode;
+
+ return bless $self, $type;
+}
+
+# Convert the spaces appropriately for line-breaking.
+sub filter {
+ my ($self, $text) = @_;
+
+ if ($self->{brmode} == $Codestriker::LINE_BREAK_ASSIST_MODE) {
+ $text =~ s/^(\s+)/my $sp='';for(my $i=0;$i<length($1);$i++){$sp.=' '}$sp;/ge;
+ }
+ else {
+ $text =~ s/\s/ /g;
+ }
+
+ return $text;
+}
+
+1;
Index: LineFilter.pm
===================================================================
RCS file: LineFilter.pm
diff -N LineFilter.pm
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ LineFilter.pm 10 Mar 2008 23:18:04 -0000 1.1
@@ -0,0 +1,29 @@
+###############################################################################
+# Codestriker: Copyright (c) 2001, 2002 David Sitsky. All rights reserved.
+# si...@us...
+#
+# This program is free software; you can redistribute it and modify it under
+# the terms of the GPL.
+
+# Base object for all line filter objects to extend from. A line filter takes
+# a line of code and transforms it in some fashion.
+
+package Codestriker::Http::LineFilter;
+
+use strict;
+
+sub new {
+ my $type = shift;
+ my $self = {};
+ return bless $self, $type;
+}
+
+sub filter {
+ my ($self, $text) = @_;
+
+ # Default is a no-op.
+ return $text;
+}
+
+1;
+
Index: TabToNbspLineFilter.pm
===================================================================
RCS file: TabToNbspLineFilter.pm
diff -N TabToNbspLineFilter.pm
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ TabToNbspLineFilter.pm 10 Mar 2008 23:18:04 -0000 1.1
@@ -0,0 +1,41 @@
+###############################################################################
+# Codestriker: Copyright (c) 2001, 2002 David Sitsky. All rights reserved.
+# si...@us...
+#
+# This program is free software; you can redistribute it and modify it under
+# the terms of the GPL.
+
+# Line filter for converting tabs to the appropriate number of
+# entities.
+
+package Codestriker::Http::TabToNbspLineFilter;
+
+use strict;
+
+use Codestriker::Http::LineFilter;
+
+@Codestriker::Http::HtmlEntityLineFilter::ISA =
+ ("Codestriker::Http::LineFilter");
+
+# Take the desired tabwidth as a parameter.
+sub new {
+ my ($type, $tabwidth) = @_;
+
+ my $self = Codestriker::Http::LineFilter->new();
+ $self->{tabwidth} = $tabwidth;
+
+ return bless $self, $type;
+}
+
+# Convert tabs to the appropriate number of entities.
+sub filter {
+ my ($self, $text) = @_;
+
+ my $tabwidth = $self->{tabwidth};
+ 1 while $text =~ s/\t+/' ' x
+ (length($&) * $tabwidth - length($`) % $tabwidth)/eo;
+
+ return $text;
+}
+
+1;
|
|
From: <si...@us...> - 2008-03-09 19:57:13
|
User: sits
Date: 08/03/09 12:57:09
Modified: lib/Codestriker/Action ViewTopic.pm
lib/Codestriker/Http UrlBuilder.pm
template/en/default viewtopic.html.tmpl
Added: lib/Codestriker/Http DeltaRenderer.pm
template/en/default viewdeltas.html.tmpl
Log:
A lot of stuff for the view topic page has been moved to templates. Still
a bit of work to be done to complete this, but a lot has been done. Still
need to move the text manipulation code into separate filter classes, so
that syntax highlighting will be easier to add in.
Index: ViewTopic.pm
===================================================================
RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Action/ViewTopic.pm,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -r1.54 -r1.55
--- ViewTopic.pm 28 Feb 2008 11:01:58 -0000 1.54
+++ ViewTopic.pm 9 Mar 2008 19:57:07 -0000 1.55
@@ -11,10 +11,13 @@
use strict;
+use HTML::Entities ();
+
use Codestriker::Model::Topic;
use Codestriker::Model::Comment;
use Codestriker::Http::UrlBuilder;
use Codestriker::Http::Render;
+use Codestriker::Http::DeltaRenderer;
use Codestriker::Repository::RepositoryFactory;
use Codestriker::TopicListeners::Manager;
@@ -227,29 +230,78 @@
}
$vars->{'filetable'} = \@filetable;
- # Pass in existing comment information.
- # Build a hash from filenumber|fileline|new -> comment array, so that
- # when rendering, lines can be coloured appropriately. Also build a list
- # of what points in the review have a comment. Also record a mapping
- # from filenumber|fileline|new -> the comment number.
- my %comment_hash = ();
- my @comment_locations = ();
- my %comment_location_map = ();
- 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;
- $comment_location_map{$key} = $#comment_locations;
+ # Determine which deltas are to be retrieved.
+ my @deltas = ();
+ if ($fview != -1) {
+ # Get only the deltas for the selected file.
+ @deltas = Codestriker::Model::Delta->get_delta_set($topicid, $fview);
+ }
+ else {
+ # Get the whole delta data.
+ @deltas = Codestriker::Model::Delta->get_delta_set($topicid, -1);
+ }
+
+ my $delta_renderer =
+ Codestriker::Http::Delta->new($topic, \@comments, \@deltas, $query,
+ $mode, $brmode);
+
+ # Set the add general comment URL.
+ $vars->{'add_general_comment_element'} =
+ $delta_renderer->comment_link(-1, -1, 1, "Add General Comment");
+
+ # Set the per-delta URL links, such as adding a file-level comment,
+ # and links to the previous/next file.
+ my $filenumber = 0;
+ my $current_filename = "";
+ foreach my $delta (@deltas) {
+ $delta->{add_file_comment_element} =
+ $delta_renderer->comment_link($filenumber, -1, 1, "[Add File Comment]");
+
+ # Determine if the file has a link to a repository system,
+ # and if so, create the appropriate links.
+ if ($delta->{repmatch} &&
+ $delta->{revision} ne $Codestriker::ADDED_REVISION &&
+ $delta->{revision} ne $Codestriker::PATCH_REVISION &&
+ defined $repository) {
+ $delta->{repository_file_view_url} =
+ $repository->getViewUrl($delta->{filename});
+ $delta->{view_old_full_url} =
+ $url_builder->view_file_url($topicid, $filenumber, 0, $delta->{old_linenumber},
+ $mode, 0);
+ $delta->{view_old_both_full_url} =
+ $url_builder->view_file_url($topicid, $filenumber, 0, $delta->{old_linenumber},
+ $mode, 1);
+ $delta->{view_new_full_url} =
+ $url_builder->view_file_url($topicid, $filenumber, 1, $delta->{new_linenumber},
+ $mode, 0);
+ $delta->{view_new_both_full_url} =
+ $url_builder->view_file_url($topicid, $filenumber, 1, $delta->{new_linenumber},
+ $mode, 1);
+ }
+
+ # Create the next/previous file URL links.
+ if ($current_filename ne $delta->{filename}) {
+ if ($filenumber > 0) {
+ $delta->{previous_file_url} =
+ $url_builder->view_url($topicid, -1, $mode, $brmode,
+ $filenumber-1) . "#" . $filenames[$filenumber-1];
+ }
+ if ($filenumber < $#filenames) {
+ $delta->{next_file_url} =
+ $url_builder->view_url($topicid, -1, $mode, $brmode,
+ $filenumber+1) . "#" . $filenames[$filenumber+1];
+ }
+
+ # Keep track of the current filename being processed.
+ $filenumber++;
+ $current_filename = $delta->{filename};
}
- push @{ $comment_hash{$key} }, $comment;
}
- $vars->{'query'} = $query;
- $vars->{'comment_hash'} = \%comment_hash;
- $vars->{'comment_locations'} = \@comment_locations;
- $vars->{'comment_location_map'} = \%comment_location_map;
+ # Annotate the deltas appropriately so that they can be easily rendered.
+ $delta_renderer->annotate_deltas();
+
+ $vars->{'deltas'} = \@deltas;
# Fire the template for generating the view topic screen.
my $template = Codestriker::Http::Template->new("viewtopic");
@@ -277,17 +329,6 @@
# Retrieve the delta set comprising this review.
my $old_filename = "";
- # Determine which deltas are to be retrieved.
- my @deltas = ();
- if ($fview != -1) {
- # Get only the deltas for the selected file.
- @deltas = Codestriker::Model::Delta->get_delta_set($topicid, $fview);
- }
- else {
- # Get the whole delta data.
- @deltas = Codestriker::Model::Delta->get_delta_set($topicid, -1);
- }
-
# Now render the selected deltas.
for (my $i = 0; $i <= $#deltas; $i++) {
my $delta = $deltas[$i];
@@ -308,6 +349,7 @@
Codestriker::TopicListeners::Manager::topic_viewed($email, $topic);
}
+
# 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.
Index: UrlBuilder.pm
===================================================================
RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Http/UrlBuilder.pm,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- UrlBuilder.pm 11 Jun 2006 08:49:42 -0000 1.29
+++ UrlBuilder.pm 9 Mar 2008 19:57:08 -0000 1.30
@@ -219,6 +219,4 @@
return $self->{query}->url() . "?action=metrics_download";
}
-
-
1;
Index: DeltaRenderer.pm
===================================================================
RCS file: DeltaRenderer.pm
diff -N DeltaRenderer.pm
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ DeltaRenderer.pm 9 Mar 2008 19:57:08 -0000 1.1
@@ -0,0 +1,284 @@
+###############################################################################
+# Codestriker: Copyright (c) 2001, 2002 David Sitsky. All rights reserved.
+# si...@us...
+#
+# This program is free software; you can redistribute it and modify it under
+# the terms of the GPL.
+
+# Object for handling the computation of a delta for displaying to HTML.
+
+package Codestriker::Http::Delta;
+
+use strict;
+
+use HTML::Entities ();
+
+# Constructor.
+sub new {
+ my ($type, $topic, $comments, $deltas, $query, $mode, $brmode) = @_;
+
+ my $self = {};
+ $self->{topic} = $topic;
+ $self->{comments} = $comments;
+ $self->{deltas} = $deltas;
+ $self->{query} = $query;
+ $self->{mode} = $mode;
+ $self->{brmode} = $brmode;
+
+ # Build a hash from filenumber|fileline|new -> comment array, so that
+ # when rendering, lines can be coloured appropriately. Also build a list
+ # of what points in the review have a comment. Also record a mapping
+ # from filenumber|fileline|new -> the comment number.
+ my %comment_hash = ();
+ my @comment_locations = ();
+ my %comment_location_map = ();
+ 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;
+ $comment_location_map{$key} = $#comment_locations;
+ }
+ push @{ $comment_hash{$key} }, $comment;
+ }
+ $self->{comment_hash} = \%comment_hash;
+ $self->{comment_locations} = \@comment_locations;
+ $self->{comment_location_map} = \%comment_location_map;
+
+ bless $self, $type;
+}
+
+# Render $text with the appropriate anchor attributes set for
+# displaying any existing comments and a link for adding new ones.
+sub comment_link
+{
+ my ($self, $filenumber, $line, $new, $text) = @_;
+
+ # Determine the anchor and edit URL for this line number.
+ my $anchor = "$filenumber|$line|$new";
+ my $edit_url = "javascript:eo('$filenumber','$line','$new')";
+
+ # Set the anchor to this line number.
+ my $params = {};
+ $params->{name} = $anchor;
+
+ # Only set the href attribute if the comment is in open state.
+ if (!Codestriker::topic_readonly($self->{topic}->{topic_state})) {
+ $params->{href} = $edit_url;
+ }
+
+ # If a comment exists on this line, set span and the overlib hooks onto
+ # it.
+ my %comment_hash = %{ $self->{comment_hash} };
+ my %comment_location_map = %{ $self->{comment_location_map} };
+ my $comment_number = undef;
+ my $query = $self->{query};
+ if (exists $comment_hash{$anchor}) {
+ # Determine what comment number this anchor refers to.
+ $comment_number = $comment_location_map{$anchor};
+ $text = $query->span({-id=>"c$comment_number"}, "") .
+ $query->span({-class=>"com"}, $text);
+
+ # Determine what the next comment in line is.
+ my $index = -1;
+ my @comment_locations = @{ $self->{comment_locations} };
+ for ($index = 0; $index <= $#comment_locations; $index++) {
+ last if $anchor eq $comment_locations[$index];
+ }
+
+ $params->{onmouseover} =
+ "return overlib(comment_text[$index],STICKY,DRAGGABLE,ALTCUT);";
+ $params->{onmouseout} = "return nd();";
+ } else {
+ $text = $query->span({-class=>"nocom"}, $text);
+ }
+
+ return $query->a($params, $text);
+}
+
+# Go through all of the deltas, and append a line array for each delta with
+# enough information to render it easily.
+sub annotate_deltas
+{
+ my ($self) = @_;
+
+ foreach my $delta (@{ $self->{deltas} }) {
+
+ # Now process the text so that the display code has minimal work to do.
+ # Also apply appropriate transformations to the line as required.
+ # TODO: put this into a proper module/plugin framework to make it easier
+ # to extend/modify.
+ my @diff_lines = split /\n/, $delta->{text};
+ my $old_linenumber = $delta->{old_linenumber};
+ my $new_linenumber = $delta->{new_linenumber};
+ @{$self->{lines}} = ();
+ @{$self->{diff_old_lines}} = ();
+ @{$self->{diff_old_lines_numbers}} = ();
+ @{$self->{diff_new_lines}} = ();
+ @{$self->{diff_new_lines_numbers}} = ();
+ $self->{filenumber} = 0;
+ $self->{current_filename} = "";
+ for (my $i = 0; $i <= $#diff_lines; $i++) {
+ my $data = $diff_lines[$i];
+
+ # TODO: make these text transformations as plugins.
+ # TODO: perform syntax highlighting.
+ # TODO: perform LXR linking.
+ # TODO: tab adjust.
+ # TODO: line breaking.
+ # Escape the data.
+ $data = HTML::Entities::encode($data);
+
+ if ($data =~ /^\-(.*)$/o) {
+ # Line corresponding to old code.
+ push @{ $self->{diff_old_lines} }, $1;
+ push @{ $self->{diff_old_lines_numbers} }, $old_linenumber;
+ $old_linenumber++;
+ } elsif ($data =~ /^\+(.*)$/o) {
+ # Line corresponding to new code.
+ push @{ $self->{diff_new_lines} }, $1;
+ push @{ $self->{diff_new_lines_numbers} }, $new_linenumber;
+ $new_linenumber++;
+ } elsif ($data =~ /^\\/) {
+ # A diff comment such as "No newline at end of file" - ignore it.
+ } else {
+ # Line corresponding to both sides. Strip the first space off
+ # the diff for proper alignment.
+ $data =~ s/^\s//;
+
+ # Render what has been currently recorded.
+ $self->_render_changes();
+
+ # Now that the diff changeset has been rendered, remove the state data.
+ @{$self->{diff_old_lines}} = ();
+ @{$self->{diff_old_lines_numbers}} = ();
+ @{$self->{diff_new_lines}} = ();
+ @{$self->{diff_new_lines_numbers}} = ();
+
+ # Now render the line which is present on both sides.
+ my $line = {};
+ my $data_class =
+ $self->{mode} == $Codestriker::COLOURED_MODE ? "n" : "msn";
+ $line->{old_data} = $data;
+ $line->{old_data_line} =
+ $self->comment_link($self->{filenumber}, $old_linenumber,
+ 0, $old_linenumber);
+ $line->{old_data_class} = $data_class;
+ $line->{new_data} = $data;
+ $line->{new_data_line} =
+ $self->comment_link($self->{filenumber}, $new_linenumber,
+ 1, $new_linenumber);
+ $line->{new_data_class} = $data_class;
+ push @{$self->{lines}}, $line;
+ $old_linenumber++;
+ $new_linenumber++;
+ }
+ }
+
+ # Render any remaining diff segments.
+ $self->_render_changes();
+
+ # Store the processed lines with the delta object for rendering.
+ @{$delta->{lines}} = @{$self->{lines}};
+
+ if ($self->{current_filename} ne $delta->{filename}) {
+ # Keep track of the current filename being processed.
+ $self->{filenumber}++;
+ $self->{current_filename} = $delta->{filename};
+ }
+ }
+}
+
+# Annotate any accumlated diff changes.
+sub _render_changes
+{
+ my ($self) = @_;
+
+ # Determine the class to use for displaying the comments.
+ my ($old_col, $old_notpresent_col, $new_col, $new_notpresent_col);
+ if (@{$self->{diff_new_lines}} > 0 && @{$self->{diff_old_lines}} > 0) {
+ # Lines have been added and removed.
+ if ($self->{mode} == $Codestriker::COLOURED_MODE) {
+ $old_col = "c";
+ $old_notpresent_col = "cb";
+ $new_col = "c";
+ $new_notpresent_col = "cb";
+ } else {
+ $old_col = "msc";
+ $old_notpresent_col = "mscb";
+ $new_col = "msc";
+ $new_notpresent_col = "mscb";
+ }
+ } elsif (@{$self->{diff_new_lines}} > 0 && @{$self->{diff_old_lines}} == 0) {
+ # New lines have been added.
+ if ($self->{mode} == $Codestriker::COLOURED_MODE) {
+ $old_col = "a";
+ $old_notpresent_col = "ab";
+ $new_col = "a";
+ $new_notpresent_col = "ab";
+ } else {
+ $old_col = "msa";
+ $old_notpresent_col = "msab";
+ $new_col = "msa";
+ $new_notpresent_col = "msab";
+ }
+ } else {
+ # Lines have been removed.
+ if ($self->{mode} == $Codestriker::COLOURED_MODE) {
+ $old_col = "r";
+ $old_notpresent_col = "rb";
+ $new_col = "r";
+ $new_notpresent_col = "rb";
+ } else {
+ $old_col = "msr";
+ $old_notpresent_col = "msrb";
+ $new_col = "msr";
+ $new_notpresent_col = "msrb";
+ }
+ }
+
+ my ($old_data, $new_data, $old_data_line, $new_data_line);
+ while (@{$self->{diff_old_lines}} > 0 || @{$self->{diff_new_lines}} > 0) {
+
+ # Retrieve the next lines which were removed (if any).
+ if (@{$self->{diff_old_lines}} > 0) {
+ $old_data = shift @{$self->{diff_old_lines}};
+ $old_data_line = shift @{$self->{diff_old_lines_numbers}};
+ } else {
+ undef($old_data);
+ undef($old_data_line);
+ }
+
+ # Retrieve the next lines which were added (if any).
+ if (@{$self->{diff_new_lines}} > 0) {
+ $new_data = shift @{$self->{diff_new_lines}};
+ $new_data_line = shift @{$self->{diff_new_lines_numbers}};
+ } else {
+ undef($new_data);
+ undef($new_data_line);
+ }
+
+ # Set the colours to use appropriately depending on what is defined.
+ my $render_old_colour = $old_col;
+ my $render_new_colour = $new_col;
+ if (defined $old_data && ! defined $new_data) {
+ $render_new_colour = $new_notpresent_col;
+ } elsif (! defined $old_data && defined $new_data) {
+ $render_old_colour = $old_notpresent_col;
+ }
+
+ my $line = {};
+ $line->{old_data} = $old_data;
+ $line->{old_data_line} =
+ $self->comment_link($self->{filenumber}, $old_data_line, 0, $old_data_line);
+ $line->{old_data_class} = $render_old_colour;
+ $line->{new_data} = $new_data;
+ $line->{new_data_line} =
+ $self->comment_link($self->{filenumber}, $new_data_line, 1, $new_data_line);
+ $line->{new_data_class} = $render_new_colour;
+ push @{$self->{lines}}, $line;
+ }
+}
+
+1;
Index: viewtopic.html.tmpl
===================================================================
RCS file: /cvsroot/codestriker/codestriker/template/en/default/viewtopic.html.tmpl,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -r1.40 -r1.41
--- viewtopic.html.tmpl 28 Feb 2008 11:01:58 -0000 1.40
+++ viewtopic.html.tmpl 9 Mar 2008 19:57:08 -0000 1.41
@@ -70,15 +70,15 @@
[%# Display the filename with an internal link if its not binary. #%]
[% IF file.binary %]
- [% file.filename %]
+ [% file.filename | html_entity %]
[% ELSE %]
- <a href="[% file.href_filename_url %]">[% file.filename %]</a>
+ <a href="[% file.href_filename_url %]">[% file.filename | html_entity %]</a>
[% END %]
</td>
[%# Display the revision information for modified files. #%]
[% IF rowstyle == "cf" %]
- <td class="[% rowstyle %]"> [% file.revision %]</td>
+ <td class="[% rowstyle %]"> [% file.revision | html_entity %]</td>
[% END %]
[%# Display the numchange information for the file. #%]
@@ -90,6 +90,7 @@
</td>
</tr>
[% END %]
+ </table>
</table>
@@ -98,7 +99,9 @@
mode = mode %]
<p>
-[% FILTER $CommentLine filenumber = -1 line = -1 new = 1 %]Add General Comment[% END %] to topic.
+<span class="general_comment">[% add_general_comment_element %]</span>
+
+[% PROCESS viewdeltas.html.tmpl deltas = deltas %]
[%# The perl script takes control from here, rendering the topic data. #%]
Index: viewdeltas.html.tmpl
===================================================================
RCS file: viewdeltas.html.tmpl
diff -N viewdeltas.html.tmpl
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ viewdeltas.html.tmpl 9 Mar 2008 19:57:08 -0000 1.1
@@ -0,0 +1,100 @@
+[%# HTML for rendering a set of deltas. #%]
+
+[% SET diff_current_filename = "" %]
+[% SET filenumber = 0 %]
+[% FOREACH delta = deltas %]
+[% FLUSH IF loop.count() % 10 == 1 %]
+ [%# Check if a heading for the current diff needs to be output. #%]
+ [% IF delta.filename != diff_current_filename %]
+
+ [%# Close off the previous table from the previous filename. #%]
+ [% IF loop.count() != 0 %]
+ </table>
+ [% END %]
+
+ <table width="100%" cellspacing="0" cellpadding="0" border="0">
+ <tr>
+ <td class="file" align="left">
+ [% IF delta.repository_file_view_url != "" %]
+ File
+ <a href="[% delta.repository_file_view_url %]">
+ [% delta.filename | html_entity %]
+ </a>
+ [% ELSE %]
+ File [% delta.filename | html_entity %]
+ [% END %]
+ </td>
+
+ <td class="file" align="right">
+ [% delta.add_file_comment_element %]
+ [% IF delta.previous_file_url != "" %]
+ <a href="[% delta.previous_file_url %]">[<<]</a>
+ [% END %]
+ <a href="#contents">[Top]</a>
+ [% IF delta.next_file_url != "" %]
+ <a href="[% delta.next_file_url %]">[>>]</a>
+ [% END %]
+ </td>
+ </tr>
+
+ [%# Output the diff description if it is present. #%]
+ [% IF delta.description != "" %]
+ <tr>
+ <td class="line" colspan="2">[% delta.description | html_entity %]</td>
+ <td class="line" colspan="2">[% delta.description | html_entity %]</td>
+ </tr>
+ [% END %]
+ </table>
+ [% filenumber = filenumber + 1 %]
+
+ [%# Make sure all the diffs are aligned in the same table. #%]
+ <table width="100%" cellspacing="0" cellpadding="0" border="0">
+ [% END %]
+
+ [%# Now output the delta header. #%]
+ [% SET diff_current_filename = delta.filename %]
+ <tr>
+ <td> </td><td> </td><td> </td><td> </td>
+ </tr>
+ <tr>
+ [% IF delta.view_old_full_url != "" %]
+ [%# Display heading with links to retrieve the entire file #%]
+ <td class="line" colspan="2">
+ <a href="javascript: myOpen('[% delta.view_old_full_url %]', 'Codestriker')">
+ Line [% delta.old_linenumber %]
+ </a>
+ |
+ <a href="javascript: myOpen('[% delta.view_old_full_both_url %]', 'Codestriker')">
+ Parallel
+ </a>
+ </td>
+ <td class="line" colspan="2">
+ <a href="javascript: myOpen('[% delta.view_new_full_url %]', 'Codestriker')">
+ Line [% delta.new_linenumber %]
+ </a>
+ |
+ <a href="javascript: myOpen('[% delta.view_new_full_both_url %]', 'Codestriker')">
+ Parallel
+ </a>
+ </td>
+ [% ELSE %]
+ [%# Just display the line numbers for the delta without any links. #%]
+ <td class="line" colspan="2">Line [% delta.old_linenumber %]</td>
+ <td class="line" colspan="2">Line [% delta.new_linenumber %]</td>
+ [% END %]
+ </tr>
+
+ [%# Now output the delta itself. #%]
+ [% FOREACH line = delta.lines %]
+ [% FLUSH IF loop.count() % 10 == 1 %]
+ <tr>
+ <td>[% line.old_data_line %]</td>
+ <td class="[% line.old_data_class %]">[% line.old_data %]</td>
+ <td>[% line.new_data_line %]</td>
+ <td class="[% line.new_data_class %]">[% line.new_data %]</td>
+ </tr>
+ [% END %]
+[% END %]
+
+[%# Close off the table from the last file's delta set. #%]
+ </table>
|
|
From: <si...@us...> - 2008-02-28 23:20:17
|
User: sits
Date: 08/02/28 15:20:15
Modified: lib/Codestriker/Model Project.pm
Log:
Fix from Rob for deleting topics in a project correctly.
Index: Project.pm
===================================================================
RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Model/Project.pm,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- Project.pm 20 Aug 2006 07:11:22 -0000 1.6
+++ Project.pm 28 Feb 2008 23:20:15 -0000 1.7
@@ -238,19 +238,14 @@
} else {
# Delete the topics in this project.
my @sort_order;
- my @topic_query_results;
- Codestriker::Model::Topic->query("", "", "", "",
- "", $id, "",
- "", "",
- "", "", "",
- \@sort_order, \@topic_query_results);
+ my @topics = Codestriker::Model::Topic->query("", "", "", "",
+ "", $id, "",
+ "", "", "", "", "",
+ \@sort_order );
# Delete each of the topics for this project
- for (my $index = 0; $index <= $#topic_query_results; $index++) {
- my $topic_row = $topic_query_results[$index];
- my $topicid = $topic_row->{id};
- my $topic_delete = Codestriker::Model::Topic->new($topicid);
- $topic_delete->delete();
+ foreach my $topic ( @topics ) {
+ $topic->delete();
}
# Now delete the project.
|
|
From: <si...@us...> - 2008-02-28 23:17:03
|
User: sits
Date: 08/02/28 15:17:00
Modified: lib/Codestriker/TopicListeners BugTracking.pm
Log:
Missed an extra parameter
Index: BugTracking.pm
===================================================================
RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/TopicListeners/BugTracking.pm,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- BugTracking.pm 22 Feb 2008 00:56:21 -0000 1.6
+++ BugTracking.pm 28 Feb 2008 23:17:00 -0000 1.7
@@ -70,7 +70,8 @@
"Description:\n" . "$topic->{description}\n";
for (my $i = 0; $i <= $#ids; $i++) {
- $bug_db_connection->update_bug($ids[$i], $text, $topic_url);
+ $bug_db_connection->update_bug($ids[$i], $text, $topic_url,
+ $topic->{topic_state});
}
$bug_db_connection->release_connection();
}
|
|
From: <si...@us...> - 2008-02-28 11:02:02
|
User: sits
Date: 08/02/28 03:01:58
Modified: lib/Codestriker/Action ViewTopic.pm
lib/Codestriker/Http Render.pm
template/en/default viewtopic.html.tmpl
Added: lib/Codestriker/Template/Plugin CommentLine.pm
Log:
Render the add general comment link via TT rather than Render.pm
Index: ViewTopic.pm
===================================================================
RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Action/ViewTopic.pm,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -r1.53 -r1.54
--- ViewTopic.pm 28 Feb 2008 06:26:18 -0000 1.53
+++ ViewTopic.pm 28 Feb 2008 11:01:58 -0000 1.54
@@ -227,6 +227,30 @@
}
$vars->{'filetable'} = \@filetable;
+ # Pass in existing comment information.
+ # Build a hash from filenumber|fileline|new -> comment array, so that
+ # when rendering, lines can be coloured appropriately. Also build a list
+ # of what points in the review have a comment. Also record a mapping
+ # from filenumber|fileline|new -> the comment number.
+ my %comment_hash = ();
+ my @comment_locations = ();
+ my %comment_location_map = ();
+ 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;
+ $comment_location_map{$key} = $#comment_locations;
+ }
+ push @{ $comment_hash{$key} }, $comment;
+ }
+
+ $vars->{'query'} = $query;
+ $vars->{'comment_hash'} = \%comment_hash;
+ $vars->{'comment_locations'} = \@comment_locations;
+ $vars->{'comment_location_map'} = \%comment_location_map;
+
# Fire the template for generating the view topic screen.
my $template = Codestriker::Http::Template->new("viewtopic");
$template->process($vars);
@@ -250,11 +274,7 @@
\@numchanges, -1,
$brmode, $fview);
- # Display the data that is being reviewed.
- $render->start();
-
# Retrieve the delta set comprising this review.
-
my $old_filename = "";
# Determine which deltas are to be retrieved.
Index: Render.pm
===================================================================
RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Http/Render.pm,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -r1.55 -r1.56
--- Render.pm 28 Feb 2008 06:26:18 -0000 1.55
+++ Render.pm 28 Feb 2008 11:01:58 -0000 1.56
@@ -18,9 +18,6 @@
# against.
my $CONTEXT_COLOUR = "red";
-sub _normal_mode_start( $ );
-sub _normal_mode_finish( $ );
-sub _coloured_mode_start( $ );
sub _coloured_mode_finish( $ );
# New lines within a diff block.
@@ -841,18 +838,6 @@
return $query->a($params, $text);
}
-# Start hook called when about to start rendering to a page.
-sub start($) {
- my ($self) = @_;
-
- # Now create the start of the rendering tables.
- if ($self->{mode} == $Codestriker::NORMAL_MODE) {
- $self->_normal_mode_start();
- } else {
- $self->_coloured_mode_start();
- }
-}
-
# Finished hook called when finished rendering to a page.
sub finish($) {
my ($self) = @_;
@@ -865,18 +850,6 @@
$self->_print_legend();
}
-# Start topic view display hook for normal mode.
-sub _normal_mode_start($) {
- my ($self) = @_;
- print "<PRE>\n";
-}
-
-# Finish topic view display hook for normal mode.
-sub _normal_mode_finish($) {
- my ($self) = @_;
- print "</PRE>\n";
-}
-
# Private functon to print the diff legend out at the bottom of the topic text page.
sub _print_legend($) {
my ($self) = @_;
@@ -901,26 +874,6 @@
print $query->end_table(), "\n";
}
-
-# Start topic view display hook for coloured mode. This displays a simple
-# legend, displays the files involved in the review, and opens up the initial
-# table.
-sub _coloured_mode_start($) {
- my ($self) = @_;
-
- my $query = $self->{query};
-
-
- # Render the "Add comment to topic" link.
- print $query->p;
- print $self->render_comment_link(-1, -1, 1, "Add General Comment",
- "general_comment", undef);
- print " to topic.";
- print $query->p;
-
- print $query->start_table() ;
-}
-
# Render the initial start of the coloured table, with an empty row setting
# the widths.
sub print_coloured_table($)
Index: CommentLine.pm
===================================================================
RCS file: CommentLine.pm
diff -N CommentLine.pm
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ CommentLine.pm 28 Feb 2008 11:01:58 -0000 1.1
@@ -0,0 +1,78 @@
+package Codestriker::Template::Plugin::CommentLine;
+
+# Template toolkit plugin module for outputting the anchor text
+# for a specific line.
+
+use Template::Plugin::Filter;
+use Codestriker;
+use Codestriker::Http::UrlBuilder;
+
+use base qw( Template::Plugin::Filter );
+
+# Indicate that the filter should be re-created on each filter call.
+our $DYNAMIC = 1;
+
+sub filter {
+ my ($self, $text, $args, $conf) = @_;
+
+ $conf = $self->merge_config($conf);
+
+ # Constructor parameters.
+ my $query = $conf->{query};
+ my $comment_hash = %{ $conf->{comment_hash} };
+ my $comment_location_map = %{ $conf->{comment_location_map} };
+ my $mode = $conf->{mode};
+
+ # Filter parameters.
+ my $filenumber = $conf->{filenumber};
+ my $line = $conf->{line};
+ my $new = $conf->{new};
+
+ # Determine the comment class to use.
+ my $comment_class = $mode eq 'coloured' ? 'com' : 'smscom';
+ my $no_comment_class = $mode eq 'coloured' ? 'nocom' : 'smsnocom';
+
+ # Determine the anchor and edit URL for this line number.
+ my $anchor = "$filenumber|$line|$new";
+ my $edit_url = "javascript:eo('$filenumber','$line','$new')";
+
+ # Set the anchor to this line number.
+ my $params = {};
+ $params->{name} = $anchor;
+
+ # Only set the href attribute if the comment is in open state.
+ if (!Codestriker::topic_readonly($self->{topic_state})) {
+ $params->{href} = $edit_url;
+ }
+
+ # If a comment exists on this line, set span and the overlib hooks onto
+ # it.
+ my $comment_number = undef;
+ if (exists $comment_hash{$anchor}) {
+ # Determine what comment number this anchor refers to.
+ $comment_number = $comment_location_map{$anchor};
+
+ if (defined $comment_class) {
+ $text = $query->span({-id=>"c$comment_number"}, "") .
+ $query->span({-class=>$comment_class}, $text);
+ }
+
+ # Determine what the next comment in line is.
+ my $index = -1;
+ my @comment_locations = @{ $self->{comment_locations} };
+ for ($index = 0; $index <= $#comment_locations; $index++) {
+ last if $anchor eq $comment_locations[$index];
+ }
+
+ $params->{onmouseover} = "return overlib(comment_text[$index],STICKY,DRAGGABLE,ALTCUT);";
+ $params->{onmouseout} = "return nd();";
+ } else {
+ if (defined $no_comment_class) {
+ $text = $query->span({-class=>$no_comment_class}, $text);
+ }
+ }
+
+ return $query->a($params, $text);
+}
+
+1;
Index: viewtopic.html.tmpl
===================================================================
RCS file: /cvsroot/codestriker/codestriker/template/en/default/viewtopic.html.tmpl,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -r1.39 -r1.40
--- viewtopic.html.tmpl 28 Feb 2008 06:26:19 -0000 1.39
+++ viewtopic.html.tmpl 28 Feb 2008 11:01:58 -0000 1.40
@@ -93,6 +93,13 @@
</table>
+[% USE CommentLine query = query comment_hash = comment_hash
+ comment_location_map = comment_location_map
+ mode = mode %]
+
+<p>
+[% FILTER $CommentLine filenumber = -1 line = -1 new = 1 %]Add General Comment[% END %] to topic.
+
[%# The perl script takes control from here, rendering the topic data. #%]
|
|
From: <si...@us...> - 2008-02-28 06:26:20
|
User: sits
Date: 08/02/27 22:26:19
Modified: html codestriker.css
lib/Codestriker/Action ViewTopic.pm
lib/Codestriker/Http Render.pm
template/en/default viewtopic.html.tmpl
Log:
First step in removing code out of Render.pm into templates. At the moment
this just handles the initial top links and the file table of contents.
Index: codestriker.css
===================================================================
RCS file: /cvsroot/codestriker/codestriker/html/codestriker.css,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- codestriker.css 29 Jun 2007 07:13:59 -0000 1.14
+++ codestriker.css 28 Feb 2008 06:26:18 -0000 1.15
@@ -54,6 +54,9 @@
/* Changed file */
TD.cf {background-color: #ffff77}
+/* Patch file */
+TD.pf {background-color: #ffff77}
+
/* Changed blank text */
TD.cb {background-color: #eeee77; font-family: Helvetica, Arial; font-size: smaller}
Index: ViewTopic.pm
===================================================================
RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Action/ViewTopic.pm,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -r1.52 -r1.53
--- ViewTopic.pm 2 Jul 2007 09:54:12 -0000 1.52
+++ ViewTopic.pm 28 Feb 2008 06:26:18 -0000 1.53
@@ -136,8 +136,6 @@
$fview = -1;
}
}
- $vars->{'mode'} = $mode;
- $vars->{'brmode'} = $brmode;
$vars->{'states'} = \@Codestriker::topic_states;
$vars->{'default_state'} = $topic->{state};
@@ -151,58 +149,90 @@
# Obtain the link to download the actual document text.
$vars->{'download_url'} = $url_builder->download_url($topicid);
- # Fire the template on the topic heading information.
- my $template = Codestriker::Http::Template->new("viewtopic");
- $template->process($vars);
-
- # The rest of the output is non-template driven, as it is quite
- # complex.
-
- # Give the user the option of swapping between diff view modes.
- # If there are no files associated with the review, remove this
- # option.
- my $coloured_url =
+ # Obtain the links for the different viewing modes.
+ $vars->{'coloured_mode_url'} =
$url_builder->view_url($topicid, -1, $Codestriker::COLOURED_MODE,
$brmode, $fview);
- my $coloured_mono_url =
+ $vars->{'coloured_mono_mode_url'} =
$url_builder->view_url($topicid, -1,
$Codestriker::COLOURED_MONO_MODE, $brmode, $fview);
- my $br_normal_url =
+ $vars->{'br_normal_mode_url'} =
$url_builder->view_url($topicid, -1, $mode,
$Codestriker::LINE_BREAK_NORMAL_MODE, $fview);
- my $br_assist_url =
+ $vars->{'br_assist_mode_url'} =
$url_builder->view_url($topicid, -1, $mode,
$Codestriker::LINE_BREAK_ASSIST_MODE, $fview);
-
+
+ # Set template variables relating to coloured mode.
if ($mode == $Codestriker::COLOURED_MODE) {
- print " View in " .
- $query->a({href=>$coloured_mono_url}, "monospace font") .
- " | ";
- } elsif ($mode == $Codestriker::COLOURED_MONO_MODE) {
- print " View in " .
- $query->a({href=>$coloured_url}, "variable-width font") .
- " | ";
+ $vars->{'mode'} = 'coloured';
+ } elsif ($mode == $Codestrikier::COLOURED_MONO_MODE) {
+ $vars->{'mode'} = 'coloured_mono';
+ } else {
+ $vars->{'mode'} = 'unknown';
}
+ # Set template variables relating to line breaking mode.
if ($brmode == $Codestriker::LINE_BREAK_NORMAL_MODE) {
- print " View with " .
- $query->a({href=>$br_assist_url}, "minimal screen width") . ".";
+ $vars->{'brmode'} = 'normal';
} elsif ($brmode == $Codestriker::LINE_BREAK_ASSIST_MODE) {
- print " View with " .
- $query->a({href=>$br_normal_url}, "minimal line breaks") . ".";
+ $vars->{'brmode'} = 'assist';
+ } else {
+ $vars->{'brmode'} = 'unknown';
}
- print " | ";
- # Display the option to change the tab width.
+ # Set varibles relating to tab-width setting.
my $newtabwidth = ($tabwidth == 4) ? 8 : 4;
- my $change_tabwidth_url;
- $change_tabwidth_url =
+ $vars->{'tabwidth'} = $tabwidth;
+ $vars->{'newtabwidth'} = $newtabwidth;
+ $vars->{'change_tabwidth_url'} =
$url_builder->view_url_extended($topicid, -1, $mode, $newtabwidth,
"", "", 0, $brmode, $fview);
- print " Tab width set to $tabwidth (";
- print $query->a({href=>"$change_tabwidth_url"},"change to $newtabwidth");
- print ")\n";
+ # Set the display all, display single URLs.
+ $vars->{'display_all_files_url'} =
+ $url_builder->view_url($topicid, -1, $mode, $brmode, -1);
+ $vars->{'display_single_file_url'} =
+ $url_builder->view_url($topicid, -1, $mode, $brmode, 0);
+ $vars->{'fview'} = $fview;
+
+ # Setup the filetable template variable for displaying the table of
+ # contents.
+ my @filetable = ();
+ for (my $i = 0; $i <= $#filenames; $i++) {
+ my $filerow = {};
+ my $filename = $filenames[$i];
+ $filerow->{filename} = $filename;
+ $filerow->{numchanges} = $numchanges[$i];
+ $filerow->{href_filename_url} =
+ $url_builder->view_url($topicid, -1, $mode, $brmode, $i) .
+ "#" . $filename;
+ $filerow->{anchor_filename_url} =
+ $url_builder->view_url($topicid, -1, $mode, $brmode, -1) .
+ "#" . $filename;
+ $filerow->{binary} = $binary[$i];
+
+ my $revision = $revisions[$i];
+ if ($revision eq $Codestriker::ADDED_REVISION) {
+ $filerow->{revision} = 'added';
+ } elsif ($revision eq $Codestriker::REMOVED_REVISION) {
+ $filerow->{revision} = 'removed';
+ } elsif ($revision eq $Codestriker::PATCH_REVISION) {
+ $filerow->{revision} = 'patch';
+ } else {
+ $filerow->{revision} = $revision;
+ }
+
+ push @filetable, $filerow;
+ }
+ $vars->{'filetable'} = \@filetable;
+
+ # Fire the template for generating the view topic screen.
+ my $template = Codestriker::Http::Template->new("viewtopic");
+ $template->process($vars);
+
+ # The rest of the output is non-template driven, as it is quite
+ # complex.
print $query->p if ($mode == $Codestriker::NORMAL_MODE);
Index: Render.pm
===================================================================
RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Http/Render.pm,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -r1.54 -r1.55
--- Render.pm 26 Feb 2008 08:32:17 -0000 1.54
+++ Render.pm 28 Feb 2008 06:26:18 -0000 1.55
@@ -909,88 +909,8 @@
my ($self) = @_;
my $query = $self->{query};
- my $topic = $self->{topic};
- my $mode = $self->{mode};
- my $brmode = $self->{brmode};
- my $fview = $self->{fview};
- my $display_all_url =
- $self->{url_builder}->view_url($topic, -1, $mode, $brmode, -1);
- my $display_single_url =
- $self->{url_builder}->view_url($topic, -1, $mode, $brmode, 0);
- # Print out the "table of contents".
- my $filenames = $self->{filenames_ref};
- my $revisions = $self->{revisions_ref};
- my $binaries = $self->{binaries_ref};
- my $numchanges = $self->{numchanges_ref};
-
- print $query->p;
- print $query->start_table({-cellspacing=>'0', -cellpadding=>'0',
- -border=>'0'}), "\n";
-
-
- # Include a link to view all files in a topic, if we are in single
- # display mode.
- if ($fview != -1) {
- print $query->Tr($query->td($query->a({name=>"contents"},
- "Files in Topic: ("),
- $query->a({href=>$display_all_url},
- "view all files"), ")"),
- $query->td(" ")), "\n";
- }
- else {
- print $query->Tr($query->td($query->a({name=>"contents"},
- "Files in Topic:")),
- $query->td(" ")), "\n";
- }
-
- my $url_builder = $self->{url_builder};
- for (my $i = 0; $i <= $#$filenames; $i++) {
- my $filename = $$filenames[$i];
- my $revision = $$revisions[$i];
- my $numchange = $$numchanges[$i];
- my $href_filename =
- $url_builder->view_url($topic, -1, $mode, $brmode, $i) .
- "#" . "$filename";
- my $anchor_filename =
- $url_builder->view_url($topic, -1, $mode, $brmode, -1) .
- "#" . "$filename";
- my $tddata = $$binaries[$i] ? $filename :
- $query->a({href=>$href_filename}, "$filename");
-
- if ($fview == -1) {
- # Add a jump to link for the all files view.
- $tddata = "[" . $query->a({href=>$anchor_filename}, "Jump to") . "] " . $tddata;
- }
-
- my $lineData = "";
-
- if ($numchange ne "") {
- $lineData = " <FONT size=-1>{$numchange}</FONT>";
- }
-
- my $class = "";
- $class = "af" if ($revision eq $Codestriker::ADDED_REVISION);
- $class = "rf" if ($revision eq $Codestriker::REMOVED_REVISION);
- $class = "cf" if ($revision eq $Codestriker::PATCH_REVISION);
- if ($revision eq $Codestriker::ADDED_REVISION ||
- $revision eq $Codestriker::REMOVED_REVISION ||
- $revision eq $Codestriker::PATCH_REVISION) {
- # Added, removed or patch file.
- print $query->Tr($query->td({-class=>"$class", -colspan=>'2'},
- $tddata),
- $query->td({-class=>"$class"}, $lineData)) . "\n";
- } else {
- # Modified file.
- print $query->Tr($query->td({-class=>'cf'}, $tddata),
- $query->td({-class=>'cf'}, " $revision"),
- $query->td({-class=>'cf'}, $lineData)) .
- "\n";
- }
- }
- print $query->end_table() . "\n";
-
# Render the "Add comment to topic" link.
print $query->p;
print $self->render_comment_link(-1, -1, 1, "Add General Comment",
Index: viewtopic.html.tmpl
===================================================================
RCS file: /cvsroot/codestriker/codestriker/template/en/default/viewtopic.html.tmpl,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- viewtopic.html.tmpl 29 Jun 2007 07:13:59 -0000 1.38
+++ viewtopic.html.tmpl 28 Feb 2008 06:26:19 -0000 1.39
@@ -12,10 +12,88 @@
<p>
-[%# Display the "Download topic text" link #%]
-<a href="[% download_url %]">Download topic text</a> |
+[%# Display the "Download topic text" link. #%]
+<a href="[% download_url %]">Download topic text</a>
-[%# The perl script takes control from here, rendering the topic data #%]
+[%# Display the different coloured viewing modes #%]
+[% IF mode == "coloured" %]
+| View in <a href="[% coloured_mono_mode_url %]">monospace font</a>
+[% ELSIF mode == "coloured_mono" %]
+| View in <a href="[% coloured_mode_url %]">variable-width font</a>
+[% END %]
+
+[%# Display the different line breaking modes. #%]
+[% IF brmode == "normal" %]
+| View with <a href="[% br_assist_mode_url %]">minimal screen width</a>
+[% ELSIF brmode == "assist" %]
+| View with <a href="[% coloured_mode_url %]">minimal line breaks</a>
+[% END %]
+
+[%# Display the different tab-width options #%]
+| Tab width set to [% tabwidth %]
+(<a href="[% change_tabwidth_url %]">change to [% newtabwidth %]</a>)
+
+[%# Display the files in a table which are a part of this topic. #%]
+[%# Display the view all files link if required. #%]
+<p>
+<table cellspacing="0" cellpadding="0" border="0">
+ <tr>
+ <td><a name="contents">Files in Topic:</a>
+ [% IF fview != -1 %]
+ (<a href="[% display_all_files_url %]">view all files</a>)
+ [% END %]
+ </td><td> </td>
+ </tr>
+
+ [%# Now display a row per file which is a part of this review. #%]
+ [% FOREACH file = filetable %]
+ [% FLUSH IF loop.count() % 10 == 1 %]
+
+ <tr>
+ [%# Determine what CSS style to apply to the line. #%]
+ [% SET rowstyle = "cf" %]
+ [% IF file.revision == "added" %][% SET rowstyle = "af" %]
+ [% ELSIF file.revision == "removed" %][% SET rowstyle = "rf" %]
+ [% ELSIF file.revision == "patch" %][% SET rowstyle = "pf" %]
+ [% END %]
+
+ [% IF rowstyle != "cf" %]
+ <td colspan="2" class="[% rowstyle %]">
+ [% ELSE %]
+ <td class="[% rowstyle %]">
+ [% END %]
+
+ [%# Display the jump to link in the case when all files are displayed. #%]
+ [% IF fview == -1 %]
+ [<a href="[% file.anchor_filename_url %]">Jump to</a>]
+ [% END %]
+
+ [%# Display the filename with an internal link if its not binary. #%]
+ [% IF file.binary %]
+ [% file.filename %]
+ [% ELSE %]
+ <a href="[% file.href_filename_url %]">[% file.filename %]</a>
+ [% END %]
+ </td>
+
+ [%# Display the revision information for modified files. #%]
+ [% IF rowstyle == "cf" %]
+ <td class="[% rowstyle %]"> [% file.revision %]</td>
+ [% END %]
+
+ [%# Display the numchange information for the file. #%]
+ <td class="[% rowstyle %]">
+
+ [% IF file.numchanges != "" %]
+ <font size="-1">{[% file.numchanges %]}</font>
+ [% END %]
+ </td>
+ </tr>
+ [% END %]
+
+</table>
+
+[%# The perl script takes control from here, rendering the topic data. #%]
|
|
From: <si...@us...> - 2008-02-26 08:32:20
|
User: sits
Date: 08/02/26 00:32:18
Modified: . CHANGELOG
lib/Codestriker/Http Render.pm
Log:
* Make sure very long filenames don't move the diff display far to the
right of the view topic page. Fix suggested by
rob...@us....
Index: CHANGELOG
===================================================================
RCS file: /cvsroot/codestriker/codestriker/CHANGELOG,v
retrieving revision 1.224
retrieving revision 1.225
diff -u -r1.224 -r1.225
--- CHANGELOG 21 Feb 2008 02:32:09 -0000 1.224
+++ CHANGELOG 26 Feb 2008 08:32:17 -0000 1.225
@@ -27,6 +27,10 @@
* Make sure if an invalid CGI parameter value is specified that its
value is encoded when displaying the generic error page. Reported
by ama...@us....
+
+* Make sure very long filenames don't move the diff display far to the
+ right of the view topic page. Fix suggested by
+ rob...@us....
Version 1.9.4
Index: Render.pm
===================================================================
RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Http/Render.pm,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -r1.53 -r1.54
--- Render.pm 13 Jun 2006 23:38:40 -0000 1.53
+++ Render.pm 26 Feb 2008 08:32:17 -0000 1.54
@@ -413,43 +413,48 @@
if ($file_url eq "") {
# Output the header without hyperlinking the filename.
- $cell = $query->td({-class=>'file', -colspan=>'3'},
- "Diff for ",
- $query->a({name=>$filename},
- $filename),
- $revision_text);
+ $cell = "Diff for " .
+ $query->a({name=>$filename},
+ $filename) .
+ $revision_text;
}
else {
# Link the filename to the repository system with more information
# about it.
- $cell = $query->td({-class=>'file', -colspan=>'3'},
- "Diff for ",
- $query->a({href=>$file_url,
- name=>$filename},
- $filename),
- $revision_text);
+ $cell = "Diff for " .
+ $query->a({href=>$file_url,
+ name=>$filename},
+ $filename) .
+ $revision_text;
}
# 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},"[>>]") : "")));
+ print $query->Tr($query->td({-class=>'file', -colspan=>'4'},
+ $query->table({-width=>'100%'},
+ $query->Tr(
+ $query->td({align=>'left'}, $cell),
+ $query->td({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},"[>>]") : ""))))));
} else {
# No match in repository, or a new file.
- print $query->Tr($query->td({-class=>'file', -colspan=>'3'},
- "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},"[>>]") : "")));
+ print $query->Tr($query->td({-class=>'file', -colspan=>'4'},
+ $query->table({-width=>'100%'},
+ $query->Tr(
+ $query->td({align=>'left'},
+ "File ",
+ $query->a({name=>$filename},
+ $filename)),
+ $query->td({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},"[>>]") : ""))))));
}
}
|
|
From: <si...@us...> - 2008-02-23 02:30:26
|
User: sits
Date: 08/02/22 18:30:15
Modified: lib/Codestriker/Action ViewTopicProperties.pm
Log:
Handle case where bugtracker is not defined.
Index: ViewTopicProperties.pm
===================================================================
RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Action/ViewTopicProperties.pm,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- ViewTopicProperties.pm 25 Aug 2007 09:11:07 -0000 1.14
+++ ViewTopicProperties.pm 23 Feb 2008 02:30:14 -0000 1.15
@@ -88,6 +88,8 @@
my @bug_id_array = split /[\s,]+/, $topic->{bug_ids};
$vars->{'bug_id_array'} = \@bug_id_array;
$vars->{'bugtracker'} = $Codestriker::bugtracker;
+ } else {
+ $vars->{'bugtracker'} = '';
}
$vars->{'document_reviewers'} =
|
|
From: <si...@us...> - 2008-02-23 02:28:27
|
User: sits
Date: 08/02/22 18:28:09
Modified: lib/Codestriker/Action ListTopics.pm
template/en/default viewtopicproperties.html.tmpl
Log:
Handle situation where bugs have been associated with a topic, but
$Codestriker::bugtracker has not been defined. From Rob.
Index: ListTopics.pm
===================================================================
RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Action/ListTopics.pm,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- ListTopics.pm 21 Dec 2004 23:02:55 -0000 1.30
+++ ListTopics.pm 23 Feb 2008 02:28:09 -0000 1.31
@@ -146,10 +146,14 @@
# bug ids
my @accum_bugs = split /, /, $topic->{bug_ids};
- for ( my $index = 0; $index < scalar(@accum_bugs); ++$index) {
- $accum_bugs[$index] =
- $query->a({href=>"$Codestriker::bugtracker$accum_bugs[$index]"},
- $accum_bugs[$index]);
+ for (my $index = 0; $index < scalar(@accum_bugs); ++$index) {
+ # Allow for no direct web link to a bug.
+ if (defined $Codestriker::bugtracker &&
+ $Codestriker::bugtracker ne '') {
+ $accum_bugs[$index] =
+ $query->a({href=>"$Codestriker::bugtracker$accum_bugs[$index]"},
+ $accum_bugs[$index]);
+ }
}
$template_topic->{'bugids'} = join ', ', @accum_bugs;
Index: viewtopicproperties.html.tmpl
===================================================================
RCS file: /cvsroot/codestriker/codestriker/template/en/default/viewtopicproperties.html.tmpl,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- viewtopicproperties.html.tmpl 23 Feb 2008 02:21:57 -0000 1.25
+++ viewtopicproperties.html.tmpl 23 Feb 2008 02:28:09 -0000 1.26
@@ -84,7 +84,11 @@
Links:
[% FOREACH bug = bug_id_array %]
[% IF loop.count() != 1 %], [% END %]
- <a href="[% bugtracker %][% bug %]">Bug [% bug %]</a>
+ [% IF bugtracker != "" %]
+ <a href="[% bugtracker %][% bug %]">Bug [% bug %]</a>
+ [% ELSE %]
+ Bug [% bug %]
+ [% END %]
[% END %]
</td>
</tr>
|
|
From: <si...@us...> - 2008-02-23 02:22:02
|
User: sits
Date: 08/02/22 18:21:58
Modified: template/en/default viewtopicproperties.html.tmpl
Log:
From Rob: don't allow bug id field to be changed if used to create topic.
Index: viewtopicproperties.html.tmpl
===================================================================
RCS file: /cvsroot/codestriker/codestriker/template/en/default/viewtopicproperties.html.tmpl,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- viewtopicproperties.html.tmpl 10 Aug 2006 11:29:05 -0000 1.24
+++ viewtopicproperties.html.tmpl 23 Feb 2008 02:21:57 -0000 1.25
@@ -78,8 +78,9 @@
<tr class="tt1">
<td>Bug IDs:</td>
<td>
+ [%# Set to readonly if topic generated from BugIDs #%]
<input type="text" name="bug_ids" value="[% bug_ids %]"
- size="30" maxlength="50" [% IF topic_readonly != 0 %]readonly[% END %] />
+ size="30" maxlength="50" [% IF topic_readonly != 0 || (start_tag == '' && end_tag == '' && module == '') %]readonly[% END %] />
Links:
[% FOREACH bug = bug_id_array %]
[% IF loop.count() != 1 %], [% END %]
|