From 1691a12aa530694d83d6a1ac6fa92d1bd89cef57 Mon Sep 17 00:00:00 2001 From: asajedi Date: Fri, 17 Dec 2021 03:36:51 +0100 Subject: [PATCH] Set up literature item page --- src/Controller/LiteratureController.php | 12 + src/Import/Importer.php | 34 ++- src/Service/EditedTextService.php | 3 +- src/Service/SolrSearchService.php | 9 + templates/partials/literature.html.twig | 6 +- templates/partials/literature_item.html.twig | 240 +++++++++++++++++++ translations/messages.de.yaml | 31 ++- 7 files changed, 307 insertions(+), 28 deletions(-) create mode 100755 templates/partials/literature_item.html.twig diff --git a/src/Controller/LiteratureController.php b/src/Controller/LiteratureController.php index 450c0d2..687f856 100755 --- a/src/Controller/LiteratureController.php +++ b/src/Controller/LiteratureController.php @@ -27,4 +27,16 @@ class LiteratureController extends AbstractController ] ); } + + /** + * @Route("/literatur/{id}", name="_literature_item") + */ + public function literatureItem(string $id): Response + { + return $this->render('partials/literature_item.html.twig', + [ + 'item' => $this->client->getLiteratureItem($id), + ] + ); + } } diff --git a/src/Import/Importer.php b/src/Import/Importer.php index 5e90c1b..447b53b 100644 --- a/src/Import/Importer.php +++ b/src/Import/Importer.php @@ -71,19 +71,7 @@ class Importer implements ImporterInterface foreach ($files as $file) { if ([] !== $invalidTeiList && !in_array(trim($file['name']), $invalidTeiList)) { $teiFileUrl = $this->gitlabProcessedTeiRepoUrl.$file['name'].'?access_token='.$this->gitlabRepoToken.'&ref=master'; - $fileData = file_get_contents($teiFileUrl); - if (is_string($fileData)) { - $fileData = json_decode($fileData, true); - - try { - $teiFilesystem->write($file['name'], base64_decode($fileData['content'])); - } catch (FileException $exception) { - echo $file['name'].' could not be imported.'; - } - } else { - // TODO retry to download the file again - echo $file['name'].' could not be imported.'; - } + $this->downloadTeiFile($teiFilesystem, $file, $teiFileUrl); } } } @@ -93,6 +81,26 @@ class Importer implements ImporterInterface } } + private function downloadTeiFile($teiFilesystem, array $file, string $teiFileUrl) + { + $fileDownload = false; + $fileData = file_get_contents($teiFileUrl); + if (is_string($fileData)) { + $fileData = json_decode($fileData, true); + + try { + $teiFilesystem->write($file['name'], base64_decode($fileData['content'])); + } catch (FileException $exception) { + echo $file['name'].' could not be imported into S3.'; + $this->downloadTeiFile($teiFilesystem, $file, $teiFileUrl); + } + + $fileDownload = true; + } + + return $fileDownload; + } + public function importLiterature(): void { $filesystem = new Filesystem(); diff --git a/src/Service/EditedTextService.php b/src/Service/EditedTextService.php index 797c835..6112279 100644 --- a/src/Service/EditedTextService.php +++ b/src/Service/EditedTextService.php @@ -48,6 +48,7 @@ class EditedTextService extends CommonTransformService $this->notes = []; $this->dates = []; $this->works = []; + $this->allAnnotationIds = []; } public function createUuid(): ?string @@ -108,7 +109,7 @@ class EditedTextService extends CommonTransformService if ($targetValue) { $targetArr = explode('#', $targetValue); $text = str_replace('_', ' ', $targetArr[1]); - $url = $targetArr[0]; + $url = './../literatur/'.$text; // Create annotation $this->works[$this->createUuid()] = ''.$text.''; diff --git a/src/Service/SolrSearchService.php b/src/Service/SolrSearchService.php index b8212bf..279edd0 100755 --- a/src/Service/SolrSearchService.php +++ b/src/Service/SolrSearchService.php @@ -226,6 +226,15 @@ class SolrSearchService implements SearchServiceInterface return $this->client->select($select)->getData()['response']['docs']; } + public function getLiteratureItem(string $id): array + { + $select = $this->client->createSelect()->setRows(1000); + $query = vsprintf('%s:%s AND %s:"%s"', ['doctype', 'literature', 'id', $id]); + $select->setQuery($query); + + return $this->client->select($select)->getData()['response']['docs'][0]; + } + public function getNumberOfAuthors(): array { $select = $this->client->createSelect()->setRows(200); diff --git a/templates/partials/literature.html.twig b/templates/partials/literature.html.twig index 051c58a..9c9d41e 100755 --- a/templates/partials/literature.html.twig +++ b/templates/partials/literature.html.twig @@ -1,6 +1,4 @@ -{# -@author Jerome - +{# literaturverezeichnis view, data distinguished by titles, subtiltes and authors, see gfl-143 #} @@ -51,7 +49,7 @@ see gfl-143 {{document.monographic_sub_title}} {% endif %}
{% if document.edition is defined %} - {{ 'Doc_editon'|trans }}: {{document.edition|join}}
+ {{ 'Doc_edition'|trans }}: {{document.edition|join}}
{% endif %} {% if document.pub_place is defined %} {{ 'Doc_publication'|trans }}:{% for place in document.pub_place %} {{place}} {% if not loop.last %} ; {% endif %} {% endfor %} : diff --git a/templates/partials/literature_item.html.twig b/templates/partials/literature_item.html.twig new file mode 100755 index 0000000..3d72bea --- /dev/null +++ b/templates/partials/literature_item.html.twig @@ -0,0 +1,240 @@ +{# +literaturverezeichnis view, data distinguished by titles, subtiltes and authors, +see gfl-143 +#} +{% extends 'base.html.twig' %} + +{% block body %} +
+
    + +
  1. + + {{ item.id }}
    + + {% if item.monographic_main_title is defined and item.series_main_title is not defined %} + {{ 'Doc_monographie'|trans }}
    + {% if item.literature_author is defined %} + {{ 'Doc_author'|trans }}: {% for author in item.literature_author %}{{ author }}{% if not loop.last %} : {% endif %} {% endfor %}
    + {% endif %} + {% if item.editor is defined %} + {{ 'Doc_editor'|trans }}: {% for editor in document.editor %} {{ editor }}{% if not loop.last %} ; {% endif %} {% endfor %}
    + {% endif %} + {% if item.monographic_main_title is defined %} + {{ 'Doc_title'|trans }}: {{ item.monographic_main_title }} + {% endif %} + {% if item.monographic_sub_title is defined %} + {{ item.monographic_sub_title }} + {% endif %}
    + {% if item.edition is defined %} + {{ 'Doc_edition'|trans }}: {{ item.edition|join }}
    + {% endif %} + {% if item.pub_place is defined %} + {{ 'Doc_publication'|trans }}:{% for place in item.pub_place %} {{ place }} {% if not loop.last %} ; {% endif %} {% endfor %} : + {% if item.publisher is defined %} + {% for publisher in item.publisher %}{{ publisher }}{% if not loop.last %} ; {% endif %}{% if loop.last %}, {% endif %}{% endfor %} + {% endif %} + {% if item.lit_pub_date is defined %} + {{ item.lit_pub_date|join }} + {% endif %} +
    + {% endif %} + {% if item.extent is defined %} + {{ 'Doc_extent'|trans }}: {{ item.extent|join }}
    + {% endif %} + {% if item.ISBN is defined %} + {{ 'Doc_ISBN'|trans }}: {{ item.ISBN|join }}
    + {% endif %} + {% if item.link is defined %} + {{ 'Doc_link'|trans }}: {{ item.link|join }}
    + {% endif %} + + + {% elseif item.monographic_main_title is defined and item.series_main_title is defined and item.analytic_main_title is not defined %} + {{ 'Doc_single_band'|trans }}
    + {% if item.literature_author is defined %} + {{ 'Doc_author'|trans }}: {{ item.literature_author|join }}
    + {% endif %} + {% if item.editor is defined %} + {{ 'Doc_editor'|trans }}: {% for editor in item.editor %} {{ editor }} {% if not loop.last %} ; {% endif %} {% endfor %}
    + {% endif %} + {% if item.monographic_main_title is defined %} + {{ 'Doc_title'|trans }}: {{ item.monographic_main_title }} + {% endif %} + {% if item.monographic_sub_title is defined %} + {{ item.monographic_sub_title|join }}. + {% endif %} + {% if item.biblScope_volume_n is defined%} + {{ item.biblScope_volume_n|join }} + {% endif %} +
    + {% if document.series_main_title is defined %} + {{ 'Doc_volume'|trans }}: {{ item.series_main_title|join }} + {% endif %} + {% if document.series_sub_title is defined %} + {{ item.series_sub_title|join }} + {% endif %} + + {% if item.biblScope_volume is defined%} + {{ item.biblScope_volume |join }} + {% endif %}
    + {% if item.pub_place is defined %} + {{ 'Doc_publication'|trans }}: + {% for place in item.pub_place %} + {{ place }}{% if not loop.last %} ; {% endif %} + {% endfor %} : + {% if item.publisher is defined %} + {% for publisher in item.publisher %}{{ publisher }}{% if not loop.last %} ; {% endif %}{% if loop.last %}, {% endif %}{% endfor %} + {% endif %} + {% if item.lit_pub_date is defined %} + {{ item.lit_pub_date|join }} + {% endif %} +
    + {% endif %} + {% if item.extent is defined %} + {{ 'Doc_extent'|trans }}: {{ item.extent|join }}
    + {% endif %} + + + {% elseif item.journal_main_title is defined and item.literature_author is not defined %} + {{ 'Doc_journal_magazine'|trans }}
    + {% if item.journal_main_title is defined %} + {{ 'Doc_title'|trans }}: {{ item.journal_main_title }}
    + {% endif %} + {% if item.journal_sub_title is defined %} + {{ 'Doc_title'|trans }}: {{ item.journal_sub_title }}
    + {% endif %} + {% if item.editor is defined %} + {{ 'Doc_editor'|trans }}: {% for editor in item.editor %} {{ editor }}; {% endfor %}
    + {% endif %} + {% if item.pub_place is defined %} + {{ 'Doc_publication'|trans }}: {% for pubplace in item.pub_place %} {{ pubplace }} {% if not loop.last %} ; {% endif %} {% endfor %} : + {% endif %} + {% if item.publisher is defined %} + {{ 'Doc_publishing_company'|trans }} {% for publisher in item.publisher %} {{ publisher }} {% if not loop.last %} ; {% endif %} {% endfor %} + {% endif %} + {% if item.lit_pub_date is defined %} + {{ item.lit_pub_date|join }} + {% endif %} +
    + {% if item.ISSN is defined %} + {{ 'Doc_ISSN'|trans }}: {{ item.ISSN|join }}
    + {% endif %} + + + {% elseif document.analytic_main_title is defined and document.journal_main_title is defined %} + {{ 'Doc_essay_magazin'|trans }}
    + {% if item.literature_author is defined %} + {{ 'Doc_author'|trans }}: {{ item.literature_author|join }}
    + {% endif %} + {% if item.analytic_main_title is defined %} + {{ 'Doc_title'|trans }}: {{ item.analytic_main_title }} + {% endif %} + {% if item.analytic_sub_title is defined %} + {{ item.analytic_sub_title }} + {% endif %}
    + {% if item.journal_main_title is defined %} + {{ 'Doc_journal'|trans }}: {{ item.journal_main_title|join }}
    + {% endif %} + {% if item.editor is defined %} + {{ 'Doc_editor'|trans }}: {{ item.editor|join }}
    + {% endif %} + {% if item.biblScope_volume is defined %} + {{ 'Doc_volume'|trans }}: {{ item.biblScope_volume|join }}
    + {% endif %} + {% if item.biblScope_part is defined %} + {{ item.biblScope_part|join }}
    + {% endif %} + {% if item.biblScope_pages is defined %} + {{ 'Doc_pages'|trans }}: {{ item.biblScope_pages|join }}
    + {% endif %} + {% if item.ISSN is defined %} + {{ 'Doc_ISSN'|trans }}: {{ item.ISSN|join }}
    + {% endif %} + + + {% elseif item.monographic_main_title is defined and item.analytic_main_title is defined %} + {{ 'Doc_contribution_collection_band'|trans }}
    + {% if item.literature_author is defined %} + {{ 'Doc_author'|trans }}: {{ item.literature_author|join }}
    + {% endif %} + {% if item.analytic_main_title is defined %} + {{ 'Doc_essay'|trans }}: {{ item.analytic_main_title }} + {% endif %} + {% if item.analytic_sub_title is defined %} + {{ item.analytic_sub_title }} + {% endif %}
    + {% if item.editor is defined %} + {{ 'Doc_editor'|trans }}: {% for editor in item.editor %} {{ editor }}{% if not loop.last %} ; {% endif %} {% endfor %}
    + {% endif %} + {% if item.series_main_title is defined %} + {{ 'Doc_volume'|trans }}: {{ item.series_main_title }} + {% if item.series_sub_title is defined %} + {{ item.series_sub_title }} + {% endif %}
    + {% endif %} + + {% if item.pub_place is defined %} + {{ 'Doc_publication'|trans }}: {% for place in item.pub_place %} {{ place }} {% if not loop.last %} ; {% endif %} {% endfor %} : + {% if item.publisher is defined %} + {{ item.publisher|join }}, + {% endif %} + {% if item.lit_pub_date is defined %} + {{ item.lit_pub_date|join }} + {% endif %} +
    + {% if item.biblScope_pages is defined %} + {{ 'Doc_scope'|trans }}:{{ item.biblScope_pages|join }} + {% endif %} + {% endif %} + + + {% elseif item.monographic_main_title is not defined and item.series_main_title is defined %} + {{ 'Doc_series'|trans }}
    + {% if item.literature_author is defined %} + {{ 'Doc_author'|trans }}: {% for author in item.literature_author %} {{ author }}{% if not loop.last %} ; {% endif %} {% endfor %}
    + {% endif %} + {% if item.editor is defined %} + {{ 'Doc_editor'|trans }}: {% for editor in item.editor %} {{ editor }}{% if not loop.last %} ; {% endif %} {% endfor %}
    + {% endif %} + {% if item.series_main_title is defined %} + {{ 'Doc_title'|trans }}: {{ item.series_main_title|join }}
    + {% endif %} + {{ 'Doc_edition'|trans }}
    + {% if item.pub_place is defined %} + {{ 'Doc_publication'|trans }}: + {% for place in itemv.pub_place %} + {{ place }} + {% if not loop.last %} ; {% endif %} + {% endfor %} : + {% if item.publisher is defined %} + {% for publisher in item.publisher %} + {{ publisher }} + {% if not loop.last %} ; {% endif %} + {% endfor %}, + {% endif %} + {% if item.lit_pub_date is defined %} + {{ item.lit_pub_date|join }} + {% endif %} +
    + {% endif %} + {% if item.extent is defined %} + {{ 'Doc_extent'|trans }}: {{ item.extent|join }}
    + {% endif %} + {% else %} + {# TODO clearify where the other (not caught) should belong to #} + {{ 'Doc_notype'|trans }} + {% endif %} + + {% if item.uri is defined %} + {% for uri in item.uri %} + {{ 'Doc_link'|trans }}: {{ uri|join }}
    + {% endfor %} + {% endif %} + {% if item.refs is defined %} + {{ 'Doc_refs'|trans }}: {{ item.refs|join }}
    + {% endif %} +
  2. +
+
+{% endblock %} diff --git a/translations/messages.de.yaml b/translations/messages.de.yaml index b8091c7..c589b5f 100755 --- a/translations/messages.de.yaml +++ b/translations/messages.de.yaml @@ -14,28 +14,38 @@ Nav_Menu_Search: Suche # Documents Lists Doc_author: Autor +Doc_contribution_collection_band: Beitrag in einem Sammelband Doc_date_publish: Jahr +Doc_editor: Herausgeber +Doc_edition: Auflage +Doc_essay: Aufsatz +Doc_essay_magazin: Aufsatz in einer Zeitschrift +Doc_extent: Umfang Doc_id: Kürzel +Doc_ISBN: ISBN +Doc_ISSN: ISSN +Doc_journal: Zeitschrift +Doc_journal_magazine: Zeitschrift / Zeitung Doc_link: Link +Doc_monographie: Monographie +Doc_notype: kein Typ + +Doc_pages: Umfang Doc_place: Ort +Doc_publication: Publikation Doc_publish: Verlag +Doc_publishing_company: Verlag Doc_refs: Referenzen +Doc_scope: Umfang +Doc_single_band: Einzelband aus einer Reihe +Doc_series: Reihe Doc_title: Titel Doc_type: Doc_type -Doc_editor: Herausgeber -Doc_editon: Auflage Doc_volume: Reihe -Doc_publication: Publikation -Doc_extent: Umfang -Doc_publishing_company: Verlag -Doc_journal: Zeitschrift Doc_vintage: Jahrgang -Doc_pages: Umfang -Doc_essay: Aufsatz Heading_prefix: Wirkungsgeschichte von Goethes Werk "Zur Farbenlehre" in Berlin 1810-1832 Image_archives: Digitalisate Leopoldina: '"Goethe. Die Schriften zur Naturwissenschaft", II. Abteilung: Ergänzungen und Erläuterungen. Band 5B: Die Schriften zur Farbenlehre und Optik nach 1810 und zur Tonlehre. Bearbeitet von Thomas Nickol, unter Mitwirkung von Dorothea Kuhn und Horst Zehe. Weimar : Hermann Böhlaus Nachf., 2007.
Mit Genehmigung der Urheber.' - Literarur_list: Literaturliste Pdf_list: Pdf Liste Repository: Repositorium @@ -78,7 +88,7 @@ Searchterm: Suchbegriff Sorted by: sortiert nach To: bis -# Sorts +# Sort author-asc: Autor aufsteigend author-desc: Autor absteigend date-asc: Datum aufsteigend @@ -106,6 +116,7 @@ destination_place_facet: Empfangsorte Include notes: Kommentare einschließen Display all records: Alle Suchtreffer anzeigen Search text: 'Bitte geben Sie mindestens ein Suchkriterium an; * für alle Dokumente.
Hinweis: Die Suche bezieht nur die bereits vorliegenden xml-Dateien ein. Ihre Funktion umfasst nur einen Teil der geplanten Optionen.
Die Anzeige der xml-Dateien befindet sich noch in der Entwicklung.' + # Project Info Title: Wirkungsgeschichte von Goethes Werk „Zur Farbenlehre“ in Berlin 1810–1832 Sub title info: Technische Informationen / Dokumentation -- GitLab