|
@@ -73,10 +73,41 @@ sub gen_line_nums($$) {
|
|
|
print $fh "</pre></div><html>";
|
|
|
close $fh;
|
|
|
|
|
|
+ $logger->info("Generated line numbers for file");
|
|
|
return $html_file;
|
|
|
|
|
|
}
|
|
|
|
|
|
+sub gen_diff_colors($$) {
|
|
|
+
|
|
|
+ my $raw_diff = shift;
|
|
|
+ my $logger = shift;
|
|
|
+
|
|
|
+ my $html_diff;
|
|
|
+ open my $fh, '>>', \$html_diff or die "Can't open variable: $!";
|
|
|
+
|
|
|
+ print $fh "<!DOCTYPE html><html><div id=\"content\"><pre id=\"blob\">";
|
|
|
+ my $line_counter = 1;
|
|
|
+ foreach my $line ( split("\n", $raw_diff) ) {
|
|
|
+ if ( $line =~ m/^\+/ ) {
|
|
|
+ print $fh "<a href=\"\#l$line_counter\" class=\"line\" id=\"l$line_counter\">$line_counter</a><font color=\"green\">\t$line</font></br>";
|
|
|
+ } elsif ( $line =~ m/^\-/ ) {
|
|
|
+ print $fh "<a href=\"\#l$line_counter\" class=\"line\" id=\"l$line_counter\">$line_counter</a><font color=\"red\">\t$line</font></br>";
|
|
|
+ } elsif ( $line =~ m/^@@/ ) {
|
|
|
+ print $fh "<a href=\"\#l$line_counter\" class=\"line\" id=\"l$line_counter\">$line_counter</a><font color=\"blue\">\t$line</font></br>";
|
|
|
+ } else {
|
|
|
+ print $fh "<a href=\"\#l$line_counter\" class=\"line\" id=\"l$line_counter\">$line_counter</a>\t$line</br>";
|
|
|
+ }
|
|
|
+ $line_counter++;
|
|
|
+ }
|
|
|
+
|
|
|
+ print $fh "</pre></div></html>";
|
|
|
+ close $fh;
|
|
|
+
|
|
|
+ return $html_diff;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
# Main sub for generating project page
|
|
|
# Might make more sense to split into more subs?
|
|
|
sub write_project_content($$$$) {
|
|
@@ -135,9 +166,10 @@ sub write_project_content($$$$) {
|
|
|
|
|
|
# iterate over array to keep ordering
|
|
|
foreach my $commit_id ( @$commit_ids_ref ) {
|
|
|
- my $filename = $commit_id . ".txt";
|
|
|
+ my $filename = $commit_id . ".html";
|
|
|
append_file("<tr><td><a href=\"$filename\">$filename</a></td>",$project_index);
|
|
|
- write_file(${$commits_ref}{$commit_id},$spec_web_dir . $filename);
|
|
|
+ my $html_diff = gen_diff_colors(${$commits_ref}{$commit_id},$logger);
|
|
|
+ write_file($html_diff,$spec_web_dir . $filename);
|
|
|
}
|
|
|
append_file("</tr></tbody></table></div></body>",$project_index);
|
|
|
append_file("</html>",$project_index);
|