Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Incluída verificação se existem press releases últimos 60 dias #160

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions opac/webapp/static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1215,6 +1215,57 @@ var Portal = {
$(".namePlublisher").attr( "data-toggle", "tooltip" );
$(".namePlublisher").attr( "title", nome );
}
},
checkPressReleases: function() {
// Obtém o valor de data-lastdays, que é o numero de dias que serão
// reduzidos da data atual para verificar se existem press-releases recentes
var lastDays = parseInt($('#pressReleasesList').attr('data-lastdays')); // Substitua '#data-attributes' pelo seletor correto do seu elemento

// Obtém a data atual
var dataAtual = new Date();

// Verifica se lastDays é um número válido
if (isNaN(lastDays) || lastDays <= 0) {
console.error('O valor de lastDays deve ser um número positivo.');
return; // Interrompe a execução se lastDays não for válido
}

// Cria uma nova data que representa 60 dias atrás
var dataMenosXDias = new Date();
dataMenosXDias.setDate(dataAtual.getDate() - lastDays);

// Verifica se dataMenosXDias é uma data válida
if (isNaN(dataMenosXDias.getTime())) {
console.error('Data inválida ao calcular a data de ' + lastDays + ' dias atrás.');
return; // Interrompe a execução se a data não for válida
}

// Exibe a data calculada no console para depuração
//console.log('Data ' + lastDays + ' dias atrás:', dataMenosXDias.toString());

// Verifica cada card com o atributo data-publication-date
var algumRecente = false;
$('#pressReleasesList .card').each(function() {
var dataPublicacaoStr = $(this).attr('data-publication-date');
var dataPublicacao = new Date(dataPublicacaoStr);

// Verifica se dataPublicacao é uma data válida
if (isNaN(dataPublicacao.getTime())) {
console.error('Data inválida encontrada em data-publication-date:', dataPublicacaoStr);
return;
}

if (dataPublicacao >= dataMenosXDias) {
algumRecente = true;
return false; // Para a iteração assim que encontrar um card recente
}
});

// Exibe ou mantém oculta a lista de press-releases baseado na verificação anterior
if (algumRecente) {
$('#pressReleasesList').removeClass('d-none'); // Exibe a lista de press-releases
}

}
};

Expand Down Expand Up @@ -1281,6 +1332,7 @@ $(function() {

if($("body.journal").length)
Journal.Init();
Journal.checkPressReleases();

if($("body.collection, body.portal").length)
Collection.Init();
Expand Down
2 changes: 1 addition & 1 deletion opac/webapp/static/js/scielo-bundle-min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion opac/webapp/static/maps/scielo-bundle-min.js.map

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,19 @@

{% if session.lang %}

<!--
<strong class="card-title">
{{ article.get_title_by_lang(session.lang[:2])|default(_('Documento sem título'), true)|striptags|truncate(80)|capitalize }}
</strong>
-->

<strong class="card-title">
{{ article.get_title_by_lang(session.lang[:2])|default(_('Documento sem título'), true)|striptags|capitalize }}
</strong>

{% endif %}

<a href="{{ url_for('.article_detail_v3', url_seg=article.journal.url_segment, article_pid_v3=article.aid) }}" target="_blank" class="btn btn-secondary d-block mb-0">{% trans%}Continue lendo{% endtrans %}</a>
<a href="{{ url_for('.article_detail_v3', url_seg=article.journal.url_segment, article_pid_v3=article.aid) }}" target="_blank" class="btn btn-secondary d-block mb-0 mt-4">{% trans%}Continue lendo{% endtrans %}</a>
</div>

</div>
21 changes: 1 addition & 20 deletions opac/webapp/templates/journal/detail.html
Original file line number Diff line number Diff line change
@@ -1,22 +1,3 @@
<style>
body{
/*padding-top: 74px;*/
}
.slick-slide{
height: auto !important;
}
.slick-dots li{
margin-top: 8px !important;
}

.card{
width: 346px;
}
.press-releases-cards .card-body{
min-height: 180px;
}
</style>

{% extends "journal/base.html" %}

{% block main_content %}
Expand Down Expand Up @@ -119,7 +100,7 @@ <h3>{% trans %}Sumário{% endtrans %}</h3>
<!-- press releases --->
{# press_releases #}
{% if press_releases %}
<section class="journalContent mb-5 press-releases-cards">
<section id="pressReleasesList" class="journalContent mb-5 press-releases-cards d-none" data-lastdays="909">
<div class="container">
<div class="row">
<div class="col">
Expand Down
2 changes: 1 addition & 1 deletion opac/webapp/templates/journal/includes/journal_info.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ <h1 class="h4" style="margin: 1rem auto">
<!-- Fim - Se houver um outro título antigo-->
</div>
<div class="col-3 pt-5">
<div class="list-group d-print-none">
<div class="list-group d-print-none mb-5">
{% if journal.online_submission_url and journal.current_status == 'current' %}
<a class="list-group-item" href="{{ journal.online_submission_url|default('', true) }}" target="_blank"><span class="material-icons-outlined">launch</span> {% trans %}Submissão de manuscritos{% endtrans %}</a>
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion opac/webapp/templates/journal/includes/levelMenu.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
</div>
<div class="col-md-3 col-sm-3 text-end">
<div class="btn-group" role="group" aria-label="Basic example">
<a href="{{ config.URL_SEARCH }}?q=*&lang={% if session.lang %}{{ session.lang[:2] }}{% endif %}&filter[journal_title][]={% if journal.title %}{{ journal.title }}{% endif %}" class="btn single"><span class="glyphBtn search"></span> {% trans %}buscar{% endtrans %}</a>
<a href="{{ config.URL_SEARCH }}?q=*&lang={% if session.lang %}{{ session.lang[:2] }}{% endif %}&filter[journal_title][]={% if journal.title %}{{ journal.title }}{% endif %}" class="btn single"><span class="glyphBtn search"></span> {% trans %}Buscar{% endtrans %}</a>

{% if journal.scielo_issn or journal.eletronic_issn or journal.print_issn %}
<a target="_blank" href="{{ config.METRICS_URL }}/?journal={{ journal.scielo_issn or journal.eletronic_issn or journal.print_issn }}&collection={{ config.OPAC_COLLECTION }}" class="btn scielo__btn-with-icon--left"><span class="material-icons-outlined">show_chart</span> {% trans %}Métricas{% endtrans %}</a>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="card">
<div class="card" data-publication-date="{{ press_release.publication_date }}">

{% if press_release.image_url %}

Expand All @@ -18,7 +18,7 @@
{{ press_release.title|striptags }}
</strong>

<a href="{{ press_release.url }}" target="_blank" class="btn btn-secondary d-block mb-0">{% trans%}Continue lendo{% endtrans %}</a>
<a href="{{ press_release.url }}" target="_blank" class="btn btn-secondary d-block mb-0 mt-4">{% trans%}Continue lendo{% endtrans %}</a>

</div>

Expand Down