Skip to content

Commit

Permalink
Allow previewing metadata (#13)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
JanOppolzer authored Dec 4, 2023
1 parent b987763 commit e99f87f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
21 changes: 21 additions & 0 deletions app/Http/Controllers/EntityPreviewMetadataController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace App\Http\Controllers;

use App\Models\Entity;

class EntityPreviewMetadataController extends Controller
{
public function __construct()
{
$this->middleware('auth');
}

public function show(Entity $entity)
{
$this->authorize('view', $entity);

return response($entity->metadata, 200)
->header('Content-Type', 'application/xml');
}
}
6 changes: 5 additions & 1 deletion resources/views/entities/show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,14 @@
<a class="hover:bg-blue-700 text-blue-50 inline-block px-4 py-2 bg-blue-600 rounded shadow"
href="{{ route('entities.showmetadata', $entity) }}"
target="_blank">{{ __('entities.show_metadata') }}</a>
@else
<a class="hover:bg-blue-700 text-blue-50 inline-block px-4 py-2 bg-blue-600 rounded shadow"
href="{{ route('entities.previewmetadata', $entity) }}"
target="_blank">{{ __('entities.show_metadata') }}</a>
@endif

@can('update', $entity)
@unless($entity->trashed())
@unless ($entity->trashed())
<a class="hover:bg-yellow-200 inline-block px-4 py-2 text-yellow-600 bg-yellow-300 rounded shadow"
href="{{ route('entities.edit', $entity) }}">{{ __('common.edit') }}</a>
@endunless
Expand Down
2 changes: 2 additions & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use App\Http\Controllers\EntityMetadataController;
use App\Http\Controllers\EntityOperatorController;
use App\Http\Controllers\EntityOrganizationController;
use App\Http\Controllers\EntityPreviewMetadataController;
use App\Http\Controllers\EntityRsController;
use App\Http\Controllers\FakeController;
use App\Http\Controllers\FederationController;
Expand Down Expand Up @@ -89,6 +90,7 @@

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

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

Expand Down

0 comments on commit e99f87f

Please sign in to comment.