master
Kaitlyn Parkhurst 3 years ago
parent 7a251f7794
commit 47f6e8ad08
  1. 20
      Web/lib/MJB/Web/Task.pm
  2. 10
      Web/lib/MJB/Web/Task/DeployBlog.pm

@ -86,7 +86,7 @@ sub system_command ( $self, $cmd, $settings = {} ){
}; };
} }
sub process_webroot ( $job, $site, $source, $dest ) { sub process_webroot ( $job, $blog, $source, $dest ) {
if ( -d $source ) { if ( -d $source ) {
@ -97,8 +97,8 @@ sub process_webroot ( $job, $site, $source, $dest ) {
my $files = Mojo::File->new( $source )->list_tree; my $files = Mojo::File->new( $source )->list_tree;
if ( $files->size > $site->max_static_file_count ) { if ( $files->size > $blog->max_static_file_count ) {
$job->fail( "This site may have up to " . $site->max_static_file_count . " static files, however the webroot contains " . $files->size . " files."); $job->fail( "This site may have up to " . $blog->max_static_file_count . " static files, however the webroot contains " . $files->size . " files.");
$job->stop; $job->stop;
} }
@ -106,9 +106,9 @@ sub process_webroot ( $job, $site, $source, $dest ) {
foreach my $file ( $files->each ) { foreach my $file ( $files->each ) {
# Does file exceed size allowed? # Does file exceed size allowed?
if ( $file->stat->size >= ( $site->max_static_file_size * 1024 * 1024 ) ) { if ( $file->stat->size >= ( $blog->max_static_file_size * 1024 * 1024 ) ) {
$job->fail( sprintf("This site may have static files up to %d MiB, however %s exceeds this limit.", $job->fail( sprintf("This site may have static files up to %d MiB, however %s exceeds this limit.",
$site->max_static_file_size, $blog->max_static_file_size,
$file->to_string $file->to_string
)); ));
$job->stop; $job->stop;
@ -117,8 +117,8 @@ sub process_webroot ( $job, $site, $source, $dest ) {
$total_file_size += $file->stat->size; $total_file_size += $file->stat->size;
# If the total file size exceeds the max_static_webroot_size, fail the job. # If the total file size exceeds the max_static_webroot_size, fail the job.
if ( $total_file_size >= ( $site->max_static_webroot_size * 1024 * 1024 ) ) { if ( $total_file_size >= ( $blog->max_static_webroot_size * 1024 * 1024 ) ) {
$job->fail( "This site may have up to " . $site->max_static_webroot_size . $job->fail( "This site may have up to " . $blog->max_static_webroot_size .
" MiB in static files, however the webroot exceeds this limit." " MiB in static files, however the webroot exceeds this limit."
); );
$job->stop; $job->stop;
@ -140,10 +140,10 @@ sub append_log ( $self, @lines ){
$self->note( logs => \@logs ); $self->note( logs => \@logs );
} }
sub checkout_repo ( $job, $site_id ) { sub checkout_repo ( $job, $blog_id ) {
my $repo = $job->app->db->site($site_id)->repo; my $blog = $job->app->db->blog($blog_id)->repo;
die "Error: No repo found for site_id: $site_id" die "Error: No repo found for site_id: $blog_id"
unless $repo; unless $repo;
my $build_dir = Mojo::File->tempdir( 'build-XXXXXX', CLEANUP => 0 ); my $build_dir = Mojo::File->tempdir( 'build-XXXXXX', CLEANUP => 0 );

@ -4,11 +4,11 @@ use Mojo::File qw( curfile );
use File::Copy::Recursive qw( dircopy ); use File::Copy::Recursive qw( dircopy );
use IPC::Run3; use IPC::Run3;
sub run ( $job, $site_id ) { sub run ( $job, $blog_id ) {
$job->note( _mds_template => 'build_static' ); $job->note( _mds_template => 'build_static' );
my $build_dir = $job->checkout_repo( $site_id ); my $build_dir = $job->checkout_repo( $blog_id );
my $site = $job->app->db->site( $site_id ); my $blog = $job->app->db->blog( $blog_id );
$job->note( is_clone_complete => 1 ); $job->note( is_clone_complete => 1 );
@ -23,7 +23,7 @@ sub run ( $job, $site_id ) {
}); });
$job->process_webroot( $job->process_webroot(
$site, $blog,
$build_dir->child('src')->child('_site')->to_string, $build_dir->child('src')->child('_site')->to_string,
$build_dir->child('build')->to_string $build_dir->child('build')->to_string
); );
@ -34,7 +34,7 @@ sub run ( $job, $site_id ) {
# probably this one. # probably this one.
Mojo::File->new($build_dir)->child('build')->child('site.yml')->spurt( Mojo::File->new($build_dir)->child('build')->child('site.yml')->spurt(
YAML::Dump({ YAML::Dump({
domain => $site->domain->domain, domain => $blog->domain->name,
www_dir => "$build_dir/build/", www_dir => "$build_dir/build/",
}) })
); );

Loading…
Cancel
Save