Skip to content

Commit

Permalink
File sync, Builder item (#711)
Browse files Browse the repository at this point in the history
  • Loading branch information
adrolli authored Sep 27, 2024
1 parent 5d72d06 commit ff9c102
Show file tree
Hide file tree
Showing 33 changed files with 1,842 additions and 117 deletions.
7 changes: 6 additions & 1 deletion app/Providers/Filament/AdminPanelProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,13 @@ public function panel(Panel $panel): Panel
->path('moox')
->passwordReset(RequestPasswordReset::class)
->login(Login::class)
// TODO: check this
//->authGuard('admin')
->brandLogo(asset('img/logo.png'))
->brandLogoHeight('1.6rem')
->colors([
'primary' => Color::Amber,
'primary' => Color::Indigo,
'secondary' => Color::Neutral,
])
->discoverResources(in: app_path('Filament/Resources'), for: 'App\\Filament\\Resources')
->discoverPages(in: app_path('Filament/Pages'), for: 'App\\Filament\\Pages')
Expand Down
118 changes: 114 additions & 4 deletions config/builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
|
*/

'single' => 'trans//core::builder.builder',
'plural' => 'trans//core::builder.builders',
'single' => 'trans//builder::translations.item',
'plural' => 'trans//builder::translations.items',

/*
|--------------------------------------------------------------------------
Expand All @@ -56,7 +56,76 @@
'all' => [
'label' => 'trans//core::core.all',
'icon' => 'gmdi-filter-list',
'query' => [],
'query' => [
[
'field' => 'deleted_at',
'operator' => '=',
'value' => null,
],
],
],
'published' => [
'label' => 'trans//core::core.published',
'icon' => 'gmdi-check-circle',
'query' => [
[
'field' => 'publish_at',
'operator' => '<=',
'value' => function () {
return now();
},
],
[
'field' => 'deleted_at',
'operator' => '=',
'value' => null,
],
],
],
'scheduled' => [
'label' => 'trans//core::core.scheduled',
'icon' => 'gmdi-schedule',
'query' => [
[
'field' => 'publish_at',
'operator' => '>',
'value' => function () {
return now();
},
],
[
'field' => 'deleted_at',
'operator' => '=',
'value' => null,
],
],
],
'draft' => [
'label' => 'trans//core::core.draft',
'icon' => 'gmdi-text-snippet',
'query' => [
[
'field' => 'publish_at',
'operator' => '=',
'value' => null,
],
[
'field' => 'deleted_at',
'operator' => '=',
'value' => null,
],
],
],
'deleted' => [
'label' => 'trans//core::core.deleted',
'icon' => 'gmdi-delete',
'query' => [
[
'field' => 'deleted_at',
'operator' => '!=',
'value' => null,
],
],
],
],
],
Expand All @@ -77,7 +146,7 @@

/*
|--------------------------------------------------------------------------
| Builder - Navigation Sort
| Navigation Sort
|--------------------------------------------------------------------------
|
| This value is the sort order of the navigation item in the
Expand All @@ -88,4 +157,45 @@

'navigation_sort' => 9990,

/*
|--------------------------------------------------------------------------
| Item Types
|--------------------------------------------------------------------------
|
| This array contains the types of items entities. You can delete
| the types you don't need and add new ones. If you don't need
| types, you can empty this array like this: 'types' => [],
|
*/

'types' => [
'post' => 'Post',
'page' => 'Page',
],

/*
|--------------------------------------------------------------------------
| Author Model
|--------------------------------------------------------------------------
|
| This sets the user model that can be used as author. It should be an
| authenticatable model and support the morph relationship.
| It should have fields similar to Moox User or WpUser.
|
*/

'author_model' => \Moox\User\Models\User::class,

/*
|--------------------------------------------------------------------------
| Allow Slug Change - WIP
|--------------------------------------------------------------------------
|
| // TODO: Work in progress.
|
*/

'allow_slug_change_after_saved' => env('ALLOW_SLUG_CHANGE_AFTER_SAVED', true),
'allow_slug_change_after_publish' => env('ALLOW_SLUG_CHANGE_AFTER_PUBLISH', false),

];
129 changes: 129 additions & 0 deletions config/sync.php
Original file line number Diff line number Diff line change
Expand Up @@ -408,4 +408,133 @@

'sync_token' => env('SYNC_TOKEN', 'Y0U_N3V3R_GU355_TH15_S3CR3T_K3Y'),

/*
|--------------------------------------------------------------------------
| Enable File Sync
|--------------------------------------------------------------------------
|
| Enables the file sync feature, which allows you to sync files between
| platforms, that can be auto-detected in your models based on
| configurable rules or by using a custom resolver.
|
*/

'file_sync' => [
'enabled' => env('FILE_SYNC_ENABLED', false),
],

/*
|--------------------------------------------------------------------------
| File Sync Allowed Extensions
|--------------------------------------------------------------------------
|
| The file sync allowed extensions are used to check if the file extension
| is allowed to be synced. You may add more extensions as needed.
|
*/

'file_sync_allowed_extensions' => [
'jpg',
'jpeg',
'png',
'gif',
'svg',
'webp',
],

/*
|--------------------------------------------------------------------------
| File Sync Mode
|--------------------------------------------------------------------------
|
| The file sync mode is used to determine the underlying
| file sync method. Currently only http is supported.
| Rsync is planned for future implementation.
|
*/

'file_sync_mode' => 'http', // TODO: rsync not implemented yet

/*
|--------------------------------------------------------------------------
| File Sync Size
|--------------------------------------------------------------------------
|
| The file sync max size is used to limit the size of the file
| that can be synced over http or rsync (planned).
| The chunk size is only relevant for http.
|
*/

'file_sync_max_size_http' => 2 * 1024 * 1024, // 5 MB
'file_sync_max_size_rsync' => 50 * 1024 * 1024, // 50 MB, not implemented yet
'file_sync_chunk_size_http' => 1 * 1024 * 1024, // 1 MB

/*
|--------------------------------------------------------------------------
| File Sync Files Count
|--------------------------------------------------------------------------
|
| The file sync files count is used to limit the number
| of files that can be synced over http or
| rsync (planned) per sync record.
|
*/

'file_sync_files_count_http' => 10,
'file_sync_files_count_rsync' => 100, // TODO: rsync not implemented yet

/*
|--------------------------------------------------------------------------
| File Sync Temp Directory
|--------------------------------------------------------------------------
|
| The file sync temp directory is used to store the file chunks
| during transfer. It should be writable by the webserver
| user, not tracked by git and maybe not backed up.
|
*/

'file_sync_temp_directory' => 'temp/file_sync',

/*
|--------------------------------------------------------------------------
| File Sync Fieldsearch
|--------------------------------------------------------------------------
|
| The file sync fields are used to detect the file sync for a model.
| If any of these words are found within the column name,
| the content will be checked for being a file path.
|
*/

'file_sync_fieldsearch' => [
'file',
'image',
'media',
'attachment',
'avatar',
'logo',
'thumbnail',
'cover',
'banner',
'picture',
'image',
'photo',
'picture',
],

/*
|--------------------------------------------------------------------------
| File Sync Resolver
|--------------------------------------------------------------------------
|
| The file sync resolver is used to resolve the file sync for a model.
| You can activate Moox Press resolver here or create your own.
|
*/

'file_sync_resolver' => [
\Moox\Press\Models\WpUser::class => \Moox\Press\Resolver\WpUserFileResolver::class,
],
];
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@ public function up(): void
$table->id();
$table->string('title');
$table->string('slug')->unique();
$table->string('featured_image_url')->nullable();
$table->text('content')->nullable();
$table->json('gallery_image_urls')->nullable();
$table->string('status')->default('draft');
$table->string('type')->default('post');
$table->string('author_id')->nullable();
$table->timestamp('publish_at')->nullable();
$table->timestamp('deleted_at')->nullable()->index();
$table->timestamps();
});
Expand Down
Loading

0 comments on commit ff9c102

Please sign in to comment.