first commit
This commit is contained in:
commit
f21d70150c
|
@ -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.
|
|
@ -0,0 +1,22 @@
|
||||||
|
<?php
|
||||||
|
namespace PeertubeVideo;
|
||||||
|
|
||||||
|
use Omeka\Module\AbstractModule;
|
||||||
|
use Laminas\EventManager\SharedEventManagerInterface;
|
||||||
|
use Laminas\Mvc\MvcEvent;
|
||||||
|
|
||||||
|
class Module extends AbstractModule
|
||||||
|
{
|
||||||
|
const NAMESPACE = __NAMESPACE__;
|
||||||
|
|
||||||
|
const RATIOS = [
|
||||||
|
'2' => '2:1',
|
||||||
|
'1.333' => '4:3',
|
||||||
|
'1.777' => '16:9'
|
||||||
|
];
|
||||||
|
|
||||||
|
public function getConfig()
|
||||||
|
{
|
||||||
|
return include __DIR__ . '/config/module.config.php';
|
||||||
|
}
|
||||||
|
}
|
|
@ -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
|
|
@ -0,0 +1,7 @@
|
||||||
|
/* Panaorama viewer custom */
|
||||||
|
@media screen {
|
||||||
|
.peertube-video {
|
||||||
|
/* width: 600px; */
|
||||||
|
/* height: 400px; */
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?php
|
||||||
|
namespace PeertubeVideo;
|
||||||
|
|
||||||
|
return [
|
||||||
|
'view_manager' => [
|
||||||
|
'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;',
|
||||||
|
]
|
||||||
|
]
|
||||||
|
];
|
|
@ -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"
|
|
@ -0,0 +1,53 @@
|
||||||
|
<?php
|
||||||
|
namespace PeertubeVideo\Form;
|
||||||
|
|
||||||
|
use PeertubeVideo\Module;
|
||||||
|
use Laminas\Form\Element;
|
||||||
|
use Laminas\Form\Form;
|
||||||
|
|
||||||
|
class PeertubeVideoBlockForm extends Form
|
||||||
|
{
|
||||||
|
public function init()
|
||||||
|
{
|
||||||
|
|
||||||
|
$this->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,
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?php
|
||||||
|
namespace PeertubeVideo\Service\BlockLayout;
|
||||||
|
|
||||||
|
use Interop\Container\ContainerInterface;
|
||||||
|
use PeertubeVideo\Site\BlockLayout\PeertubeVideo;
|
||||||
|
use Laminas\ServiceManager\Factory\FactoryInterface;
|
||||||
|
|
||||||
|
class PeertubeVideoFactory implements FactoryInterface
|
||||||
|
{
|
||||||
|
public function __invoke(ContainerInterface $services, $requestedName, array $options = null)
|
||||||
|
{
|
||||||
|
return new PeertubeVideo(
|
||||||
|
$services->get('FormElementManager'),
|
||||||
|
$services->get('Config')['DefaultSettings']['PeertubeVideoBlockForm']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
|
@ -0,0 +1,93 @@
|
||||||
|
<?php
|
||||||
|
namespace PeertubeVideo\Site\BlockLayout;
|
||||||
|
|
||||||
|
use Omeka\Api\Representation\SiteRepresentation;
|
||||||
|
use Omeka\Api\Representation\SitePageRepresentation;
|
||||||
|
use Omeka\Api\Representation\SitePageBlockRepresentation;
|
||||||
|
use Omeka\Site\BlockLayout\AbstractBlockLayout;
|
||||||
|
use Laminas\View\Renderer\PhpRenderer;
|
||||||
|
|
||||||
|
use Laminas\Form\FormElementManager;
|
||||||
|
|
||||||
|
use PeertubeVideo\Form\PeertubeVideoBlockForm;
|
||||||
|
|
||||||
|
class PeertubeVideo extends AbstractBlockLayout
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var FormElementManager
|
||||||
|
*/
|
||||||
|
protected $formElementManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $defaultSettings = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param FormElementManager $formElementManager
|
||||||
|
* @param array $defaultSettings
|
||||||
|
*/
|
||||||
|
public function __construct(FormElementManager $formElementManager, array $defaultSettings)
|
||||||
|
{
|
||||||
|
$this->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 .= '<a href="#" class="collapse" aria-label="collapse"><h4>' . $view->translate('Options'). '</h4></a>';
|
||||||
|
$html .= '<div class="collapsible" style="padding-top:6px;">';
|
||||||
|
$html .= $view->formCollection($form);
|
||||||
|
$html .= '</div>';
|
||||||
|
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,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
<div class="3d-model-wrap" style="position:relative;">
|
||||||
|
|
||||||
|
<?php
|
||||||
|
$this->headLink()->appendStylesheet($this->assetUrl('css/peertube-video.css',
|
||||||
|
'PeertubeVideo'));
|
||||||
|
?>
|
||||||
|
<style>
|
||||||
|
#<?= $id ?> {
|
||||||
|
height: <?= $height ?>px;
|
||||||
|
width: <?= $width ?>px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<div class="3d-model-wrap">
|
||||||
|
|
||||||
|
<iframe
|
||||||
|
id="<?= $id ?>"
|
||||||
|
sandbox="allow-same-origin allow-scripts allow-popups"
|
||||||
|
src="<?= $url ?>"
|
||||||
|
frameborder="0"
|
||||||
|
allowfullscreen>
|
||||||
|
</iframe>
|
||||||
|
|
||||||
|
</div>
|
Loading…
Reference in New Issue