/**
  * Render the page for generating a static site.
  *
  * @return void
  */
 public function display_generate_page()
 {
     if ($this->check_system_requirements()) {
         $this->view->assign('system_requirements_check_failed', true);
     }
     if (isset($_POST['generate'])) {
         $archive_creator = new Simply_Static_Archive_Creator(self::SLUG, $this->options->get('destination_scheme'), $this->options->get('destination_host'), $this->options->get('temp_files_dir'), $this->options->get('additional_urls'));
         $archive_creator->create_archive();
         // TODO: archive_url could be a WP_Error
         if ($this->options->get('delivery_method') == 'zip') {
             $archive_url = $archive_creator->create_zip();
             if (is_wp_error($archive_url)) {
                 $error = $archive_url->get_error_message();
                 $this->view->add_flash('error', $error);
             } else {
                 $message = __('ZIP archive created: ', self::SLUG);
                 $message .= ' <a href="' . $archive_url . '">' . __('Click here to download', self::SLUG) . '</a>';
                 $this->view->add_flash('updated', $message);
             }
         } elseif ($this->options->get('delivery_method') == 'local') {
             $local_dir = $this->options->get('local_dir');
             $result = $archive_creator->copy_static_files($local_dir);
             if (is_wp_error($result)) {
                 $error = $result->get_error_message();
                 $this->view->add_flash('error', $error);
             } else {
                 $message = __('Static files copied to: ' . $local_dir, self::SLUG);
                 $this->view->add_flash('updated', $message);
             }
         } elseif ($this->options->get('delivery_method') == 's3') {
             $bucket = $this->options->get('aws_s3_bucket');
             $result = $archive_creator->publish_to_s3($bucket, $this->options->get('aws_access_key_id'), $this->options->get('aws_secret_access_key'));
             if (is_wp_error($result)) {
                 $error = $result->get_error_message();
                 $this->view->add_flash('error', $error);
             } else {
                 $message = __('Site published to S3 bucket: ' . $bucket, self::SLUG);
                 $this->view->add_flash('updated', $message);
             }
         }
         if ($this->options->get('delete_temp_files') == '1') {
             $deleted_successfully = $archive_creator->delete_static_files();
         }
         $export_log = $archive_creator->get_export_log();
         $this->view->assign('export_log', $export_log);
     }
     $this->view->set_layout('admin')->set_template('generate')->render();
 }