Skip to content

Commit

Permalink
[FEATURE] Support for musical sources, multi-level metadata and exper…
Browse files Browse the repository at this point in the history
…imental annotations (kitodo#1281)

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: Christopher <[email protected]>
Co-authored-by: Frank Schirlitz <[email protected]>
Co-authored-by: haogatyp <[email protected]>
Co-authored-by: Matthias Richter <[email protected]>
Co-authored-by: Hizkiel Alemayehu <[email protected]>
Co-authored-by: Daniel Röwenstrunk <[email protected]>
Co-authored-by: Hizkiel Alemayehu <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Beatrycze Volk <[email protected]>
Co-authored-by: frank-ulrich-weber <[email protected]>
  • Loading branch information
11 people authored Jul 20, 2024
1 parent 729110e commit d7d6ce6
Show file tree
Hide file tree
Showing 66 changed files with 82,206 additions and 572 deletions.
3 changes: 3 additions & 0 deletions .github/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ query-filters:
- note

paths-ignore:
- Resources/Public/JavaScript/Gridstack
- Resources/Public/JavaScript/jPlayer
- Resources/Public/JavaScript/jQuery
- Resources/Public/JavaScript/jQueryUI
- Resources/Public/JavaScript/OpenLayers
- Resources/Public/JavaScript/Toastify
- Resources/Public/JavaScript/Verovio
- Resources/Public/JavaScript/WildWebMidi
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*.bak
/.buildpath
/.cache
/.idea/
Expand All @@ -16,3 +17,4 @@
/public/
/var/
/vendor/
.DS_Store
78 changes: 78 additions & 0 deletions Classes/Common/AnnotationRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?php

namespace Kitodo\Dlf\Common;

/**
* (c) Kitodo. Key to digital objects e.V. <[email protected]>
*
* This file is part of the Kitodo and TYPO3 projects.
*
* @license GNU General Public License version 3 or later.
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*/

class AnnotationRequest
{
/**
* @var string
*/
protected $apiUrl = '';

/**
* @param string $apiUrl The url of the annotation server api.
*/
public function __construct($apiUrl)
{
$this->apiUrl = trim($apiUrl, "/ ");
}


/**
* Requests the annotation server
*
* @param string $url The annotation request url.
* @return array
*/
protected function requestAnnotions($url) : array
{
$jsonld = Helper::getUrl($url);

if ($jsonld) {
$annotationData = json_decode($jsonld, true);

if ($annotationData) {
return $annotationData;
}
}

return [];
}

/**
* Returns all annotations of a document.
*
* @param string $id Document id (purl)
* @return array
*/
public function getAll($id)
{
$annotations = [];

$annotationData = $this->requestAnnotions($this->apiUrl . '?target=' . urlencode($id . '/*'));

if (array_key_exists('first', $annotationData)) {
$annotationPageData = $annotationData['first'];
$annotations = array_merge($annotations, $annotationPageData["items"]);

while (array_key_exists('next', $annotationPageData)) {
$annotationPageData = $this->requestAnnotions($annotationPageData['next']);
if (array_key_exists('items', $annotationPageData)) {
$annotations = array_merge($annotations, $annotationPageData["items"]);
}
}
}

return $annotations;
}
}
Loading

0 comments on commit d7d6ce6

Please sign in to comment.