Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
b68c2e0
Route model binding
snipe May 11, 2025
c1c5814
Route model binding, gather payload
snipe May 11, 2025
c5ecc8f
Use uploads presenter
snipe May 11, 2025
9cf23d1
Removed logging
snipe May 13, 2025
2671e81
Added validation error handler
snipe May 13, 2025
b814164
Nicer error messages on failure for bulk files
snipe May 13, 2025
b5dc39e
Removed update_at
snipe May 13, 2025
b65cb96
Added catch for validation exception specifically
snipe May 13, 2025
4058312
Fixed tests
snipe May 14, 2025
0009142
Added route comments
snipe May 15, 2025
dbd864b
Added a search to the listing
snipe May 15, 2025
a182c43
Added icon to presenter
snipe May 15, 2025
1413ba0
Pass uploads list route
snipe May 15, 2025
5e1ee05
Fixed test
snipe May 15, 2025
35b47cd
Added method to check file extension
snipe May 15, 2025
676f941
Added fields to transformer
snipe May 15, 2025
bd635ce
Updated blades
snipe May 19, 2025
32f7eae
New uploads controller
snipe May 19, 2025
732e125
Removed repeated routes
snipe May 19, 2025
6cc10b9
Added two helper methods on action log model
snipe May 19, 2025
3e26acd
Added loggable to user model
snipe May 19, 2025
f9372df
Use new action log methods for file path and url
snipe May 19, 2025
966745e
Added download column to presenter
snipe May 19, 2025
3456c99
Changed route name
snipe May 19, 2025
7183cec
Allow gifs as inlineable
snipe May 19, 2025
7ef83de
Fixed routes
snipe May 20, 2025
e3e164f
Added additional object types
snipe May 20, 2025
851cb29
Set note to null if blank
snipe May 20, 2025
0bacbe1
Fixed path name
snipe May 20, 2025
702f1d0
Consolidated file type display
snipe May 20, 2025
f77ed72
Added method formatters
snipe May 20, 2025
73ffa3d
Comments for routes
snipe May 20, 2025
d862da2
Updated tests
snipe May 20, 2025
0a4d6e3
Added trailing slashes, standardized translation strings
snipe May 20, 2025
1e4d452
Added file upload translations
snipe May 20, 2025
9be02c6
Added use statement
snipe May 20, 2025
53f9768
Removed asset files controller
snipe May 20, 2025
a9a6a80
Switched order in API
snipe May 20, 2025
e38ea12
Switched order
snipe May 20, 2025
cc01f15
Updated translation
snipe May 22, 2025
83565b2
Removed weird conditional
snipe May 22, 2025
d50bcd6
Change spaces to dashes in filename
snipe May 22, 2025
35cbd58
Fixed route name
snipe May 22, 2025
16f3169
Passed object to transformer
snipe May 22, 2025
03efa06
Added custom view
snipe May 22, 2025
f930899
Added generic file delete translation
snipe May 22, 2025
82723a3
Added custom view library
snipe May 22, 2025
98eaa9e
Updated webpack for new custom view library
snipe May 22, 2025
27c3131
Fixed multiple upload for users GUI controller
snipe May 22, 2025
94e6e5e
Removed debugging
snipe May 22, 2025
b0451fc
Removed debugging
snipe May 22, 2025
5c5405d
Nicer custom view
snipe May 22, 2025
f3bfbc8
Nicer formatting for gallery view
snipe Jun 3, 2025
fa07f21
Commiting this so I don’t lose the history, but will open a smaller PR
snipe Jun 27, 2025
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
20 changes: 16 additions & 4 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,12 @@ public function report(Throwable $exception)
public function render($request, Throwable $e)
{


// CSRF token mismatch error
if ($e instanceof \Illuminate\Session\TokenMismatchException) {
return redirect()->back()->with('error', trans('general.token_expired'));
}

// Invalid JSON exception
// TODO: don't understand why we have to do this when we have the invalidJson() method, below, but, well, whatever
if ($e instanceof JsonException) {
return response()->json(Helper::formatStandardApiResponse('error', null, 'Invalid JSON'), 422);
}
Expand All @@ -88,8 +86,9 @@ public function render($request, Throwable $e)
return redirect()->back()->withInput()->with('error', trans('validation.date', ['attribute' => 'date']));
}


// Handle API requests that fail
if ($request->ajax() || $request->wantsJson()) {
if ($request->ajax() || $request->wantsJson() || ($request->route() && $request->route()->named('api.files.*'))) {

// Handle API requests that fail because Carbon cannot parse the date on validation (when a submitted date value is definitely not a date)
if ($e instanceof InvalidFormatException) {
Expand All @@ -102,6 +101,7 @@ public function render($request, Throwable $e)
return response()->json(Helper::formatStandardApiResponse('error', null, $className . ' not found'), 200);
}


// Handle API requests that fail because of an HTTP status code and return a useful error message
if ($this->isHttpException($e)) {

Expand All @@ -116,12 +116,24 @@ public function render($request, Throwable $e)
return response()->json(Helper::formatStandardApiResponse('error', null, 'Method not allowed'), 405);
default:
return response()->json(Helper::formatStandardApiResponse('error', null, $statusCode), $statusCode);

}
}

// This handles API validation exceptions that happen at the Form Request level, so they
// never even get to the controller where we normally nicely format JSON responses
if ($e instanceof ValidationException) {
$response = $this->invalidJson($request, $e);
return response()->json(Helper::formatStandardApiResponse('error', null, $e->errors()), 200);
}

// return response()->json(Helper::formatStandardApiResponse('error', null, 'Undefined exception'), 200);



}



// This is traaaaash but it handles models that are not found while using route model binding :(
// The only alternative is to set that at *each* route, which is crazypants
if ($e instanceof \Illuminate\Database\Eloquent\ModelNotFoundException) {
Expand Down
14 changes: 13 additions & 1 deletion app/Helpers/StorageHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,29 @@ public static function allowSafeInline($file_with_path) {
'avif',
'webp',
'png',
'gif',
];


// The file exists and is allowed to be displayed inline
if (Storage::exists($file_with_path) && (in_array(pathinfo($file_with_path, PATHINFO_EXTENSION), $allowed_inline))) {
return true;
}

return false;

}

public static function getFiletype($file_with_path) {

// The file exists and is allowed to be displayed inline
if (Storage::exists($file_with_path)) {
return pathinfo($file_with_path, PATHINFO_EXTENSION);
}

return null;

}

/**
* Decide whether to show the file inline or download it.
*/
Expand Down
200 changes: 0 additions & 200 deletions app/Http/Controllers/Api/AssetFilesController.php

This file was deleted.

Loading