diff --git a/README.md b/README.md index 32b532d..d653996 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Archive.org media for Omeka S +# Sketchfab models for Omeka S [Sketchfab] is a module for [Omeka S] that integrates Sketchfab 3D models. @@ -7,7 +7,7 @@ ``` cd ./modules -https://git.hangar.org/arcHIVE-tech/Sketchfab/archive/main.zip +https://git.hangar.org/arcHIVE-tech/Sketchfab-omeka-module.git unzip main.zip mv archiveorg/ Sketchfab rm main.zip diff --git a/config/module.ini b/config/module.ini index 79389c7..8572160 100644 --- a/config/module.ini +++ b/config/module.ini @@ -1,12 +1,12 @@ [info] -name = "Archive.org media viewer" -description = "Embed Archive.org media" +name = "Sketchfab model viewer" +description = "Embed Sketchfab models" tags = "" license = "MIT" author = "Hangar.org" author_link = "https://git.hangar.org/chris" -module_link = "https://git.hangar.org/arcHIVE-tech/Sketchfab" -support_link = "https://git.hangar.org/arcHIVE-tech/Sketchfab/issues" +module_link = "https://git.hangar.org/arcHIVE-tech/Sketchfab-omeka-module" +support_link = "https://git.hangar.org/arcHIVE-tech/Sketchfab-omeka-module/issues" configurable = false version = "1.0.0" omeka_version_constraint = "^3.0.1" diff --git a/src/Media/Ingester/SketchfabMediaIngester.php b/src/Media/Ingester/SketchfabMediaIngester.php index 3ab6be0..7ac0651 100644 --- a/src/Media/Ingester/SketchfabMediaIngester.php +++ b/src/Media/Ingester/SketchfabMediaIngester.php @@ -18,7 +18,7 @@ class SketchfabMediaIngester implements IngesterInterface } public function getLabel() { - return 'Archive.org media'; // @translate + return 'Sketchfab model'; // @translate } public function getRenderer() { @@ -28,10 +28,11 @@ class SketchfabMediaIngester implements IngesterInterface { $input = new Text('o:media[__index__][o:identifier]'); $input->setOptions([ - 'label' => 'Indentifier', // @translate + 'label' => 'URL of the model', // @translate ]); $input->setAttributes([ 'required' => true, + 'placeholder' => 'https://sketchfab.com/3d-models/....', ]); return $view->formRow($input); } @@ -43,7 +44,18 @@ class SketchfabMediaIngester implements IngesterInterface $errorStore->addError('o:identifier', 'No identifier specified'); return; } - $url = 'https://archive.org/embed/' . $data['o:identifier']; - $media->setSource($url); + $url = 'https://sketchfab.com/oembed/?url=' . $data['o:identifier']; + $response = $this->client->setUri($url)->send(); + if (!$response->isOk()) { + $errorStore->addError('o:source', sprintf( + 'Cannot find model URL: '.$data['o:identifier'], + $response->getReasonPhrase(), + $response->getStatusCode() + )); + return false; + } + // Set the Media source and data. + $media->setSource($data['o:source']); + $media->setData(json_decode($response->getBody(), true));; } } diff --git a/src/Media/Renderer/SketchfabMediaRenderer.php b/src/Media/Renderer/SketchfabMediaRenderer.php index a1378c4..1efd384 100644 --- a/src/Media/Renderer/SketchfabMediaRenderer.php +++ b/src/Media/Renderer/SketchfabMediaRenderer.php @@ -11,13 +11,12 @@ class SketchfabMediaRenderer implements RendererInterface MediaRepresentation $media, array $options = []) { - $url = $media->source(); - $html = '