initial commit

This commit is contained in:
buttle 2021-05-24 22:18:43 +02:00
commit 34dc2e3869
11 changed files with 270 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
composer.lock
vendor/*

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.

16
Module.php Normal file
View File

@ -0,0 +1,16 @@
<?php
namespace TechDocument;
use Omeka\Module\AbstractModule;
use Laminas\EventManager\SharedEventManagerInterface;
use Laminas\Mvc\MvcEvent;
class Module extends AbstractModule
{
const NAMESPACE = __NAMESPACE__;
public function getConfig()
{
return include __DIR__ . '/config/module.config.php';
}
}

28
README.md Normal file
View File

@ -0,0 +1,28 @@
# A Simple Text for Omeka S
[Simple Text] is a module for [Omeka S] that integrates a simple text block
that does some markdown rendering.
## Install
```
cd ./modules
https://git.hangar.org/arcHIVE-tech/TechDocument/archive/main.zip
unzip main.zip
mv techdocument/ TechDocument
cd TechDocument
composer install
chmod -R a+w vendor/mpdf/mpdf/tmp
```
## LISENCE
The module is released under the [MIT] License.
[arc-hive]: https://arc-hive.zone/
[Simple Text]: https://git.hangar.org/arcHIVE-tech/TechDocument
[Pannellum]: https://pannellum.org/
[Omeka S]: https://omeka.org/s
[MIT]: http://opensource.org/licenses/MIT

12
composer.json Normal file
View File

@ -0,0 +1,12 @@
{
"require": {
"erusev/parsedown": "dev-master",
"mpdf/mpdf": "8.0.11"
},
"autoload-dev": {
"psr-4": {
"Parsedown\\": "vendor/erusev/parsedown/Parsedown",
"MPDF\\": "vendor/mpdf/src/Mpdf"
}
}
}

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

@ -0,0 +1,47 @@
<?php
namespace TechDocument;
return [
'view_manager' => [
'template_path_stack' => [
dirname(__DIR__) . '/view',
]
],
'block_layouts' => [
'factories' => [
'techDocument' => Service\BlockLayout\TechDocumentFactory::class,
],
],
'form_elements' => [
'invokables' => [
Form\TechDocumentBlockForm::class => Form\TechDocumentBlockForm::class,
],
],
'DefaultSettings' => [
'TechDocumentBlockForm' => [
'wrapStyle' => 'overflow-y: hidden;display: flex;flex-direction: column;justify-content: center;',
//'imgStyle' => '',
'ui_background' => 'rgba(0,0,0,0.1)',
'characteristics' => 'Title:
Author: (artist, collective, scientist...)
Date:
Summary:
Extended description:
Keywords:
Size:
Dimension Length:
Dimension Breadth:
Dimension Height:
Weight:
Volume structure: (flat or 3D)
Volume state: (flexible or rigid)
Raw Material(s): (Materials or substances used in the primary production or manufacturing of the item)
Glossiness: (The property of being smooth and shiny. burnish, polish, gloss)
Color: (the property possessed by an object of producing different sensations on the eye as a result of the way it reflects or emits light.)
Transport: (movable or fixed)
Status: (stable, unstable, living, dead(fixed or decaying), inert)
Lifespan:
Life cycle:',
]
]
];

12
config/module.ini Normal file
View File

@ -0,0 +1,12 @@
[info]
name = "Achive technical document"
description = "Generates a PDF that describes a project"
tags = ""
license = "MIT"
author = "Hangar.org"
author_link = "https://git.hangar.org/chris"
module_link = "https://git.hangar.org/arcHIVE-tech/TechDocument"
support_link = "https://git.hangar.org/arcHIVE-tech/TechDocument/issues"
configurable = false
version = "1.0.0"
omeka_version_constraint = "^3.0.1"

View File

@ -0,0 +1,26 @@
<?php
namespace TechDocument\Form;
use TechDocument\Module;
use Laminas\Form\Element;
use Laminas\Form\Form;
class TechDocumentBlockForm extends Form
{
public function init()
{
$this->add([
'name' => 'o:block[__blockIndex__][o:data][characteristics]',
'type' => Element\Textarea::class,
'options' => [
'label' => 'Characteristics',
'info' => 'https://www.markdownguide.org/cheat-sheet',
],
'attributes' => [
'rows' => '10',
],
]);
}
}

View File

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

View File

@ -0,0 +1,85 @@
<?php
namespace TechDocument\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 TechDocument\Form\TechDocumentBlockForm;
//require_once(dirname(__DIR__, 3) . '/vendor/erusev/parsedown/Parsedown.php');
//require_once(dirname(__DIR__, 3) . '/vendor/mpdf/mpdf/src/Mpdf.php');
require_once(dirname(__DIR__, 3) . '/vendor/autoload.php');
use Parsedown;
//use Module\vendor\parsedown\Parsedown;
//use Module\vendor\mpdf\Mpdf;
class TechDocument 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 'Techical document';
}
public function form(PhpRenderer $view,
SiteRepresentation $site,
SitePageRepresentation $page = null,
SitePageBlockRepresentation $block = null
) {
$form = $this->formElementManager->get(TechDocumentBlockForm::class);
$data = $block
? $block->data() + $this->defaultSettings
: $this->defaultSettings;
$form->setData([
'o:block[__blockIndex__][o:data][characteristics]' => $data['characteristics'],
]);
$form->prepare();
$html = '';
$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)
{
$parsedown = new Parsedown();
$text = "# Arc-hive technical documentation\n";
$text .= "## characteristics\n";
$text .= $block->dataValue('characteristics');
$html = $parsedown->text($text);
$mpdf = new \Mpdf\Mpdf();
$mpdf = $mpdf->WriteHTML($html);
$mpdf->Output();
return $html;
}
}

3
vendor/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
!.gitignore
vendor/mpdf