adds ingester using sketchfab api

This commit is contained in:
buttle 2021-06-22 11:14:12 +02:00
parent d9292e49a9
commit 421b71c9d8
5 changed files with 30 additions and 19 deletions

View File

@ -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 [Sketchfab] is a module for [Omeka S] that integrates Sketchfab
3D models. 3D models.
@ -7,7 +7,7 @@
``` ```
cd ./modules 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 unzip main.zip
mv archiveorg/ Sketchfab mv archiveorg/ Sketchfab
rm main.zip rm main.zip

View File

@ -1,12 +1,12 @@
[info] [info]
name = "Archive.org media viewer" name = "Sketchfab model viewer"
description = "Embed Archive.org media" description = "Embed Sketchfab models"
tags = "" tags = ""
license = "MIT" license = "MIT"
author = "Hangar.org" author = "Hangar.org"
author_link = "https://git.hangar.org/chris" author_link = "https://git.hangar.org/chris"
module_link = "https://git.hangar.org/arcHIVE-tech/Sketchfab" module_link = "https://git.hangar.org/arcHIVE-tech/Sketchfab-omeka-module"
support_link = "https://git.hangar.org/arcHIVE-tech/Sketchfab/issues" support_link = "https://git.hangar.org/arcHIVE-tech/Sketchfab-omeka-module/issues"
configurable = false configurable = false
version = "1.0.0" version = "1.0.0"
omeka_version_constraint = "^3.0.1" omeka_version_constraint = "^3.0.1"

View File

@ -18,7 +18,7 @@ class SketchfabMediaIngester implements IngesterInterface
} }
public function getLabel() public function getLabel()
{ {
return 'Archive.org media'; // @translate return 'Sketchfab model'; // @translate
} }
public function getRenderer() public function getRenderer()
{ {
@ -28,10 +28,11 @@ class SketchfabMediaIngester implements IngesterInterface
{ {
$input = new Text('o:media[__index__][o:identifier]'); $input = new Text('o:media[__index__][o:identifier]');
$input->setOptions([ $input->setOptions([
'label' => 'Indentifier', // @translate 'label' => 'URL of the model', // @translate
]); ]);
$input->setAttributes([ $input->setAttributes([
'required' => true, 'required' => true,
'placeholder' => 'https://sketchfab.com/3d-models/....',
]); ]);
return $view->formRow($input); return $view->formRow($input);
} }
@ -43,7 +44,18 @@ class SketchfabMediaIngester implements IngesterInterface
$errorStore->addError('o:identifier', 'No identifier specified'); $errorStore->addError('o:identifier', 'No identifier specified');
return; return;
} }
$url = 'https://archive.org/embed/' . $data['o:identifier']; $url = 'https://sketchfab.com/oembed/?url=' . $data['o:identifier'];
$media->setSource($url); $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));;
} }
} }

View File

@ -11,13 +11,12 @@ class SketchfabMediaRenderer implements RendererInterface
MediaRepresentation $media, MediaRepresentation $media,
array $options = []) array $options = [])
{ {
$url = $media->source(); return $media->mediaData()['html'];
$html = '<iframe '; }
$html .= 'src="' . $url . '" '; public function thumbnailUrl(PhpRenderer $view,
$html .= 'frameborder="0" webkitallowfullscreen="true" mozallowfullscreen="true" allowfullscreen>'; MediaRepresentation $media,
$html .= '</iframe>'; array $options = [])
return $html; {
return $media->mediaData()['thumbnail_url'];
//return $media->mediaData()['html'];
} }
} }

View File

@ -34,7 +34,7 @@ class Sketchfab extends AbstractBlockLayout
} }
public function getLabel() { public function getLabel() {
return 'Archive.org media'; return 'Sketchfab model';
} }
public function form(PhpRenderer $view, public function form(PhpRenderer $view,