first commit

This commit is contained in:
buttle 2021-09-07 11:01:22 +02:00
commit b77a5565d8
12 changed files with 498 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.

23
Module.php Normal file
View File

@ -0,0 +1,23 @@
<?php
namespace SmartGallery;
use Omeka\Module\AbstractModule;
use Laminas\EventManager\SharedEventManagerInterface;
use Laminas\Mvc\MvcEvent;
class Module extends AbstractModule
{
const NAMESPACE = __NAMESPACE__;
const IMAGE_WIDTH = [
'25' => '25 %',
'50' => '50 %',
'75' => '75 %',
'100' => '100 %',
];
public function getConfig()
{
return include __DIR__ . '/config/module.config.php';
}
}

23
README.md Normal file
View File

@ -0,0 +1,23 @@
# SmartGallery for Omeka S
[SmartGallery] is a module for [Omeka S] that displays image media.
It uses https://github.com/appleple/SmartPhoto
## Install
```
cd ./modules
wget https://git.hangar.org/arcHIVE-tech/SmartGallery-omeka-module/archive/main.zip
unzip main.zip
mv imagegallery-omeka-module/ SmartGallery
rm main.zip
```
## LISENCE
The module is released under the [MIT] License.
[arc-hive]: https://arc-hive.zone/
[Omeka S]: https://omeka.org/s
[SmartGallery]: https://git.hangar.org/arcHIVE-tech/SmartGallery-omeka-module
[MIT]: http://opensource.org/licenses/MIT

1
asset/css/smartphoto.min.css vendored Normal file

File diff suppressed because one or more lines are too long

88
asset/css/style.css Normal file
View File

@ -0,0 +1,88 @@
wrapper{
max-width: 100%;
margin: 0 auto;
}
.masonry {
-moz-transition: all .5s ease-in-out;
-webkit-transition: all .5s ease-in-out;
transition: all .5s ease-in-out;
-moz-column-gap: 30px;
-webkit-column-gap: 30px;
column-gap: 30px;
-moz-column-fill: initial;
-webkit-column-fill: initial;
column-fill: initial;
}
.masonry .brick {
margin-bottom: 30px;
overflow: hidden;
}
.masonry .brick img {
-moz-transition: all .5s ease-in-out;
-webkit-transition: all .5s ease-in-out;
transition: all .5s ease-in-out;
}
.masonry .brick:hover img {
opacity: .75;
}
.masonry.bordered {
-moz-column-rule: 1px solid #eee;
-webkit-column-rule: 1px solid #eee;
column-rule: 1px solid #eee;
-moz-column-gap: 50px;
-webkit-column-gap: 50px;
column-gap: 50px;
}
.masonry.bordered .brick {
padding-bottom: 25px;
margin-bottom: 25px;
border-bottom: 1px solid #eee;
}
.masonry.gutterless {
-moz-column-gap: 0;
-webkit-column-gap: 0;
column-gap: 0;
}
.masonry.gutterless .brick {
margin-bottom: 0;
}
.span {
-moz-column-span: all;
-webkit-column-span: all;
column-span: all;
*margin: 30px 0;
}
@media only screen and (min-width: 1024px) {
.desc {
font-size: 1.25em;
}
.intro {
letter-spacing: 1px;
}
.wrapper {
width: 80%;
padding: 2em;
}
.masonry {
-moz-column-count: 3;
-webkit-column-count: 3;
column-count: 3;
}
}
@media only screen and (min-width: 768px) and (max-width: 1023px) {
.wrapper {
width: 85%;
padding: 1.5em;
}
.masonry {
-moz-column-count: 2;
-webkit-column-count: 2;
column-count: 2;
}
}

56
asset/js/jquery-smartphoto.min.js vendored Normal file

File diff suppressed because one or more lines are too long

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

@ -0,0 +1,28 @@
<?php
namespace SmartGallery;
return [
'view_manager' => [
'template_path_stack' => [
dirname(__DIR__) . '/view',
]
],
'block_layouts' => [
'factories' => [
'smartGallery' => Service\BlockLayout\SmartGalleryFactory::class,
],
],
'form_elements' => [
'invokables' => [
Form\SmartGalleryBlockForm::class => Form\SmartGalleryBlockForm::class,
],
],
'DefaultSettings' => [
'SmartGalleryBlockForm' => [
'title' => '',
'renderSourceLink' => true,
'width' => 600,
'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 = "Smart gallery"
description = "An image gallery for Omeka build with SmartPhoto"
tags = ""
license = "MIT"
author = "Hangar.org"
author_link = "https://git.hangar.org/chris"
module_link = "https://git.hangar.org/arcHIVE-tech/SmartGallery"
support_link = "https://git.hangar.org/arcHIVE-tech/SmartGallery/issues"
configurable = false
version = "1.0.0"
omeka_version_constraint = "^3.0.1"

View File

@ -0,0 +1,41 @@
<?php
namespace SmartGallery\Form;
use SmartGallery\Module;
use Laminas\Form\Element;
use Laminas\Form\Form;
class SmartGalleryBlockForm extends Form
{
public function init()
{
$this->add([
'name' => 'o:block[__blockIndex__][o:data][width]',
'type' => Element\Select::class,
'options' => [
'label' => 'Width',
'value_options' => Module::IMAGE_WIDTH,
],
]);
$this->add([
'type' => Element\Checkbox::class,
'name' => 'o:block[__blockIndex__][o:data][renderSourceLink]',
'options' => [
'label' => 'Display a link to the item',
//'use_hidden_element' => true,
'checked_value' => true,
'unchecked_value' => false,
],
]);
$this->add([
'name' => 'o:block[__blockIndex__][o:data][title]',
'type' => Element\Text::class,
'options' => [
'label' => 'Sub-title',
]
]);
}
}

View File

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

View File

@ -0,0 +1,119 @@
<?php
namespace SmartGallery\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 SmartGallery\Form\SmartGalleryBlockForm;
class SmartGallery 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 'Smart gallery';
}
public function form(PhpRenderer $view,
SiteRepresentation $site,
SitePageRepresentation $page = null,
SitePageBlockRepresentation $block = null
) {
$form = $this->formElementManager->get(SmartGalleryBlockForm::class);
$data = $block
? $block->data() + $this->defaultSettings
: $this->defaultSettings;
$form->setData([
'o:block[__blockIndex__][o:data][title]' => $data['title'],
'o:block[__blockIndex__][o:data][width]' => $data['width'],
'o:block[__blockIndex__][o:data][renderSourceLink]' => $data['renderSourceLink'],
]);
$form->prepare();
$html = '';
$html .= $view->blockAttachmentsForm($block);
$html .= '<a href="#" class="collapse" aria-label="collapse"><h4>';
$html .= $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 $gallery_id = 0;
$images = [];
/*
$media = $attachments[0]->item()->media()[0];
$item = $attachments[0]->item();
$item_url = null;
if ($block->dataValue('renderSourceLink')) {
$item_url = $attachments[0]->item()->url();
}
*/
foreach ($attachments as $attachment)
{
$img_id = 0;
foreach($attachment->item()->media() as $media)
{
$mediaType = $media->mediaType();
$mediaRenderer = $media->renderer();
if ((strpos($mediaType, 'image/') !== false) || (strpos($mediaRenderer, 'youtube') !== false)) {
array_push($images, ["media_url" => $media->originalUrl(),
"item_url" => $attachment->item()->url(),
"image_title" => $media->title(),
"img_id" => 'gi_' . $gallery_id . '_' . $img_id,
]);
$img_id = $img_id +1;
}
}
}
$max_width = $block->dataValue('width');
return $view->partial('common/block-layout/smartGallery', [
'gallery_id' => 'ig_' . ++$gallery_id,
'title' => $block->dataValue('title'),
//'item' => $item,
'images' => $images,
//'images' => $item->media(),
//'item_url' => $item_url,
'renderSourceLink' => $block->dataValue('renderSourceLink'),
'width' => $block->dataValue('width'),
'max_width' => $max_width,
]);
}
}

View File

@ -0,0 +1,68 @@
<?php
$this->headLink()->appendStylesheet($this->assetUrl('css/smartphoto.min.css',
'SmartGallery'));
$this->headLink()->appendStylesheet($this->assetUrl('css/style.css',
'SmartGallery'));
?>
<?php $image_id = 0; ?>
<div class="archive-item-block smart-gallery">
<?php if ($renderSourceLink) { ?>
<div class="source-link">
<a href="<?= $item_url ?>">Source</a>
</div>
<?php } ?>
<div class="wrapper">
<div class="masonry">
<?php foreach ($images as $image) { ?>
<?php $image_id = $image_id +1;
$img_id = $gallery_id . '-' . $image_id;
?>
<div class="brick">
<a href="<?= $image['media_url'] ?>"
class="<?= $gallery_id ?>"
data-caption="<?= $image['image_title'] ?>"
data-id="<?= $img_id ?>">
<img src="<?= $image['media_url'] ?>"
alt=""
item_url="<?= $image['item_url'] ?>"
width="250"
/>
</a>
</div>
<?php } ?>
</div>
</div>
<?php if ($title) { ?>
<div class="item_title">
<?= $title ?>
</div>
<?php } ?>
</div>
<?php
echo $this->inlineScript()
->prependFile($this->assetUrl('js/jquery-smartphoto.min.js?v=1"',
'SmartGallery'));
?>
<script>
jQuery(document).ready(function() {
$(function(){
$(".<?= $gallery_id ?>").SmartPhoto({
resizeStyle: 'fit',
});
});
});
function updateSourceURL(thumbnail){
$(thumbnail).closest(".archive-gallery")
.find('.source-link')
.find('a').prop('href', $(thumbnail).attr('item_url'));
}
</script>