Skip to content

Commit

Permalink
[harvest] record url attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
rastislav-chynoransky committed Oct 30, 2023
1 parent 203664c commit 892bfaf
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 11 deletions.
6 changes: 2 additions & 4 deletions app/Authority.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/ItemController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')) {
Expand Down
4 changes: 2 additions & 2 deletions app/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
11 changes: 11 additions & 0 deletions app/SpiceHarvesterRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
}
2 changes: 0 additions & 2 deletions config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
];
2 changes: 1 addition & 1 deletion resources/views/authorities/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
<td class="action">
{!! link_to_action('App\Http\Controllers\AuthorityController@edit', 'Upraviť', array($a->id), array('class' => 'btn btn-primary btn-xs btn-outline')) !!}
<a href="{!! $a->getUrl() !!}" class="btn btn-success btn-xs btn-outline" target="_blank">Na webe</a>
<a href="{!! $a->getOaiUrl() !!}" class="btn btn-warning btn-xs btn-outline" target="_blank">OAI záznam</a>
@if($a->oai_url)<a href="{{ $a->oai_url }}" class="btn btn-warning btn-xs btn-outline" target="_blank">OAI záznam</a>@endif
</td>
</tr>
@endforeach
Expand Down
2 changes: 1 addition & 1 deletion resources/views/items/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
<td class="action">
{!! link_to_action('App\Http\Controllers\ItemController@show', 'Detail', array($i->id), array('class' => 'btn btn-primary btn-detail btn-xs btn-outline', )) !!}&nbsp;{!! link_to_action('App\Http\Controllers\ItemController@edit', 'Upraviť', array($i->id), array('class' => 'btn btn-primary btn-xs btn-outline')) !!} <br>
<a href="{!! $i->getUrl() !!}" class="btn btn-success btn-xs btn-outline" target="_blank">Na webe</a>
<a href="{!! $i->getOaiUrl() !!}" class="btn btn-warning btn-xs btn-outline" target="_blank">OAI záznam</a>
@if($i->oai_url)<a href="{{ $i->oai_url }}" class="btn btn-warning btn-xs btn-outline" target="_blank">OAI záznam</a>@endif
</td>
</tr>
@endforeach
Expand Down

0 comments on commit 892bfaf

Please sign in to comment.