Skip to content

Commit e99f87f

Browse files
authored
Allow previewing metadata (#13)
Metadata download is taken from the Git repository, however, metadata pending approval isn't stored in the Git repository yet and thus must be taken from the database instead.
1 parent b987763 commit e99f87f

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
namespace App\Http\Controllers;
4+
5+
use App\Models\Entity;
6+
7+
class EntityPreviewMetadataController extends Controller
8+
{
9+
public function __construct()
10+
{
11+
$this->middleware('auth');
12+
}
13+
14+
public function show(Entity $entity)
15+
{
16+
$this->authorize('view', $entity);
17+
18+
return response($entity->metadata, 200)
19+
->header('Content-Type', 'application/xml');
20+
}
21+
}

resources/views/entities/show.blade.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,14 @@
149149
<a class="hover:bg-blue-700 text-blue-50 inline-block px-4 py-2 bg-blue-600 rounded shadow"
150150
href="{{ route('entities.showmetadata', $entity) }}"
151151
target="_blank">{{ __('entities.show_metadata') }}</a>
152+
@else
153+
<a class="hover:bg-blue-700 text-blue-50 inline-block px-4 py-2 bg-blue-600 rounded shadow"
154+
href="{{ route('entities.previewmetadata', $entity) }}"
155+
target="_blank">{{ __('entities.show_metadata') }}</a>
152156
@endif
153157

154158
@can('update', $entity)
155-
@unless($entity->trashed())
159+
@unless ($entity->trashed())
156160
<a class="hover:bg-yellow-200 inline-block px-4 py-2 text-yellow-600 bg-yellow-300 rounded shadow"
157161
href="{{ route('entities.edit', $entity) }}">{{ __('common.edit') }}</a>
158162
@endunless

routes/web.php

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use App\Http\Controllers\EntityMetadataController;
1111
use App\Http\Controllers\EntityOperatorController;
1212
use App\Http\Controllers\EntityOrganizationController;
13+
use App\Http\Controllers\EntityPreviewMetadataController;
1314
use App\Http\Controllers\EntityRsController;
1415
use App\Http\Controllers\FakeController;
1516
use App\Http\Controllers\FederationController;
@@ -89,6 +90,7 @@
8990

9091
Route::get('entities/{entity}/metadata', [EntityMetadataController::class, 'store'])->name('entities.metadata');
9192
Route::get('entities/{entity}/showmetadata', [EntityMetadataController::class, 'show'])->name('entities.showmetadata');
93+
Route::get('entities/{entity}/previewmetadata', [EntityPreviewMetadataController::class, 'show'])->name('entities.previewmetadata');
9294

9395
Route::post('entities/{entity}/organization', [EntityOrganizationController::class, 'update'])->name('entities.organization');
9496

0 commit comments

Comments
 (0)