Commit d821c915 authored by Bourdot's avatar Bourdot
Browse files

Landing page OMP alignée sur OJS

parent 1dd6d5b2
Loading
Loading
Loading
Loading
+24 −13
Changes for XML2HTMLPlugin.php: 24 added lines, 13 removed lines.
Original line number Diff line number Diff line
@@ -118,19 +118,7 @@ class XML2HTMLPlugin extends GenericPlugin
        if (!$templateMgr->getTemplateVars('hasAccess')) {
            return false;
        }
        // read by the bibliometrics filter of xml_2_html.js, only for the roles allowed by the stats API
        $user = $request->getUser();
        if ($user && (
            $user->hasRole([Role::ROLE_ID_MANAGER, Role::ROLE_ID_SUB_EDITOR], $request->getContext()->getId())
            || $user->hasRole([Role::ROLE_ID_SITE_ADMIN], Application::SITE_CONTEXT_ID)
        )) {
            $templateMgr->assign('statsApiUrl', $request->getDispatcher()->url(
                $request,
                Application::ROUTE_API,
                $request->getContext()->getPath(),
                'stats/publications/' . $submission->getId()
            ));
        }
        $this->assignStatsApiUrl($request, $submission);

        try {
            foreach ($publication->getData('galleys') ?? [] as $galley) {
@@ -171,6 +159,7 @@ class XML2HTMLPlugin extends GenericPlugin
            if (!$submissionFile || !BookUtils::userCanReadBookFile($request, $submission, $submissionFile)) {
                return false;
            }
            $this->assignStatsApiUrl($request, $submission);

            $this->landingPageView(
                $submissionFile->getData('path'),
@@ -189,6 +178,25 @@ class XML2HTMLPlugin extends GenericPlugin
        }
    }

    /**
     * @brief URL read by the bibliometrics filter of xml_2_html.js, only for the roles allowed by the stats API
     */
    private function assignStatsApiUrl($request, $submission): void
    {
        $user = $request->getUser();
        if ($user && (
            $user->hasRole([Role::ROLE_ID_MANAGER, Role::ROLE_ID_SUB_EDITOR], $request->getContext()->getId())
            || $user->hasRole([Role::ROLE_ID_SITE_ADMIN], Application::SITE_CONTEXT_ID)
        )) {
            TemplateManager::getManager($request)->assign('statsApiUrl', $request->getDispatcher()->url(
                $request,
                Application::ROUTE_API,
                $request->getContext()->getPath(),
                'stats/publications/' . $submission->getId()
            ));
        }
    }

    private function getBookFullTextFile($publication, $chapter)
    {
        // only the files of the displayed publication
@@ -654,6 +662,9 @@ class XML2HTMLPlugin extends GenericPlugin
        $proc = new XSLTProcessor();
        $proc->importStyleSheet($xsl);
        $proc->setParameter('', 'lang', Locale::getLocale());
        $application = Application::get();
        $version = $application->getCurrentVersion();
        $proc->setParameter('', 'application', ($application->getName() === 'omp' ? 'OMP' : 'OJS') . ' ' . $version->getMajor() . '.' . $version->getMinor());
        return $proc->transformToXML($xml);
    }

+7 −0
Changes for resources/javascript/xml_2_html.js: 7 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -618,6 +618,13 @@ function hideHtmlDownloadLinks() {
            wrapper.style.display = 'none';
        }
    });
    // a downloads block left without any visible link is hidden with its title
    document.querySelectorAll('.item.galleys, .item.files').forEach(function (item) {
        const hasVisibleLink = [...item.querySelectorAll('a')].some((a) => a.offsetParent !== null);
        if (!hasVisibleLink) {
            item.style.display = 'none';
        }
    });
}


+61 −36
Changes for resources/styles/landingpage.css: 61 added lines, 36 removed lines.
Original line number Diff line number Diff line
@@ -162,6 +162,7 @@ body.dark .landingPage #moon:hover {
}

.obj_article_details,
.obj_monograph_full,
.landingPage {

    margin: 0;
@@ -1484,14 +1485,16 @@ body.dark .obj_article_details h1.page_title {
    border-bottom-color: var(--dark-border);
}

.obj_article_details .row {
.obj_article_details .row,
.obj_monograph_full .row {
    display: flex;
    gap: var(--spacing-xl);
    align-items: flex-start;
    padding-bottom: var(--spacing-xl);
}

.obj_article_details .main_entry {
.obj_article_details .main_entry,
.obj_monograph_full .main_entry {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
@@ -1510,11 +1513,13 @@ body.dark .obj_article_details h1.page_title {

.pkp_structure_main,
.pkp_structure_content,
.page.page_article {
.page.page_article,
.page.page_book {
    max-width: none !important;
}

.obj_article_details,
.obj_monograph_full,
.landingPage {
    max-width: var(--max-content-width) !important;
}
@@ -1540,7 +1545,7 @@ body.dark .obj_article_details .entry_details {
    background: none;
}

.obj_article_details h2.pkp_screen_reader {
.pkp_screen_reader {
    position: absolute;
    width: 1px;
    height: 1px;
@@ -1654,17 +1659,20 @@ body.dark .obj_article_details .item.issue .value {
    color: var(--dark-text-secondary);
}

.obj_article_details {
.obj_article_details,
.obj_monograph_full {
    border-bottom: 2px solid #718EAC;
}

@media (max-width: 768px) {
    .obj_article_details .row {
    .obj_article_details .row,
    .obj_monograph_full .row {
        flex-direction: column;
        gap: var(--spacing-lg);
    }

    .obj_article_details .main_entry {
    .obj_article_details .main_entry,
    .obj_monograph_full .main_entry {
        padding-right: 0;
    }

@@ -2017,9 +2025,9 @@ div[id*="figures"] figure figcaption {
}


/* Landing page : colonne de détails OJS (couverture, galleys, numéro…)
/* Landing page : colonne de détails OJS/OMP (couverture, galleys ou fichiers, numéro ou collection…)
   - métadonnées source : .landing_entry_details, placé à droite de la page de titre
   - métadonnées OJS : .entry_details de article_details.tpl */
   - métadonnées OJS/OMP : .entry_details de article_details.tpl, monograph_full.tpl et chapter.tpl */

.landingPage .landing_header {
    display: flex;
@@ -2033,7 +2041,7 @@ div[id*="figures"] figure figcaption {
    min-width: 0;
}

:is(.landingPage .landing_entry_details, .obj_article_details .entry_details) {
:is(.landingPage .landing_entry_details, .obj_article_details .entry_details, .obj_monograph_full .entry_details) {
    flex: 0 0 280px;
    min-width: 0;
    max-width: 280px;
@@ -2044,20 +2052,21 @@ div[id*="figures"] figure figcaption {
    line-height: 1.5;
}

.obj_article_details .entry_details {
.obj_article_details .entry_details,
.obj_monograph_full .entry_details {
    display: block;
    border-left: 1px solid #ddd !important;
}

:is(.landingPage .landing_entry_details, .obj_article_details .entry_details) .item {
:is(.landingPage .landing_entry_details, .obj_article_details .entry_details, .obj_monograph_full .entry_details) .item {
    padding: 1.5rem 0 1.5rem 2rem;
}

:is(.landingPage .landing_entry_details, .obj_article_details .entry_details) .item + .item {
:is(.landingPage .landing_entry_details, .obj_article_details .entry_details, .obj_monograph_full .entry_details) .item + .item {
    border-top: 1px solid #ddd;
}

:is(.landingPage .landing_entry_details, .obj_article_details .entry_details) .cover_image img {
:is(.landingPage .landing_entry_details, .obj_article_details .entry_details, .obj_monograph_full .entry_details) :is(.cover_image, .cover) img {
    display: block;
    width: 100%;
    height: auto;
@@ -2067,11 +2076,27 @@ div[id*="figures"] figure figcaption {
    box-shadow: none;
}

:is(.landingPage .landing_entry_details, .obj_article_details .entry_details) .item.galleys {
:is(.landingPage .landing_entry_details, .obj_article_details .entry_details, .obj_monograph_full .entry_details) :is(.item.galleys, .item.files) {
    font-size: 1rem;
}

:is(.landingPage .landing_entry_details, .obj_article_details .entry_details) .item.galleys ul {
:is(.landingPage .landing_entry_details, .obj_article_details .entry_details, .obj_monograph_full .entry_details) .item.files [class*="pub_format_"] + [class*="pub_format_"] {
    margin-top: 0.75rem;
}

:is(.landingPage .landing_entry_details, .obj_article_details .entry_details, .obj_monograph_full .entry_details) .item.files .label {
    display: block;
    margin-bottom: 0.25rem;
    color: #757575;
}

:is(.landingPage .landing_entry_details, .obj_article_details .entry_details, .obj_monograph_full .entry_details) .item.files ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

:is(.landingPage .landing_entry_details, .obj_article_details .entry_details, .obj_monograph_full .entry_details) .item.galleys ul {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
@@ -2081,12 +2106,12 @@ div[id*="figures"] figure figcaption {
    list-style: none;
}

:is(.landingPage .landing_entry_details, .obj_article_details .entry_details) .item.galleys li {
:is(.landingPage .landing_entry_details, .obj_article_details .entry_details, .obj_monograph_full .entry_details) .item.galleys li {
    margin: 0;
    padding: 0;
}

:is(.landingPage .landing_entry_details, .obj_article_details .entry_details) .item.galleys a.obj_galley_link {
:is(.landingPage .landing_entry_details, .obj_article_details .entry_details, .obj_monograph_full .entry_details) :is(.item.galleys a.obj_galley_link, .item.files a.cmp_download_link, .item.files a.remote_resource) {
    display: inline-flex;
    align-items: center;
    gap: 0.4em;
@@ -2105,7 +2130,7 @@ div[id*="figures"] figure figcaption {
    line-height: 1.6;
}

:is(.landingPage .landing_entry_details, .obj_article_details .entry_details) .item.galleys a.obj_galley_link::before {
:is(.landingPage .landing_entry_details, .obj_article_details .entry_details, .obj_monograph_full .entry_details) :is(.item.galleys a.obj_galley_link, .item.files a.cmp_download_link, .item.files a.remote_resource)::before {
    content: "";
    flex: none;
    width: 1em;
@@ -2115,17 +2140,17 @@ div[id*="figures"] figure figcaption {
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.6' stroke-linejoin='round'%3E%3Cpath d='M6 2.5h8l4.5 4.5v14.5H6z'/%3E%3Cpath d='M14 2.5V7h4.5M9 11h6M9 14h6M9 17h6'/%3E%3C/svg%3E") center / contain no-repeat;
}

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

:is(.landingPage .landing_entry_details, .obj_article_details .entry_details) .sub_item + .sub_item {
:is(.landingPage .landing_entry_details, .obj_article_details .entry_details, .obj_monograph_full .entry_details) .sub_item + .sub_item {
    margin-top: 1.5rem;
}

:is(.landingPage .landing_entry_details, .obj_article_details .entry_details) :is(.item, .sub_item) > h2.label {
:is(.landingPage .landing_entry_details, .obj_article_details .entry_details, .obj_monograph_full .entry_details) :is(.item, .sub_item) > h2.label {
    margin: 0 0 0.25rem;
    padding: 0;
    border: none;
@@ -2138,42 +2163,42 @@ div[id*="figures"] figure figcaption {
    color: #757575;
}

:is(.landingPage .landing_entry_details, .obj_article_details .entry_details) .item .value {
:is(.landingPage .landing_entry_details, .obj_article_details .entry_details, .obj_monograph_full .entry_details) .item .value {
    font-size: 1rem;
    color: var(--text-primary, #1e293b);
}

:is(.landingPage .landing_entry_details, .obj_article_details .entry_details) .item .value a {
:is(.landingPage .landing_entry_details, .obj_article_details .entry_details, .obj_monograph_full .entry_details) .item .value a {
    color: var(--primary-color, #006798);
    text-decoration: underline;
}

body.dark :is(.landingPage .landing_entry_details, .obj_article_details .entry_details),
body.dark :is(.landingPage .landing_entry_details, .obj_article_details .entry_details) .item + .item {
body.dark :is(.landingPage .landing_entry_details, .obj_article_details .entry_details, .obj_monograph_full .entry_details),
body.dark :is(.landingPage .landing_entry_details, .obj_article_details .entry_details, .obj_monograph_full .entry_details) .item + .item {
    border-color: var(--dark-border, #334155) !important;
}

body.dark :is(.landingPage .landing_entry_details, .obj_article_details .entry_details) .item.galleys a.obj_galley_link {
body.dark :is(.landingPage .landing_entry_details, .obj_article_details .entry_details, .obj_monograph_full .entry_details) :is(.item.galleys a.obj_galley_link, .item.files a.cmp_download_link, .item.files a.remote_resource) {
    border-color: var(--accent-color, #0ea5e9);
    background: transparent;
    color: var(--accent-color, #0ea5e9);
}

body.dark :is(.landingPage .landing_entry_details, .obj_article_details .entry_details) .item.galleys a.obj_galley_link:hover,
body.dark :is(.landingPage .landing_entry_details, .obj_article_details .entry_details) .item.galleys a.obj_galley_link:focus {
body.dark :is(.landingPage .landing_entry_details, .obj_article_details .entry_details, .obj_monograph_full .entry_details) :is(.item.galleys a.obj_galley_link, .item.files a.cmp_download_link, .item.files a.remote_resource):hover,
body.dark :is(.landingPage .landing_entry_details, .obj_article_details .entry_details, .obj_monograph_full .entry_details) :is(.item.galleys a.obj_galley_link, .item.files a.cmp_download_link, .item.files a.remote_resource):focus {
    background: var(--accent-color, #0ea5e9);
    color: #fff;
}

body.dark :is(.landingPage .landing_entry_details, .obj_article_details .entry_details) :is(.item, .sub_item) > h2.label {
body.dark :is(.landingPage .landing_entry_details, .obj_article_details .entry_details, .obj_monograph_full .entry_details) :is(.item, .sub_item) > h2.label {
    color: var(--dark-text-secondary, #cbd5e1);
}

body.dark :is(.landingPage .landing_entry_details, .obj_article_details .entry_details) .item .value {
body.dark :is(.landingPage .landing_entry_details, .obj_article_details .entry_details, .obj_monograph_full .entry_details) .item .value {
    color: var(--dark-text-primary, #e2e8f0);
}

body.dark :is(.landingPage .landing_entry_details, .obj_article_details .entry_details) .item .value a {
body.dark :is(.landingPage .landing_entry_details, .obj_article_details .entry_details, .obj_monograph_full .entry_details) .item .value a {
    color: var(--accent-color, #0ea5e9);
}

@@ -2184,7 +2209,7 @@ body.dark :is(.landingPage .landing_entry_details, .obj_article_details .entry_d
        gap: 0;
    }

    :is(.landingPage .landing_entry_details, .obj_article_details .entry_details) {
    :is(.landingPage .landing_entry_details, .obj_article_details .entry_details, .obj_monograph_full .entry_details) {
        flex: none;
        width: 100%;
        max-width: none;
@@ -2192,11 +2217,11 @@ body.dark :is(.landingPage .landing_entry_details, .obj_article_details .entry_d
        border-top: 1px solid #ddd;
    }

    :is(.landingPage .landing_entry_details, .obj_article_details .entry_details) .item {
    :is(.landingPage .landing_entry_details, .obj_article_details .entry_details, .obj_monograph_full .entry_details) .item {
        padding-left: 0;
    }

    :is(.landingPage .landing_entry_details, .obj_article_details .entry_details) .cover_image img {
    :is(.landingPage .landing_entry_details, .obj_article_details .entry_details, .obj_monograph_full .entry_details) :is(.cover_image, .cover) img {
        width: 160px;
    }
}
+97 −0
Changes for templates/LandingPageBook.tpl: 97 added lines, 0 removed lines.
Original line number Diff line number Diff line
{**
 * plugins/generic/xml2html/templates/LandingPageBook.tpl
 *
 * Book or chapter landing page with the full text rendered from the XML zip publication format file.
 * Adapted from templates/frontend/pages/book.tpl, aligned on LandingPage.tpl.
 *
 * @uses $metadataSource string 'tei' to replace OMP metadata by the source's, keeping the publication formats
 * @uses $text string HTML rendering of the publication format file
 * @uses $assetsPath string URL of the plugin's resources directory
 * @uses $cssLandingPageUrl string|null URL of the press's custom CSS
 * @uses $sourceTitle string title of the source when $metadataSource is 'tei', empty otherwise
 *
 * @hook Templates::Catalog::Book::Footer::PageFooter []
 *}
{if $isChapterRequest}
    {assign var=pageTitle value=$chapter->getLocalizedFullTitle()}
{else}
@@ -15,6 +29,7 @@
	</title>
	{capture assign="frontendHeader"}{load_header context="frontend"}{/capture}
	{$frontendHeader|xml2html_source_metas}
	<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/github-dark.min.css">
	{if $loadThemeStyles}
		{load_stylesheet context="frontend"}
	{/if}
@@ -26,9 +41,20 @@
</head>
<body class="pkp_page_{$requestedPage|escape|default:"index"} pkp_op_{$requestedOp|escape|default:"index"}" dir="{$currentLocaleLangDir|escape|default:"ltr"}">


<header class="pkp_structure_head" id="headerNavigationContainer" role="banner">
			<div class="pkp_head_wrapper">

				<div class="pkp_site_name_wrapper">
					{if !$requestedPage || $requestedPage === 'index'}
						<h1 class="pkp_screen_reader">
							{if $currentContext}
								{$displayPageHeaderTitle|escape}
							{else}
								{$siteTitle|escape}
							{/if}
						</h1>
					{/if}
					<div class="pkp_site_name">
					{capture assign="homeUrl"}
						{url page="index" router=$smarty.const.ROUTE_PAGE}
@@ -46,6 +72,7 @@
					{/if}
					</div>
				</div>

				<nav class="landing_head_tools" aria-label="{translate|escape key="common.navigation.user"}">
					{if $currentContext && $requestedPage !== 'search'}
						<a href="{url page="search"}" class="landing_search">
@@ -58,6 +85,12 @@
			</div>
		</header>

    {if $series}
    {include file="frontend/components/breadcrumbs_catalog.tpl" type="series" parent=$series currentTitle=$pageTitle|strip_tags}
    {else}
    {include file="frontend/components/breadcrumbs_catalog.tpl" currentTitle=$pageTitle|strip_tags}
    {/if}

<div class="page page_book">
    {if $metadataSource != 'tei'}
        {if $isChapterRequest}
@@ -68,14 +101,34 @@
    {/if}
    <script>
        let lang = "{$currentLocale|escape:"javascript"}";
        let statsApiUrl = "{$statsApiUrl|escape:"javascript"}";
    </script>
    <script src="{$assetsPath}javascript/xml_2_html.js">
    </script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
    <script>hljs.highlightAll();</script>
    <script id="MathJax-script" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js">
    </script>



    <div class="landingPage {if $metadataSource == 'tei'}metadata_tei{else}metadata_pkp{/if}">
        {if $metadataSource == 'tei'}
            {if $publication->getId() === $currentPublication->getId()}
                {capture assign="bookUrl"}{url page="catalog" op="book" path=$publishedSubmission->getBestId()}{/capture}
            {else}
                {capture assign="bookUrl"}{url page="catalog" op="book" path=$publishedSubmission->getBestId()|to_array:"version":$publication->getId()}{/capture}
            {/if}
            <div class="landing_entry_details">
                <div class="item cover_image">
                    {assign var="coverImage" value=$publication->getLocalizedData('coverImage')}
                    {if $isChapterRequest}<a href="{$bookUrl}">{/if}
                        <img
                            src="{$publication->getLocalizedCoverImageUrl($publishedSubmission->getData('contextId'))|escape}"
                            alt="{$coverImage.altText|escape|default:''}"
                        >
                    {if $isChapterRequest}</a>{/if}
                </div>
                {if $isChapterRequest}
                    {pluck_files assign=publicationFiles files=$availableFiles by="chapter" value=$chapter->getId()}
                {else}
@@ -87,10 +140,54 @@
                        {include file="frontend/components/publicationFormats.tpl" monograph=$publishedSubmission publicationFiles=$publicationFiles}
                    </div>
                {/if}
                {if $isChapterRequest || $series || $categories}
                    <div class="item issue">
                        {if $isChapterRequest}
                            <section class="sub_item">
                                <h2 class="label">{translate key="chapter.volume"}</h2>
                                <div class="value">
                                    <a class="title" href="{$bookUrl}">
                                        {$publication->getLocalizedFullTitle(null, 'html')|strip_unsafe_html}
                                    </a>
                                </div>
                            </section>
                            {if $chapter->getPages()}
                                <section class="sub_item">
                                    <h2 class="label">{translate key="chapter.pages"}</h2>
                                    <div class="value">{$chapter->getPages()|escape}</div>
                                </section>
                            {/if}
                        {/if}
                        {if $series}
                            <section class="sub_item">
                                <h2 class="label">{translate key="series.series"}</h2>
                                <div class="value">
                                    <a class="title" href="{url page="catalog" op="series" path=$series->getPath()}">
                                        {$series->getLocalizedFullTitle()|escape}
                                    </a>
                                </div>
                            </section>
                        {/if}
                        {if !$isChapterRequest && $categories}
                            <section class="sub_item">
                                <h2 class="label">{translate key="catalog.categories"}</h2>
                                <div class="value">
                                    {foreach from=$categories item="category" name="categories"}
                                        <a href="{url page="catalog" op="category" path=$category->getPath()}">{$category->getLocalizedTitle()|strip_unsafe_html}</a>{if !$smarty.foreach.categories.last}, {/if}
                                    {/foreach}
                                </div>
                            </section>
                        {/if}
                    </div>
                {/if}
            </div>
        {/if}
        {$text}
    </div>
        {call_hook name="Templates::Catalog::Book::Footer::PageFooter"}

    </div>
    <!-- .page -->


    {include file=$footerTemplate}
+3 −1
Changes for xsl/jats/jats-metas2html.xsl: 3 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -13,6 +13,8 @@

    <!-- locale OJS/OMP (fr_FR, en…) passée par XML2HTMLPlugin::transformMetas() -->
    <xsl:param name="lang" select="''"/>
    <!-- application et version (OJS 3.5, OMP 3.5…) passées par XML2HTMLPlugin::transformMetas() -->
    <xsl:param name="application" select="'OJS 3.5'"/>
    <xsl:variable name="uiLang" select="substring-before(concat(translate($lang, '-', '_'), '_'), '_')"/>

    <xsl:variable name="journal" select="/article/front/journal-meta"/>
@@ -29,7 +31,7 @@

    <xsl:template match="/">
        <metas>
            <meta name="generator" content="Métopes, OJS 3.5"/>
            <meta name="generator" content="Métopes, {$application}"/>
            <xsl:call-template name="meta">
                <xsl:with-param name="names" select="'citation_journal_title'"/>
                <xsl:with-param name="content" select="($journal/journal-title-group/journal-title | $journal/journal-title)[1]"/>
Loading