commit d9292e49a91114518506f13b5371461d815b2f93 Author: buttle Date: Tue Jun 22 10:19:26 2021 +0200 First commit diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..9bd6b00 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018 Neo-Inspiration + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Module.php b/Module.php new file mode 100644 index 0000000..f1c99fc --- /dev/null +++ b/Module.php @@ -0,0 +1,28 @@ + 'Video', + 'audio' => 'Audio', + 'image' => 'Image', + ]; + + const RATIOS = [ + '1.777' => '16:9', + '1.333' => '4:3', + '2' => '2:1', + ]; + + public function getConfig() + { + return include __DIR__ . '/config/module.config.php'; + } +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..32b532d --- /dev/null +++ b/README.md @@ -0,0 +1,29 @@ +# Archive.org media for Omeka S + +[Sketchfab] is a module for [Omeka S] that integrates Sketchfab +3D models. + +## Install + +``` +cd ./modules +https://git.hangar.org/arcHIVE-tech/Sketchfab/archive/main.zip +unzip main.zip +mv archiveorg/ Sketchfab +rm main.zip +``` + +## LISENCE +The module is released under the [MIT] License. + + +[arc-hive]: https://arc-hive.zone/ +[Archive.org media ]: https://git.hangar.org/arcHIVE-tech/Sketchfab +[Omeka S]: https://omeka.org/s +[Archive.org]: https://archive.org +[MIT]: http://opensource.org/licenses/MIT + + +## Notes + +https://sketchfab.com/developers/oembed diff --git a/asset/css/archiveOrg.css b/asset/css/archiveOrg.css new file mode 100644 index 0000000..59c4481 --- /dev/null +++ b/asset/css/archiveOrg.css @@ -0,0 +1,7 @@ +/* Panaorama viewer custom */ +@media screen { + .archive_org { + /* width: 600px; */ + /* height: 400px; */ + } +} diff --git a/config/module.config.php b/config/module.config.php new file mode 100644 index 0000000..0ff93e9 --- /dev/null +++ b/config/module.config.php @@ -0,0 +1,40 @@ + [ + 'template_path_stack' => [ + dirname(__DIR__) . '/view', + ] + ], + 'block_layouts' => [ + 'factories' => [ + 'sketchfab' => Service\BlockLayout\SketchfabFactory::class, + ], + ], + 'form_elements' => [ + 'invokables' => [ + Form\SketchfabBlockForm::class => Form\SketchfabBlockForm::class, + ], + ], + 'media_ingesters' => [ + 'factories' => [ + 'Sketchfab_media' => Service\Media\Ingester\SketchfabMediaFactory::class, + ], + ], + 'media_renderers' => [ + 'invokables' => [ + 'Sketchfab_media' => Media\Renderer\SketchfabMediaRenderer::class, + ], + ], + 'DefaultSettings' => [ + 'SketchfabBlockForm' => [ + 'media_type' => 'video', + 'title' => '', + 'width' => 600, + 'ratio' => '2', + 'autoLoad' => false, + 'wrapStyle' => 'overflow-y: hidden;display: flex;flex-direction: column;justify-content: center;', + ] + ] +]; diff --git a/config/module.ini b/config/module.ini new file mode 100644 index 0000000..79389c7 --- /dev/null +++ b/config/module.ini @@ -0,0 +1,12 @@ +[info] +name = "Archive.org media viewer" +description = "Embed Archive.org media" +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" +configurable = false +version = "1.0.0" +omeka_version_constraint = "^3.0.1" diff --git a/src/Form/SketchfabBlockForm.php b/src/Form/SketchfabBlockForm.php new file mode 100644 index 0000000..0124e0a --- /dev/null +++ b/src/Form/SketchfabBlockForm.php @@ -0,0 +1,51 @@ +add([ + 'name' => 'o:block[__blockIndex__][o:data][title]', + 'type' => Element\Text::class, + 'options' => [ + 'label' => 'Title (option)', + ] + ]); + + $this->add([ + 'name' => 'o:block[__blockIndex__][o:data][media_type]', + 'type' => Element\Select::class, + 'options' => [ + 'label' => 'Media type', + 'value_options' => Module::MEDIA_TYPE, + ], + ]); + + $this->add([ + 'name' => 'o:block[__blockIndex__][o:data][width]', + 'type' => Element\Number::class, + 'options' => [ + 'label' => 'Width in pixels', + ], + 'attributes' => [ + 'min' => '100', + ], + ]); + + $this->add([ + 'name' => 'o:block[__blockIndex__][o:data][ratio]', + 'type' => Element\Select::class, + 'options' => [ + 'label' => 'Ratio', + 'value_options' => Module::RATIOS, + ], + ]); + + } +} diff --git a/src/Media/Ingester/SketchfabMediaIngester.php b/src/Media/Ingester/SketchfabMediaIngester.php new file mode 100644 index 0000000..3ab6be0 --- /dev/null +++ b/src/Media/Ingester/SketchfabMediaIngester.php @@ -0,0 +1,49 @@ +client = $client; + } + public function getLabel() + { + return 'Archive.org media'; // @translate + } + public function getRenderer() + { + return 'Sketchfab_media'; + } + public function form(PhpRenderer $view, array $options = []) + { + $input = new Text('o:media[__index__][o:identifier]'); + $input->setOptions([ + 'label' => 'Indentifier', // @translate + ]); + $input->setAttributes([ + 'required' => true, + ]); + return $view->formRow($input); + } + public function ingest(Media $media, Request $request, ErrorStore $errorStore) + { + // Validate the request data. + $data = $request->getContent(); + if (!isset($data['o:identifier'])) { + $errorStore->addError('o:identifier', 'No identifier specified'); + return; + } + $url = 'https://archive.org/embed/' . $data['o:identifier']; + $media->setSource($url); + } +} diff --git a/src/Media/Renderer/SketchfabMediaRenderer.php b/src/Media/Renderer/SketchfabMediaRenderer.php new file mode 100644 index 0000000..a1378c4 --- /dev/null +++ b/src/Media/Renderer/SketchfabMediaRenderer.php @@ -0,0 +1,23 @@ +source(); + $html = ' + +