From 892bfaf3f5922c8dfc12dcb53719923667d67406 Mon Sep 17 00:00:00 2001 From: Rastislav Chynoransky Date: Mon, 30 Oct 2023 15:26:05 +0100 Subject: [PATCH] [harvest] record url attribute --- app/Authority.php | 6 ++---- app/Http/Controllers/ItemController.php | 2 +- app/Item.php | 4 ++-- app/SpiceHarvesterRecord.php | 11 +++++++++++ config/app.php | 2 -- resources/views/authorities/index.blade.php | 2 +- resources/views/items/index.blade.php | 2 +- 7 files changed, 18 insertions(+), 11 deletions(-) diff --git a/app/Authority.php b/app/Authority.php index 4771ebaa9..7f71b733f 100644 --- a/app/Authority.php +++ b/app/Authority.php @@ -240,11 +240,9 @@ public function getUrl() return self::detailUrl($this->id); } - public function getOaiUrl() + public function getOaiUrlAttribute(): ?string { - return Config::get('app.old_url') . - '/oai-pmh/authority?verb=GetRecord&metadataPrefix=ulan&identifier=' . - $this->id; + return $this->record?->url; } public static function detailUrl($authority_id) diff --git a/app/Http/Controllers/ItemController.php b/app/Http/Controllers/ItemController.php index 795a040a0..134a38fb1 100644 --- a/app/Http/Controllers/ItemController.php +++ b/app/Http/Controllers/ItemController.php @@ -45,7 +45,7 @@ public function __construct(ItemRepository $itemRepository) */ public function index() { - $items = Item::query(); + $items = Item::query()->with(['record.harvest']); $collection = null; if (Request::has('collection_id')) { diff --git a/app/Item.php b/app/Item.php index 60361409e..3f6e32479 100644 --- a/app/Item.php +++ b/app/Item.php @@ -236,9 +236,9 @@ public function getUrl($params = []) return $url; } - public function getOaiUrl() + public function getOaiUrlAttribute(): ?string { - return Config::get('app.old_url').'/oai-pmh/?verb=GetRecord&metadataPrefix=oai_dc&identifier='.$this->id; + return $this->record?->url; } /** diff --git a/app/SpiceHarvesterRecord.php b/app/SpiceHarvesterRecord.php index df0ee1213..dbdd13fc4 100644 --- a/app/SpiceHarvesterRecord.php +++ b/app/SpiceHarvesterRecord.php @@ -56,4 +56,15 @@ public function process(callable $onProcess, Progress $progress) } } } + + public function getUrlAttribute(): string + { + $query = http_build_query([ + 'identifier' => $this->identifier, + 'metadataPrefix' => $this->harvest->metadata_prefix, + 'verb' => 'GetRecord', + ]); + + return "{$this->harvest->base_url}?$query"; + } } diff --git a/config/app.php b/config/app.php index 990d63f29..20e6cc171 100644 --- a/config/app.php +++ b/config/app.php @@ -222,8 +222,6 @@ 'google_recaptcha_secret' => env('GOOGLE_RECAPTCHA_SECRET'), - 'old_url' => 'http://stary.webumenia.sk', - 'iip_private' => env('IIP_PRIVATE', 'http://127.0.0.1:8002'), 'iip_public' => env('IIP_PUBLIC', 'https://img.webumenia.sk'), ]; diff --git a/resources/views/authorities/index.blade.php b/resources/views/authorities/index.blade.php index 67ecefa8f..07638db00 100644 --- a/resources/views/authorities/index.blade.php +++ b/resources/views/authorities/index.blade.php @@ -59,7 +59,7 @@ {!! link_to_action('App\Http\Controllers\AuthorityController@edit', 'Upraviť', array($a->id), array('class' => 'btn btn-primary btn-xs btn-outline')) !!} Na webe - OAI záznam + @if($a->oai_url)OAI záznam@endif @endforeach diff --git a/resources/views/items/index.blade.php b/resources/views/items/index.blade.php index aa9f2b667..7b9b754ec 100644 --- a/resources/views/items/index.blade.php +++ b/resources/views/items/index.blade.php @@ -101,7 +101,7 @@ {!! link_to_action('App\Http\Controllers\ItemController@show', 'Detail', array($i->id), array('class' => 'btn btn-primary btn-detail btn-xs btn-outline', )) !!} {!! link_to_action('App\Http\Controllers\ItemController@edit', 'Upraviť', array($i->id), array('class' => 'btn btn-primary btn-xs btn-outline')) !!}
Na webe - OAI záznam + @if($i->oai_url)OAI záznam@endif @endforeach