Added option to clear icon chache

This commit is contained in:
Julian Prieber 2022-11-28 20:20:43 +01:00
parent 40964d9197
commit bdb293c7a8
3 changed files with 21 additions and 1 deletions

View File

@ -402,6 +402,23 @@ class UserController extends Controller
return redirect('/studio/links');
}
//Delete icon
public function clearIcon(request $request)
{
$linkId = $request->id;
$directory = base_path("studio/favicon/icons");
$files = scandir($directory);
foreach($files as $file) {
if (strpos($file, $linkId.".") !== false) {
$pathinfo = pathinfo($file, PATHINFO_EXTENSION);}}
if (isset($pathinfo)) {
try{File::delete(base_path("studio/favicon/icons")."/".$linkId.".".$pathinfo);} catch (exception $e) {}
}
return redirect('/studio/links');
}
//Raise link on the littlelink page
public function upLink(request $request)
{

View File

@ -122,7 +122,9 @@
@endif
<a href="{{ route('deleteLink', $link->id ) }}" onclick="return confirm('Are you sure you want to delete `{{$link->title}}` ?')" class="float-right hvr-grow p-1 text-danger"><i class='bi bi-trash'></i></a>
<a href="{{ route('deleteLink', $link->id ) }}" title="Delete" onclick="return confirm('Are you sure you want to delete `{{$link->title}}` ?')" class="float-right hvr-grow p-1 text-danger"><i class='bi bi-trash'></i></a>
<a href="{{ route('clearIcon', $link->id ) }}" title="Clear icon cache" class="float-right hvr-grow p-1 text-primary"><i style="-webkit-text-stroke:1px;padding-right:5px;" class="bi bi-arrow-repeat"></i></a>

View File

@ -101,6 +101,7 @@ Route::get('/studio/links/all', [UserController::class, 'showLinksAll'])->name('
Route::get('/studio/theme', [UserController::class, 'showTheme'])->name('showTheme');
Route::post('/studio/theme', [UserController::class, 'editTheme'])->name('editTheme');
Route::get('/deleteLink/{id}', [UserController::class, 'deleteLink'])->name('deleteLink');
Route::get('/clearIcon/{id}', [UserController::class, 'clearIcon'])->name('clearIcon');
Route::get('/upLink/{up}/{id}', [UserController::class, 'upLink'])->name('upLink');
Route::post('/studio/edit-link/{id}', [UserController::class, 'editLink'])->name('editLink');
Route::get('/studio/button-editor/{id}', [UserController::class, 'showCSS'])->name('showCSS');