Thread: [Codestriker-commits] CVS update: codestriker/template/en/default viewdeltas.html.tmpl
Brought to you by:
sits
|
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_u...
[truncated message content] |
|
From: <si...@us...> - 2008-07-01 06:00:16
|
User: sits
Date: 08/06/30 23:00:15
Modified: template/en/default viewdeltas.html.tmpl
Log:
For binary files, don't bother showing the line links, as there are no lines.
Index: viewdeltas.html.tmpl
===================================================================
RCS file: /cvsroot/codestriker/codestriker/template/en/default/viewdeltas.html.tmpl,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- viewdeltas.html.tmpl 11 Jun 2008 07:52:04 -0000 1.6
+++ viewdeltas.html.tmpl 1 Jul 2008 06:00:15 -0000 1.7
@@ -55,7 +55,7 @@
Parallel
</a>
</td>
- [% ELSE %]
+ [% ELSIF !delta.binary %]
[%# 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>
|
|
From: <si...@us...> - 2008-07-01 06:02:01
|
User: sits
Date: 08/06/30 23:02:00
Modified: template/en/default viewdeltas.html.tmpl
Log:
Don't bother creating links for the "Line XXX" text for now, since it just goes to the same Parallel view anyway.
Index: viewdeltas.html.tmpl
===================================================================
RCS file: /cvsroot/codestriker/codestriker/template/en/default/viewdeltas.html.tmpl,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- viewdeltas.html.tmpl 1 Jul 2008 06:00:15 -0000 1.7
+++ viewdeltas.html.tmpl 1 Jul 2008 06:02:00 -0000 1.8
@@ -38,18 +38,14 @@
[% 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
|
|
From: <si...@us...> - 2008-07-01 11:08:49
|
User: sits
Date: 08/07/01 04:08:47
Modified: template/en/default viewdeltas.html.tmpl
Log:
Prepend a space to each code line for better output.
Index: viewdeltas.html.tmpl
===================================================================
RCS file: /cvsroot/codestriker/codestriker/template/en/default/viewdeltas.html.tmpl,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- viewdeltas.html.tmpl 1 Jul 2008 06:02:00 -0000 1.8
+++ viewdeltas.html.tmpl 1 Jul 2008 11:08:47 -0000 1.9
@@ -65,12 +65,12 @@
<tr>
[% IF delta.new_file %]
<td>[% line.new_data_line %]</td>
- <td class="[% delta.new_file_class %]" colspan="3">[% line.new_data %]</td>
+ <td class="[% delta.new_file_class %]" colspan="3"> [% line.new_data %]</td>
[% ELSE %]
<td>[% line.old_data_line %]</td>
- <td class="[% line.old_data_class %]">[% line.old_data %]</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>
+ <td class="[% line.new_data_class %]"> [% line.new_data %]</td>
[% END %]
</tr>
[% END %]
|