first commit

This commit is contained in:
buttle 2021-04-17 19:13:22 +02:00
commit 6ee322316b
13 changed files with 417 additions and 0 deletions

21
LICENSE Normal file
View File

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

27
Module.php Normal file
View File

@ -0,0 +1,27 @@
<?php
namespace ArchiveOrg;
use Omeka\Module\AbstractModule;
use Laminas\EventManager\SharedEventManagerInterface;
use Laminas\Mvc\MvcEvent;
class Module extends AbstractModule
{
const NAMESPACE = __NAMESPACE__;
const MEDIA_TYPE = [
'video' => 'Video',
'audio' => 'Audio',
];
const RATIOS = [
'1.777' => '16:9',
'1.333' => '4:3',
'2' => '2:1',
];
public function getConfig()
{
return include __DIR__ . '/config/module.config.php';
}
}

21
README.md Normal file
View File

@ -0,0 +1,21 @@
# Archive.org media for Omeka S
[Archive.org media] is a module for [Omeka S] that integrates [Archive.org] media.
## Install
```
cd ./modules
https://git.hangar.org/arcHIVE-tech/ArchiveOrg/archive/main.zip
unzip main.zip
mv panoramaviewer/ ArchiveOrg
```
## LISENCE
The module is released under the [MIT] License.
[arc-hive]: https://arc-hive.zone/
[Archive Viewer]: https://git.hangar.org/arcHIVE-tech/ArchiveOrg
[Omeka S]: https://omeka.org/s
[MIT]: http://opensource.org/licenses/MIT

View File

@ -0,0 +1,7 @@
/* Panaorama viewer custom */
@media screen {
.panorama-viewer {
/* width: 600px; */
/* height: 400px; */
}
}

40
config/module.config.php Normal file
View File

@ -0,0 +1,40 @@
<?php
namespace ArchiveOrg;
return [
'view_manager' => [
'template_path_stack' => [
dirname(__DIR__) . '/view',
]
],
'block_layouts' => [
'factories' => [
'archiveOrg' => Service\BlockLayout\ArchiveOrgFactory::class,
],
],
'form_elements' => [
'invokables' => [
Form\ArchiveOrgBlockForm::class => Form\ArchiveOrgBlockForm::class,
],
],
'media_ingesters' => [
'factories' => [
'ArchiveOrg_media' => Service\Media\Ingester\ArchiveOrgMediaFactory::class,
],
],
'media_renderers' => [
'invokables' => [
'ArchiveOrg_media' => Media\Renderer\ArchiveOrgMediaRenderer::class,
],
],
'DefaultSettings' => [
'ArchiveOrgBlockForm' => [
'media_type' => 'video',
'title' => '',
'width' => 600,
'ratio' => '2',
'autoLoad' => false,
'wrapStyle' => 'overflow-y: hidden;display: flex;flex-direction: column;justify-content: center;',
]
]
];

12
config/module.ini Normal file
View File

@ -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/ArchiveOrg"
support_link = "https://git.hangar.org/arcHIVE-tech/ArchiveOrg/issues"
configurable = false
version = "1.0.0"
omeka_version_constraint = "^3.0.1"

View File

@ -0,0 +1,51 @@
<?php
namespace ArchiveOrg\Form;
use ArchiveOrg\Module;
use Laminas\Form\Element;
use Laminas\Form\Form;
class ArchiveOrgBlockForm extends Form
{
public function init()
{
$this->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' => 'Video width in pixels',
],
'attributes' => [
'min' => '100',
],
]);
$this->add([
'name' => 'o:block[__blockIndex__][o:data][ratio]',
'type' => Element\Select::class,
'options' => [
'label' => 'Video ratio',
'value_options' => Module::RATIOS,
],
]);
}
}

View File

@ -0,0 +1,49 @@
<?php
namespace ArchiveOrg\Media\Ingester;
use Omeka\Api\Request;
use Omeka\Entity\Media;
use Omeka\Media\Ingester\IngesterInterface;
use Omeka\Stdlib\ErrorStore;
use Zend\Form\Element\Text;
use Zend\Http\Client;
use Zend\View\Renderer\PhpRenderer;
class ArchiveOrgMediaIngester implements IngesterInterface
{
protected $client;
public function __construct($client)
{
$this->client = $client;
}
public function getLabel()
{
return 'Archive.org media'; // @translate
}
public function getRenderer()
{
return 'ArchiveOrg_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);
}
}

View File

@ -0,0 +1,23 @@
<?php
namespace ArchiveOrg\Media\Renderer;
use Omeka\Api\Representation\MediaRepresentation;
use Omeka\Media\Renderer\RendererInterface;
use Zend\View\Renderer\PhpRenderer;
class ArchiveOrgMediaRenderer implements RendererInterface
{
public function render(PhpRenderer $view,
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'];
}
}

View File

@ -0,0 +1,18 @@
<?php
namespace ArchiveOrg\Service\BlockLayout;
use Interop\Container\ContainerInterface;
use ArchiveOrg\Site\BlockLayout\ArchiveOrg;
use Laminas\ServiceManager\Factory\FactoryInterface;
class ArchiveOrgFactory implements FactoryInterface
{
public function __invoke(ContainerInterface $services, $requestedName, array $options = null)
{
return new ArchiveOrg(
$services->get('FormElementManager'),
$services->get('Config')['DefaultSettings']['ArchiveOrgBlockForm']
);
}
}
?>

View File

@ -0,0 +1,16 @@
<?php
namespace ArchiveOrg\Service\Media\Ingester;
use ArchiveOrg\Media\Ingester\ArchiveOrgMediaIngester;
use Zend\ServiceManager\Factory\FactoryInterface;
use Interop\Container\ContainerInterface;
class ArchiveOrgMediaFactory implements FactoryInterface
{
public function __invoke(ContainerInterface $services,
$requestedName,
array $options = null)
{
return new ArchiveOrgMediaIngester($services->get('Omeka\HttpClient'));
}
}

View File

@ -0,0 +1,89 @@
<?php
namespace ArchiveOrg\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 ArchiveOrg\Form\ArchiveOrgBlockForm;
class ArchiveOrg 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 'Archive.org media';
}
public function form(PhpRenderer $view,
SiteRepresentation $site,
SitePageRepresentation $page = null,
SitePageBlockRepresentation $block = null
) {
$form = $this->formElementManager->get(ArchiveOrgBlockForm::class);
$data = $block
? $block->data() + $this->defaultSettings
: $this->defaultSettings;
$form->setData([
'o:block[__blockIndex__][o:data][media_type]' => $data['media_type'],
'o:block[__blockIndex__][o:data][title]' => $data['title'],
'o:block[__blockIndex__][o:data][width]' => $data['width'],
'o:block[__blockIndex__][o:data][ratio]' => $data['ratio'],
]);
$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 '';
}
$thumbnails = [];
static $id = 0;
$media = $attachments[0]->item()->media()[0];
$width = $block->dataValue('width');
$height = $width / $block->dataValue('ratio');
return $view->partial('common/block-layout/archiveOrg', [
'media_type' => $block->dataValue('media_type'),
'title' => $block->dataValue('title'),
'width' => $width,
'height' => $height,
'url' => $media->source(),
'id' => 'achive_org-' . ++$id,
'thumbnails' => $thumbnails,
]);
}
}

View File

@ -0,0 +1,43 @@
<div class="pannemmul-wrap" style="position:relative;">
<?php
if ($title !== false && $title !== "") {
$title = sprintf('<p id="panorama-viewer-title">%s</p>', $title);
} else {
$title = false;
}
?>
<style>
#<?= $id ?> {
height: <?= $height ?>px;
width: <?= $width ?>px;
}
</style>
<div class="pannellum-wrap">
<?php if ($media_type == "video") { ?>
<iframe
id="<?= $id ?>"
src="<?= $url ?>"
frameborder="0"
webkitallowfullscreen="true"
mozallowfullscreen="true"
allowfullscreen >;
</iframe>
<?php } ?>
<?php if ($media_type == "audio") { ?>
<iframe
src="<?= $url ?>"
frameborder="0"
webkitallowfullscreen="true"
mozallowfullscreen="true"
allowfullscreen >;
</iframe>
<?php } ?>
</div>