tags ui
This commit is contained in:
@@ -3,9 +3,15 @@
|
||||
|
||||
use Illuminate\Contracts\Filesystem\Filesystem;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class StaticGenerator
|
||||
{
|
||||
/**
|
||||
* @var array<string> $directoriesIndex
|
||||
*/
|
||||
public array $directoriesIndex = [];
|
||||
|
||||
public function __construct(
|
||||
public Writer $writer,
|
||||
@@ -16,8 +22,36 @@ class StaticGenerator
|
||||
|
||||
public function run(callable $callback): void
|
||||
{
|
||||
|
||||
echo "Start".PHP_EOL;
|
||||
$this->removePreviousDirectories();
|
||||
echo "Removing previous data".PHP_EOL;
|
||||
$callback($this->writer);
|
||||
echo "Finito".PHP_EOL;
|
||||
}
|
||||
|
||||
private function removePreviousDirectories() :void{
|
||||
if(!file_exists(storage_path("lucent/directories.log"))){
|
||||
return;
|
||||
}
|
||||
$directories = file_get_contents(storage_path("lucent/directories.log"));
|
||||
$directoriesArr = array_reverse(explode(PHP_EOL,$directories));
|
||||
foreach ($directoriesArr as $directory){
|
||||
if(empty($directory) || $directory === "/") {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!file_exists(public_path($directory."/index.html"))){
|
||||
continue;
|
||||
}
|
||||
unlink(public_path($directory."/index.html"));
|
||||
rmdir(public_path($directory));
|
||||
}
|
||||
if(file_exists(public_path("index.html"))){
|
||||
unlink(public_path("index.html"));
|
||||
}
|
||||
unlink(storage_path("lucent/directories.log"));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -22,19 +22,19 @@ class Writer
|
||||
}
|
||||
|
||||
file_put_contents($filepath, $html);
|
||||
file_put_contents(storage_path("lucent/directories.log"), $path.PHP_EOL, FILE_APPEND);
|
||||
echo "Path: /$path".PHP_EOL;
|
||||
}
|
||||
|
||||
|
||||
public function recordIterator(callable $query, callable $parser, int $skip = 0): int
|
||||
public function recordIterator(callable $query, callable $parser, int $skip = 0, $limit = 100): int
|
||||
{
|
||||
$limit = 100;
|
||||
// logger("fetching $skip");
|
||||
|
||||
$records = $query($limit, $skip);
|
||||
$parser($records);
|
||||
$parser($records,$limit, $skip);
|
||||
|
||||
if ($records->hasResults()) {
|
||||
if ($records->count() > 0) {
|
||||
return $this->recordIterator($query, $parser, $skip + $limit);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user