fix paths
This commit is contained in:
@@ -10,6 +10,8 @@
|
|||||||
let imageSide;
|
let imageSide;
|
||||||
let fileSide;
|
let fileSide;
|
||||||
let fontSize;
|
let fontSize;
|
||||||
|
|
||||||
|
console.log({ channel });
|
||||||
if (size == "large") {
|
if (size == "large") {
|
||||||
imageSide = 256;
|
imageSide = 256;
|
||||||
fileSide = 32;
|
fileSide = 32;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import Preview from "../files/Preview.svelte";
|
import Preview from "../files/Preview.svelte";
|
||||||
import {fileurl} from "../files/imageserver"
|
import { fileurl } from "../files/imageserver";
|
||||||
import {getContext} from "svelte"
|
import { getContext } from "svelte";
|
||||||
|
|
||||||
const channel = getContext("channel");
|
const channel = getContext("channel");
|
||||||
export let record;
|
export let record;
|
||||||
@@ -11,10 +11,9 @@
|
|||||||
{#if schema.type === "files"}
|
{#if schema.type === "files"}
|
||||||
<div class="record-edit-file-preview">
|
<div class="record-edit-file-preview">
|
||||||
<div>
|
<div>
|
||||||
<Preview {record} size="large"/>
|
<Preview {record} size="large" />
|
||||||
</div>
|
</div>
|
||||||
<div class="file-details">
|
<div class="file-details">
|
||||||
|
|
||||||
<div class="file-details-item">
|
<div class="file-details-item">
|
||||||
<span class="text-muted">Filename</span>
|
<span class="text-muted">Filename</span>
|
||||||
<span>{record._file.path}</span>
|
<span>{record._file.path}</span>
|
||||||
@@ -42,9 +41,13 @@
|
|||||||
<span>{record._file.checksum}</span>
|
<span>{record._file.checksum}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="file-details-item">
|
<div class="file-details-item">
|
||||||
<a class="button primary" target="_blank" style="display: inline-flex" href="{fileurl(channel,record)}">Download</a>
|
<a
|
||||||
|
class="button primary"
|
||||||
|
target="_blank"
|
||||||
|
style="display: inline-flex"
|
||||||
|
href={fileurl(channel, record)}>Download</a
|
||||||
|
>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
|||||||
@@ -2,11 +2,9 @@
|
|||||||
import { array_move } from "../../edges/sortEdges";
|
import { array_move } from "../../edges/sortEdges";
|
||||||
import Sortable from "../../libs/Sortable.svelte";
|
import Sortable from "../../libs/Sortable.svelte";
|
||||||
import PreviewFile from "../previews/PreviewFile.svelte";
|
import PreviewFile from "../previews/PreviewFile.svelte";
|
||||||
import { getContext } from "svelte";
|
|
||||||
import FileDialog from "../../dialog/FileDialog.svelte";
|
import FileDialog from "../../dialog/FileDialog.svelte";
|
||||||
import Uploader from "../../files/Uploader.svelte";
|
import Uploader from "../../files/Uploader.svelte";
|
||||||
|
|
||||||
const channel = getContext("channel");
|
|
||||||
export let field;
|
export let field;
|
||||||
export let record;
|
export let record;
|
||||||
export let value = [];
|
export let value = [];
|
||||||
|
|||||||
@@ -34,14 +34,16 @@ final class Channel
|
|||||||
|
|
||||||
private function makeFilesUrl(): string
|
private function makeFilesUrl(): string
|
||||||
{
|
{
|
||||||
$lucentDisk = config("lucent.disk");
|
$lucentDisk = config("lucent.public_disk");
|
||||||
|
|
||||||
return match (config("filesystems.disks.$lucentDisk.driver")) {
|
return match (config("filesystems.disks.$lucentDisk.driver")) {
|
||||||
"s3" => config("filesystems.disks.$lucentDisk.endpoint") .
|
"s3" => config("filesystems.disks.$lucentDisk.endpoint") .
|
||||||
"/" .
|
"/lucent" .
|
||||||
config("filesystems.disks.$lucentDisk.bucket"),
|
config("filesystems.disks.$lucentDisk.bucket"),
|
||||||
"local" => $this->url .
|
"local" => $this->url .
|
||||||
"/storage" .
|
"/storage/lucent" .
|
||||||
config("filesystems.disks.$lucentDisk.endpoint"),
|
config("filesystems.disks.$lucentDisk.endpoint"),
|
||||||
|
|
||||||
default => "",
|
default => "",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ namespace Lucent\Channel;
|
|||||||
|
|
||||||
use Lucent\Channel\Data\UserCommand;
|
use Lucent\Channel\Data\UserCommand;
|
||||||
use Lucent\Data\ChannelAuth;
|
use Lucent\Data\ChannelAuth;
|
||||||
|
use Lucent\File\FileService;
|
||||||
use Lucent\Primitive\Collection;
|
use Lucent\Primitive\Collection;
|
||||||
use Lucent\Data\Schema;
|
use Lucent\Data\Schema;
|
||||||
use Lucent\Schema\SchemaService;
|
use Lucent\Schema\SchemaService;
|
||||||
@@ -18,8 +19,9 @@ final class ChannelService
|
|||||||
public static function fromConfig(): ChannelService
|
public static function fromConfig(): ChannelService
|
||||||
{
|
{
|
||||||
$schemasArray = [];
|
$schemasArray = [];
|
||||||
if (file_exists(schemas_path())) {
|
$privateDisk = FileService::loadPrivateDisk();
|
||||||
$schemasJson = file_get_contents(schemas_path());
|
if ($privateDisk->exists(schemas_path())) {
|
||||||
|
$schemasJson = $privateDisk->get(schemas_path());
|
||||||
$schemasArray = json_decode($schemasJson, true);
|
$schemasArray = json_decode($schemasJson, true);
|
||||||
}
|
}
|
||||||
$schemaService = new SchemaService();
|
$schemaService = new SchemaService();
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ use DirectoryIterator;
|
|||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use Lucent\Data\Schema;
|
use Lucent\Data\Schema;
|
||||||
use Lucent\Schema\SchemaService;
|
use Lucent\Schema\SchemaService;
|
||||||
|
use Lucent\File\FileService;
|
||||||
|
|
||||||
class CompileSchemas extends Command
|
class CompileSchemas extends Command
|
||||||
{
|
{
|
||||||
@@ -13,8 +14,10 @@ class CompileSchemas extends Command
|
|||||||
|
|
||||||
protected $description = "Compiles schemas";
|
protected $description = "Compiles schemas";
|
||||||
|
|
||||||
public function handle(SchemaService $schemaService)
|
public function handle(
|
||||||
{
|
SchemaService $schemaService,
|
||||||
|
FileService $fileService,
|
||||||
|
) {
|
||||||
$configDir = base_path(config("lucent.schemas_path"));
|
$configDir = base_path(config("lucent.schemas_path"));
|
||||||
$schemasDirIterator = new DirectoryIterator($configDir);
|
$schemasDirIterator = new DirectoryIterator($configDir);
|
||||||
$schemas = [];
|
$schemas = [];
|
||||||
@@ -63,8 +66,8 @@ class CompileSchemas extends Command
|
|||||||
mkdir(storage_path("lucent"));
|
mkdir(storage_path("lucent"));
|
||||||
}
|
}
|
||||||
|
|
||||||
file_put_contents(schemas_path(), json_encode($json));
|
$disk = $fileService->loadPrivateDisk();
|
||||||
|
$disk->put(schemas_path(), json_encode($json));
|
||||||
$this->info("Lucent Schemas were updated");
|
$this->info("Lucent Schemas were updated");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
namespace Lucent\Commands;
|
namespace Lucent\Commands;
|
||||||
|
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Lucent\File\FileService;
|
||||||
use ZipArchive;
|
use ZipArchive;
|
||||||
|
|
||||||
class Export extends Command
|
class Export extends Command
|
||||||
@@ -13,7 +13,7 @@ class Export extends Command
|
|||||||
|
|
||||||
protected $description = "Export data and files";
|
protected $description = "Export data and files";
|
||||||
|
|
||||||
public function handle(): void
|
public function handle(FileService $fileService): void
|
||||||
{
|
{
|
||||||
$db = config("database.connections.pgsql");
|
$db = config("database.connections.pgsql");
|
||||||
$tables = [
|
$tables = [
|
||||||
@@ -23,7 +23,8 @@ class Export extends Command
|
|||||||
"lucent_edges",
|
"lucent_edges",
|
||||||
];
|
];
|
||||||
|
|
||||||
$exportDir = storage_path("exports");
|
$disk = $fileService->loadPrivateDisk();
|
||||||
|
$exportDir = $disk->path("lucent/exports");
|
||||||
if (!is_dir($exportDir)) {
|
if (!is_dir($exportDir)) {
|
||||||
mkdir($exportDir, 0755, true);
|
mkdir($exportDir, 0755, true);
|
||||||
}
|
}
|
||||||
@@ -55,7 +56,9 @@ class Export extends Command
|
|||||||
$this->info("Database dumped.");
|
$this->info("Database dumped.");
|
||||||
|
|
||||||
// Zip SQL + files
|
// Zip SQL + files
|
||||||
$filesDir = Storage::disk(config("lucent.disk"))->path("files");
|
$publicDisk = $fileService->loadPublicDisk();
|
||||||
|
|
||||||
|
$filesDir = $publicDisk->path("lucent/files");
|
||||||
|
|
||||||
$zip = new ZipArchive();
|
$zip = new ZipArchive();
|
||||||
if (
|
if (
|
||||||
|
|||||||
+21
-9
@@ -3,7 +3,7 @@
|
|||||||
namespace Lucent\Commands;
|
namespace Lucent\Commands;
|
||||||
|
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Lucent\File\FileService;
|
||||||
use ZipArchive;
|
use ZipArchive;
|
||||||
|
|
||||||
class Import extends Command
|
class Import extends Command
|
||||||
@@ -12,9 +12,10 @@ class Import extends Command
|
|||||||
|
|
||||||
protected $description = "Import data and files from an export archive";
|
protected $description = "Import data and files from an export archive";
|
||||||
|
|
||||||
public function handle(): void
|
public function handle(FileService $fileService): void
|
||||||
{
|
{
|
||||||
$exportDir = storage_path("exports");
|
$disk = $fileService->loadPrivateDisk();
|
||||||
|
$exportDir = $disk->path("lucent/exports");
|
||||||
|
|
||||||
if (!is_dir($exportDir)) {
|
if (!is_dir($exportDir)) {
|
||||||
$this->error("No exports directory found at {$exportDir}");
|
$this->error("No exports directory found at {$exportDir}");
|
||||||
@@ -34,7 +35,9 @@ class Import extends Command
|
|||||||
$chosen = $this->choice("Select an export to import", $choices, 0);
|
$chosen = $this->choice("Select an export to import", $choices, 0);
|
||||||
$zipFile = $exportDir . "/" . $chosen;
|
$zipFile = $exportDir . "/" . $chosen;
|
||||||
|
|
||||||
$this->warn("This will REPLACE all records, revisions, edges, files data and uploaded files.");
|
$this->warn(
|
||||||
|
"This will REPLACE all records, revisions, edges, files data and uploaded files.",
|
||||||
|
);
|
||||||
|
|
||||||
if (!$this->confirm("Import {$chosen}?", false)) {
|
if (!$this->confirm("Import {$chosen}?", false)) {
|
||||||
$this->info("Aborted.");
|
$this->info("Aborted.");
|
||||||
@@ -118,16 +121,23 @@ class Import extends Command
|
|||||||
$srcFilesDir = $tempDir . "/files";
|
$srcFilesDir = $tempDir . "/files";
|
||||||
|
|
||||||
if (is_dir($srcFilesDir)) {
|
if (is_dir($srcFilesDir)) {
|
||||||
$disk = Storage::disk(config("lucent.disk"));
|
$publicDisk = $fileService->loadPublicDisk();
|
||||||
$destFilesDir = $disk->path("files");
|
$filesDir = $publicDisk->path("lucent");
|
||||||
|
$destFilesDir = $publicDisk->path("lucent");
|
||||||
|
|
||||||
// Remove existing files directory
|
// Remove existing files directory or create it if missing
|
||||||
if (is_dir($destFilesDir)) {
|
if (is_dir($destFilesDir)) {
|
||||||
exec("rm -rf " . escapeshellarg($destFilesDir));
|
exec("rm -rf " . escapeshellarg($destFilesDir));
|
||||||
|
} else {
|
||||||
|
mkdir($destFilesDir, 0755, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
exec(
|
exec(
|
||||||
sprintf("cp -R %s %s", escapeshellarg($srcFilesDir), escapeshellarg($destFilesDir)),
|
sprintf(
|
||||||
|
"cp -R %s %s",
|
||||||
|
escapeshellarg($srcFilesDir),
|
||||||
|
escapeshellarg($destFilesDir),
|
||||||
|
),
|
||||||
result_code: $copyCode,
|
result_code: $copyCode,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -139,7 +149,9 @@ class Import extends Command
|
|||||||
|
|
||||||
$this->info("Files restored.");
|
$this->info("Files restored.");
|
||||||
} else {
|
} else {
|
||||||
$this->warn("No files directory found in archive — skipping file restore.");
|
$this->warn(
|
||||||
|
"No files directory found in archive — skipping file restore.",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->cleanup($tempDir);
|
$this->cleanup($tempDir);
|
||||||
|
|||||||
@@ -2,17 +2,11 @@
|
|||||||
|
|
||||||
namespace Lucent\Commands;
|
namespace Lucent\Commands;
|
||||||
|
|
||||||
use DirectoryIterator;
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use Intervention\Image\ImageManager;
|
|
||||||
use Lucent\Channel\ChannelService;
|
|
||||||
use Lucent\File\FileRepo;
|
use Lucent\File\FileRepo;
|
||||||
use Lucent\File\FileService;
|
use Lucent\File\FileService;
|
||||||
use Lucent\Query\Query;
|
use Lucent\Query\Query;
|
||||||
use Lucent\Schema\FilesSchema;
|
|
||||||
use Lucent\Schema\Schema;
|
|
||||||
use Lucent\Schema\Type;
|
|
||||||
|
|
||||||
class RebuildThumbnails extends Command
|
class RebuildThumbnails extends Command
|
||||||
{
|
{
|
||||||
@@ -31,7 +25,7 @@ class RebuildThumbnails extends Command
|
|||||||
{
|
{
|
||||||
$this->info("Rebuilding thumbnails ");
|
$this->info("Rebuilding thumbnails ");
|
||||||
$files = FileRepo::query()->get();
|
$files = FileRepo::query()->get();
|
||||||
$disk = $this->fileService->loadDisk();
|
$disk = $this->fileService->loadPublicDisk();
|
||||||
foreach ($files as $file) {
|
foreach ($files as $file) {
|
||||||
try {
|
try {
|
||||||
$this->fileService->createTemplates($disk, $file->path);
|
$this->fileService->createTemplates($disk, $file->path);
|
||||||
|
|||||||
+3
-2
@@ -4,12 +4,13 @@ return [
|
|||||||
"env" => env("LUCENT_ENV", "production"),
|
"env" => env("LUCENT_ENV", "production"),
|
||||||
// lucent or lunar
|
// lucent or lunar
|
||||||
"auth" => env("LUCENT_AUTH", "lucent"),
|
"auth" => env("LUCENT_AUTH", "lucent"),
|
||||||
"disk" => env("LUCENT_DISK", "public"),
|
"private_disk" => env("LUCENT_PRIVATE_DISK", "local"),
|
||||||
|
"public_disk" => env("LUCENT_PUBLIC_DISK", "public"),
|
||||||
"schemas_path" => env("LUCENT_SCHEMAS_PATH", "resources/lucent/schemas"),
|
"schemas_path" => env("LUCENT_SCHEMAS_PATH", "resources/lucent/schemas"),
|
||||||
"database" => env("LUCENT_DB_CONNECTION", env("DB_CONNECTION", "sqlite")),
|
"database" => env("LUCENT_DB_CONNECTION", env("DB_CONNECTION", "sqlite")),
|
||||||
"name" => env("LUCENT_NAME", "Lucent"),
|
"name" => env("LUCENT_NAME", "Lucent"),
|
||||||
"url" => env("LUCENT_URL", env("APP_URL")),
|
"url" => env("LUCENT_URL", env("APP_URL")),
|
||||||
"previewTarget" => env("LUCENT_PREVIEW_TARGET", "previewTarget"),
|
"preview_target" => env("LUCENT_PREVIEW_TARGET", "previewTarget"),
|
||||||
/*
|
/*
|
||||||
* Make available laravel artisan commands for admin users
|
* Make available laravel artisan commands for admin users
|
||||||
* example:
|
* example:
|
||||||
|
|||||||
+14
-11
@@ -4,16 +4,13 @@ namespace Lucent\File;
|
|||||||
|
|
||||||
use Illuminate\Contracts\Filesystem\Filesystem;
|
use Illuminate\Contracts\Filesystem\Filesystem;
|
||||||
use Illuminate\Http\UploadedFile;
|
use Illuminate\Http\UploadedFile;
|
||||||
use Illuminate\Log\Logger;
|
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use Intervention\Image\ImageManager;
|
use Intervention\Image\ImageManager;
|
||||||
use Lucent\Channel\ChannelService;
|
use Lucent\Channel\ChannelService;
|
||||||
use Lucent\Database\Database;
|
|
||||||
use Lucent\Id\Id;
|
use Lucent\Id\Id;
|
||||||
use Lucent\LucentException;
|
use Lucent\LucentException;
|
||||||
use Lucent\Data\File as DataFile;
|
use Lucent\Data\File as DataFile;
|
||||||
use Lucent\Record\QueryRecord;
|
|
||||||
use Spatie\ImageOptimizer\OptimizerChainFactory;
|
use Spatie\ImageOptimizer\OptimizerChainFactory;
|
||||||
|
|
||||||
class FileService
|
class FileService
|
||||||
@@ -21,7 +18,6 @@ class FileService
|
|||||||
public function __construct(
|
public function __construct(
|
||||||
public ChannelService $channelService,
|
public ChannelService $channelService,
|
||||||
public ImageManager $imageManager,
|
public ImageManager $imageManager,
|
||||||
public Logger $logger,
|
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
public function createFromUrl(
|
public function createFromUrl(
|
||||||
@@ -58,10 +54,10 @@ class FileService
|
|||||||
|
|
||||||
$checksum = sha1_file($file);
|
$checksum = sha1_file($file);
|
||||||
|
|
||||||
$disk = $this->loadDisk();
|
$disk = $this->loadPublicDisk();
|
||||||
$path = "files/" . $recordId . "/" . $filename;
|
$path = "files/" . $recordId . "/" . $filename;
|
||||||
$res = $disk->put(
|
$res = $disk->put(
|
||||||
$path,
|
"lucent/" . $path,
|
||||||
file_get_contents($file),
|
file_get_contents($file),
|
||||||
// 'public' // now managed by aws policy
|
// 'public' // now managed by aws policy
|
||||||
);
|
);
|
||||||
@@ -117,22 +113,29 @@ class FileService
|
|||||||
return in_array($mimetype, $imageMimes);
|
return in_array($mimetype, $imageMimes);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function loadDisk(): Filesystem
|
public static function loadPublicDisk(): Filesystem
|
||||||
{
|
{
|
||||||
return Storage::disk(config("lucent.disk"));
|
return Storage::disk(config("lucent.public_disk"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function loadPrivateDisk(): Filesystem
|
||||||
|
{
|
||||||
|
return Storage::disk(config("lucent.private_disk"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createTemplates(Filesystem $disk, string $path): void
|
public function createTemplates(Filesystem $disk, string $path): void
|
||||||
{
|
{
|
||||||
$originalImage = $this->imageManager->make($disk->get($path));
|
$originalImage = $this->imageManager->make(
|
||||||
|
$this->loadPublicDisk()->get("lucent/" . $path),
|
||||||
|
);
|
||||||
foreach (config("lucent.imageFilters") as $preset => $filterClass) {
|
foreach (config("lucent.imageFilters") as $preset => $filterClass) {
|
||||||
$imageClone = clone $originalImage;
|
$imageClone = clone $originalImage;
|
||||||
$image = $imageClone->filter(new $filterClass());
|
$image = $imageClone->filter(new $filterClass());
|
||||||
$templateUri = "/templates/" . $preset . "/" . $path;
|
$templateUri = "lucent/templates/" . $preset . "/" . $path;
|
||||||
$disk->put($templateUri, $image->encode("webp", 75));
|
$disk->put($templateUri, $image->encode("webp", 75));
|
||||||
}
|
}
|
||||||
|
|
||||||
$thumbDir = "thumbs/" . $path;
|
$thumbDir = "lucent/thumbs/" . $path;
|
||||||
|
|
||||||
$image = $originalImage->fit(300, 300);
|
$image = $originalImage->fit(300, 300);
|
||||||
$disk->put($thumbDir, $image->encode("webp", 75));
|
$disk->put($thumbDir, $image->encode("webp", 75));
|
||||||
|
|||||||
+1
-1
@@ -39,7 +39,7 @@ if (!function_exists("make_dir_r")) {
|
|||||||
if (!function_exists("schemas_path")) {
|
if (!function_exists("schemas_path")) {
|
||||||
function schemas_path(): string
|
function schemas_path(): string
|
||||||
{
|
{
|
||||||
return storage_path("lucent/lucent.schemas.json");
|
return "lucent/lucent.schemas.json";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user