12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- #!/usr/bin/perl
- use strict;
- use warnings;
- use Getopt::Long qw(GetOptions);
- use Log::Log4perl qw(:easy);
- use lib "/usr/local/lib";
- use Shellex::Shellex qw(shellex findBin);
- use Gsg::ConfigParse qw(parse_gsg_config);
- use Gsg::Gather qw(get_file_tree get_projects trim_project_paths);
- use Gsg::Html qw(write_file append_file write_root_index clean_web_root write_project_content);
- # TODO set this in config file?
- my $log_file = "gsg.log";
- sub get_log_name { return $log_file; };
- my $log_conf = q(
- log4perl.rootLogger = INFO, LOG1, screen
- log4perl.appender.LOG1 = Log::Log4perl::Appender::File
- log4perl.appender.LOG1.filename = sub { get_log_name(); }
- log4perl.appender.LOG1.mode = append
- log4perl.appender.LOG1.layout = Log::Log4perl::Layout::PatternLayout
- log4perl.appender.LOG1.layout.ConversionPattern = %d %p >> %m %n
- log4perl.appender.screen = Log::Log4perl::Appender::Screen
- log4perl.appender.screen.stderr = 0
- log4perl.appender.screen.layout = PatternLayout
- log4perl.appender.screen.layout.ConversionPattern = %d %p >> %m %n
- );
- Log::Log4perl::init(\$log_conf);
- my $logger = get_logger();
- # Args processing: TODO
- my %args;
- GetOptions(
- \%args,
- "config-file=s",
- "version",
- );
- my $version = "0.1";
- if ( defined $args{'version'} ) {
- print "git-site-gen: Version $version\n";
- exit 0;
- }
- # Read config
- my $config_file;
- if ( ! defined $args{'config-file'} ) {
- $config_file = "config.default";
- } else {
- $config_file = $args{'config-file'};
- }
- my %config = parse_gsg_config($config_file,$logger);
- # Set default vars
- my $web_root = $config{'WebRoot'};
- my $web_projects_dir = $web_root . "/projects/";
- my $root_index = $web_root . "/" . "index.html";
- # Really just here for testing right now
- sub dump_config {
- foreach my $key ( keys %config ) {
- if ( $key eq "IgnoredProjects" ) {
- print "$key contains:\n";
- foreach my $val ( @{$config{$key}} ) {
- print "$val\n";
- }
- } else {
- print "Key is $key and val is $config{$key}\n";
- }
- }
- }
- # Get projects list
- my $git_projects_ref = get_projects($config{'GitHome'},$config{'IgnoredProjects'},$logger);
- foreach my $p ( @$git_projects_ref ) {
- print "$p\n";
- }
- # Get trimmed (name only) git projects
- my $trimmed_git_projects_ref = trim_project_paths($git_projects_ref,$logger);
- # Clean webroot if there is anything we no longer want to display
- # clean_web_root($web_projects_dir,$trimmed_git_projects_ref,$logger);
- # Write root index
- write_root_index($root_index,$trimmed_git_projects_ref,$web_projects_dir,$logger);
- # Write project contents
- write_project_content($git_projects_ref,$trimmed_git_projects_ref,$web_projects_dir,$logger);
- $logger->info("Done");
|