[Codestriker-commits] CVS update: codestriker/template/en/default viewtopic.html.tmpl
Brought to you by:
sits
|
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. #%]
|