reading metadata in shared link v0.1

This commit is contained in:
Peter Papp
2020-08-25 12:04:13 +02:00
parent 6f9f2f2d34
commit f3a2758bcc
4 changed files with 19 additions and 7 deletions

View File

@@ -123,9 +123,13 @@ class AppFunctionsController extends Controller
->where('unique_id', $shared->item_id) ->where('unique_id', $shared->item_id)
->first(); ->first();
if ($file->thumbnail) {
$file->setPublicUrl($token);
}
$metadata = [ $metadata = [
'is_protected' => $shared->protected, 'is_protected' => $shared->protected,
'url' => url('/shared', ['token' => $token]), 'url' => $file->thumbnail ? $file->thumbnail : null,
'user' => $user->name, 'user' => $user->name,
'name' => $file->name, 'name' => $file->name,
'size' => $file->filesize, 'size' => $file->filesize,
@@ -133,6 +137,8 @@ class AppFunctionsController extends Controller
]; ];
} }
return $metadata;
// Handle single file // Handle single file
if ($shared->type === 'folder') { if ($shared->type === 'folder') {

View File

@@ -52,4 +52,8 @@ return [
'col_amount' => 'Amount', 'col_amount' => 'Amount',
'total' => 'Total', 'total' => 'Total',
// OG Page
'user_sending' => '',
'protected_file' => '',
]; ];

View File

@@ -23,6 +23,7 @@
@if(! $metadata['is_protected']) @if(! $metadata['is_protected'])
@if($metadata['thumbnail']) @if($metadata['thumbnail'])
<meta property="og:type" content="image" />
<meta property="og:image" content="{{ $metadata['thumbnail'] }}"> <meta property="og:image" content="{{ $metadata['thumbnail'] }}">
@endif @endif

View File

@@ -11,10 +11,6 @@
| |
*/ */
// Get og site for web crawlers
if( Crawler::isCrawler()) {
Route::get('/shared/{token}', 'AppFunctionsController@og_site');
}
// Stripe WebHook // Stripe WebHook
Route::post('/stripe/webhook', 'WebhookController@handleWebhook'); Route::post('/stripe/webhook', 'WebhookController@handleWebhook');
@@ -40,6 +36,11 @@ Route::group(['middleware' => ['auth:api', 'auth.master', 'scope:master']], func
Route::get('/invoice/{customer}/{token}', 'Admin\InvoiceController@show'); Route::get('/invoice/{customer}/{token}', 'Admin\InvoiceController@show');
}); });
// Pages // Get og site for web crawlers
Route::get('/shared/{token}', 'Sharing\FileSharingController@index'); if( Crawler::isCrawler()) {
Route::get('/shared/{token}', 'AppFunctionsController@og_site');
} else {
Route::get('/shared/{token}', 'Sharing\FileSharingController@index');
}
Route::get('/{any?}', 'AppFunctionsController@index')->where('any', '.*'); Route::get('/{any?}', 'AppFunctionsController@index')->where('any', '.*');