Remove orchestra/asset, using our our blade now

This commit is contained in:
Deon George 2021-11-22 13:52:16 +11:00
parent dd64cba897
commit ca99748361
No known key found for this signature in database
GPG Key ID: 7670E8DC27415254
2 changed files with 80 additions and 3 deletions

View File

@ -11,8 +11,7 @@
],
"require": {
"igaster/laravel-theme": "^2.0.17",
"creativeorange/gravatar": "^1.0",
"orchestra/asset": "^6.0"
"creativeorange/gravatar": "^1.0"
},
"require-dev": {
},
@ -27,7 +26,8 @@
"extra": {
"laravel": {
"providers": [
"Leenooks\\Providers\\LeenooksServiceProvider"
"Leenooks\\Providers\\LeenooksServiceProvider",
"Leenooks\\Providers\\CustomBladeServiceProvider"
]
}
},

View File

@ -0,0 +1,77 @@
<?php
namespace Leenooks\Providers;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\ServiceProvider;
class CustomBladeServiceProvider extends ServiceProvider
{
/**
* Bootstrap services.
*
* @return void
*/
public function boot()
{
Blade::directive('css',function(string $expression,array $args=[]) {
$html = '';
switch (trim($expression,"'")) {
case 'datatables':
return
'<link type="text/css" rel="stylesheet" href="https://cdn.datatables.net/1.10.25/css/dataTables.bootstrap5.min.css" media="screen">'.
'<link type="text/css" rel="stylesheet" href="'.asset('plugin/dataTables/dataTables.bootstrap5.css').'" media="screen">';
case 'select2':
return
'<link type="text/css" rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/css/select2.min.css">';
case 'simplemde':
return
'<link type="text/css" rel="stylesheet" href="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.css">';
default:
throw new \Exception('Unknown CSS: '.$expression);
}
return $html;
});
Blade::directive('js',function($expression) {
$html = '';
switch (trim($expression,"'")) {
case 'datatables':
return
'<script type="text/javascript" src="https://cdn.datatables.net/1.10.25/js/jquery.dataTables.min.js"></script>'.
'<script type="text/javascript" src="'.asset('plugin/dataTables/dataTables.conditionalPaging.js').'"></script>'.
'<script type="text/javascript" src="https://cdn.datatables.net/rowgroup/1.1.2/js/dataTables.rowGroup.min.js"></script>'.
'<script type="text/javascript" src="https://cdn.datatables.net/1.10.25/js/dataTables.bootstrap5.min.js"></script>';
case 'highcharts':
return
'<script type="text/javascript" src="https://code.highcharts.com/highcharts.js"></script>'.
'<script type="text/javascript" src="https://code.highcharts.com/modules/data.js"></script>'.
'<script type="text/javascript" src="https://code.highcharts.com/modules/drilldown.js"></script>'.
'<script type="text/javascript" src="https://code.highcharts.com/modules/exporting.js"></script>'.
'<script type="text/javascript" src="https://code.highcharts.com/modules/export-data.js"></script>'.
'<script type="text/javascript" src="https://code.highcharts.com/themes/dark-unica.js"></script>';
case 'select2':
return
'<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/js/select2.min.js"></script>'.
'<script type="text/javascript" src="'.asset('plugin/select2/fix-autofocus.js').'"></script>';
case 'simplemde':
return
'<script type="text/javascript" src="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.js"></script>';
default:
throw new \Exception('Unknown JS: '.$expression);
}
return $html;
});
}
}