Skip to content
Open
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
181 changes: 172 additions & 9 deletions opac/webapp/config/lang_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,15 +194,178 @@
}


LANGS_FALLBACK = {
"pt_BR": {
"de": "Alemão",
"fr": "Francês",
"ru": "Russo",
"zh": "Chinês",
"zh-Hans": "Chinês",
"zh-Hant": "Chinês",
"it": "Italiano",
"en": "Inglês",
"pt": "Português",
"es": "Espanhol",
"af": "Afrikaans", # às vezes "Africâner"
"nso": "Lamnso",
"ar": "Árabe",
"eu": "Basco/Eusquera",
"bg": "Búlgaro",
"ca": "Catalão",
"cs": "Tcheco",
"da": "Dinamarquês",
"nl": "Neerlandês/Holandês",
"eo": "Esperanto",
"gl": "Galego",
"gr": "Grego", # considere usar "el"
"he": "Hebraico",
"hi": "Hindi",
"hu": "Húngaro",
"in": "Indonésio", # considere usar "id"
"ia": "Interlíngua",
"ie": "Interlíngue",
"ja": "Japonês",
"ko": "Coreano",
"la": "Latim",
"no": "Norueguês",
"pl": "Polonês",
"ro": "Romeno",
"sa": "Sânscrito",
"sh": "Servo-croata",
"sk": "Eslovaco",
"sn": "Esloveno",
"sv": "Sueco",
"tr": "Turco",
"uk": "Ucraniano",
"ur": "Urdu",
"zz": "Outro",
# opcionais ISO modernos (espelho de chaves alternativas)
"el": "Grego", # alternativo a "gr"
"id": "Indonésio", # alternativo a "in"
"nb": "Norueguês (Bokmål)",
"nn": "Norueguês (Nynorsk)",
"sr": "Sérvio",
"hr": "Croata",
"bs": "Bósnio",
},
"en": {
"de": "German",
"fr": "French",
"ru": "Russian",
"zh": "Chinese",
"zh-Hans": "Chinese",
"zh-Hant": "Chinese",
"it": "Italian",
"en": "English",
"pt": "Portuguese",
"es": "Spanish",
"af": "Afrikaans",
"nso": "Lamnso",
"ar": "Arabic",
"eu": "Basque",
"bg": "Bulgarian",
"ca": "Catalan",
"cs": "Czech",
"da": "Danish",
"nl": "Dutch",
"eo": "Esperanto",
"gl": "Galician",
"gr": "Greek", # consider "el"
"he": "Hebrew",
"hi": "Hindi",
"hu": "Hungarian",
"in": "Indonesian", # consider "id"
"ia": "Interlingua",
"ie": "Interlingue",
"ja": "Japanese",
"ko": "Korean",
"la": "Latin",
"no": "Norwegian",
"pl": "Polish",
"ro": "Romanian",
"sa": "Sanskrit",
"sh": "Serbo-Croat",
"sk": "Slovak",
"sn": "Slovenian",
"sv": "Swedish",
"tr": "Turkish",
"uk": "Ukrainian",
"ur": "Urdu",
"zz": "Other",
"el": "Greek", # mirror for "gr"
"id": "Indonesian", # mirror for "in"
"nb": "Norwegian (Bokmål)",
"nn": "Norwegian (Nynorsk)",
"sr": "Serbian",
"hr": "Croatian",
"bs": "Bosnian",
},
"es": {
"de": "Alemán",
"fr": "Francés",
"ru": "Ruso",
"zh": "Chino",
"zh-Hans": "Chino",
"zh-Hant": "Chino",
"it": "Italiano",
"en": "Inglés",
"pt": "Portugués",
"es": "Español",
"af": "Afrikaans",
"nso": "Lamnso",
"ar": "Árabe",
"eu": "Vasco/Euskera",
"bg": "Búlgaro",
"ca": "Catalán",
"cs": "Checo",
"da": "Danés",
"nl": "Neerlandés/Holandés",
"eo": "Esperanto",
"gl": "Gallego",
"gr": "Griego", # considere usar "el"
"he": "Hebreo",
"hi": "Hindi",
"hu": "Húngaro",
"in": "Indonesio", # considere "id"
"ia": "Interlingua",
"ie": "Interlingue",
"ja": "Japonés",
"ko": "Coreano",
"la": "Latín",
"no": "Noruego",
"pl": "Polaco",
"ro": "Rumano",
"sa": "Sánscrito",
"sh": "Serbocroata",
"sk": "Eslovaco",
"sn": "Esloveno",
"sv": "Sueco",
"tr": "Turco",
"uk": "Ucraniano",
"ur": "Urdu",
"zz": "Otro",
# espejos ISO modernos
"el": "Griego", # espejo de "gr"
"id": "Indonesio", # espejo de "in"
"nb": "Noruego (Bokmål)",
"nn": "Noruego (Nynorsk)",
"sr": "Serbio",
"hr": "Croata",
"bs": "Bosnio",
},
}


LANGS_FALLBACK_NORMALIZED = {
str(locale).lower(): {str(k).lower(): v for k, v in mapping.items()}
for locale, mapping in LANGS_FALLBACK.items()
}

def get_original_lang_name(code):
return LANG_NAMES.get(code, (None, code))[0]


def display_original_lang_name(code):
name = get_original_lang_name(code)
if name is None:
return code
name = name.capitalize()
if "," in name:
return name.split(",")[0]
return name
def display_lang_name_fallback(locale, code):
locale_key = str(locale).lower() if locale is not None else ""
code_key = str(code).lower() if code is not None else ""
lang = LANGS_FALLBACK_NORMALIZED.get(locale_key, {}).get(code_key)
return lang or code
6 changes: 6 additions & 0 deletions opac/webapp/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1748,6 +1748,12 @@ def get_page_by_slug_name(slug_name, lang=None, is_draft=False):
return Pages.objects(language=lang, slug_name=slug_name, is_draft=is_draft).first()


def get_page_about_root(lang, is_draft=False):
return Pages.objects(language=lang, journal="", is_draft=is_draft, parent_page=None, page_type__ne="free")

def get_free_page_by_slug(slug, lang, is_draft=False):
return Pages.objects(slug_name=slug, is_draft=is_draft, page_type="free", language=lang).first()

def related_links(article):
expr = []
if article.title or article.section:
Expand Down
47 changes: 32 additions & 15 deletions opac/webapp/main/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
from webapp import babel, cache, controllers, forms
from webapp.choices import STUDY_AREAS
from webapp.controllers import create_press_release_record
from webapp.config.lang_names import display_original_lang_name
from webapp.config.lang_names import display_lang_name_fallback
from webapp.utils import utils
from webapp.utils.caching import cache_key_with_lang, cache_key_with_lang_with_qs
from webapp.main.errors import page_not_found, internal_server_error
Expand Down Expand Up @@ -323,28 +323,44 @@ def collection_list_feed():
return feed.get_response()



@main.route("/about/<path:slug_name>", methods=["GET"])
def page_about_detail(slug_name):
language = session.get("lang", get_locale())
page = controllers.get_page_by_slug_name(slug_name, lang=language, is_draft=False)

if not page:
abort(404, _("Página não encontrada"))
breadcrumbs = utils.build_breadcrumbs(page)
context = {
"breadcrumbs": breadcrumbs,
Comment on lines +334 to +336
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

children = page.get_children() é colocado no contexto, mas não é usado no template collection/about_detail.html. Isso pode gerar trabalho/query desnecessário. Remova children do view ou passe a usar esse valor no template em vez de chamar métodos do modelo repetidamente.

Copilot uses AI. Check for mistakes.
"page": page,
}
return render_template("collection/about_detail.html", **context)
Comment on lines +327 to +339
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description mentions adding new fields to the Pages admin form (parent/child navigation), but this diff doesn't include any changes under opac/webapp/admin/ or the admin templates to expose those fields. If the form changes are required for this feature, they seem to be missing from the PR; otherwise, the PR description should be updated to match what’s actually shipped.

Copilot uses AI. Check for mistakes.


@main.route("/about/", methods=["GET"])
@main.route("/about/<string:slug_name>", methods=["GET"])
@cache.cached(key_prefix=cache_key_with_lang_with_qs)
def about_collection(slug_name=None):
def about_collection():
Comment on lines 342 to +344
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ao remover a rota /about/<slug_name> do endpoint about_collection (agora só /about/), chamadas existentes como url_for('main.about_collection', slug_name=...) deixam de funcionar (há testes e possivelmente links externos usando isso). Considere manter compatibilidade (rota antiga com redirect para page_about_detail) ou atualizar todas as referências.

Copilot uses AI. Check for mistakes.
language = session.get("lang", get_locale())

context = {}
page = None
if slug_name:
# caso seja uma página
page = controllers.get_page_by_slug_name(slug_name, language)
if not page:
abort(404, _("Página não encontrada"))
context["page"] = page
else:
# caso não seja uma página é uma lista
pages = controllers.get_pages_by_lang(language)
context["pages"] = pages
pages = controllers.get_page_about_root(language)

context["pages"] = pages.order_by("order")
return render_template("collection/about.html", **context)
Comment on lines 342 to 351
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

about_collection() now always renders the list view (it no longer accepts a slug_name and never provides page in the template context). However, collection/about.html still contains a full {% if page %} rendering branch, which is now unreachable and can cause confusion during future changes. Consider removing the unused template branch or reintroducing page rendering via a dedicated route/template (as done for page_about_detail).

Copilot uses AI. Check for mistakes.


@main.route("/free/<string:slug_name>", methods=["GET"])
def free_page(slug_name):
language = session.get("lang", get_locale())
page = controllers.get_free_page_by_slug(slug_name, lang=language, is_draft=False)

Comment on lines +354 to +358
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A chamada controllers.get_free_page_by_slug(..., is_draft=False) vai falhar porque o controller não aceita o parâmetro is_draft. Alinhe a assinatura do controller com o uso aqui (ou remova o argumento) e garanta que a função retorne uma única página.

Copilot uses AI. Check for mistakes.
if not page:
abort(404, _("Página não encontrada"))

return render_template("collection/about_detail.html", page=page)

# ###################################Journal#####################################


Expand Down Expand Up @@ -1281,12 +1297,13 @@ def _handle_html():
logger.exception(exc)

abort(500, _("Erro inesperado"))
language = session.get("lang", get_locale())

text_versions = sorted(
[
(
lang,
display_original_lang_name(lang),
display_lang_name_fallback(locale=language, code=lang),
url_for(
"main.article_detail_v3",
url_seg=article.journal.url_segment,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
{% elif abstract['language'] == 'pt' %}
(PT)
{% else %}
{{ abstract['language'] }}
({{ abstract['language']|upper }})
{% endif %}
{% endif %}
{% endfor %}
Expand Down
2 changes: 1 addition & 1 deletion opac/webapp/templates/article/includes/levelMenu_pdf.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
{% elif pdf.lang == 'pt' %}
{% trans %}Download PDF (Português){% endtrans %}
{% else %}
{{ pdf.lang }}
Download PDF ({{ pdf.lang }})
{% endif %}
</a>
</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
{% elif lang == 'pt' %}
(PT)
{% else %}
({{ text_lang }})
({{ text_lang|upper }})
{% endif %}
{% endif %}
{% endfor %}
Expand Down
46 changes: 4 additions & 42 deletions opac/webapp/templates/collection/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,59 +6,21 @@

<section class="collection collectionAbout">
<div class="container">

{% if pages %}

<div class="row">
<div class="col">

<h1 class="h4 pt-1 mb-4"> {% trans %}Sobre o SciELO{% endtrans %} {{ coll_macro.get_collection_name() }}</h1>

<div class="about">
<ul class="networkList">

{% for page in pages %}
<a href="/about/{{ page.slug_name }}">
<li>
{% trans %} {{ page }} {% endtrans %}
</li>
</a>
{% endfor %}

</ul>
{% set nodes = pages %}
{% set ul_class = "networkList" %}
{% include "collection/includes/_page_tree.html" %}
</div>
</div>
</div>

{% endif %}

{% if page %}
<div class="row">
<div class="col-12">
<h1 class="h4">{{ page }}</h1>

{%- if page.content -%}
{{ page.content|safe }}
{%- else -%}
{% trans %} Conteúdo não cadastrado {% endtrans %}
{%- endif -%}
</div>
</div>

{% with page_updated_at=page.updated_at %}
<div class="row">
<div class="col">
{% include "includes/page_updated_at_info.html" %}
</div>
</div>
{% endwith %}

{% endif %}

{% if page %}

{% endif %}

{% endif %}
</div>
</section>

Expand Down
Loading
Loading