From f655e84081dcc47a19d090ca902f7ca85dc63832 Mon Sep 17 00:00:00 2001 From: buttle Date: Mon, 28 Jun 2021 12:07:44 +0200 Subject: [PATCH] first commit --- LICENSE | 21 +++++ Module.php | 23 +++++ README.md | 25 ++++++ asset/css/gallery.css | 52 +++++++++++ config/module.config.php | 28 ++++++ config/module.ini | 12 +++ src/Form/ImageGalleryBlockForm.php | 41 +++++++++ .../BlockLayout/ImageGalleryFactory.php | 18 ++++ src/Site/BlockLayout/ImageGallery.php | 89 +++++++++++++++++++ view/common/block-layout/imageGallery.phtml | 43 +++++++++ 10 files changed, 352 insertions(+) create mode 100644 LICENSE create mode 100644 Module.php create mode 100644 README.md create mode 100644 asset/css/gallery.css create mode 100644 config/module.config.php create mode 100644 config/module.ini create mode 100644 src/Form/ImageGalleryBlockForm.php create mode 100644 src/Service/BlockLayout/ImageGalleryFactory.php create mode 100644 src/Site/BlockLayout/ImageGallery.php create mode 100644 view/common/block-layout/imageGallery.phtml 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..aeece8f --- /dev/null +++ b/Module.php @@ -0,0 +1,23 @@ + '25 %', + '50' => '50 %', + '75' => '75 %', + '100' => '100 %', + ]; + + public function getConfig() + { + return include __DIR__ . '/config/module.config.php'; + } +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..a2c9adf --- /dev/null +++ b/README.md @@ -0,0 +1,25 @@ +# ImageGallery media for Omeka S + +[ImageGallery] is a module for [Omeka S] that optionally enables [wheelzoom], +a script for zooming IMG elements with the mousewheel/trackpad and [zoom], +a script to enlarge images on touch, click, or mouseover. + +## Install + +``` +cd ./modules +https://git.hangar.org/arcHIVE-tech/ImageGallery/archive/main.zip +unzip main.zip +mv imageviewer-omeka-module/ ImageGallery +rm main.zip +``` + +## LISENCE +The module is released under the [MIT] License. + +[arc-hive]: https://arc-hive.zone/ +[wheelzoom]: https://github.com/jackmoore/wheelzoom +[zoom]: https://github.com/jackmoore/zoom +[Omeka S]: https://omeka.org/s +[ImageGallery]: https://git.hangar.org/arcHIVE-tech/ImageGallery +[MIT]: http://opensource.org/licenses/MIT diff --git a/asset/css/gallery.css b/asset/css/gallery.css new file mode 100644 index 0000000..6ebbf41 --- /dev/null +++ b/asset/css/gallery.css @@ -0,0 +1,52 @@ +.archive-gallery * { + box-sizing: border-box; +} + +.archive-gallery .source-link { + display: flex; + margin: 0 auto; +} + +.archive-gallery img { + max-width: 100%; + vertical-align: top; +} + +.archive-gallery .gallery { + display: flex; + /*margin: 10px auto;*/ + margin: 0 auto; + max-width: 600px; + position: relative; + /*padding-top: 66.6666666667%;*/ +} +/* +.archive-gallery @media screen and (min-width: 600px) { + .gallery { + padding-top: 400px; + } +} +*/ +.archive-gallery .gallery__img { + position: absolute; + top: 0; + left: 0; + opacity: 0; + transition: opacity 0.3s ease-in-out; +} +.archive-gallery .gallery__thumb { + padding-top: 6px; + margin: 6px; + display: block; +} +.archive-gallery .gallery__selector { + position: absolute; + opacity: 0; + visibility: hidden; +} +.archive-gallery .gallery__selector:checked + .gallery__img { + opacity: 1; +} +.archive-gallery .gallery__selector:checked ~ .gallery__thumb > img { + box-shadow: 0 0 0 3px #0be2f6; +} diff --git a/config/module.config.php b/config/module.config.php new file mode 100644 index 0000000..871df5d --- /dev/null +++ b/config/module.config.php @@ -0,0 +1,28 @@ + [ + 'template_path_stack' => [ + dirname(__DIR__) . '/view', + ] + ], + 'block_layouts' => [ + 'factories' => [ + 'imageGallery' => Service\BlockLayout\ImageGalleryFactory::class, + ], + ], + 'form_elements' => [ + 'invokables' => [ + Form\ImageGalleryBlockForm::class => Form\ImageGalleryBlockForm::class, + ], + ], + 'DefaultSettings' => [ + 'ImageGalleryBlockForm' => [ + 'title' => '', + 'renderSourceLink' => true, + 'width' => 600, + '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..9511b75 --- /dev/null +++ b/config/module.ini @@ -0,0 +1,12 @@ +[info] +name = "Image gallery" +description = "A pure CSS image gallery" +tags = "" +license = "MIT" +author = "Hangar.org" +author_link = "https://git.hangar.org/chris" +module_link = "https://git.hangar.org/arcHIVE-tech/ImageGallery" +support_link = "https://git.hangar.org/arcHIVE-tech/ImageGallery/issues" +configurable = false +version = "1.0.0" +omeka_version_constraint = "^3.0.1" diff --git a/src/Form/ImageGalleryBlockForm.php b/src/Form/ImageGalleryBlockForm.php new file mode 100644 index 0000000..ee1fdbf --- /dev/null +++ b/src/Form/ImageGalleryBlockForm.php @@ -0,0 +1,41 @@ +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', + ] + ]); + } +} diff --git a/src/Service/BlockLayout/ImageGalleryFactory.php b/src/Service/BlockLayout/ImageGalleryFactory.php new file mode 100644 index 0000000..99d4bd0 --- /dev/null +++ b/src/Service/BlockLayout/ImageGalleryFactory.php @@ -0,0 +1,18 @@ +get('FormElementManager'), + $services->get('Config')['DefaultSettings']['ImageGalleryBlockForm'] + ); + } +} +?> \ No newline at end of file diff --git a/src/Site/BlockLayout/ImageGallery.php b/src/Site/BlockLayout/ImageGallery.php new file mode 100644 index 0000000..9d0ac82 --- /dev/null +++ b/src/Site/BlockLayout/ImageGallery.php @@ -0,0 +1,89 @@ +formElementManager = $formElementManager; + $this->defaultSettings = $defaultSettings; + } + + public function getLabel() { + return 'Image gallery'; + } + + public function form(PhpRenderer $view, + SiteRepresentation $site, + SitePageRepresentation $page = null, + SitePageBlockRepresentation $block = null + ) { + $form = $this->formElementManager->get(ImageGalleryBlockForm::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 .= '

'; + $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 ''; + } + + $thumbnails = []; + static $id = 0; + + $media = $attachments[0]->item()->media()[0]; + $item = $attachments[0]->item(); + return $view->partial('common/block-layout/imageGallery', [ + 'title' => $block->dataValue('title'), + 'item' => $item, + 'images' => $item->media(), + 'item_url' => $attachments[0]->item()->url(), + 'renderSourceLink' => $block->dataValue('renderSourceLink'), + 'width' => $block->dataValue('width'), + 'image' => $media->primaryMedia()->thumbnailUrl('large'), + 'gallery_id' => 'ig-' . ++$id, + ]); + } +} diff --git a/view/common/block-layout/imageGallery.phtml b/view/common/block-layout/imageGallery.phtml new file mode 100644 index 0000000..5923207 --- /dev/null +++ b/view/common/block-layout/imageGallery.phtml @@ -0,0 +1,43 @@ + +headLink()->appendStylesheet($this->assetUrl('css/gallery.css', 'ImageGallery')); +?> + + + + +