Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
163efa4
85 dont detect assets for initial filelist
leonstafford Jun 9, 2020
a35334e
85 use fixed name for export dir
leonstafford Jun 9, 2020
3c72019
wip CrawlQueue;CrawlLog
leonstafford Jun 9, 2020
a3423b4
bump deps;fix version
leonstafford Jun 12, 2020
89cd2c3
wip adjust CrawlQueue population;logging
leonstafford Jun 12, 2020
04fa65e
WsLog to Logger
leonstafford Jun 12, 2020
3523c65
show detected urls immediately
leonstafford Jun 12, 2020
8821fb3
wip crawling from DB
leonstafford Jun 12, 2020
43b2aad
wip using CrawlLog
leonstafford Jun 12, 2020
87128bd
wip infinite crawling
leonstafford Jun 12, 2020
5ccba11
rm pagination detection
leonstafford Jun 12, 2020
3e41c39
generate and view crawl queue
leonstafford Jun 13, 2020
6931aaf
show incremental crawl progress
leonstafford Jun 13, 2020
75653d9
rm folder deploy option
leonstafford Jun 13, 2020
b8c03ee
adjust detected urls list
leonstafford Jun 13, 2020
9fc23d3
wip export and crawl log changes
leonstafford Jun 13, 2020
712a561
adjust sequence of log truncation
leonstafford Jun 13, 2020
889ee5d
get things working
crstauf Jun 14, 2020
3437b89
implement progress bar
crstauf Jun 14, 2020
d30bd58
add debug output
crstauf Jun 14, 2020
18c1898
Merge pull request #99 from crstauf/infinite-crawl
leonstafford Jun 14, 2020
e45add9
match default crawl increment to description
leonstafford Jun 13, 2020
0313924
fix typing;linting
leonstafford Jun 14, 2020
6442862
wip Exclusions;CrawlLog patch
leonstafford Jun 14, 2020
5899a36
rm unused fn
leonstafford Jun 14, 2020
ca7d1e8
WP supported version bump
leonstafford Jun 14, 2020
4e85dcb
write detected URLs within SiteCrawler
leonstafford Jun 15, 2020
a702a55
wip DeployQueue
leonstafford Jun 15, 2020
581df8c
wip DeployCache
leonstafford Jun 15, 2020
6fd0e76
fix typing
leonstafford Jun 15, 2020
1a5cf8e
deploy progress endpoint
leonstafford Jun 15, 2020
d7287d8
update deploy cache deletion btn
leonstafford Jun 15, 2020
6735d29
netlify new site TLD in hints
leonstafford Jun 15, 2020
166d2be
S3 deploy cache
leonstafford Jun 15, 2020
e5405c9
GitHub deploy cache
leonstafford Jun 15, 2020
7924907
Bitbucket deploy cache
leonstafford Jun 15, 2020
94dd482
GitLab deploy cache
leonstafford Jun 15, 2020
8cb86d2
fix typing
leonstafford Jun 15, 2020
b7ce8a5
GitLab get filetree without txt file
leonstafford Jun 15, 2020
14945c0
ver 6.6.19
leonstafford Jun 15, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
Contributors: leonstafford
Tags: security, performance, static
Requires at least: 3.2
Tested up to: 5.4.1
Tested up to: 5.4.2
Requires PHP: 7.3
Stable tag: 6.6.18
Stable tag: 6.6.19

Publish your website as static HTML for improved performance and security.

Expand Down Expand Up @@ -128,8 +128,10 @@ Everyone's WordPress hosting environment and configuration is unique, with diffe

== Changelog ==

= 6.6.18 =
= 6.6.19 =

* granular crawl and deploy progress indicators
* no more txt files polluting uploads dir, slowing things down
* progress indicator on WP_CLI generate cmd
* finally supporting UTF/multibyte URLs!
* preserve font hex values in parsed stylesheets
Expand Down
56 changes: 3 additions & 53 deletions src/Archive.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,63 +17,13 @@ public function __construct() {
[ 'wpenv' ]
);

$this->path = '';
$this->name = '';
}

public function setToCurrentArchive() : void {
$handle = fopen(
$this->settings['wp_uploads_path'] .
'/WP2STATIC-CURRENT-ARCHIVE.txt',
'r'
);

if ( ! is_resource( $handle ) ) {
return;
}

$path = stream_get_line( $handle, 0 );

if ( ! $path ) {
return;
}

$this->path = $path;
$this->path = $this->settings['wp_uploads_path'] . '/static-html-output/';
$this->name = basename( $this->path );
}

public function currentArchiveExists() : bool {
return is_file(
$this->settings['wp_uploads_path'] .
'/WP2STATIC-CURRENT-ARCHIVE.txt'
);
}

public function create() : void {
$this->name = $this->settings['wp_uploads_path'] .
'/wp-static-html-output-' . time();

$this->path = $this->name . '/';
$this->name = basename( $this->path );

if ( wp_mkdir_p( $this->path ) ) {
$result = file_put_contents(
$this->settings['wp_uploads_path'] .
'/WP2STATIC-CURRENT-ARCHIVE.txt',
$this->path
);

if ( ! $result ) {
WsLog::l( 'USER WORKING DIRECTORY NOT WRITABLE' );
}

chmod(
$this->settings['wp_uploads_path'] .
'/WP2STATIC-CURRENT-ARCHIVE.txt',
0664
);
} else {
WsLog::l( "Couldn't create archive directory at $this->path" );
if ( ! wp_mkdir_p( $this->path ) ) {
Logger::l( "Couldn't create archive directory at $this->path" );
}
}
}
Expand Down
97 changes: 4 additions & 93 deletions src/ArchiveProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,9 @@ class ArchiveProcessor extends StaticHTMLOutput {
* @var Archive
*/
public $archive;
/**
* @var string
*/
public $target_folder;

public function __construct() {
$this->archive = new Archive();
$this->archive->setToCurrentArchive();

$this->loadSettings(
[
Expand All @@ -29,14 +24,13 @@ public function __construct() {
'processing',
'netlify',
'zip',
'folder',
]
);
}

public function renameWPDirectory( string $source, string $target ) : void {
if ( empty( $source ) || empty( $target ) ) {
WsLog::l(
Logger::l(
'Failed trying to rename: ' .
'Source: ' . $source .
' to: ' . $target
Expand All @@ -54,7 +48,7 @@ public function renameWPDirectory( string $source, string $target ) : void {
$original_dir
);
} else {
WsLog::l(
Logger::l(
'Trying to rename non-existent directory: ' .
$original_dir
);
Expand Down Expand Up @@ -146,89 +140,6 @@ public function put_safety_file( string $dirname ) : bool {
return true;
}

public function copyStaticSiteToPublicFolder() : void {
if ( $this->settings['selected_deployment_option'] === 'folder' ) {
$target_folder = trim( $this->settings['targetFolder'] );
$this->target_folder = $target_folder;

if ( ! $target_folder ) {
return;
}

// instantiate with safe defaults
$directory_exists = true;
$directory_empty = false;
$dir_has_safety_file = false;

// CHECK #1: directory exists or can be created
$directory_exists = is_dir( $target_folder );

if ( $directory_exists ) {
$directory_empty = $this->dir_is_empty( $target_folder );
} else {
if ( wp_mkdir_p( $target_folder ) ) {
if ( ! $this->put_safety_file( $target_folder ) ) {
WsLog::l(
'Couldn\'t put safety file in ' .
'Target Directory' .
$target_folder
);

die();
}
} else {
WsLog::l(
'Couldn\'t create Target Directory: ' .
$target_folder
);

die();
}
}

// CHECK #2: check directory empty and add safety file
if ( $directory_empty ) {
if ( ! $this->put_safety_file( $target_folder ) ) {
WsLog::l(
'Couldn\'t put safety file in ' .
'Target Directory' .
$target_folder
);

die();
}
}

$dir_has_safety_file =
$this->dir_has_safety_file( $target_folder );

if ( $directory_empty || $dir_has_safety_file ) {
$this->recursive_copy(
$this->archive->path,
$this->target_folder
);

if ( ! $this->put_safety_file( $target_folder ) ) {
WsLog::l(
'Couldn\'t put safety file in ' .
'Target Directory' .
$target_folder
);

die();
}
} else {
WsLog::l(
'Target Directory wasn\'t empty ' .
'or didn\'t contain safety file ' .
$target_folder
);

die();
}
}
}

public function createNetlifySpecialFiles() : void {
if ( $this->settings['selected_deployment_option'] !== 'netlify' ) {
return;
Expand Down Expand Up @@ -262,7 +173,7 @@ public function create_zip() : void {
$zip_archive = new ZipArchive();

if ( $zip_archive->open( $temp_zip, ZIPARCHIVE::CREATE ) !== true ) {
WsLog::l( 'Could not create archive' );
Logger::l( 'Could not create archive' );
return;
}

Expand All @@ -284,7 +195,7 @@ public function create_zip() : void {
str_replace( $this->archive->path, '', $filename )
)
) {
WsLog::l( 'Could not add file: ' . $filename );
Logger::l( 'Could not add file: ' . $filename );
return;
}
}
Expand Down
Loading