|
@@ -54,6 +54,29 @@ sub write_root_index($$$$) {
|
|
|
|
|
|
}
|
|
|
|
|
|
+sub gen_line_nums($$) {
|
|
|
+
|
|
|
+ my $raw_file = shift;
|
|
|
+ my $logger = shift;
|
|
|
+
|
|
|
+ my $html_file;
|
|
|
+ # Might be a better way to do this? TODO
|
|
|
+ open my $fh, '>>', \$html_file 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_file) ) {
|
|
|
+ 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_file;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
# Main sub for generating project page
|
|
|
# Might make more sense to split into more subs?
|
|
|
sub write_project_content($$$$) {
|
|
@@ -91,15 +114,16 @@ sub write_project_content($$$$) {
|
|
|
## Write files ##
|
|
|
append_file("<table><div id=\"cotent\"><table id=\"index\"><thead><tr><td><b>File</b></td><td><b>Commit</b></td></tr></thead><tbody>",$project_index);
|
|
|
foreach my $filename ( sort keys %$file_content_ref ) {
|
|
|
- my $browserCompat = $filename . ".txt";
|
|
|
+ my $browserCompat = $filename . ".html";
|
|
|
# Rewrite dir paths so we can save on disk without producing actual dir structure
|
|
|
if ( $filename =~ m/\// ) {
|
|
|
my $copy = $filename;
|
|
|
$copy =~ s/\//_/g;
|
|
|
- $browserCompat = $copy . ".txt";
|
|
|
+ $browserCompat = $copy . ".html";
|
|
|
}
|
|
|
append_file("<tr><td><a href=\"$browserCompat\">$filename</a></td><td>${$file_tree_ref}{$filename}</td>",$project_index);
|
|
|
- write_file("${$file_content_ref}{$filename}",$spec_web_dir . $browserCompat);
|
|
|
+ my $html_file = gen_line_nums(${$file_content_ref}{$filename},$logger);
|
|
|
+ write_file("$html_file",$spec_web_dir . $browserCompat);
|
|
|
}
|
|
|
|
|
|
append_file("</tr></tbody></table></div></body>",$project_index);
|