Updates to extension installation

Extension logo's get imported correctly now, as well as extension buttons in the /admin/extensions page. Routes and view controllers get added automatically as well.
This commit is contained in:
purple 2023-03-26 17:24:30 +02:00
parent 468fade5e0
commit 0f95d98c37
5 changed files with 18 additions and 11 deletions

View file

@ -81,25 +81,34 @@ if [[ $2 == "-i" ]]; then
cp -R .blueprint/defaults/extensions/admin.default .blueprint/defaults/extensions/admin.default.bak 2> /dev/null;
cp -R .blueprint/defaults/extensions/controller.default .blueprint/defaults/extensions/controller.default.bak 2> /dev/null;
cp -R .blueprint/defaults/extensions/route.default .blueprint/defaults/extensions/route.default.bak 2> /dev/null;
cp -R .blueprint/defaults/extensions/button.default .blueprint/defaults/extensions/button.default.bak 2> /dev/null;
mkdir public/assets/extensions/$identifier;
cp .blueprint/tmp/$3/icon.jpg public/assets/extensions/$identifier/icon.jpg;
ICON="public/assets/extensions/$identifier/icon.jpg";
ICON="/assets/extensions/$identifier/icon.jpg";
CONTENT=$(cat .blueprint/tmp/$3/admin/index.blade.php);
sed -i "s!␀title␀!$name!g" .blueprint/defaults/extensions/admin.default.bak > /dev/null;
sed -i "s!␀name␀!$name!g" .blueprint/defaults/extensions/admin.default.bak > /dev/null;
sed -i "s!␀breadcrumb␀!$name!g" .blueprint/defaults/extensions/admin.default.bak > /dev/null;
sed -i "s?␀name␀?$name?g" .blueprint/defaults/extensions/button.default.bak > /dev/null;
sed -i "s!␀description␀!$description!g" .blueprint/defaults/extensions/admin.default.bak > /dev/null;
sed -i "s!␀version␀!$version!g" .blueprint/defaults/extensions/admin.default.bak > /dev/null;
sed -i "s?␀version␀?$version?g" .blueprint/defaults/extensions/button.default.bak > /dev/null;
sed -i "s!␀icon␀!$ICON!g" .blueprint/defaults/extensions/admin.default.bak > /dev/null;
sed -i "s!␀content␀!$CONTENT!g" .blueprint/defaults/extensions/admin.default.bak > /dev/null;
sed -i "s!␀id␀!$identifier!g" .blueprint/defaults/extensions/controller.default.bak > /dev/null;
sed -i "s!␀id␀!$identifier!g" .blueprint/defaults/extensions/route.default.bak > /dev/null;
sed -i "s?␀id␀?$identifier?g" .blueprint/defaults/extensions/button.default.bak > /dev/null;
ADMINVIEW_RESULT=$(cat .blueprint/defaults/extensions/admin.default.bak);
ADMINROUTE_RESULT=$(cat .blueprint/defaults/extensions/route.default.bak);
ADMINBUTTON_RESULT=$(cat .blueprint/defaults/extensions/button.default.bak);
ADMINCONTROLLER_RESULT=$(cat .blueprint/defaults/extensions/controller.default.bak);
ADMINCONTROLLER_NAME=$identifier"ExtensionController.php";
@ -111,11 +120,14 @@ if [[ $2 == "-i" ]]; then
touch app/Http/Controllers/Admin/Extensions/$identifier/$ADMINCONTROLLER_NAME;
echo $ADMINCONTROLLER_RESULT > app/Http/Controllers/Admin/Extensions/$identifier/$ADMINCONTROLLER_NAME;
sed -i "s!/*␀**␀*/!$ADMINROUTE_RESULT!g" routes/admin.php > /dev/null;
echo $ADMINROUTE_RESULT >> routes/admin.php;
sed -i "s?<!--␀replace␀-->?$ADMINBUTTON_RESULT\n<!--␀replace␀-->?g" resources/views/admin/extensions.blade.php > /dev/null;
rm .blueprint/defaults/extensions/admin.default.bak;
rm .blueprint/defaults/extensions/controller.default.bak;
rm .blueprint/defaults/extensions/route.default.bak;
rm .blueprint/defaults/extensions/button.default.bak;
rm -R .blueprint/tmp/$3;
fi;

View file

@ -0,0 +1 @@
<div class="col-xs-6 col-sm-3 text-center"><a href="{{ route('admin.extensions.␀id␀.index') }}"><button class="btn btn-gray" style="width:100%;margin-bottom:17px;"><img src="/assets/extensions/␀id␀/icon.jpg" alt="logo" class="img-btn"> ␀name␀ <small>␀version␀</small></button></a></div>

View file

@ -30,9 +30,4 @@ tag[blue] {background-color:#288afb;}
height:25px;
border-radius:3px;
margin-right:2px;
};
.btn-row {
width:100%;
margin-bottom:25px;
};

View file

@ -14,7 +14,7 @@
@section('content')
<div class="col-xs-6 col-sm-3 text-center">
<a href="{{ route('admin.extensions.blueprint.index') }}"><button class="btn btn-gray btn-row" style="width:100%;"><img src="/assets/extensions/blueprint/logo.jpg" alt="logo" class="img-btn"> Blueprint <small>{{ $bp->version() }}</small></button></a>
<a href="{{ route('admin.extensions.blueprint.index') }}"><button class="btn btn-gray" style="width:100%;margin-bottom:17px;"><img src="/assets/extensions/blueprint/logo.jpg" alt="logo" class="img-btn"> Blueprint <small>{{ $bp->version() }}</small></button></a>
</div>
<!-- blueprint.replace -->
<!--␀replace␀-->
@endsection

View file

@ -241,5 +241,4 @@ Route::group(['prefix' => 'extensions'], function () {
Route::group(['prefix' => 'extensions/blueprint'], function () {
Route::get('/', [Admin\Extensions\Blueprint\BlueprintExtensionController::class, 'index'])->name('admin.extensions.blueprint.index');
Route::patch('/', [Admin\Extensions\Blueprint\BlueprintExtensionController::class, 'update']);
});
/*␀**␀*/
});