Skip to content

Commit

Permalink
feat: Version 0.2.2 (#18)
Browse files Browse the repository at this point in the history
* feat: packaged cmseditor (#2)

* feat: composer file

* feat: add license + changelog

* Add files via upload

* Delete CmsEditor directory

* Delete resources/views directory

---------

Co-authored-by: Rene <rene@notfound.nl>
Co-authored-by: Xander Schuurman <44030544+keeama13@users.noreply.github.com>

* feat: migrations + routes + restructure (#3)

* feat: migrations + routes + restructure

* fix: added composer + removed cmseditor folder

* fix: providers

* feat: models in package (#4)

* feat: models in package

* feat: packaged controllers

* feat: seeders in package

* fix: removed test echo

* feat: lang + views

* feat: services + provides

* feat: package

* feat: finalizing package

* feat: last changes

* fix: remove surplus migrations

* feat: database seeders

* feat: add helpers

* fix: policy namespacing

* fix: class name

* fix: remove user provider

* feat: last configs

---------

Co-authored-by: Rene <rene@notfound.nl>

* fix: syntax error in composer file

* style: formatting

* feat: add pinter

* fix!: database prefix (#6)

* feat: Events (#7)

* feat: models in package

* feat: packaged controllers

* feat: seeders in package

* fix: removed test echo

* feat: lang + views

* feat: services + provides

* feat: package

* feat: finalizing package

* feat: last changes

* fix: remove surplus migrations

* feat: database seeders

* feat: add helpers

* fix: policy namespacing

* fix: class name

* fix: remove user provider

* feat: last configs

* feat: events

* feat: events namespace

* fix: namespace errors

* style: formatting

* fix: composer syntax error

---------

Co-authored-by: keeama13 <xander@schuurmannen.nl>
Co-authored-by: Rene <rene@notfound.nl>

* fix: forms

* feat: namespace changes (#9)

* feat: namespace changes

* feat: namespacing

* feat: working views

* fix: remove duplicate entries

* fix: remove SiteBoss namspace

* style: formatting

---------

Co-authored-by: René <github@registraties.notfound.nl>
Co-authored-by: Rene <rene@notfound.nl>

* fix: removed laravel assets from publish (#10)

* fix: class path name

* fix!: formbuilder problem quickfix

* style: formatting

* Fix/solr indexer (#13)

* fix: add timestamps to search table

* fix: replace all white spaces by single spaces

* fix: get page title

* style: formatting

---------

Co-authored-by: Thessa Kockelkorn <thessa@notfound.nl>
Co-authored-by: René <rene@notfound.nl>

* feat: add Siteboss Helper

* fix: helper class namespace

* fix: visible for CmsConfig

* feat: remove unused function (#15)

* feat: removed siteboss_path()

* feat: app config, routes, factory updated

* fix: factorytype

* style: formatting

* style: formatting

* feat: SOLR localization (#14)

* feat: forced localization of path

* fix: mv creation of content string to pageservice

* fix: get localized title

---------

Co-authored-by: Thessa Kockelkorn <thessa@notfound.nl>

* feat: searchable

* feat!: Form handler (#16)

* fix: clamav no socket

* feat: call FormHandler

* fix: re-add getSummaryHtml

* fix getSummaryHtml for files

* style: formatting

---------

Co-authored-by: René <rene@notfound.nl>

* feat: mail helper (#17)

* feat: send mail from helper

* style: formatting

* fix: send debug mails

---------

Co-authored-by: Rene <rene@notfound.nl>

---------

Co-authored-by: Rene <rene@notfound.nl>
Co-authored-by: Xander Schuurman <44030544+keeama13@users.noreply.github.com>
Co-authored-by: keeama13 <xander@schuurmannen.nl>
Co-authored-by: thessakockelkorn <70509512+thessakockelkorn@users.noreply.github.com>
Co-authored-by: Thessa Kockelkorn <thessa@notfound.nl>
  • Loading branch information
6 people authored Jun 12, 2023
1 parent 6c69173 commit 2b5d144
Show file tree
Hide file tree
Showing 21 changed files with 286 additions and 140 deletions.
79 changes: 10 additions & 69 deletions config/app.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php

use Illuminate\Support\Facades\Facade;
use Illuminate\Support\ServiceProvider;

return [

/*
Expand Down Expand Up @@ -134,45 +137,19 @@
|
*/

'providers' => [
NotFound\Framework\Providers\LocalizationServiceProvider::class,

/*
* Laravel Framework Service Providers...
*/
Illuminate\Auth\AuthServiceProvider::class,
// Illuminate\Broadcasting\BroadcastServiceProvider::class,
Illuminate\Bus\BusServiceProvider::class,
Illuminate\Cache\CacheServiceProvider::class,
Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
Illuminate\Cookie\CookieServiceProvider::class,
Illuminate\Database\DatabaseServiceProvider::class,
Illuminate\Encryption\EncryptionServiceProvider::class,
Illuminate\Filesystem\FilesystemServiceProvider::class,
Illuminate\Foundation\Providers\FoundationServiceProvider::class,
Illuminate\Hashing\HashServiceProvider::class,
Illuminate\Mail\MailServiceProvider::class,
Illuminate\Notifications\NotificationServiceProvider::class,
Illuminate\Pagination\PaginationServiceProvider::class,
// Illuminate\Pipeline\PipelineServiceProvider::class,
Illuminate\Queue\QueueServiceProvider::class,
// Illuminate\Redis\RedisServiceProvider::class,
Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
Illuminate\Session\SessionServiceProvider::class,
Illuminate\Translation\TranslationServiceProvider::class,
Illuminate\Validation\ValidationServiceProvider::class,
Illuminate\View\ViewServiceProvider::class,
'providers' => ServiceProvider::defaultProviders()->merge([

/*
* Application Service Providers...
*/
App\Providers\AuthServiceProvider::class,
NotFound\Framework\Providers\EventServiceProvider::class,
NotFound\Framework\Providers\RouteServiceProvider::class,
NotFound\Framework\Providers\AuthServiceProvider::class,
NotFound\Framework\Providers\LogServiceProvider::class,
NotFound\Framework\Providers\MigrationServiceProvider::class,
NotFound\Framework\Providers\LocalizationServiceProvider::class,

],
])->toArray(),

/*
|--------------------------------------------------------------------------
Expand All @@ -185,44 +162,8 @@
|
*/

'aliases' => [
'App' => Illuminate\Support\Facades\App::class,
'Arr' => Illuminate\Support\Arr::class,
'Artisan' => Illuminate\Support\Facades\Artisan::class,
'Auth' => Illuminate\Support\Facades\Auth::class,
'Blade' => Illuminate\Support\Facades\Blade::class,
'Broadcast' => Illuminate\Support\Facades\Broadcast::class,
'Bus' => Illuminate\Support\Facades\Bus::class,
'Cache' => Illuminate\Support\Facades\Cache::class,
'Config' => Illuminate\Support\Facades\Config::class,
'Cookie' => Illuminate\Support\Facades\Cookie::class,
'Crypt' => Illuminate\Support\Facades\Crypt::class,
'Date' => Illuminate\Support\Facades\Date::class,
'DB' => Illuminate\Support\Facades\DB::class,
'Eloquent' => Illuminate\Database\Eloquent\Model::class,
'Event' => Illuminate\Support\Facades\Event::class,
'File' => Illuminate\Support\Facades\File::class,
'Gate' => Illuminate\Support\Facades\Gate::class,
'Hash' => Illuminate\Support\Facades\Hash::class,
'Http' => Illuminate\Support\Facades\Http::class,
'Lang' => Illuminate\Support\Facades\Lang::class,
'Log' => Illuminate\Support\Facades\Log::class,
'Mail' => Illuminate\Support\Facades\Mail::class,
'Notification' => Illuminate\Support\Facades\Notification::class,
'Password' => Illuminate\Support\Facades\Password::class,
'Queue' => Illuminate\Support\Facades\Queue::class,
'RateLimiter' => Illuminate\Support\Facades\RateLimiter::class,
'Redirect' => Illuminate\Support\Facades\Redirect::class,
'Request' => Illuminate\Support\Facades\Request::class,
'Response' => Illuminate\Support\Facades\Response::class,
'Route' => Illuminate\Support\Facades\Route::class,
'Schema' => Illuminate\Support\Facades\Schema::class,
'Session' => Illuminate\Support\Facades\Session::class,
'Storage' => Illuminate\Support\Facades\Storage::class,
'Str' => Illuminate\Support\Str::class,
'URL' => Illuminate\Support\Facades\URL::class,
'Validator' => Illuminate\Support\Facades\Validator::class,
'View' => Illuminate\Support\Facades\View::class,
],
'aliases' => Facade::defaultAliases()->merge([
'Sb' => \NotFound\Framework\Helpers\SitebossHelper::class,
])->toArray(),

];
27 changes: 27 additions & 0 deletions database/migrations/2023_06_07_114849_update_search_table.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
//
Schema::table('cms_search', function (Blueprint $table) {
$table->timestamps();
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
//
}
};
3 changes: 1 addition & 2 deletions src/FrameworkServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public function boot(): void
Blade::componentNamespace('NotFound\\Framework\\View\\Components\\Forms\\Fields', 'fields');

$this->publishes([
__DIR__.'/../config/app.php' => config_path('app.php'),
__DIR__.'/../config/auth.php' => config_path('auth.php'),
__DIR__.'/../config/siteboss.php' => config_path('siteboss.php'),
__DIR__.'/../config/openid.php' => config_path('openid.php'),
Expand All @@ -31,8 +32,6 @@ public function boot(): void

public function register(): void
{
$this->mergeConfigFrom(__DIR__.'/../config/app.php', 'app');

app('router')->aliasMiddleware('set-forget-locale', \NotFound\Framework\Http\Middleware\SetAndForgetLocale::class);
app('router')->aliasMiddleware('role', \NotFound\Framework\Http\Middleware\EnsureUserHasRole::class);
}
Expand Down
79 changes: 79 additions & 0 deletions src/Helpers/SitebossHelper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?php

namespace NotFound\Framework\Helpers;

use NotFound\Framework\Models\CmsConfig;

class SitebossHelper
{
public static ?array $config = null;

/**
* config
*
* Returns a value from the cms_config table.
*
* @param mixed $code The internal code for the config value.
* @param mixed $failOnMissing Whether to throw an exception if the config value is missing.
* @return string|object|null The value of the config.
*/
public static function config(string $code, bool $failOnMissing = true): string|object|null
{
if (is_null(self::$config)) {
self::$config = CmsConfig::all()->keyBy('code')->toArray();
}

if (! isset(self::$config[$code])) {
if ($failOnMissing) {
throw new \Exception("Missing config code: {$code}");
}

return null;
}

if (self::$config[$code]['type'] === 2) {
return json_decode(self::$config[$code]['value'], true);
}

return self::$config[$code]['value'];
}

public static function mail(string $to_name, string $to_email, string $subject, $html, $data = false)
{
$sendgrid_api_key = self::config('sendgrid_api_key', true);
$sendgrid_sender_email = self::config('sendgrid_sender_email', true);
$sendgrid_sender_name = self::config('sendgrid_sender_name', true);

$email = new \SendGrid\Mail\Mail();
$email->setFrom($sendgrid_sender_email, $sendgrid_sender_name);
$email->setSubject($subject);

if (app()->hasDebugModeEnabled()) {
$email->addTo(\env('SB_ERROR_EMAIL', $to_email));
} else {
if (filter_var($to_email, FILTER_VALIDATE_EMAIL)) {
$email->addTo($to_email, $to_name);
} else {
return 400;
}
}

// if ($data != false) {
// // HTML is a Twig template with data
// if(!site::$page->twig)
// {
// site::$page->getTwig();
// }
// $html = site::$page->twig->render($html, $data);
// }
$email->addContent('text/html', $html);
$sendgrid = new \SendGrid($sendgrid_api_key);
try {
$response = $sendgrid->send($email);

return $response->statusCode();
} catch (\Exception $e) {
echo 'Caught exception: '.$e->getMessage()."\n";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ public function readOne(Template $table)
$form->addInput((new LayoutInputCheckbox('enabled', 'Active'))->setValue($table->enabled == 1 ?? false));
$form->addInput((new LayoutInputCheckbox('meta', 'Add meta fields'))->setValue($table->properties->meta ?? false));

$form->addInput((new LayoutInputCheckbox('searchable', 'Searchable via SOLR'))->setValue($table->properties->searchable ?? false));

$form->addButton(new LayoutButton('Update template properties'));
$widget1->addTitle((new LayoutTitle('Edit template'))->setSize(4));
$widget1->addForm($form);
Expand Down Expand Up @@ -176,14 +178,17 @@ public function update(FormDataRequest $request, Template $table)
'params' => 'string|nullable',
'allow_children' => 'string|nullable',
'enabled' => 'boolean',
'meta' => 'boolean',
'searchable' => 'boolean',
]);

$properties = (object) array_merge(
(array) $table->properties,
[
'disable_sticky_submit' => $request->disable_sticky_submit,
'stay_on_page' => $request->stay_on_page,
// 'stay_on_page' => $request->stay_on_page,
'meta' => $request->meta,
'searchable' => $request->searchable,
]
);

Expand Down
20 changes: 15 additions & 5 deletions src/Http/Controllers/Forms/DataController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace NotFound\Framework\Http\Controllers\Forms;

use Illuminate\Http\Request;
use NotFound\Framework\Helpers\SitebossHelper;
use NotFound\Framework\Http\Controllers\Controller;
use NotFound\Framework\Models\Forms\Data;
use NotFound\Framework\Models\Forms\Field;
Expand Down Expand Up @@ -125,12 +126,21 @@ public function deleteRow($formId, $recordId)

private function runSuccessAction($langurl, $formInfo, $formValidator)
{
//TODO: use laravel events?
if (trim($formInfo->success_action) != '') {
$action = trim($formInfo->success_action);
// Trigger default form handler
$action = SitebossHelper::config('form_success_action') ?? '';
if ($action && trim($action !== '')) {
$actionClass = new $action($langurl, $formInfo, $formValidator);
$actionClass->run();

$actionObj = new $action($langurl, $formInfo, $formValidator);
$actionObj->run();
} else {

//TODO: use Laravel events?
if (trim($formInfo->success_action) != '') {
$action = trim($formInfo->success_action);

$actionObj = new $action($langurl, $formInfo, $formValidator);
$actionObj->run();
}
}
}
}
13 changes: 0 additions & 13 deletions src/Http/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,6 @@
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Str;

if (! function_exists('siteboss_path')) {
/**
* Helper function to return the root of the siteboss folder
*
* @param $path adds string to the path
* @return string root path of the 'site' folder
*/
function siteboss_path(?string $path = null): string
{
return base_path().'/../site/'.$path;
}
}

if (! function_exists('set_database_prefix')) {
/**
* Converts [][] to the DB prefix set in the config
Expand Down
10 changes: 10 additions & 0 deletions src/Interfaces/FormHandlerInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace NotFound\Framework\Interfaces;

interface FormHandlerInterface
{
public function __construct(string $langUrl, $formInfo, $formValidator);

public function run(): bool;
}
2 changes: 2 additions & 0 deletions src/Models/CmsConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ class CmsConfig extends BaseModel
{
protected $table = 'cms_config';

protected $visible = ['type', 'value'];

public function hasJsonValue()
{
return $this->attributes['type'] === 2;
Expand Down
2 changes: 1 addition & 1 deletion src/Models/Indexes/SolrIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public function addOrUpdateItem(string $url, string $title, string $contents, st

$doc = [
'title' => $title,
'content' => html_entity_decode(strip_tags($contents)),
'content' => html_entity_decode(trim(preg_replace('/\s+/', ' ', strip_tags($contents)))),
'type' => $type,
'url' => $url,
'priority' => $priority,
Expand Down
14 changes: 14 additions & 0 deletions src/Models/Menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,4 +217,18 @@ public function getSlug(): string
{
return $this->url;
}

/**
* getLocalizedPath
*
* Get the relative URL from the root of the site with explicit localization
*
* @return void
*/
public function getLocalizedPath(): string
{
$res = explode('/', $this->url(), 4);

return app()->getLocale().'/'.$res[3];
}
}
5 changes: 4 additions & 1 deletion src/Providers/RouteServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

class RouteServiceProvider extends ServiceProvider
{
const HOME = '/';
const HOME = '/home';

/**
* The controller namespace for the application.
Expand Down Expand Up @@ -39,6 +39,9 @@ public function boot()
$pageRouter = new PageRouterService();
$pageRouter->create();
});

Route::middleware('web')
->group(base_path('routes/web.php'));
});
}

Expand Down
Loading

0 comments on commit 2b5d144

Please sign in to comment.