Adiciona links acadêmicos ao MicrositeHeaderBlock e formatadores de campo

- Formatadores FieldFormatter para Lattes, ORCID e MathSciNet: geram
  link para o perfil na plataforma a partir do ID armazenado no campo
- MicrositeHeaderBlock: inclui lattes_id, orcid_id e mathscinet_id
- Template: exibe ícones SVG via site_tools_academic_icon() (extensão
  Twig do módulo site_tools) com links acessíveis para cada plataforma
- CSS: estilos para .msite-header-block__academic-links com animação
  de hover nos ícones

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-17 08:52:28 -03:00
parent 84f4661798
commit 9ec7f951bf
7 changed files with 209 additions and 3 deletions

View File

@@ -17,9 +17,12 @@ function site_users_microsite_theme(): array {
'photo_url' => NULL,
'photo_alt' => '',
'name' => NULL,
'bio' => NULL,
'phone' => NULL,
'email' => NULL,
'bio' => NULL,
'phone' => NULL,
'email' => NULL,
'lattes_id' => NULL,
'orcid_id' => NULL,
'mathscinet_id' => NULL,
],
],
];

View File

@@ -68,6 +68,9 @@ class MicrositeHeaderBlock extends BlockBase implements ContainerFactoryPluginIn
'#bio' => $this->getProcessedValue($user, 'field_user_bio'),
'#phone' => $this->getFieldValue($user, 'field_user_phone'),
'#email' => $user->getEmail(),
'#lattes_id' => $this->getFieldValue($user, 'field_user_id_lattes'),
'#orcid_id' => $this->getFieldValue($user, 'field_user_orcid'),
'#mathscinet_id' => $this->getFieldValue($user, 'field_user_mathscinetid'),
'#cache' => [
'tags' => $user->getCacheTags(),
'contexts' => ['route'],

View File

@@ -11,6 +11,9 @@
* - bio: Biografia (string|null).
* - phone: Telefone (string|null).
* - email: E-mail (string|null).
* - lattes_id: ID do Currículo Lattes (string|null).
* - orcid_id: ORCID iD (string|null).
* - mathscinet_id: MathSciNet Author ID (string|null).
*/
#}
<div class="msite-header-block">
@@ -54,6 +57,39 @@
</ul>
{% endif %}
{% if lattes_id or orcid_id or mathscinet_id %}
<div class="msite-header-block__academic-links">
{% if lattes_id %}
<a href="https://lattes.cnpq.br/{{ lattes_id }}"
class="msite-header-block__academic-link msite-header-block__academic-link--lattes"
target="_blank" rel="noopener noreferrer"
aria-label="{{ 'Currículo Lattes'|t }}">
{{ site_tools_academic_icon('lattes') }}
</a>
{% endif %}
{% if orcid_id %}
<a href="https://orcid.org/{{ orcid_id }}"
class="msite-header-block__academic-link msite-header-block__academic-link--orcid"
target="_blank" rel="noopener noreferrer"
aria-label="{{ 'Perfil ORCID'|t }}">
{{ site_tools_academic_icon('orcid') }}
</a>
{% endif %}
{% if mathscinet_id %}
<a href="https://mathscinet.ams.org/mathscinet/author?AuthorID={{ mathscinet_id }}"
class="msite-header-block__academic-link msite-header-block__academic-link--mathscinet"
target="_blank" rel="noopener noreferrer"
aria-label="{{ 'Perfil MathSciNet'|t }}">
{{ site_tools_academic_icon('mathscinet') }}
</a>
{% endif %}
</div>
{% endif %}
</div>
</div>

View File

@@ -0,0 +1,48 @@
<?php
namespace Drupal\site_users\Plugin\Field\FieldFormatter;
use Drupal\Core\Field\Attribute\FieldFormatter;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Field\FormatterBase;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\Core\Url;
/**
* Formata o ID Lattes como link para o Currículo Lattes.
*
* URL gerada: https://lattes.cnpq.br/{id}
*
* @FieldFormatter(
* id = "site_users_lattes_link",
* label = @Translation("Link para o Currículo Lattes"),
* field_types = {"integer"}
* )
*/
#[FieldFormatter(
id: 'site_users_lattes_link',
label: new TranslatableMarkup('Link para o Currículo Lattes'),
field_types: ['integer'],
)]
class LattesLinkFormatter extends FormatterBase {
public static function isApplicable(FieldDefinitionInterface $field_definition): bool {
return $field_definition->getName() === 'field_user_id_lattes';
}
public function viewElements(FieldItemListInterface $items, $langcode): array {
$elements = [];
foreach ($items as $delta => $item) {
$id = (string) $item->value;
$elements[$delta] = [
'#type' => 'link',
'#title' => $id,
'#url' => Url::fromUri('https://lattes.cnpq.br/' . $id),
'#attributes' => ['target' => '_blank', 'rel' => 'noopener noreferrer'],
];
}
return $elements;
}
}

View File

@@ -0,0 +1,48 @@
<?php
namespace Drupal\site_users\Plugin\Field\FieldFormatter;
use Drupal\Core\Field\Attribute\FieldFormatter;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Field\FormatterBase;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\Core\Url;
/**
* Formata o MathSciNet ID como link para o perfil de autor no MathSciNet.
*
* URL gerada: https://mathscinet.ams.org/mathscinet/author?AuthorID={id}
*
* @FieldFormatter(
* id = "site_users_mathscinet_link",
* label = @Translation("Link para o perfil MathSciNet"),
* field_types = {"integer"}
* )
*/
#[FieldFormatter(
id: 'site_users_mathscinet_link',
label: new TranslatableMarkup('Link para o perfil MathSciNet'),
field_types: ['integer'],
)]
class MathSciNetLinkFormatter extends FormatterBase {
public static function isApplicable(FieldDefinitionInterface $field_definition): bool {
return $field_definition->getName() === 'field_user_mathscinetid';
}
public function viewElements(FieldItemListInterface $items, $langcode): array {
$elements = [];
foreach ($items as $delta => $item) {
$id = (string) $item->value;
$elements[$delta] = [
'#type' => 'link',
'#title' => $id,
'#url' => Url::fromUri('https://mathscinet.ams.org/mathscinet/author?AuthorID=' . $id),
'#attributes' => ['target' => '_blank', 'rel' => 'noopener noreferrer'],
];
}
return $elements;
}
}

View File

@@ -0,0 +1,48 @@
<?php
namespace Drupal\site_users\Plugin\Field\FieldFormatter;
use Drupal\Core\Field\Attribute\FieldFormatter;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Field\FormatterBase;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\Core\Url;
/**
* Formata o ORCID como link para o perfil em orcid.org.
*
* URL gerada: https://orcid.org/{orcid}
*
* @FieldFormatter(
* id = "site_users_orcid_link",
* label = @Translation("Link para o perfil ORCID"),
* field_types = {"string"}
* )
*/
#[FieldFormatter(
id: 'site_users_orcid_link',
label: new TranslatableMarkup('Link para o perfil ORCID'),
field_types: ['string'],
)]
class OrcidLinkFormatter extends FormatterBase {
public static function isApplicable(FieldDefinitionInterface $field_definition): bool {
return $field_definition->getName() === 'field_user_orcid';
}
public function viewElements(FieldItemListInterface $items, $langcode): array {
$elements = [];
foreach ($items as $delta => $item) {
$id = $item->value;
$elements[$delta] = [
'#type' => 'link',
'#title' => $id,
'#url' => Url::fromUri('https://orcid.org/' . $id),
'#attributes' => ['target' => '_blank', 'rel' => 'noopener noreferrer'],
];
}
return $elements;
}
}

View File

@@ -253,6 +253,26 @@ body.microsite {
text-decoration: underline;
}
/* --- Links acadêmicos (Lattes, ORCID, MathSciNet) ------------------------- */
.msite-header-block__academic-links {
display: flex;
gap: 0.6rem;
margin-top: 0.75rem;
}
.msite-header-block__academic-link svg {
display: block;
width: 32px;
height: 32px;
transition: opacity 0.15s, transform 0.15s;
}
.msite-header-block__academic-link:hover svg {
opacity: 0.85;
transform: scale(1.1);
}
/* Top Bar ------------------------------------------------------------------ */
/*
* Barra estreita no topo da página, antes do header.