sidebar
This commit is contained in:
File diff suppressed because one or more lines are too long
Vendored
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"main.js": {
|
||||
"file": "assets/main.e9ef6ca6.js",
|
||||
"file": "assets/main.6a78412a.js",
|
||||
"src": "main.js",
|
||||
"isEntry": true,
|
||||
"css": [
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{#if otherSchemas}
|
||||
{#if otherSchemas.length > 0}
|
||||
<div class="accordion-item">
|
||||
<h2 class="accordion-header" id="panelsStayOpen-headingOther">
|
||||
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse"
|
||||
@@ -83,7 +83,7 @@
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
{#if fileSchemas}
|
||||
{#if fileSchemas.length > 0}
|
||||
<div class="accordion-item">
|
||||
<h2 class="accordion-header" id="panelsStayOpen-headingFS">
|
||||
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse"
|
||||
|
||||
@@ -63,10 +63,9 @@
|
||||
{/if}
|
||||
{#if !inProgress && logs}
|
||||
<span class="badge text-bg-info">
|
||||
Build completed at
|
||||
Build completed
|
||||
</span>
|
||||
{/if}
|
||||
<span class="badge text-bg-light"> {date}</span>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
@@ -47,6 +47,7 @@ class BuildController extends Controller
|
||||
{
|
||||
return response()->stream(function () {
|
||||
while (true) {
|
||||
sleep(1); // 50ms
|
||||
$data["date"] = date("Y-m-d H:i:s");
|
||||
$data["logs"] = file_get_contents(storage_path("build.log"));
|
||||
$lines = explode("\n",$data["logs"]);
|
||||
@@ -57,7 +58,7 @@ class BuildController extends Controller
|
||||
ob_flush();
|
||||
flush();
|
||||
|
||||
if(in_array("Finito",$lines)){
|
||||
if(str_contains("Finito",$lines)){
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php namespace Lucent\StaticGenerator;
|
||||
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Contracts\Filesystem\Filesystem;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Support\Facades\File;
|
||||
@@ -8,10 +9,6 @@ use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class StaticGenerator
|
||||
{
|
||||
/**
|
||||
* @var array<string> $directoriesIndex
|
||||
*/
|
||||
public array $directoriesIndex = [];
|
||||
|
||||
public function __construct(
|
||||
public Writer $writer,
|
||||
@@ -23,37 +20,29 @@ class StaticGenerator
|
||||
public function run(callable $callback): void
|
||||
{
|
||||
|
||||
echo "Start".PHP_EOL;
|
||||
$this->removePreviousDirectories();
|
||||
echo "Start ".Carbon::now()->format("Y-m-d H:i:s").PHP_EOL;
|
||||
$this->removeBuildDirectory();
|
||||
echo "Removing previous data".PHP_EOL;
|
||||
$callback($this->writer);
|
||||
echo "Finito".PHP_EOL;
|
||||
$this->copyBuildDirectory();
|
||||
echo "Finito ".Carbon::now()->format("Y-m-d H:i:s").PHP_EOL;
|
||||
}
|
||||
|
||||
private function removePreviousDirectories() :void{
|
||||
if(!file_exists(storage_path("lucent/directories.log"))){
|
||||
private function removeBuildDirectory() :void{
|
||||
if(!file_exists(storage_path("lucent/build"))){
|
||||
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;
|
||||
}
|
||||
$cmd = "rm -rf ".storage_path("lucent/build");
|
||||
exec($cmd);
|
||||
}
|
||||
|
||||
if(!file_exists(public_path($directory."/index.html"))){
|
||||
if(file_exists(public_path($directory))){
|
||||
rmdir(public_path($directory));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
unlink(public_path($directory."/index.html"));
|
||||
rmdir(public_path($directory));
|
||||
private function copyBuildDirectory() :void{
|
||||
if(file_exists(storage_path("lucent/live"))){
|
||||
$cmd = "rm -rf ".storage_path("lucent/live");
|
||||
exec($cmd);
|
||||
}
|
||||
if(file_exists(public_path("index.html"))){
|
||||
unlink(public_path("index.html"));
|
||||
}
|
||||
unlink(storage_path("lucent/directories.log"));
|
||||
$cmd = sprintf("cp -R %s %s",storage_path("lucent/build"),storage_path("lucent/live"));
|
||||
exec($cmd);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -6,24 +6,29 @@ use Illuminate\Contracts\View\View;
|
||||
class Writer
|
||||
{
|
||||
|
||||
public function __construct(
|
||||
)
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
private function buildPath(string $path): string
|
||||
{
|
||||
if (!file_exists(storage_path("lucent/build"))) {
|
||||
mkdir(storage_path("lucent/build"));
|
||||
}
|
||||
return storage_path("lucent/build/" . ltrim($path, "/"));
|
||||
}
|
||||
|
||||
public function save(string $path, string $html): void
|
||||
{
|
||||
$path = trim($path, "/");
|
||||
|
||||
$filepath = public_path($path . "/index.html");
|
||||
$filepath = $this->buildPath($path. "/index.html");
|
||||
|
||||
if (!file_exists(pathinfo($filepath, PATHINFO_DIRNAME))) {
|
||||
make_dir_r(pathinfo($filepath, PATHINFO_DIRNAME));
|
||||
}
|
||||
|
||||
file_put_contents($filepath, $html);
|
||||
file_put_contents(storage_path("lucent/directories.log"), $path.PHP_EOL, FILE_APPEND);
|
||||
echo "Path: /$path".PHP_EOL;
|
||||
echo "Path: $path" . PHP_EOL;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +37,7 @@ class Writer
|
||||
// logger("fetching $skip");
|
||||
|
||||
$records = $query($limit, $skip);
|
||||
$parser($records,$limit, $skip);
|
||||
$parser($records, $limit, $skip);
|
||||
|
||||
if ($records->count() > 0) {
|
||||
return $this->recordIterator($query, $parser, $skip + $limit);
|
||||
|
||||
Reference in New Issue
Block a user