commit f21d70150ce667896b87f808687d4388a8a0a24e Author: buttle Date: Fri Apr 9 11:31:13 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..d41bb9f --- /dev/null +++ b/Module.php @@ -0,0 +1,22 @@ + '2:1', + '1.333' => '4:3', + '1.777' => '16:9' + ]; + + public function getConfig() + { + return include __DIR__ . '/config/module.config.php'; + } +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..b1a48b3 --- /dev/null +++ b/README.md @@ -0,0 +1,22 @@ +# Video embed for Omeka S + +[PeerTube video] is a module for [Omeka S] that embeds [Peertube] videos. + + +## Install + +``` +cd ./modules +https://git.hangar.org/arcHIVE-tech/PeertubeVideo/archive/main.zip +unzip main.zip +mv 3d-renderer/ PeertubeVideo +``` + +## LISENCE +The module is released under the [MIT] License. + +[arc-hive]: https://arc-hive.zone/ +[PeerTube video]: https://git.hangar.org/arcHIVE-tech/PeertubeVideo +[Peertube]: https://en.wikipedia.org/wiki/PeerTube +[Omeka S]: https://omeka.org/s +[MIT]: http://opensource.org/licenses/MIT diff --git a/asset/css/peertube-video.css b/asset/css/peertube-video.css new file mode 100644 index 0000000..f860055 --- /dev/null +++ b/asset/css/peertube-video.css @@ -0,0 +1,7 @@ +/* Panaorama viewer custom */ +@media screen { + .peertube-video { + /* width: 600px; */ + /* height: 400px; */ + } +} diff --git a/config/module.config.php b/config/module.config.php new file mode 100644 index 0000000..275e6fe --- /dev/null +++ b/config/module.config.php @@ -0,0 +1,30 @@ + [ + 'template_path_stack' => [ + dirname(__DIR__) . '/view', + ] + ], + 'block_layouts' => [ + 'factories' => [ + 'peertubeVideo' => Service\BlockLayout\PeertubeVideoFactory::class, + ], + ], + 'form_elements' => [ + 'invokables' => [ + Form\PeertubeVideoBlockForm::class => Form\PeertubeVideoBlockForm::class, + ], + ], + 'DefaultSettings' => [ + 'PeertubeVideoBlockForm' => [ + 'url' => '', + 'title' => '', + 'width' => 600, + 'ratio' => '16:9', + 'vertical' => 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..9a1a767 --- /dev/null +++ b/config/module.ini @@ -0,0 +1,12 @@ +[info] +name = "Peertube video" +description = "Embeds a Peertube video" +tags = "" +license = "MIT" +author = "Hangar.org" +author_link = "https://git.hangar.org/chris" +module_link = "https://git.hangar.org/arcHIVE-tech/PeertubeVideo" +support_link = "https://git.hangar.org/arcHIVE-tech/PeertubeVideo/issues" +configurable = false +version = "1.0.0" +omeka_version_constraint = "^3.0.1" diff --git a/src/Form/PeertubeVideoBlockForm.php b/src/Form/PeertubeVideoBlockForm.php new file mode 100644 index 0000000..80e46bd --- /dev/null +++ b/src/Form/PeertubeVideoBlockForm.php @@ -0,0 +1,53 @@ +add([ + 'name' => 'o:block[__blockIndex__][o:data][url]', + 'type' => Element\Text::class, + 'options' => [ + 'label' => 'Video URL', + ] + ]); + + $this->add([ + 'name' => 'o:block[__blockIndex__][o:data][ratio]', + 'type' => Element\Select::class, + 'options' => [ + 'label' => 'Ratio', + 'value_options' => MODULE::RATIOS, + ], + ]); + + $this->add([ + 'name' => 'o:block[__blockIndex__][o:data][width]', + 'type' => Element\Number::class, + 'options' => [ + 'label' => 'Width in pixels', + ], + 'attributes' => [ + 'min' => '100', + ], + ]); + + $this->add([ + 'type' => Element\Checkbox::class, + 'name' => 'o:block[__blockIndex__][o:data][vertical]', + 'options' => [ + 'label' => 'Flip vertically', + //'use_hidden_element' => true, + 'checked_value' => true, + 'unchecked_value' => false, + ], + ]); + + } +} diff --git a/src/Service/BlockLayout/PeertubeVideoFactory.php b/src/Service/BlockLayout/PeertubeVideoFactory.php new file mode 100644 index 0000000..c3206c0 --- /dev/null +++ b/src/Service/BlockLayout/PeertubeVideoFactory.php @@ -0,0 +1,18 @@ +get('FormElementManager'), + $services->get('Config')['DefaultSettings']['PeertubeVideoBlockForm'] + ); + } +} +?> \ No newline at end of file diff --git a/src/Site/BlockLayout/PeertubeVideo.php b/src/Site/BlockLayout/PeertubeVideo.php new file mode 100644 index 0000000..cc5f79d --- /dev/null +++ b/src/Site/BlockLayout/PeertubeVideo.php @@ -0,0 +1,93 @@ +formElementManager = $formElementManager; + $this->defaultSettings = $defaultSettings; + } + + public function getLabel() { + return 'PeerTube video'; + } + + public function form(PhpRenderer $view, + SiteRepresentation $site, + SitePageRepresentation $page = null, + SitePageBlockRepresentation $block = null + ) { + $form = $this->formElementManager->get(PeertubeVideoBlockForm::class); + $data = $block + ? $block->data() + $this->defaultSettings + : $this->defaultSettings; + $form->setData([ + 'o:block[__blockIndex__][o:data][url]' => $data['url'], + 'o:block[__blockIndex__][o:data][ratio]' => $data['ratio'], + 'o:block[__blockIndex__][o:data][width]' => $data['width'], + 'o:block[__blockIndex__][o:data][vertical]' => $data['vertical'], + ]); + $form->prepare(); + + $html = ''; + //$html .= $view->blockAttachmentsForm($block); + $html .= '

' . $view->translate('Options'). '

'; + $html .= '
'; + $html .= $view->formCollection($form); + $html .= '
'; + return $html; + } + + public function render(PhpRenderer $view, SitePageBlockRepresentation $block) + { + $attachments = $block->attachments(); + if ($attachments) { + return ''; + } + static $id = 0; + $width = $block->dataValue('width'); + if ($block->dataValue('vertical') == false) { + $height = $width / $block->dataValue('ratio'); + } else { + $height = $width * $block->dataValue('ratio'); + } + $url = $block->dataValue('url'); + $url = str_replace('watch', 'embed', $url); + if (parse_url($url, PHP_URL_QUERY)) { + $url .= '&peertubeLink=0'; + } else { + $url .= '?peertubeLink=0'; + } + return $view->partial('common/block-layout/peertube-video', [ + 'url' => $url, + 'width' => $width, + 'height' => $height, + 'id' => 'pt-v-' . ++$id, + ]); + } +} diff --git a/view/common/block-layout/peertube-video.phtml b/view/common/block-layout/peertube-video.phtml new file mode 100644 index 0000000..f1ec09a --- /dev/null +++ b/view/common/block-layout/peertube-video.phtml @@ -0,0 +1,24 @@ +
+ +headLink()->appendStylesheet($this->assetUrl('css/peertube-video.css', + 'PeertubeVideo')); +?> + + +
+ + + +