From 54cfe7eea785e21943678617eea88024b1fe6856 Mon Sep 17 00:00:00 2001 From: astanley Date: Wed, 27 Nov 2024 15:34:25 -0400 Subject: [PATCH] initial commit --- config/schema/islandora_altmetric.schema.yml | 7 ++ islandora_altmetric.info.yml | 7 ++ islandora_altmetric.libraries.yml | 4 + islandora_altmetric.module | 6 ++ js/doi_embed.js | 1 + src/Plugin/Block/IslandoraAltimetricBlock.php | 91 +++++++++++++++++++ 6 files changed, 116 insertions(+) create mode 100644 config/schema/islandora_altmetric.schema.yml create mode 100644 islandora_altmetric.info.yml create mode 100644 islandora_altmetric.libraries.yml create mode 100644 islandora_altmetric.module create mode 100644 js/doi_embed.js create mode 100644 src/Plugin/Block/IslandoraAltimetricBlock.php diff --git a/config/schema/islandora_altmetric.schema.yml b/config/schema/islandora_altmetric.schema.yml new file mode 100644 index 0000000..64d154e --- /dev/null +++ b/config/schema/islandora_altmetric.schema.yml @@ -0,0 +1,7 @@ +block.settings.islandora_altmetric_islandora_altmetric: + type: block_settings + label: 'Islandora Altmetric block' + mapping: + example: + type: string + label: Example diff --git a/islandora_altmetric.info.yml b/islandora_altmetric.info.yml new file mode 100644 index 0000000..ab3d4a3 --- /dev/null +++ b/islandora_altmetric.info.yml @@ -0,0 +1,7 @@ +name: 'Islandora Altmetric' +type: module +description: 'Displays Altmetric Badge in a block' +package: Custom +core_version_requirement: ^10 || ^11 +dependencies: + - islandora:islandora diff --git a/islandora_altmetric.libraries.yml b/islandora_altmetric.libraries.yml new file mode 100644 index 0000000..9495057 --- /dev/null +++ b/islandora_altmetric.libraries.yml @@ -0,0 +1,4 @@ +islandora_altmetric: + js: + js/doi_embed.js: {} + diff --git a/islandora_altmetric.module b/islandora_altmetric.module new file mode 100644 index 0000000..7dfc6ec --- /dev/null +++ b/islandora_altmetric.module @@ -0,0 +1,6 @@ +routeMatch = $route_match; + $this->entityTypeManager = $entity_typemanager; + parent::__construct($configuration, $plugin_id, $plugin_definition); + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition): self { + return new self( + $configuration, + $plugin_id, + $plugin_definition, + $container->get('entity_type.manager'), + $container->get('current_route_match'), + ); + } + + /** + * {@inheritdoc} + */ + public function build(): array { + $node = $this->routeMatch->getParameter('node'); + $doi = $node->field_doi->value; + $markup = << + + EOD; + + $build['content'] = [ + '#markup' => $markup, + ]; + + $build['content'] = [ + '#markup' => $markup, + '#attached' => [ + 'library' => [ + 'islandora_altmetric/islandora_altmetric', + ], + ], + ]; + return $build; + } + +}