2012-09-21 07:47:26 +02:00
|
|
|
<?php
|
|
|
|
/**
|
2012-09-25 10:02:26 +02:00
|
|
|
* @package staticpublisher
|
2012-09-21 07:47:26 +02:00
|
|
|
*/
|
|
|
|
class StaticExporterTask extends BuildTask {
|
|
|
|
|
|
|
|
public function run($request) {
|
2013-06-08 03:57:57 +02:00
|
|
|
$now = microtime(true);
|
2012-09-21 07:47:26 +02:00
|
|
|
$export = new StaticExporter();
|
|
|
|
|
|
|
|
$url = $request->getVar('baseurl');
|
|
|
|
$sym = $request->getVar('symlink');
|
|
|
|
$quiet = $request->getVar('quiet');
|
|
|
|
$folder = $request->getVar('path');
|
|
|
|
|
|
|
|
if(!$folder) $folder = TEMP_FOLDER . '/static-export';
|
|
|
|
|
|
|
|
$url = ($url) ? $url : Director::baseURL();
|
|
|
|
$symlink = ($sym != "false");
|
|
|
|
$quiet = ($quiet) ? $quiet : false;
|
|
|
|
|
|
|
|
if(!$quiet) printf("Exporting website with %s base URL... %s", $url, PHP_EOL);
|
|
|
|
$path = $export->doExport($url, $folder, $symlink, $quiet);
|
|
|
|
|
2013-06-08 03:57:57 +02:00
|
|
|
if(!$quiet) {
|
|
|
|
printf("\nWebsite exported to %s\nTotal time %s\nMemory used %s. %s",
|
|
|
|
$path,
|
|
|
|
number_format(microtime(true) - $now, 2) . 's',
|
|
|
|
number_format(memory_get_peak_usage() / 1024 / 1024, 2) .'mb',
|
|
|
|
PHP_EOL
|
|
|
|
);
|
|
|
|
}
|
2012-09-21 07:47:26 +02:00
|
|
|
}
|
|
|
|
}
|