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
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

View File

@ -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"

View File

@ -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));;
}
}

View File

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

View File

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