|
@@ -3,6 +3,43 @@ use strict;
|
|
|
use warnings;
|
|
|
use Log::Log4perl qw(:easy);
|
|
|
use Exporter qw(import);
|
|
|
-our @EXPORT_OK = qw();
|
|
|
+our @EXPORT_OK = qw(write_file append_file write_root_index);
|
|
|
+
|
|
|
+# These subs might belong in shellex
|
|
|
+sub write_file {
|
|
|
+
|
|
|
+ my $content = shift;
|
|
|
+ my $path = shift;
|
|
|
+ open(my $fh, ">", $path) or die "Couldnt open $path\n";
|
|
|
+ print $fh "$content";
|
|
|
+ close $fh;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+sub append_file {
|
|
|
+ my $content = shift;
|
|
|
+ my $path = shift;
|
|
|
+ open(my $fh, ">>", $path) or die "Couldnt open $path\n";
|
|
|
+ print $fh "$content";
|
|
|
+ close $fh;
|
|
|
+}
|
|
|
+
|
|
|
+sub write_root_index {
|
|
|
+
|
|
|
+ my $index = shift;
|
|
|
+ my $project_dirs_ref = shift;
|
|
|
+ write_file("", $index);
|
|
|
+ append_file("<html><body><b>Git Projects</b><br><head><META NAME=\"ROBOTS\" CONTENT=\"NOINDEX, NOFOLLOW\"></head>\n",$index);
|
|
|
+ append_file("<small><i>Statically generated web root for browsing my git projects</i></small><br>",$index);
|
|
|
+ append_file("<small><i>This is a read-only site and does not provide a merge/clone interface</i></small><hr/>",$index);
|
|
|
+
|
|
|
+ foreach my $project ( @$project_dirs_ref ) {
|
|
|
+ append_file("<table><div id=\"cotent\"><table id=\"index\"><tbody>",$index);
|
|
|
+ append_file("<tr><td><a href=\"projects/$project/index.html\">$project</a></td>",$index);
|
|
|
+ system("mkdir -p $projects_dir$project") == 0 or die "Couldnt create $projects_dir/$project";
|
|
|
+ }
|
|
|
+ append_file("</tr></tbody></table></div></body></html>",$index);
|
|
|
+
|
|
|
+}
|
|
|
|
|
|
1;
|