From 34dc2e386991bf0a84578fc19ac178a07c725999 Mon Sep 17 00:00:00 2001 From: buttle Date: Mon, 24 May 2021 22:18:43 +0200 Subject: [PATCH] initial commit --- .gitignore | 2 + LICENSE | 21 +++++ Module.php | 16 ++++ README.md | 28 ++++++ composer.json | 12 +++ config/module.config.php | 47 ++++++++++ config/module.ini | 12 +++ src/Form/TechDocumentBlockForm.php | 26 ++++++ .../BlockLayout/TechDocumentFactory.php | 18 ++++ src/Site/BlockLayout/TechDocument.php | 85 +++++++++++++++++++ vendor/.gitignore | 3 + 11 files changed, 270 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 Module.php create mode 100644 README.md create mode 100644 composer.json create mode 100644 config/module.config.php create mode 100644 config/module.ini create mode 100644 src/Form/TechDocumentBlockForm.php create mode 100644 src/Service/BlockLayout/TechDocumentFactory.php create mode 100644 src/Site/BlockLayout/TechDocument.php create mode 100644 vendor/.gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5708e16 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +composer.lock +vendor/* 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..46fa763 --- /dev/null +++ b/Module.php @@ -0,0 +1,16 @@ + [ + '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:', + ] + ] +]; diff --git a/config/module.ini b/config/module.ini new file mode 100644 index 0000000..82ff214 --- /dev/null +++ b/config/module.ini @@ -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" diff --git a/src/Form/TechDocumentBlockForm.php b/src/Form/TechDocumentBlockForm.php new file mode 100644 index 0000000..6bf577a --- /dev/null +++ b/src/Form/TechDocumentBlockForm.php @@ -0,0 +1,26 @@ +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', + ], + ]); + + } +} diff --git a/src/Service/BlockLayout/TechDocumentFactory.php b/src/Service/BlockLayout/TechDocumentFactory.php new file mode 100644 index 0000000..c76b66d --- /dev/null +++ b/src/Service/BlockLayout/TechDocumentFactory.php @@ -0,0 +1,18 @@ +get('FormElementManager'), + $services->get('Config')['DefaultSettings']['TechDocumentBlockForm'] + ); + } +} +?> \ No newline at end of file diff --git a/src/Site/BlockLayout/TechDocument.php b/src/Site/BlockLayout/TechDocument.php new file mode 100644 index 0000000..ecd3ad9 --- /dev/null +++ b/src/Site/BlockLayout/TechDocument.php @@ -0,0 +1,85 @@ +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 .= '

' . $view->translate('Options'). '

'; + $html .= '
'; + $html .= $view->formCollection($form); + $html .= '
'; + 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; + } +} diff --git a/vendor/.gitignore b/vendor/.gitignore new file mode 100644 index 0000000..b3a0fd3 --- /dev/null +++ b/vendor/.gitignore @@ -0,0 +1,3 @@ +!.gitignore +vendor/mpdf +