more refactoring

This commit is contained in:
Frans Allen 2019-05-16 18:00:10 +07:00
parent 3af0fc09e0
commit 3f3c481b4e
2 changed files with 5 additions and 30 deletions

View file

@ -1,6 +1,6 @@
=== Plugin Name ===
Contributors: leonstafford
Donate link: https://leonstafford.github.io
Donate link: https:/ljs.dev
Tags: wp2static,github,static
Requires at least: 3.2
Tested up to: 5.0.3
@ -8,11 +8,11 @@ Stable tag: 0.1
License: Unlicense
License URI: http://unlicense.org

Adds AWS GitHub as a deployment option for WP2Static.
Adds GitHub as a deployment option for WP2Static.

== Description ==

Take advantage of the GitHub and optionally CloudFront to host your WordPress
Take advantage of GitHub host your WordPress
powered static website.

== Installation ==

View file

@ -49,7 +49,8 @@ class GitHub extends SitePublisher {
foreach ( $lines as $line ) {
list($this->local_file, $this->target_path) = explode( ',', $line );

$this->local_file = '/' .
$this->local_file = SiteInfo::getPath( 'uploads' ) .
'wp2static-exported-site/' .
$this->local_file;

if ( ! is_file( $this->local_file ) ) {
@ -65,10 +66,6 @@ class GitHub extends SitePublisher {
$this->target_path;
}

$this->logAction(
"Uploading {$local_file} to {$this->target_path} in GitHub"
);

$this->local_file_contents = file_get_contents( $this->local_file );

$this->hash_key =
@ -91,10 +88,6 @@ class GitHub extends SitePublisher {
$this->local_file_contents
);
} else {
$this->logAction(
"Skipping {$this->target_path} as identical " .
'to deploy cache'
);
}
} else {
if ( $this->fileExistsInGitHub() ) {
@ -177,7 +170,6 @@ class GitHub extends SitePublisher {
WsLog::l(
'BAD RESPONSE STATUS (' . $status_code . '): '
);
error_log( $this->remote_path );
throw new Exception( 'GitHub API bad response status' );
}
} catch ( Exception $e ) {
@ -229,9 +221,6 @@ JSON;
)
);

$this->logAction( "API response code {$this->client->status_code}" );
$this->logAction( "API response body {$this->client->body}" );

$this->checkForValidResponses(
$this->client->status_code,
array( '100', '200', '201', '301', '302', '304' )
@ -246,14 +235,12 @@ JSON;
$commit_message = '';

if ( ! empty( $this->existing_file_object ) ) {
$this->logAction( "{$this->target_path} path exists in GitHub" );

return true;
}
}

public function updateFileInGitHub() {
$this->logAction( "Updating {$this->target_path} in GitHub" );

$action = 'UPDATE';
$existing_sha = $this->existing_file_object['oid'];
@ -301,11 +288,6 @@ JSON;
)
);

$this->logAction(
"API response code {$this->client->status_code}"
);
$this->logAction( "API response body {$this->client->body}" );

$this->checkForValidResponses(
$this->client->status_code,
array( '100', '200', '201', '301', '302', '304' )
@ -316,8 +298,6 @@ JSON;
}

public function createFileInGitHub() {
$this->logAction( "Creating {$this->target_path} in GitHub" );

$action = 'CREATE';

$b64_file_contents = base64_encode( $this->local_file_contents );
@ -361,11 +341,6 @@ JSON;
)
);

$this->logAction(
"API response code {$this->client->status_code}"
);
$this->logAction( "API response body {$this->client->body}" );

$this->checkForValidResponses(
$this->client->status_code,
array( '100', '200', '201', '301', '302', '304' )