Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
{
"name": "cybertroniankelvin/graper",
"description": "GrapeJS page builder for Filament",
"description": "A visual drag-and-drop page builder for Filament admin panels, powered by GrapeJS v3. Build landing pages, marketing sites, and custom content pages without writing code.",
"keywords": [
"graper",
"filament",
"laravel",
"grapejs"
"grapejs",
"page-builder",
"cms",
"drag-and-drop",
"visual-editor",
"admin"
],
"homepage": "https://github.com/cybertroniankelvin/graper",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion config/graper.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

return [
'page_route_prefix' => '/',
'page_route_prefix' => 'pages',

'include_tailwind' => true,

'block_theme' => env('GRAPER_BLOCK_THEME', 'tailwind'),

Check failure on line 8 in config/graper.php

View workflow job for this annotation

GitHub Actions / phpstan

Called 'env' outside of the config directory which returns null when the config is cached, use 'config'.

'default_height' => '500px',

Expand Down
6 changes: 0 additions & 6 deletions routes/graper.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,4 @@
Route::get('/graper/api/page/{page}', [GraperPageController::class, 'show'])->name('graper.show');
Route::put('/graper/api/page/{page}', [GraperPageController::class, 'update'])->name('graper.update');
Route::get('/graper/edit/{page}', [GraperPageController::class, 'edit'])->name('graper.edit');

$prefix = config('graper.page_route_prefix', '');
$displayPrefix = $prefix ? "/{$prefix}" : '';
Route::get("{$displayPrefix}/{slug}", [GraperPageController::class, 'display'])
->name('graper.page.display')
->where('slug', '[a-z0-9-]+');
});
8 changes: 4 additions & 4 deletions src/Commands/GraperInstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ public function handle(): int
$this->info('Installing Graper...');

$this->call('vendor:publish', [
'--package' => 'graper/graper',
'--tag' => 'grapesjs-config',
'--provider' => 'CybertronianKelvin\Graper\GraperServiceProvider',
'--tag' => 'graper-config',
]);

$this->call('vendor:publish', [
'--package' => 'graper/graper',
'--tag' => 'grapesjs-migrations',
'--provider' => 'CybertronianKelvin\Graper\GraperServiceProvider',
'--tag' => 'graper-migrations',
]);

$this->info('Graper installed successfully.');
Expand Down
2 changes: 1 addition & 1 deletion src/ComponentTraits/ComponentTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ public function toArray(): array
'options' => static::getOptions(),
];
}
}
}
6 changes: 3 additions & 3 deletions src/ComponentTraits/ComponentTraitRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

public static function make(): static
{
return self::$instance ??= new self();
return self::$instance ??= new self;

Check failure on line 18 in src/ComponentTraits/ComponentTraitRegistry.php

View workflow job for this annotation

GitHub Actions / phpstan

Method CybertronianKelvin\Graper\ComponentTraits\ComponentTraitRegistry::make() should return static(CybertronianKelvin\Graper\ComponentTraits\ComponentTraitRegistry) but returns CybertronianKelvin\Graper\ComponentTraits\ComponentTraitRegistry.
}

public static function reset(): void
Expand All @@ -26,7 +26,7 @@
public function register(string|ComponentTrait $trait): static
{
if (is_string($trait)) {
$trait = new $trait();
$trait = new $trait;
}

$this->traits[$trait::getId()] = $trait;
Expand Down Expand Up @@ -58,4 +58,4 @@
->values()
->all();
}
}
}
2 changes: 1 addition & 1 deletion src/GraperPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

namespace CybertronianKelvin\Graper;

use CybertronianKelvin\Graper\Resources\GraperPageResource;
use Filament\Contracts\Plugin;
use Filament\Panel;
use CybertronianKelvin\Graper\Resources\GraperPageResource;

class GraperPlugin implements Plugin
{
Expand Down
18 changes: 10 additions & 8 deletions src/GraperServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace CybertronianKelvin\Graper;

use CybertronianKelvin\Graper\Blocks\BlockRegistry;
use CybertronianKelvin\Graper\Commands\GraperCommand;
use CybertronianKelvin\Graper\Commands\GraperInstallCommand;
use CybertronianKelvin\Graper\Http\Controllers\GraperPageController;
Expand All @@ -21,8 +20,7 @@ public function configurePackage(Package $package): void
{
$package
->name('graper')
->hasConfigFile('graper')
->hasConfigFile('grapesjs')
->hasConfigFile(['graper', 'grapesjs'])
->hasViews()
->hasMigration('create_graper_pages_table')
->hasCommand(GraperCommand::class)
Expand All @@ -31,7 +29,7 @@ public function configurePackage(Package $package): void

public function boot(): void
{
view()->addNamespace('graper', base_path('packages/graper/resources/views'));
parent::boot();

$this->loadRoutes();
$this->registerDisplayRoute();
Expand All @@ -44,12 +42,16 @@ public function boot(): void

protected function registerDisplayRoute(): void
{
$prefix = trim(config('graper.page_route_prefix', '/'), '/');
$path = $prefix === '' ? '/{slug}' : '/'.$prefix.'/{slug}';
$prefix = trim(config('graper.page_route_prefix', ''), '/');

Route::get($path, [GraperPageController::class, 'display'])
if ($prefix === '') {
return;
}

Route::get('/'.$prefix.'/{slug}', [GraperPageController::class, 'display'])
->middleware('web')
->name('graper.page.display');
->name('graper.page.display')
->where('slug', '[a-z0-9-]+');
}

protected function loadRoutes(): void
Expand Down
2 changes: 1 addition & 1 deletion src/Helpers/GraperHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,4 @@ private static function extractStyles(array $projectData): string

return $css;
}
}
}
1 change: 0 additions & 1 deletion src/Models/GraperPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace CybertronianKelvin\Graper\Models;

use CybertronianKelvin\Graper\Helpers\GraperHelper;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
Expand Down Expand Up @@ -35,9 +34,9 @@

public function getContentAttribute(): ?string
{
$html = $this->html;

Check failure on line 37 in src/Models/GraperPage.php

View workflow job for this annotation

GitHub Actions / phpstan

Access to an undefined property CybertronianKelvin\Graper\Models\GraperPage::$html.
$css = $this->css;

Check failure on line 38 in src/Models/GraperPage.php

View workflow job for this annotation

GitHub Actions / phpstan

Access to an undefined property CybertronianKelvin\Graper\Models\GraperPage::$css.
$projectData = $this->project_data;

Check failure on line 39 in src/Models/GraperPage.php

View workflow job for this annotation

GitHub Actions / phpstan

Access to an undefined property CybertronianKelvin\Graper\Models\GraperPage::$project_data.

if ($html === null && $css === null && ($projectData === null || empty($projectData))) {
return null;
Expand All @@ -57,7 +56,7 @@
}

$data = json_decode($value, true) ?? [];
$this->html = $data['html'] ?? '';

Check failure on line 59 in src/Models/GraperPage.php

View workflow job for this annotation

GitHub Actions / phpstan

Access to an undefined property CybertronianKelvin\Graper\Models\GraperPage::$html.
$this->css = $data['css'] ?? '';
$this->project_data = $data['project_data'] ?? [];
}
Expand Down
2 changes: 1 addition & 1 deletion src/Pages/GrapesJsPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

namespace CybertronianKelvin\Graper\Pages;

use CybertronianKelvin\Graper\Models\GraperPage;
use Filament\Pages\Page;
use Filament\Panel;
use CybertronianKelvin\Graper\Models\GraperPage;
use Illuminate\Support\Facades\Route;

class GrapesJsPage extends Page
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace CybertronianKelvin\Graper\Resources\GraperPageResource\Pages;

use Filament\Resources\Pages\CreateRecord;
use CybertronianKelvin\Graper\Resources\GraperPageResource;
use Filament\Resources\Pages\CreateRecord;

class CreateGraperPage extends CreateRecord
{
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/GraperPageResource/Pages/EditGraperPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

namespace CybertronianKelvin\Graper\Resources\GraperPageResource\Pages;

use CybertronianKelvin\Graper\Resources\GraperPageResource;
use Filament\Actions;
use Filament\Resources\Pages\EditRecord;
use CybertronianKelvin\Graper\Resources\GraperPageResource;
use Illuminate\Database\Eloquent\Model;

class EditGraperPage extends EditRecord
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/GraperPageResource/Pages/ListGraperPages.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace CybertronianKelvin\Graper\Resources\GraperPageResource\Pages;

use Filament\Resources\Pages\ListRecords;
use CybertronianKelvin\Graper\Resources\GraperPageResource;
use Filament\Resources\Pages\ListRecords;

class ListGraperPages extends ListRecords
{
Expand Down
15 changes: 10 additions & 5 deletions tests/ArchTest.php
Original file line number Diff line number Diff line change
@@ -1,30 +1,35 @@
<?php

declare(strict_types=1);
use CybertronianKelvin\Graper\Storage\StorageDriver;
use Filament\Contracts\Plugin;
use Illuminate\Console\Command;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Routing\Controller;

arch('no debugging functions in source')
->expect(['dd', 'dump', 'ray', 'var_dump'])
->each->not->toBeUsed();

arch('models extend Eloquent Model')
->expect('CybertronianKelvin\Graper\Models')
->toExtend(\Illuminate\Database\Eloquent\Model::class);
->toExtend(Model::class);

arch('controllers extend Laravel Controller')
->expect('CybertronianKelvin\Graper\Http\Controllers')
->toExtend(\Illuminate\Routing\Controller::class);
->toExtend(Controller::class);

arch('storage driver implements StorageDriver interface')
->expect('CybertronianKelvin\Graper\Storage\EloquentDriver')
->toImplement(\CybertronianKelvin\Graper\Storage\StorageDriver::class);
->toImplement(StorageDriver::class);

arch('plugin implements Filament Plugin contract')
->expect('CybertronianKelvin\Graper\GraperPlugin')
->toImplement(\Filament\Contracts\Plugin::class);
->toImplement(Plugin::class);

arch('commands extend Illuminate Command')
->expect('CybertronianKelvin\Graper\Commands')
->toExtend(\Illuminate\Console\Command::class);
->toExtend(Command::class);

arch('all source files use strict types')
->expect('CybertronianKelvin\Graper')
Expand Down
1 change: 0 additions & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use CybertronianKelvin\Graper\Http\Controllers\GraperPageController;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Facades\File;
use Illuminate\Routing\Router;
use Orchestra\Testbench\TestCase as Orchestra;

class TestCase extends Orchestra
Expand Down
Loading
Loading