Commit 67e0061d authored by Charles Bourdot's avatar Charles Bourdot
Browse files

màj ressources

parent 8d5ef1b4
Loading
Loading
Loading
Loading
+126 −67
Changes for resources/javascript/xml_2_html.js: 126 added lines, 67 removed lines.
Original line number Diff line number Diff line
@@ -73,6 +73,22 @@ const dict = {
        'ann': ' (annotateur)',
        'com': ' (compilateur)',
        'ctg': ' (cartographe)',
        'loading': 'Chargement…',
        'stats-title': 'Statistiques de consultation',
        'stats-unavailable': 'Statistiques indisponibles.',
        'views-abstract': 'Vues du résumé',
        'views-html': 'Vues HTML',
        'views-pdf': 'Vues PDF',
        'views-other': 'Autres téléchargements',
        'views-total': 'Total des consultations',
        'publication-info': 'Informations de publication',
        'published-on': 'Publié le',
        'section': 'Rubrique',
        'formats': 'Formats disponibles',
        'no-galley': 'Aucun lien galley trouvé dans la page.',
        'copied': '✓ Copié dans le presse-papier',
        'fulltext': 'Texte intégral',
        'project-id': 'Référence du projet',

    },
    en: {
@@ -149,6 +165,22 @@ const dict = {
        'ann': ' (annotateur)',
        'com': ' (compiler)',
        'ctg': ' (cartographer)',
        'loading': 'Loading…',
        'stats-title': 'Usage statistics',
        'stats-unavailable': 'Statistics unavailable.',
        'views-abstract': 'Abstract views',
        'views-html': 'HTML views',
        'views-pdf': 'PDF views',
        'views-other': 'Other downloads',
        'views-total': 'Total views',
        'publication-info': 'Publication information',
        'published-on': 'Published on',
        'section': 'Section',
        'formats': 'Available formats',
        'no-galley': 'No galley link found on the page.',
        'copied': '✓ Copied to clipboard',
        'fulltext': 'Full text',
        'project-id': 'Project ID',

    },
    es: {
@@ -225,12 +257,29 @@ const dict = {
        'ann': ' (autor de anotación)',
        'com': ' (compilador)',
        'ctg': ' (cartógrafo)',
        'loading': 'Cargando…',
        'stats-title': 'Estadísticas de consulta',
        'stats-unavailable': 'Estadísticas no disponibles.',
        'views-abstract': 'Vistas del resumen',
        'views-html': 'Vistas HTML',
        'views-pdf': 'Vistas PDF',
        'views-other': 'Otras descargas',
        'views-total': 'Total de consultas',
        'publication-info': 'Información de publicación',
        'published-on': 'Publicado el',
        'section': 'Sección',
        'formats': 'Formatos disponibles',
        'no-galley': 'No se encontró ningún enlace de galerada en la página.',
        'copied': '✓ Copiado al portapapeles',
        'fulltext': 'Texto completo',
        'project-id': 'Referencia del proyecto',

    }
}

function getText(key){
    return dict[lang][key];
    // Fall back to English for locales without a dictionary, then to the key itself
    return (dict[lang] || dict.en)[key] ?? key;
}

function translatePage(newLang){
@@ -270,7 +319,6 @@ window.addEventListener('DOMContentLoaded', (event) => {
            let tocItem = document.getElementById("toc-contents").querySelector("a[href='"+tocItemRef+"']");
            if(!tocItem)
                continue;
            //console.log(anchors[i].offsetTop, anchors[i].clientHeight)
                if (scrollTop + 100> anchors[i].offsetTop) {
                document.getElementById("toc-contents").querySelectorAll('a').forEach(
                    (a) => a.classList.remove('active')
@@ -694,6 +742,7 @@ document.addEventListener('DOMContentLoaded', function() {
// -------------------------------------------------------
function deactivateAllFilters(exceptBtnId) {
  const filters = [
    { btnId: 'btn-filter-fulltext',      injectedId: null },
    { btnId: 'btn-filter-figures',       injectedId: null },
    { btnId: 'btn-filter-metadata',      injectedId: 'injected-metadata' },
    { btnId: 'btn-filter-bibliometrics', injectedId: 'injected-bibliometrics' },
@@ -716,6 +765,15 @@ function deactivateAllFilters(exceptBtnId) {
  });
}

// -------------------------------------------------------
// Texte intégral : aucun filtre actif
// -------------------------------------------------------
function showFullText() {
  deactivateAllFilters('btn-filter-fulltext');
  const btn = document.getElementById('btn-filter-fulltext');
  if (btn) btn.classList.add('active');
}

// -------------------------------------------------------
// Filtre Figures
// -------------------------------------------------------
@@ -724,8 +782,7 @@ function toggleFiguresFilter() {
  const btn = document.getElementById('btn-filter-figures');

  if (btn.classList.contains('active')) {
    btn.classList.remove('active');
    articleWrap.querySelectorAll('*').forEach(el => el.style.removeProperty('display'));
    showFullText();
    return;
  }

@@ -733,18 +790,13 @@ function toggleFiguresFilter() {
  deactivateAllFilters('btn-filter-figures');
  btn.classList.add('active');

  articleWrap.querySelectorAll('p:not(table p), table.linguistic, ul.index-unordered, h1, h2, h3, h4, a').forEach(el => {
  // Ne garder que les figures (pas les tableaux ni les formules JATS),
  // leurs éléments parents et leur contenu
  const figures = [...articleWrap.querySelectorAll('figure:not(.fig-table):not(.fig-formula)')];
  articleWrap.querySelectorAll('*').forEach(el => {
    const isFigurePart = figures.some(fig => fig === el || fig.contains(el) || el.contains(fig));
    if (!isFigurePart) {
      el.style.display = 'none';
  });
  articleWrap.querySelectorAll('section').forEach(el => {
    el.style.display = 'block';
  });
  articleWrap.querySelectorAll('figure').forEach(el => {
    el.style.display = 'block';
    let parent = el.parentElement;
    while (parent && parent !== articleWrap) {
      parent.style.display = 'block';
      parent = parent.parentElement;
    }
  });
}
@@ -757,10 +809,7 @@ function toggleMetadataFilter() {
  const btn = document.getElementById('btn-filter-metadata');

  if (btn.classList.contains('active')) {
    btn.classList.remove('active');
    const injected = document.getElementById('injected-metadata');
    if (injected) injected.remove();
    articleWrap.querySelectorAll('*').forEach(el => el.style.removeProperty('display'));
    showFullText();
    return;
  }

@@ -789,12 +838,9 @@ async function toggleBibliometrics() {
  const articleWrap = document.querySelector('.article-wrap');
  const btn = document.getElementById('btn-filter-bibliometrics');

  // Si déjà actif → simple désactivation
  // Si déjà actif → retour au texte intégral
  if (btn.classList.contains('active')) {
    btn.classList.remove('active');
    const injected = document.getElementById('injected-bibliometrics');
    if (injected) injected.remove();
    articleWrap.querySelectorAll('*').forEach(el => el.style.removeProperty('display'));
    showFullText();
    return;
  }

@@ -814,53 +860,69 @@ async function toggleBibliometrics() {
  injected = document.createElement('div');
  injected.id = 'injected-bibliometrics';
  injected.style.cssText = 'display:block; padding: 1em;';
  injected.innerHTML = '<p>Chargement…</p>';
  injected.textContent = getText('loading');
  articleWrap.appendChild(injected);

  // Données statiques du DOM
  const published = document.querySelector('.item.published .value')?.innerText.trim() ?? 'N/A';
  const section   = document.querySelector('.item.issue .sub_item .value')?.innerText.trim() ?? 'N/A';
  const keywords  = document.querySelector('.item.keywords .value')?.innerText.trim() ?? 'N/A';
  const galleys   = [...document.querySelectorAll('.galleys_links a')].map(a => a.innerText.trim()).join(', ') || 'N/A';

  // Données dynamiques via API OJS stats
  const match = window.location.pathname.match(/article\/view\/(\d+)/);
  const articleId = match ? match[1] : null;

  const slugMatch = window.location.pathname.match(/\/index\.php\/([^\/]+)\//);
  const journalSlug = slugMatch ? slugMatch[1] : null;


  let statsHTML = '<li><em>Statistiques indisponibles.</em></li>';
  if (articleId) {
  const readText = selector => document.querySelector(selector)?.innerText.trim() || 'N/A';
  const published = readText('.item.published .value');
  const section   = readText('.item.issue .sub_item .value');
  const keywords  = readText('.item.keywords .value');
  const galleys   = [...document.querySelectorAll('.galleys_links a, .item.files a.cmp_download_link, .item.files a.remote_resource')].map(a => a.innerText.trim()).join(', ') || 'N/A';

  // Données dynamiques via l'API stats d'OJS (réservée aux utilisateurs autorisés)
  let stats = null;
  if (typeof statsApiUrl !== 'undefined' && statsApiUrl) {
    try {
      const res = await fetch(`/index.php/${journalSlug}/api/v1/stats/publications/${articleId}`);
      const data = await res.json();
      statsHTML = `
        <li>Vues du résumé : ${data.abstractViews ?? 0}</li>
        <li>Vues HTML : ${data.htmlViews ?? 0}</li>
        <li>Vues PDF : ${data.pdfViews ?? 0}</li>
        <li>Autres téléchargements : ${data.otherViews ?? 0}</li>
        <li>Total des consultations : ${data.galleyViews ?? 0}</li>`;
    } catch (e) {}
  }

  injected.innerHTML = `
    <h4>Statistiques de consultation</h4>
    <ul>${statsHTML}</ul>
    <h4>Informations de publication</h4>
    <ul>
      <li>Publié le : ${published}</li>
      <li>Rubrique : ${section}</li>
      <li>Mots-clés : ${keywords}</li>
      <li>Formats disponibles : ${galleys}</li>
    </ul>`;
      const res = await fetch(statsApiUrl, { credentials: 'same-origin' });
      if (res.ok) {
        stats = await res.json();
      }
    } catch (e) {
      console.warn('[bibliometrics] stats request failed:', e);
    }
  }

  // Les valeurs viennent de la page : construites en texte, jamais en HTML
  const heading = text => {
    const h = document.createElement('h4');
    h.textContent = text;
    return h;
  };
  const list = items => {
    const ul = document.createElement('ul');
    items.forEach(text => {
      const li = document.createElement('li');
      li.textContent = text;
      ul.appendChild(li);
    });
    return ul;
  };
  const colon = getText('colon');

  injected.replaceChildren(
    heading(getText('stats-title')),
    stats ? list([
      getText('views-abstract') + colon + (stats.abstractViews ?? 0),
      getText('views-html') + colon + (stats.htmlViews ?? 0),
      getText('views-pdf') + colon + (stats.pdfViews ?? 0),
      getText('views-other') + colon + (stats.otherViews ?? 0),
      getText('views-total') + colon + (stats.galleyViews ?? 0),
    ]) : list([getText('stats-unavailable')]),
    heading(getText('publication-info')),
    list([
      getText('published-on') + colon + published,
      getText('section') + colon + section,
      getText('keywords') + colon + keywords,
      getText('formats') + colon + galleys,
    ])
  );
}
function openGalleyIframe() {
  // Récupère le lien galley présent dans la page
  const galleyLink = document.querySelector('.galleys_links .obj_galley_link');
  const galleyLink = document.querySelector('.galleys_links .obj_galley_link, .item.files .cmp_download_link');
  if (!galleyLink) {
    alert('Aucun lien galley trouvé dans la page.');
    alert(getText('no-galley'));
    return;
  }

@@ -928,18 +990,16 @@ function closeModal() {

function initCitationCopy() {
    const els = document.querySelectorAll('.data-citation');
    console.log('[citationCopy] éléments trouvés :', els.length);
 
    els.forEach(function(el) {
        el.addEventListener('click', function() {
            const text = el.innerText.trim();
            console.log('[citationCopy] clic, texte :', text);
 
            function showFeedback() {
                const original = el.innerText;
                el.classList.add('copied');
                el.setAttribute('data-original', original);
                el.innerText = '✓ Copié dans le presse-papier';
                el.innerText = getText('copied');
                setTimeout(function() {
                    el.innerText = el.getAttribute('data-original');
                    el.classList.remove('copied');
@@ -955,7 +1015,6 @@ function initCitationCopy() {
                ta.select();
                try {
                    const ok = document.execCommand('copy');
                    console.log('[citationCopy] execCommand résultat :', ok);
                    if (ok) showFeedback();
                } catch(e) {
                    console.error('[citationCopy] execCommand erreur :', e);
+24 −8
Changes for resources/styles/landingpage.css: 24 added lines, 8 removed lines.
Original line number Diff line number Diff line
@@ -1235,13 +1235,16 @@ body.dark .landingPage div.boxed-text {
    font-size: 1.2rem;
}

.landingPage div.item.galleys {
.landingPage div.item.galleys,
.landingPage div.item.files {
    font-size: 0.75rem;
}
.landingPage div.item.galleys h2 {
.landingPage div.item.galleys h2,
.landingPage div.item.files h2 {
    display: none;
}
.landingPage div.item.galleys ul {
.landingPage div.item.galleys ul,
.landingPage div.item.files ul {
    list-style-type: none;
}

@@ -1584,7 +1587,8 @@ body.dark .obj_article_details .item.abstract p {
    color: var(--dark-text-secondary);
}

.obj_article_details .item.galleys ul.galleys_links {
.obj_article_details .item.galleys ul.galleys_links,
.landingPage .item.galleys ul.galleys_links {
    list-style: none;
    padding: 0;
    margin: 0;
@@ -1593,7 +1597,10 @@ body.dark .obj_article_details .item.abstract p {
    gap: 6px;
}

.obj_article_details .item.galleys a.obj_galley_link {
.obj_article_details .item.galleys a.obj_galley_link,
.landingPage .item.galleys a.obj_galley_link,
.landingPage .item.files a.cmp_download_link,
.landingPage .item.files a.remote_resource {
    display: inline-flex;
    align-items: center;
    justify-content: center;
@@ -1613,17 +1620,26 @@ body.dark .obj_article_details .item.abstract p {
    background: transparent;
}

.obj_article_details .item.galleys a.obj_galley_link:hover {
.obj_article_details .item.galleys a.obj_galley_link:hover,
.landingPage .item.galleys a.obj_galley_link:hover,
.landingPage .item.files a.cmp_download_link:hover,
.landingPage .item.files a.remote_resource:hover {
    background: var(--primary-color);
    color: #fff;
}

body.dark .obj_article_details .item.galleys a.obj_galley_link {
body.dark .obj_article_details .item.galleys a.obj_galley_link,
body.dark .landingPage .item.galleys a.obj_galley_link,
body.dark .landingPage .item.files a.cmp_download_link,
body.dark .landingPage .item.files a.remote_resource {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

body.dark .obj_article_details .item.galleys a.obj_galley_link:hover {
body.dark .obj_article_details .item.galleys a.obj_galley_link:hover,
body.dark .landingPage .item.galleys a.obj_galley_link:hover,
body.dark .landingPage .item.files a.cmp_download_link:hover,
body.dark .landingPage .item.files a.remote_resource:hover {
    background: var(--accent-color);
    color: #fff;
}
+246 −8

File changed.

Preview size limit exceeded, changes collapsed.

+15 −2
Changes for xsl/tei/03-tei2html_core.xsl: 15 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -136,6 +136,9 @@
            <xsl:apply-templates select="//tei:ab[@subtype='HTML']//tei:idno[@type='DOI'][normalize-space() != '']"/>
        </div>
        <div class="filter-bar" id="filter-bar">
            <button id="btn-filter-fulltext" class="active" onclick="showFullText()">
                <span class="trans" data-key="fulltext"/>
            </button>
            <button id="btn-filter-figures" onclick="toggleFiguresFilter()">
                Figures
            </button>
@@ -1076,7 +1079,7 @@
                <p class="orgname"><xsl:value-of select="tei:orgName"/></p>
            </xsl:if>

            <xsl:if test="child::tei:idno[@type]">
            <xsl:if test="child::tei:idno[@type] or self::tei:funder/tei:idno">
                <div class="idno">
                    <xsl:call-template name="idno"/>
                </div>
@@ -1172,10 +1175,20 @@
    </xsl:template>
    
    <xsl:template name="idno">
        <xsl:for-each select="child::tei:idno[@type]">
        <xsl:for-each select="child::tei:idno[@type] | self::tei:funder/tei:idno[not(@type)]">
            <xsl:variable name="idType" select="translate(@type,'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
            <p class="{concat(local-name(.),' ',@type)}">
                <xsl:choose>
                    <xsl:when test="$idType='FUNDER_REGISTRY' and not(@subtype)">
                        <span class="idno">DOI</span>
                    </xsl:when>
                    <xsl:when test="$idType='FUNDER_REGISTRY' or not(@type)">
                        <span class="idno trans" data-key="project-id"/>
                    </xsl:when>
                    <xsl:otherwise>
                        <span class="idno"><xsl:value-of select="@type"/></span>
                    </xsl:otherwise>
                </xsl:choose>
                <span class="idno trans" data-key='colon'/>
                <xsl:variable name="href">
                    <xsl:choose>