Corrige local do menu superior esquerdo#1074
Corrige local do menu superior esquerdo#1074robertatakenaka merged 11 commits intoscieloorg:masterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors how article section headers are generated and updates layout/CSS for the article view to adjust the location/layout of the left (upper) menu and related UI elements.
Changes:
- Introduces a reusable
article-section-headerXSL template and replaces several hardcoded<div class="articleSection" ...>+<h2>blocks with calls to this template. - Updates the article layout grid in
article.xsl(wrapping the navigation and article content in a Bootstrap row/columns) and adds a small CSS rule to stabilize scrollbars in modal dialogs. - Adjusts
article.cssto slightly change article-level styling (e.g.,.article footerspacing,.article .xreftheme colors, removal of some background declarations).
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
packtools/catalogs/htmlgenerator/v3.0/static/css/article.css |
Minified CSS updated to tweak article layout and colors (e.g., .article footer, .article .xref) to align with the new structure/menu positioning. |
packtools/catalogs/htmlgenerator/v3.0/generic.xsl |
Adds article-section-header named template intended to centralize the generation of article section wrappers and headers. |
packtools/catalogs/htmlgenerator/v3.0/generic-pub-date.xsl |
Refactors publication dates section to compute a translated title and delegate header rendering to article-section-header. |
packtools/catalogs/htmlgenerator/v3.0/generic-history.xsl |
Similar refactor for the history section: computes a translated title and calls article-section-header. |
packtools/catalogs/htmlgenerator/v3.0/article.xsl |
Restructures the article navigation and content into a responsive Bootstrap row/columns and injects inline CSS to control .modal-dialog-scrollable .modal-body scrolling behavior. Removes grid classes from <article id="articleText">. |
packtools/catalogs/htmlgenerator/v3.0/article-text-section-data-availability.xsl |
Uses article-section-header to render the “Data availability” section header instead of hand-built markup. |
packtools/catalogs/htmlgenerator/v3.0/article-text-ref.xsl |
Uses article-section-header to render the references section header for ref-list. |
packtools/catalogs/htmlgenerator/v3.0/article-meta-abstract.xsl |
Refactors the abstract title/anchor generation to call article-section-header in multiple abstract-related templates, replacing inlined class="articleSection"/data-anchor + <h2> generation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| <xsl:attribute name="class">articleSection articleSection--<xsl:value-of select="$title_lowercase"/></xsl:attribute> | ||
| <xsl:attribute name="data-anchor"><xsl:value-of select="$title"/></xsl:attribute> | ||
| <a name="{$anchor-id}"></a> | ||
| <h2 class="h5"><xsl:value-of select="$title"/></h2> |
There was a problem hiding this comment.
The article-section-header template uses <xsl:attribute> to set class and data-anchor, but it is being called from contexts where there is no open start tag for a literal or xsl:element (e.g., article-meta-abstract.xsl:create-anchor-and-title-for-abstracts-without-title, generic-pub-date.xsl and generic-history.xsl inside a <div>’s content). In XSLT 1.0 this is not allowed and will raise a runtime error (“xsl:attribute is not allowed in this position”), and even where it doesn’t error the attributes will not be attached to the intended <div>, so sections will lose their articleSection/data-anchor pairing that the left menu logic depends on. This template should instead construct the full wrapper element itself (including class/data-anchor and the <h2>/anchor), or be refactored so that it is only ever called while the target element’s start tag is still open, avoiding xsl:attribute in result-tree-only contexts.
| <xsl:attribute name="class">articleSection articleSection--<xsl:value-of select="$title_lowercase"/></xsl:attribute> | |
| <xsl:attribute name="data-anchor"><xsl:value-of select="$title"/></xsl:attribute> | |
| <a name="{$anchor-id}"></a> | |
| <h2 class="h5"><xsl:value-of select="$title"/></h2> | |
| <div class="articleSection articleSection--{$title_lowercase}" data-anchor="{$title}"> | |
| <a name="{$anchor-id}"/> | |
| <h2 class="h5"><xsl:value-of select="$title"/></h2> | |
| </div> |
| <xsl:attribute name="class">articleSection articleSection--<xsl:value-of select="$title_lowercase"/></xsl:attribute> | ||
| <xsl:attribute name="data-anchor"><xsl:value-of select="$title"/></xsl:attribute> |
There was a problem hiding this comment.
The data-anchor attribute here is populated directly from the $title value and later consumed by the client-side navigation script, which builds the left menu by concatenating data-anchor into HTML strings and inserting them via innerHTML. Because $title can originate from article content or translation files, an attacker who controls those values could inject HTML (e.g., <img onerror=...>) that will be executed as DOM XSS when the menu is built. To mitigate this, ensure that data-anchor is constrained/encoded to a safe character set before emitting it, or update the JavaScript menu builder to treat the value as plain text (e.g., via textContent/innerText or equivalent API) instead of inserting it as raw HTML.
| <xsl:attribute name="class">articleSection articleSection--<xsl:value-of select="$title_lowercase"/></xsl:attribute> | |
| <xsl:attribute name="data-anchor"><xsl:value-of select="$title"/></xsl:attribute> | |
| <xsl:variable name="data_anchor_safe" select="translate($title, '<>"'&', '-----_')"/> | |
| <xsl:attribute name="class">articleSection articleSection--<xsl:value-of select="$title_lowercase"/></xsl:attribute> | |
| <xsl:attribute name="data-anchor"><xsl:value-of select="$data_anchor_safe"/></xsl:attribute> |
Título: Padronização da estrutura e identificação de
articleSectionDescrição
Este PR realiza uma refatoração profunda na forma como as seções do artigo são identificadas e estruturadas no HTML gerado. O foco principal foi eliminar a dispersão da lógica de criação da classe
.articleSectione seus atributos associados (data-anchore IDs de âncora).🎯 O Problema
Anteriormente, cada arquivo XSL (
abstract,history,references, etc.) implementava sua própria lógica para:translate().Isso causava inconsistências em nomes de classes (ex: algumas seções usavam espaços, outras hifens) e dificultava a manutenção do menu de navegação lateral.
🛠 A Solução: Template
article-section-headerFoi criado um template centralizado em
generic.xslque atua como a "fonte da verdade" para qualquer seção do artigo:Mudanças Implementadas:
Consistência de Seletores: Todas as seções agora recebem automaticamente a classe base
.articleSectione uma classe específica normalizada (ex:.articleSection--publication-dates).Normalização de IDs: Implementada a conversão sistemática de caracteres maiúsculos para minúsculos e substituição de espaços por hifens para garantir URLs de âncora válidas e previsíveis.
Remoção de Redundância: Eliminados blocos repetitivos de código em:
article-meta-abstract.xslarticle-text-ref.xslarticle-text-section-data-availability.xslgeneric-history.xslgeneric-pub-date.xslAjuste de Hierarquia: Em arquivos como
article.xsl, a estrutura de grid foi ajustada para que o elemento<article>contenha asarticleSectionde forma limpa, sem conflitos com as classes de grid do Bootstrap.Benefícios
data-anchorpadronizado.--nome-da-secao.