diff --git a/spsvalidator/packaging/build_linux.sh b/spsvalidator/packaging/build_linux.sh index 2b4a38f..808554c 100644 --- a/spsvalidator/packaging/build_linux.sh +++ b/spsvalidator/packaging/build_linux.sh @@ -7,6 +7,7 @@ cd "$ROOT_DIR" python -m pip install -e ".[dev]" python -m pip install pyinstaller pybabel compile -d src/spsvalidator/translations +bash packaging/generate_build_info.sh pyinstaller --noconfirm --windowed \ --name spsvalidator \ --icon src/spsvalidator/web/static/img/icon.png \ diff --git a/spsvalidator/packaging/build_windows.ps1 b/spsvalidator/packaging/build_windows.ps1 index 19ea96e..7c52171 100644 --- a/spsvalidator/packaging/build_windows.ps1 +++ b/spsvalidator/packaging/build_windows.ps1 @@ -7,6 +7,7 @@ Set-Location $RootDir python -m pip install -e ".[dev]" python -m pip install pyinstaller pybabel compile -d src/spsvalidator/translations +& "$PSScriptRoot\generate_build_info.ps1" pyinstaller --noconfirm --windowed ` --name spsvalidator ` --icon src/spsvalidator/web/static/img/icon.png ` diff --git a/spsvalidator/packaging/generate_build_info.ps1 b/spsvalidator/packaging/generate_build_info.ps1 new file mode 100644 index 0000000..52b154b --- /dev/null +++ b/spsvalidator/packaging/generate_build_info.ps1 @@ -0,0 +1,14 @@ +Set-StrictMode -Version Latest +$ErrorActionPreference = "Stop" + +$RootDir = Split-Path -Path $PSScriptRoot -Parent +$TargetPath = Join-Path $RootDir "src\spsvalidator\build_info.py" +Set-Location $RootDir + +$AppVersion = python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])" + +@" +APP_VERSION = "$AppVersion" +BUILD_MACOS_VERSION = "development" +BUILD_PLATFORM = "Windows" +"@ | Set-Content -Path $TargetPath -Encoding UTF8 \ No newline at end of file diff --git a/spsvalidator/src/spsvalidator/build_metadata.py b/spsvalidator/src/spsvalidator/build_metadata.py index c9cdecb..eab3f5f 100644 --- a/spsvalidator/src/spsvalidator/build_metadata.py +++ b/spsvalidator/src/spsvalidator/build_metadata.py @@ -5,12 +5,15 @@ from flask_babel import gettext from spsvalidator import build_info +from spsvalidator.version import is_running_from_source def get_footer_build_label() -> str: if ( - build_info.BUILD_MACOS_VERSION != "development" + not is_running_from_source() + and build_info.BUILD_MACOS_VERSION != "development" and build_info.BUILD_PLATFORM == "macOS" + and platform.system() == "Darwin" ): return gettext( "Compilado para macOS %(version)s", diff --git a/spsvalidator/src/spsvalidator/db/repository.py b/spsvalidator/src/spsvalidator/db/repository.py index e27d1f3..dd290f7 100644 --- a/spsvalidator/src/spsvalidator/db/repository.py +++ b/spsvalidator/src/spsvalidator/db/repository.py @@ -175,6 +175,109 @@ def count_validations( return int(total) +def _articles_filter_clause( + name_query: str | None, + doi_query: str | None, + pid_query: str | None, + status: str | None, + history_id: str | None, +) -> tuple[str, list]: + conditions = [] + params: list = [] + if name_query: + conditions.append("LOWER(package_validation_history.package_name) LIKE LOWER(?)") + params.append(f"%{name_query}%") + if doi_query: + conditions.append("LOWER(package_article_snapshot.doi) LIKE LOWER(?)") + params.append(f"%{doi_query}%") + if pid_query: + conditions.append("LOWER(package_article_snapshot.pid) LIKE LOWER(?)") + params.append(f"%{pid_query}%") + if status: + conditions.append("package_article_snapshot.article_status = ?") + params.append(status) + if history_id: + conditions.append("package_article_snapshot.history_id = ?") + params.append(history_id) + where_clause = " WHERE " + " AND ".join(conditions) if conditions else "" + return where_clause, params + + +def list_articles( + db_path: str, + name_query: str | None = None, + doi_query: str | None = None, + pid_query: str | None = None, + status: str | None = None, + history_id: str | None = None, + limit: int | None = None, + offset: int = 0, +) -> list[dict]: + where_clause, params = _articles_filter_clause( + name_query, doi_query, pid_query, status, history_id + ) + sql = f""" + SELECT + package_article_snapshot.id, + package_article_snapshot.history_id, + package_article_snapshot.xml_path, + package_article_snapshot.title, + package_article_snapshot.authors_text, + package_article_snapshot.doi, + package_article_snapshot.pid, + package_article_snapshot.article_status, + package_article_snapshot.issue_count, + package_validation_history.package_name, + package_validation_history.validated_at + FROM package_article_snapshot + JOIN package_validation_history + ON package_validation_history.id = package_article_snapshot.history_id + {where_clause} + ORDER BY datetime(package_validation_history.validated_at) DESC, + package_article_snapshot.xml_path + """ + if limit is not None: + sql += " LIMIT ? OFFSET ?" + params = params + [limit, offset] + + with sqlite3.connect(db_path) as connection: + connection.row_factory = sqlite3.Row + rows = connection.execute(sql, params).fetchall() + return [dict(row) for row in rows] + + +def count_articles( + db_path: str, + name_query: str | None = None, + doi_query: str | None = None, + pid_query: str | None = None, + status: str | None = None, + history_id: str | None = None, +) -> int: + where_clause, params = _articles_filter_clause( + name_query, doi_query, pid_query, status, history_id + ) + sql = f""" + SELECT COUNT(*) + FROM package_article_snapshot + JOIN package_validation_history + ON package_validation_history.id = package_article_snapshot.history_id + {where_clause} + """ + with sqlite3.connect(db_path) as connection: + total = connection.execute(sql, params).fetchone()[0] + return int(total) + + +def get_package_name(db_path: str, history_id: str) -> str | None: + with sqlite3.connect(db_path) as connection: + row = connection.execute( + "SELECT package_name FROM package_validation_history WHERE id = ?", + (history_id,), + ).fetchone() + return row[0] if row else None + + def get_validation_details(db_path: str, history_id: str) -> dict | None: with sqlite3.connect(db_path) as connection: connection.row_factory = sqlite3.Row diff --git a/spsvalidator/src/spsvalidator/translations/en/LC_MESSAGES/messages.po b/spsvalidator/src/spsvalidator/translations/en/LC_MESSAGES/messages.po index c68f183..cd15ceb 100644 --- a/spsvalidator/src/spsvalidator/translations/en/LC_MESSAGES/messages.po +++ b/spsvalidator/src/spsvalidator/translations/en/LC_MESSAGES/messages.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: spsvalidator 0.0.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-07-27 19:51-0300\n" +"POT-Creation-Date: 2026-07-31 09:39-0300\n" "PO-Revision-Date: 2026-07-14 10:59-0300\n" "Last-Translator: SciELO\n" "Language: en\n" @@ -19,255 +19,311 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Generated-By: Babel 2.18.0\n" -#: src/spsvalidator/build_metadata.py:16 src/spsvalidator/build_metadata.py:30 +#: src/spsvalidator/build_metadata.py:18 src/spsvalidator/build_metadata.py:32 #, python-format msgid "Compilado para macOS %(version)s" msgstr "Built for macOS %(version)s" -#: src/spsvalidator/build_metadata.py:33 +#: src/spsvalidator/build_metadata.py:35 #, python-format msgid "Build de desenvolvimento (%(platform)s)" msgstr "Development build (%(platform)s)" -#: src/spsvalidator/web/routes.py:161 +#: src/spsvalidator/web/routes.py:84 +msgid "PDF principal" +msgstr "Main PDF" + +#: src/spsvalidator/web/routes.py:206 msgid "Selecione um arquivo .zip para validar." msgstr "Select a .zip file to validate." -#: src/spsvalidator/web/routes.py:168 +#: src/spsvalidator/web/routes.py:213 msgid "Apenas arquivos .zip SPS são suportados." msgstr "Only SPS .zip files are supported." -#: src/spsvalidator/web/routes.py:184 -#: src/spsvalidator/web/templates/_history_list.html:7 +#: src/spsvalidator/web/routes.py:238 +#: src/spsvalidator/web/templates/_history_list.html:8 msgid "Pacote" msgstr "Package" -#: src/spsvalidator/web/routes.py:185 +#: src/spsvalidator/web/routes.py:239 msgid "Gravidade" msgstr "Severity" -#: src/spsvalidator/web/routes.py:186 +#: src/spsvalidator/web/routes.py:240 msgid "Categoria" msgstr "Category" -#: src/spsvalidator/web/routes.py:187 -#: src/spsvalidator/web/templates/report.html:194 +#: src/spsvalidator/web/routes.py:241 +#: src/spsvalidator/web/templates/report.html:826 msgid "Problema" msgstr "Issue" -#: src/spsvalidator/web/routes.py:188 -#: src/spsvalidator/web/templates/report.html:173 -#: src/spsvalidator/web/templates/report.html:195 +#: src/spsvalidator/web/routes.py:242 +#: src/spsvalidator/web/templates/report.html:798 +#: src/spsvalidator/web/templates/report.html:827 msgid "Ação de correção" msgstr "Corrective action" #: src/spsvalidator/web/templates/_history_list.html:2 -#: src/spsvalidator/web/templates/index.html:107 +#: src/spsvalidator/web/templates/index.html:351 #, fuzzy msgid "Válido" msgstr "Validate" #: src/spsvalidator/web/templates/_history_list.html:2 -#: src/spsvalidator/web/templates/index.html:108 +#: src/spsvalidator/web/templates/index.html:352 msgid "Inválido" msgstr "" #: src/spsvalidator/web/templates/_history_list.html:2 -#: src/spsvalidator/web/templates/index.html:109 +#: src/spsvalidator/web/templates/index.html:353 msgid "Erro" msgstr "" -#: src/spsvalidator/web/templates/_history_list.html:6 +#: src/spsvalidator/web/templates/_history_list.html:7 msgid "Data" msgstr "Date" -#: src/spsvalidator/web/templates/_history_list.html:8 -#: src/spsvalidator/web/templates/index.html:143 -msgid "Status" -msgstr "" - #: src/spsvalidator/web/templates/_history_list.html:9 -msgid "XMLs" +#: src/spsvalidator/web/templates/index.html:386 +msgid "Status" msgstr "" #: src/spsvalidator/web/templates/_history_list.html:10 -msgid "CRITICAL" +msgid "XMLs" msgstr "" #: src/spsvalidator/web/templates/_history_list.html:11 -msgid "ERROR" +msgid "CRITICAL" msgstr "" #: src/spsvalidator/web/templates/_history_list.html:12 -msgid "WARNING" +msgid "ERROR" msgstr "" #: src/spsvalidator/web/templates/_history_list.html:13 -msgid "Exceptions" +msgid "WARNING" msgstr "" #: src/spsvalidator/web/templates/_history_list.html:14 -#: src/spsvalidator/web/templates/_history_list.html:36 -msgid "Relatório" -msgstr "Report" +msgid "Exceções" +msgstr "Exceptions" #: src/spsvalidator/web/templates/_history_list.html:15 -#: src/spsvalidator/web/templates/_history_list.html:46 -msgid "CSV" -msgstr "CSV" - -#: src/spsvalidator/web/templates/_history_list.html:16 -msgid "HTML" -msgstr "" - -#: src/spsvalidator/web/templates/_history_list.html:17 -msgid "PDF" -msgstr "" +msgid "Ações" +msgstr "Actions" #: src/spsvalidator/web/templates/_history_list.html:35 #, python-format msgid "Ver relatório de %(name)s" msgstr "View report of %(name)s" -#: src/spsvalidator/web/templates/_history_list.html:45 +#: src/spsvalidator/web/templates/_history_list.html:36 +#: src/spsvalidator/web/templates/_history_list.html:43 +msgid "Relatório" +msgstr "Report" + +#: src/spsvalidator/web/templates/_history_list.html:52 #, python-format msgid "Baixar CSV de %(name)s" -msgstr "Download CSV of %(name)s" +msgstr "Download CSV for %(name)s" + +#: src/spsvalidator/web/templates/_history_list.html:53 +msgid "Baixar CSV" +msgstr "Download CSV" + +#: src/spsvalidator/web/templates/_history_list.html:59 +msgid "CSV" +msgstr "CSV" -#: src/spsvalidator/web/templates/_history_list.html:78 +#: src/spsvalidator/web/templates/_history_list.html:71 +msgid "Pré-visualização HTML" +msgstr "HTML preview" + +#: src/spsvalidator/web/templates/_history_list.html:114 msgid "Nenhum pacote encontrado com esse filtro." msgstr "" -#: src/spsvalidator/web/templates/_history_list.html:80 +#: src/spsvalidator/web/templates/_history_list.html:116 msgid "Nenhum pacote validado ainda." msgstr "No packages validated yet." -#: src/spsvalidator/web/templates/_history_list.html:85 +#: src/spsvalidator/web/templates/_history_list.html:120 +msgid "Paginação" +msgstr "Pagination" + +#: src/spsvalidator/web/templates/_history_list.html:122 #, python-format msgid "Página %(page)s de %(total_pages)s (%(total)s pacotes)" msgstr "" -#: src/spsvalidator/web/templates/_history_list.html:91 +#: src/spsvalidator/web/templates/_history_list.html:130 +#: src/spsvalidator/web/templates/_history_list.html:132 msgid "Anterior" msgstr "" -#: src/spsvalidator/web/templates/_history_list.html:98 +#: src/spsvalidator/web/templates/_history_list.html:152 +#: src/spsvalidator/web/templates/_history_list.html:154 msgid "Próxima" msgstr "" -#: src/spsvalidator/web/templates/index.html:79 +#: src/spsvalidator/web/templates/index.html:311 msgid "Validação de pacotes SPS" msgstr "SPS package validation" -#: src/spsvalidator/web/templates/index.html:86 +#: src/spsvalidator/web/templates/index.html:318 msgid "Validar pacote SPS" msgstr "Validate SPS package" -#: src/spsvalidator/web/templates/index.html:89 +#: src/spsvalidator/web/templates/index.html:323 msgid "Validar" msgstr "Validate" -#: src/spsvalidator/web/templates/index.html:97 +#: src/spsvalidator/web/templates/index.html:334 +msgid "Artigos" +msgstr "Articles" + +#: src/spsvalidator/web/templates/index.html:335 +msgid "Pacotes" +msgstr "Packages" + +#: src/spsvalidator/web/templates/index.html:338 msgid "Pacotes validados" msgstr "Validated packages" -#: src/spsvalidator/web/templates/index.html:103 +#: src/spsvalidator/web/templates/index.html:347 msgid "Buscar pelo nome do pacote" msgstr "" -#: src/spsvalidator/web/templates/index.html:106 +#: src/spsvalidator/web/templates/index.html:350 msgid "Todos" msgstr "" -#: src/spsvalidator/web/templates/index.html:111 +#: src/spsvalidator/web/templates/index.html:355 msgid "Itens por página" msgstr "" -#: src/spsvalidator/web/templates/index.html:120 +#: src/spsvalidator/web/templates/index.html:364 msgid "Buscar" msgstr "" -#: src/spsvalidator/web/templates/index.html:122 +#: src/spsvalidator/web/templates/index.html:366 #, fuzzy msgid "Limpar" msgstr "Validate" -#: src/spsvalidator/web/templates/index.html:133 -msgid "Artigos Considerados" -msgstr "Articles Considered" - -#: src/spsvalidator/web/templates/index.html:138 +#: src/spsvalidator/web/templates/index.html:381 msgid "Arquivo XML" msgstr "XML file" -#: src/spsvalidator/web/templates/index.html:139 +#: src/spsvalidator/web/templates/index.html:382 msgid "Título" msgstr "Title" -#: src/spsvalidator/web/templates/index.html:140 +#: src/spsvalidator/web/templates/index.html:383 msgid "Autores" msgstr "Authors" -#: src/spsvalidator/web/templates/index.html:169 +#: src/spsvalidator/web/templates/index.html:412 #, python-brace-format msgid "Arquivo salvo em {path}" msgstr "File saved to {path}" -#: src/spsvalidator/web/templates/index.html:170 +#: src/spsvalidator/web/templates/index.html:413 msgid "Falha ao baixar CSV." msgstr "Failed to download CSV." -#: src/spsvalidator/web/templates/report.html:123 +#: src/spsvalidator/web/templates/index.html:414 +msgid "Validando..." +msgstr "Validating..." + +#: src/spsvalidator/web/templates/report.html:663 msgid "Relatório de validação agrupado por gravidade e categoria" msgstr "Validation report grouped by severity and category" -#: src/spsvalidator/web/templates/report.html:126 -#, python-format -msgid "%(total)s ocorrências no total" -msgstr "%(total)s occurrences in total" +#: src/spsvalidator/web/templates/report.html:667 +msgid "Ações do relatório" +msgstr "Report actions" -#: src/spsvalidator/web/templates/report.html:127 -#: src/spsvalidator/web/templates/report.html:147 -#: src/spsvalidator/web/templates/report.html:153 -msgid "corrigidas" -msgstr "" +#: src/spsvalidator/web/templates/report.html:670 +msgid "Histórico" +msgstr "History" -#: src/spsvalidator/web/templates/report.html:129 +#: src/spsvalidator/web/templates/report.html:678 msgid "Limpar marcações" msgstr "Clear markings" -#: src/spsvalidator/web/templates/report.html:134 -msgid "Voltar ao histórico" -msgstr "Back to history" +#: src/spsvalidator/web/templates/report.html:687 +msgid "Resumo do relatório" +msgstr "Report summary" -#: src/spsvalidator/web/templates/report.html:135 -msgid "Baixar CSV" -msgstr "Download CSV" +#: src/spsvalidator/web/templates/report.html:690 +msgid "Total de ocorrências" +msgstr "Total occurrences" + +#: src/spsvalidator/web/templates/report.html:700 +msgid "Corrigidas" +msgstr "Fixed" + +#: src/spsvalidator/web/templates/report.html:719 +msgid "Filtrar por gravidade" +msgstr "Filter by severity" + +#: src/spsvalidator/web/templates/report.html:721 +#, python-format +msgid "Todos (%(count)s)" +msgstr "All (%(count)s)" -#: src/spsvalidator/web/templates/report.html:140 +#: src/spsvalidator/web/templates/report.html:731 +msgid "Buscar no relatório" +msgstr "Search in report" + +#: src/spsvalidator/web/templates/report.html:735 +msgid "Buscar problema, ação ou detalhe" +msgstr "Search problem, action or detail" + +#: src/spsvalidator/web/templates/report.html:741 msgid "Nenhuma ocorrência encontrada para este pacote." msgstr "No occurrences found for this package." -#: src/spsvalidator/web/templates/report.html:158 +#: src/spsvalidator/web/templates/report.html:754 +msgid "corrigidas" +msgstr "fixed" + +#: src/spsvalidator/web/templates/report.html:779 #, python-format msgid "%(count)s ocorrências" msgstr "%(count)s occurrences" -#: src/spsvalidator/web/templates/report.html:165 +#: src/spsvalidator/web/templates/report.html:788 msgid "Marcar todas como corrigidas" msgstr "Mark all as fixed" -#: src/spsvalidator/web/templates/report.html:171 -#: src/spsvalidator/web/templates/report.html:192 +#: src/spsvalidator/web/templates/report.html:801 +#: src/spsvalidator/web/templates/report.html:830 +msgid "Detalhes técnicos" +msgstr "Technical details" + +#: src/spsvalidator/web/templates/report.html:813 +#: src/spsvalidator/web/templates/report.html:842 msgid "Corrigido" msgstr "Fixed" -#: src/spsvalidator/web/templates/report.html:176 -#: src/spsvalidator/web/templates/report.html:198 -msgid "Detalhes técnicos" -msgstr "Technical details" +#: src/spsvalidator/web/templates/report.html:855 +msgid "Nenhum resultado para os filtros atuais." +msgstr "No results for the current filters." -#: src/spsvalidator/web/templates/report.html:307 +#: src/spsvalidator/web/templates/report.html:963 msgid "Limpar todas as marcações deste relatório?" msgstr "Clear all markings in this report?" +#~ msgid "HTML" +#~ msgstr "" + +#~ msgid "PDF" +#~ msgstr "" + +#~ msgid "%(total)s ocorrências no total" +#~ msgstr "%(total)s occurrences in total" + diff --git a/spsvalidator/src/spsvalidator/translations/es/LC_MESSAGES/messages.po b/spsvalidator/src/spsvalidator/translations/es/LC_MESSAGES/messages.po index e906065..024dc68 100644 --- a/spsvalidator/src/spsvalidator/translations/es/LC_MESSAGES/messages.po +++ b/spsvalidator/src/spsvalidator/translations/es/LC_MESSAGES/messages.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: spsvalidator 0.0.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-07-27 19:51-0300\n" +"POT-Creation-Date: 2026-07-31 09:39-0300\n" "PO-Revision-Date: 2026-07-14 10:59-0300\n" "Last-Translator: SciELO\n" "Language: es\n" @@ -19,253 +19,309 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Generated-By: Babel 2.18.0\n" -#: src/spsvalidator/build_metadata.py:16 src/spsvalidator/build_metadata.py:30 +#: src/spsvalidator/build_metadata.py:18 src/spsvalidator/build_metadata.py:32 #, python-format msgid "Compilado para macOS %(version)s" msgstr "Compilado para macOS %(version)s" -#: src/spsvalidator/build_metadata.py:33 +#: src/spsvalidator/build_metadata.py:35 #, python-format msgid "Build de desenvolvimento (%(platform)s)" msgstr "Build de desarrollo (%(platform)s)" -#: src/spsvalidator/web/routes.py:161 +#: src/spsvalidator/web/routes.py:84 +msgid "PDF principal" +msgstr "PDF principal" + +#: src/spsvalidator/web/routes.py:206 msgid "Selecione um arquivo .zip para validar." msgstr "Seleccione un archivo .zip para validar." -#: src/spsvalidator/web/routes.py:168 +#: src/spsvalidator/web/routes.py:213 msgid "Apenas arquivos .zip SPS são suportados." msgstr "Solo se admiten archivos .zip SPS." -#: src/spsvalidator/web/routes.py:184 -#: src/spsvalidator/web/templates/_history_list.html:7 +#: src/spsvalidator/web/routes.py:238 +#: src/spsvalidator/web/templates/_history_list.html:8 msgid "Pacote" msgstr "Paquete" -#: src/spsvalidator/web/routes.py:185 +#: src/spsvalidator/web/routes.py:239 msgid "Gravidade" msgstr "Gravedad" -#: src/spsvalidator/web/routes.py:186 +#: src/spsvalidator/web/routes.py:240 msgid "Categoria" msgstr "Categoría" -#: src/spsvalidator/web/routes.py:187 -#: src/spsvalidator/web/templates/report.html:194 +#: src/spsvalidator/web/routes.py:241 +#: src/spsvalidator/web/templates/report.html:826 msgid "Problema" msgstr "Problema" -#: src/spsvalidator/web/routes.py:188 -#: src/spsvalidator/web/templates/report.html:173 -#: src/spsvalidator/web/templates/report.html:195 +#: src/spsvalidator/web/routes.py:242 +#: src/spsvalidator/web/templates/report.html:798 +#: src/spsvalidator/web/templates/report.html:827 msgid "Ação de correção" msgstr "Acción de corrección" #: src/spsvalidator/web/templates/_history_list.html:2 -#: src/spsvalidator/web/templates/index.html:107 +#: src/spsvalidator/web/templates/index.html:351 msgid "Válido" msgstr "" #: src/spsvalidator/web/templates/_history_list.html:2 -#: src/spsvalidator/web/templates/index.html:108 +#: src/spsvalidator/web/templates/index.html:352 msgid "Inválido" msgstr "" #: src/spsvalidator/web/templates/_history_list.html:2 -#: src/spsvalidator/web/templates/index.html:109 +#: src/spsvalidator/web/templates/index.html:353 msgid "Erro" msgstr "" -#: src/spsvalidator/web/templates/_history_list.html:6 +#: src/spsvalidator/web/templates/_history_list.html:7 msgid "Data" msgstr "Fecha" -#: src/spsvalidator/web/templates/_history_list.html:8 -#: src/spsvalidator/web/templates/index.html:143 -msgid "Status" -msgstr "" - #: src/spsvalidator/web/templates/_history_list.html:9 -msgid "XMLs" +#: src/spsvalidator/web/templates/index.html:386 +msgid "Status" msgstr "" #: src/spsvalidator/web/templates/_history_list.html:10 -msgid "CRITICAL" +msgid "XMLs" msgstr "" #: src/spsvalidator/web/templates/_history_list.html:11 -msgid "ERROR" +msgid "CRITICAL" msgstr "" #: src/spsvalidator/web/templates/_history_list.html:12 -msgid "WARNING" +msgid "ERROR" msgstr "" #: src/spsvalidator/web/templates/_history_list.html:13 -msgid "Exceptions" +msgid "WARNING" msgstr "" #: src/spsvalidator/web/templates/_history_list.html:14 -#: src/spsvalidator/web/templates/_history_list.html:36 -msgid "Relatório" -msgstr "Informe" +msgid "Exceções" +msgstr "Excepciones" #: src/spsvalidator/web/templates/_history_list.html:15 -#: src/spsvalidator/web/templates/_history_list.html:46 -msgid "CSV" -msgstr "CSV" - -#: src/spsvalidator/web/templates/_history_list.html:16 -msgid "HTML" -msgstr "" - -#: src/spsvalidator/web/templates/_history_list.html:17 -msgid "PDF" -msgstr "" +msgid "Ações" +msgstr "Acciones" #: src/spsvalidator/web/templates/_history_list.html:35 #, python-format msgid "Ver relatório de %(name)s" msgstr "Ver informe de %(name)s" -#: src/spsvalidator/web/templates/_history_list.html:45 +#: src/spsvalidator/web/templates/_history_list.html:36 +#: src/spsvalidator/web/templates/_history_list.html:43 +msgid "Relatório" +msgstr "Informe" + +#: src/spsvalidator/web/templates/_history_list.html:52 #, python-format msgid "Baixar CSV de %(name)s" msgstr "Descargar CSV de %(name)s" -#: src/spsvalidator/web/templates/_history_list.html:78 +#: src/spsvalidator/web/templates/_history_list.html:53 +msgid "Baixar CSV" +msgstr "Descargar CSV" + +#: src/spsvalidator/web/templates/_history_list.html:59 +msgid "CSV" +msgstr "CSV" + +#: src/spsvalidator/web/templates/_history_list.html:71 +msgid "Pré-visualização HTML" +msgstr "Vista previa HTML" + +#: src/spsvalidator/web/templates/_history_list.html:114 msgid "Nenhum pacote encontrado com esse filtro." msgstr "" -#: src/spsvalidator/web/templates/_history_list.html:80 +#: src/spsvalidator/web/templates/_history_list.html:116 msgid "Nenhum pacote validado ainda." msgstr "Ningún paquete validado todavía." -#: src/spsvalidator/web/templates/_history_list.html:85 +#: src/spsvalidator/web/templates/_history_list.html:120 +msgid "Paginação" +msgstr "Paginación" + +#: src/spsvalidator/web/templates/_history_list.html:122 #, python-format msgid "Página %(page)s de %(total_pages)s (%(total)s pacotes)" msgstr "" -#: src/spsvalidator/web/templates/_history_list.html:91 +#: src/spsvalidator/web/templates/_history_list.html:130 +#: src/spsvalidator/web/templates/_history_list.html:132 msgid "Anterior" msgstr "" -#: src/spsvalidator/web/templates/_history_list.html:98 +#: src/spsvalidator/web/templates/_history_list.html:152 +#: src/spsvalidator/web/templates/_history_list.html:154 msgid "Próxima" msgstr "" -#: src/spsvalidator/web/templates/index.html:79 +#: src/spsvalidator/web/templates/index.html:311 msgid "Validação de pacotes SPS" msgstr "Validación de paquetes SPS" -#: src/spsvalidator/web/templates/index.html:86 +#: src/spsvalidator/web/templates/index.html:318 msgid "Validar pacote SPS" msgstr "Validar paquete SPS" -#: src/spsvalidator/web/templates/index.html:89 +#: src/spsvalidator/web/templates/index.html:323 msgid "Validar" msgstr "" -#: src/spsvalidator/web/templates/index.html:97 +#: src/spsvalidator/web/templates/index.html:334 +msgid "Artigos" +msgstr "Artículos" + +#: src/spsvalidator/web/templates/index.html:335 +msgid "Pacotes" +msgstr "Paquetes" + +#: src/spsvalidator/web/templates/index.html:338 msgid "Pacotes validados" msgstr "Paquetes validados" -#: src/spsvalidator/web/templates/index.html:103 +#: src/spsvalidator/web/templates/index.html:347 msgid "Buscar pelo nome do pacote" msgstr "" -#: src/spsvalidator/web/templates/index.html:106 +#: src/spsvalidator/web/templates/index.html:350 msgid "Todos" msgstr "" -#: src/spsvalidator/web/templates/index.html:111 +#: src/spsvalidator/web/templates/index.html:355 msgid "Itens por página" msgstr "" -#: src/spsvalidator/web/templates/index.html:120 +#: src/spsvalidator/web/templates/index.html:364 msgid "Buscar" msgstr "" -#: src/spsvalidator/web/templates/index.html:122 +#: src/spsvalidator/web/templates/index.html:366 msgid "Limpar" msgstr "" -#: src/spsvalidator/web/templates/index.html:133 -msgid "Artigos Considerados" -msgstr "Artículos Considerados" - -#: src/spsvalidator/web/templates/index.html:138 +#: src/spsvalidator/web/templates/index.html:381 msgid "Arquivo XML" msgstr "Archivo XML" -#: src/spsvalidator/web/templates/index.html:139 +#: src/spsvalidator/web/templates/index.html:382 msgid "Título" msgstr "Título" -#: src/spsvalidator/web/templates/index.html:140 +#: src/spsvalidator/web/templates/index.html:383 msgid "Autores" msgstr "Autores" -#: src/spsvalidator/web/templates/index.html:169 +#: src/spsvalidator/web/templates/index.html:412 #, python-brace-format msgid "Arquivo salvo em {path}" msgstr "Archivo guardado en {path}" -#: src/spsvalidator/web/templates/index.html:170 +#: src/spsvalidator/web/templates/index.html:413 msgid "Falha ao baixar CSV." msgstr "Error al descargar CSV." -#: src/spsvalidator/web/templates/report.html:123 +#: src/spsvalidator/web/templates/index.html:414 +msgid "Validando..." +msgstr "Validando..." + +#: src/spsvalidator/web/templates/report.html:663 msgid "Relatório de validação agrupado por gravidade e categoria" msgstr "Informe de validación agrupado por gravedad y categoría" -#: src/spsvalidator/web/templates/report.html:126 -#, python-format -msgid "%(total)s ocorrências no total" -msgstr "%(total)s ocurrencias en total" +#: src/spsvalidator/web/templates/report.html:667 +msgid "Ações do relatório" +msgstr "Acciones del informe" -#: src/spsvalidator/web/templates/report.html:127 -#: src/spsvalidator/web/templates/report.html:147 -#: src/spsvalidator/web/templates/report.html:153 -msgid "corrigidas" -msgstr "" +#: src/spsvalidator/web/templates/report.html:670 +msgid "Histórico" +msgstr "Historial" -#: src/spsvalidator/web/templates/report.html:129 +#: src/spsvalidator/web/templates/report.html:678 msgid "Limpar marcações" msgstr "Borrar marcas" -#: src/spsvalidator/web/templates/report.html:134 -msgid "Voltar ao histórico" -msgstr "Volver al historial" +#: src/spsvalidator/web/templates/report.html:687 +msgid "Resumo do relatório" +msgstr "Resumen del informe" -#: src/spsvalidator/web/templates/report.html:135 -msgid "Baixar CSV" -msgstr "Descargar CSV" +#: src/spsvalidator/web/templates/report.html:690 +msgid "Total de ocorrências" +msgstr "Total de ocurrencias" + +#: src/spsvalidator/web/templates/report.html:700 +msgid "Corrigidas" +msgstr "Corregidas" -#: src/spsvalidator/web/templates/report.html:140 +#: src/spsvalidator/web/templates/report.html:719 +msgid "Filtrar por gravidade" +msgstr "Filtrar por gravedad" + +#: src/spsvalidator/web/templates/report.html:721 +#, python-format +msgid "Todos (%(count)s)" +msgstr "Todos (%(count)s)" + +#: src/spsvalidator/web/templates/report.html:731 +msgid "Buscar no relatório" +msgstr "Buscar en el informe" + +#: src/spsvalidator/web/templates/report.html:735 +msgid "Buscar problema, ação ou detalhe" +msgstr "Buscar problema, acción o detalle" + +#: src/spsvalidator/web/templates/report.html:741 msgid "Nenhuma ocorrência encontrada para este pacote." msgstr "No se encontraron ocurrencias para este paquete." -#: src/spsvalidator/web/templates/report.html:158 +#: src/spsvalidator/web/templates/report.html:754 +msgid "corrigidas" +msgstr "corregidas" + +#: src/spsvalidator/web/templates/report.html:779 #, python-format msgid "%(count)s ocorrências" msgstr "%(count)s ocurrencias" -#: src/spsvalidator/web/templates/report.html:165 +#: src/spsvalidator/web/templates/report.html:788 msgid "Marcar todas como corrigidas" msgstr "Marcar todas como corregidas" -#: src/spsvalidator/web/templates/report.html:171 -#: src/spsvalidator/web/templates/report.html:192 +#: src/spsvalidator/web/templates/report.html:801 +#: src/spsvalidator/web/templates/report.html:830 +msgid "Detalhes técnicos" +msgstr "Detalles técnicos" + +#: src/spsvalidator/web/templates/report.html:813 +#: src/spsvalidator/web/templates/report.html:842 msgid "Corrigido" msgstr "Corregido" -#: src/spsvalidator/web/templates/report.html:176 -#: src/spsvalidator/web/templates/report.html:198 -msgid "Detalhes técnicos" -msgstr "Detalles técnicos" +#: src/spsvalidator/web/templates/report.html:855 +msgid "Nenhum resultado para os filtros atuais." +msgstr "No se encontraron resultados para los filtros actuales." -#: src/spsvalidator/web/templates/report.html:307 +#: src/spsvalidator/web/templates/report.html:963 msgid "Limpar todas as marcações deste relatório?" msgstr "¿Borrar todas las marcas de este informe?" +#~ msgid "HTML" +#~ msgstr "" + +#~ msgid "PDF" +#~ msgstr "" + +#~ msgid "%(total)s ocorrências no total" +#~ msgstr "%(total)s ocurrencias en total" + diff --git a/spsvalidator/src/spsvalidator/translations/pt/LC_MESSAGES/messages.po b/spsvalidator/src/spsvalidator/translations/pt/LC_MESSAGES/messages.po index 5f24466..fa19444 100644 --- a/spsvalidator/src/spsvalidator/translations/pt/LC_MESSAGES/messages.po +++ b/spsvalidator/src/spsvalidator/translations/pt/LC_MESSAGES/messages.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: spsvalidator 0.0.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-07-27 19:51-0300\n" +"POT-Creation-Date: 2026-07-31 09:39-0300\n" "PO-Revision-Date: 2026-07-14 10:59-0300\n" "Last-Translator: SciELO\n" "Language: pt\n" @@ -19,108 +19,98 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Generated-By: Babel 2.18.0\n" -#: src/spsvalidator/build_metadata.py:16 src/spsvalidator/build_metadata.py:30 +#: src/spsvalidator/build_metadata.py:18 src/spsvalidator/build_metadata.py:32 #, python-format msgid "Compilado para macOS %(version)s" msgstr "" -#: src/spsvalidator/build_metadata.py:33 +#: src/spsvalidator/build_metadata.py:35 #, python-format msgid "Build de desenvolvimento (%(platform)s)" msgstr "" -#: src/spsvalidator/web/routes.py:161 +#: src/spsvalidator/web/routes.py:84 +msgid "PDF principal" +msgstr "" + +#: src/spsvalidator/web/routes.py:206 msgid "Selecione um arquivo .zip para validar." msgstr "" -#: src/spsvalidator/web/routes.py:168 +#: src/spsvalidator/web/routes.py:213 msgid "Apenas arquivos .zip SPS são suportados." msgstr "" -#: src/spsvalidator/web/routes.py:184 -#: src/spsvalidator/web/templates/_history_list.html:7 +#: src/spsvalidator/web/routes.py:238 +#: src/spsvalidator/web/templates/_history_list.html:8 msgid "Pacote" msgstr "" -#: src/spsvalidator/web/routes.py:185 +#: src/spsvalidator/web/routes.py:239 msgid "Gravidade" msgstr "" -#: src/spsvalidator/web/routes.py:186 +#: src/spsvalidator/web/routes.py:240 msgid "Categoria" msgstr "" -#: src/spsvalidator/web/routes.py:187 -#: src/spsvalidator/web/templates/report.html:194 +#: src/spsvalidator/web/routes.py:241 +#: src/spsvalidator/web/templates/report.html:826 msgid "Problema" msgstr "" -#: src/spsvalidator/web/routes.py:188 -#: src/spsvalidator/web/templates/report.html:173 -#: src/spsvalidator/web/templates/report.html:195 +#: src/spsvalidator/web/routes.py:242 +#: src/spsvalidator/web/templates/report.html:798 +#: src/spsvalidator/web/templates/report.html:827 msgid "Ação de correção" msgstr "" #: src/spsvalidator/web/templates/_history_list.html:2 -#: src/spsvalidator/web/templates/index.html:107 +#: src/spsvalidator/web/templates/index.html:351 msgid "Válido" msgstr "" #: src/spsvalidator/web/templates/_history_list.html:2 -#: src/spsvalidator/web/templates/index.html:108 +#: src/spsvalidator/web/templates/index.html:352 msgid "Inválido" msgstr "" #: src/spsvalidator/web/templates/_history_list.html:2 -#: src/spsvalidator/web/templates/index.html:109 +#: src/spsvalidator/web/templates/index.html:353 msgid "Erro" msgstr "" -#: src/spsvalidator/web/templates/_history_list.html:6 +#: src/spsvalidator/web/templates/_history_list.html:7 msgid "Data" msgstr "" -#: src/spsvalidator/web/templates/_history_list.html:8 -#: src/spsvalidator/web/templates/index.html:143 -msgid "Status" -msgstr "" - #: src/spsvalidator/web/templates/_history_list.html:9 -msgid "XMLs" +#: src/spsvalidator/web/templates/index.html:386 +msgid "Status" msgstr "" #: src/spsvalidator/web/templates/_history_list.html:10 -msgid "CRITICAL" +msgid "XMLs" msgstr "" #: src/spsvalidator/web/templates/_history_list.html:11 -msgid "ERROR" +msgid "CRITICAL" msgstr "" #: src/spsvalidator/web/templates/_history_list.html:12 -msgid "WARNING" +msgid "ERROR" msgstr "" #: src/spsvalidator/web/templates/_history_list.html:13 -msgid "Exceptions" +msgid "WARNING" msgstr "" #: src/spsvalidator/web/templates/_history_list.html:14 -#: src/spsvalidator/web/templates/_history_list.html:36 -msgid "Relatório" +msgid "Exceções" msgstr "" #: src/spsvalidator/web/templates/_history_list.html:15 -#: src/spsvalidator/web/templates/_history_list.html:46 -msgid "CSV" -msgstr "" - -#: src/spsvalidator/web/templates/_history_list.html:16 -msgid "HTML" -msgstr "" - -#: src/spsvalidator/web/templates/_history_list.html:17 -msgid "PDF" +msgid "Ações" msgstr "" #: src/spsvalidator/web/templates/_history_list.html:35 @@ -128,144 +118,213 @@ msgstr "" msgid "Ver relatório de %(name)s" msgstr "" -#: src/spsvalidator/web/templates/_history_list.html:45 +#: src/spsvalidator/web/templates/_history_list.html:36 +#: src/spsvalidator/web/templates/_history_list.html:43 +msgid "Relatório" +msgstr "" + +#: src/spsvalidator/web/templates/_history_list.html:52 #, python-format msgid "Baixar CSV de %(name)s" msgstr "" -#: src/spsvalidator/web/templates/_history_list.html:78 +#: src/spsvalidator/web/templates/_history_list.html:53 +msgid "Baixar CSV" +msgstr "" + +#: src/spsvalidator/web/templates/_history_list.html:59 +msgid "CSV" +msgstr "" + +#: src/spsvalidator/web/templates/_history_list.html:71 +msgid "Pré-visualização HTML" +msgstr "" + +#: src/spsvalidator/web/templates/_history_list.html:114 msgid "Nenhum pacote encontrado com esse filtro." msgstr "" -#: src/spsvalidator/web/templates/_history_list.html:80 +#: src/spsvalidator/web/templates/_history_list.html:116 msgid "Nenhum pacote validado ainda." msgstr "" -#: src/spsvalidator/web/templates/_history_list.html:85 +#: src/spsvalidator/web/templates/_history_list.html:120 +msgid "Paginação" +msgstr "" + +#: src/spsvalidator/web/templates/_history_list.html:122 #, python-format msgid "Página %(page)s de %(total_pages)s (%(total)s pacotes)" msgstr "" -#: src/spsvalidator/web/templates/_history_list.html:91 +#: src/spsvalidator/web/templates/_history_list.html:130 +#: src/spsvalidator/web/templates/_history_list.html:132 msgid "Anterior" msgstr "" -#: src/spsvalidator/web/templates/_history_list.html:98 +#: src/spsvalidator/web/templates/_history_list.html:152 +#: src/spsvalidator/web/templates/_history_list.html:154 msgid "Próxima" msgstr "" -#: src/spsvalidator/web/templates/index.html:79 +#: src/spsvalidator/web/templates/index.html:311 msgid "Validação de pacotes SPS" msgstr "" -#: src/spsvalidator/web/templates/index.html:86 +#: src/spsvalidator/web/templates/index.html:318 msgid "Validar pacote SPS" msgstr "" -#: src/spsvalidator/web/templates/index.html:89 +#: src/spsvalidator/web/templates/index.html:323 msgid "Validar" msgstr "" -#: src/spsvalidator/web/templates/index.html:97 +#: src/spsvalidator/web/templates/index.html:334 +msgid "Artigos" +msgstr "" + +#: src/spsvalidator/web/templates/index.html:335 +msgid "Pacotes" +msgstr "" + +#: src/spsvalidator/web/templates/index.html:338 msgid "Pacotes validados" msgstr "" -#: src/spsvalidator/web/templates/index.html:103 +#: src/spsvalidator/web/templates/index.html:347 msgid "Buscar pelo nome do pacote" msgstr "" -#: src/spsvalidator/web/templates/index.html:106 +#: src/spsvalidator/web/templates/index.html:350 msgid "Todos" msgstr "" -#: src/spsvalidator/web/templates/index.html:111 +#: src/spsvalidator/web/templates/index.html:355 msgid "Itens por página" msgstr "" -#: src/spsvalidator/web/templates/index.html:120 +#: src/spsvalidator/web/templates/index.html:364 msgid "Buscar" msgstr "" -#: src/spsvalidator/web/templates/index.html:122 +#: src/spsvalidator/web/templates/index.html:366 msgid "Limpar" msgstr "" -#: src/spsvalidator/web/templates/index.html:133 -msgid "Artigos Considerados" -msgstr "" - -#: src/spsvalidator/web/templates/index.html:138 +#: src/spsvalidator/web/templates/index.html:381 msgid "Arquivo XML" msgstr "" -#: src/spsvalidator/web/templates/index.html:139 +#: src/spsvalidator/web/templates/index.html:382 msgid "Título" msgstr "" -#: src/spsvalidator/web/templates/index.html:140 +#: src/spsvalidator/web/templates/index.html:383 msgid "Autores" msgstr "" -#: src/spsvalidator/web/templates/index.html:169 +#: src/spsvalidator/web/templates/index.html:412 #, python-brace-format msgid "Arquivo salvo em {path}" msgstr "" -#: src/spsvalidator/web/templates/index.html:170 +#: src/spsvalidator/web/templates/index.html:413 msgid "Falha ao baixar CSV." msgstr "" -#: src/spsvalidator/web/templates/report.html:123 +#: src/spsvalidator/web/templates/index.html:414 +msgid "Validando..." +msgstr "" + +#: src/spsvalidator/web/templates/report.html:663 msgid "Relatório de validação agrupado por gravidade e categoria" msgstr "" -#: src/spsvalidator/web/templates/report.html:126 -#, python-format -msgid "%(total)s ocorrências no total" +#: src/spsvalidator/web/templates/report.html:667 +msgid "Ações do relatório" msgstr "" -#: src/spsvalidator/web/templates/report.html:127 -#: src/spsvalidator/web/templates/report.html:147 -#: src/spsvalidator/web/templates/report.html:153 -msgid "corrigidas" +#: src/spsvalidator/web/templates/report.html:670 +msgid "Histórico" msgstr "" -#: src/spsvalidator/web/templates/report.html:129 +#: src/spsvalidator/web/templates/report.html:678 msgid "Limpar marcações" msgstr "" -#: src/spsvalidator/web/templates/report.html:134 -msgid "Voltar ao histórico" +#: src/spsvalidator/web/templates/report.html:687 +msgid "Resumo do relatório" msgstr "" -#: src/spsvalidator/web/templates/report.html:135 -msgid "Baixar CSV" +#: src/spsvalidator/web/templates/report.html:690 +msgid "Total de ocorrências" +msgstr "" + +#: src/spsvalidator/web/templates/report.html:700 +msgid "Corrigidas" +msgstr "" + +#: src/spsvalidator/web/templates/report.html:719 +msgid "Filtrar por gravidade" msgstr "" -#: src/spsvalidator/web/templates/report.html:140 +#: src/spsvalidator/web/templates/report.html:721 +#, python-format +msgid "Todos (%(count)s)" +msgstr "" + +#: src/spsvalidator/web/templates/report.html:731 +msgid "Buscar no relatório" +msgstr "" + +#: src/spsvalidator/web/templates/report.html:735 +msgid "Buscar problema, ação ou detalhe" +msgstr "" + +#: src/spsvalidator/web/templates/report.html:741 msgid "Nenhuma ocorrência encontrada para este pacote." msgstr "" -#: src/spsvalidator/web/templates/report.html:158 +#: src/spsvalidator/web/templates/report.html:754 +msgid "corrigidas" +msgstr "" + +#: src/spsvalidator/web/templates/report.html:779 #, python-format msgid "%(count)s ocorrências" msgstr "" -#: src/spsvalidator/web/templates/report.html:165 +#: src/spsvalidator/web/templates/report.html:788 msgid "Marcar todas como corrigidas" msgstr "" -#: src/spsvalidator/web/templates/report.html:171 -#: src/spsvalidator/web/templates/report.html:192 +#: src/spsvalidator/web/templates/report.html:801 +#: src/spsvalidator/web/templates/report.html:830 +msgid "Detalhes técnicos" +msgstr "" + +#: src/spsvalidator/web/templates/report.html:813 +#: src/spsvalidator/web/templates/report.html:842 msgid "Corrigido" msgstr "" -#: src/spsvalidator/web/templates/report.html:176 -#: src/spsvalidator/web/templates/report.html:198 -msgid "Detalhes técnicos" +#: src/spsvalidator/web/templates/report.html:855 +msgid "Nenhum resultado para os filtros atuais." msgstr "" -#: src/spsvalidator/web/templates/report.html:307 +#: src/spsvalidator/web/templates/report.html:963 msgid "Limpar todas as marcações deste relatório?" msgstr "" +#~ msgid "HTML" +#~ msgstr "" + +#~ msgid "PDF" +#~ msgstr "" + +#~ msgid "%(total)s ocorrências no total" +#~ msgstr "" + +#~ msgid "Voltar ao histórico" +#~ msgstr "" + diff --git a/spsvalidator/src/spsvalidator/version.py b/spsvalidator/src/spsvalidator/version.py index b9d68d5..1d19572 100644 --- a/spsvalidator/src/spsvalidator/version.py +++ b/spsvalidator/src/spsvalidator/version.py @@ -4,10 +4,24 @@ from pathlib import Path +def _pyproject_path() -> Path: + return Path(__file__).resolve().parents[2] / "pyproject.toml" + + +def is_running_from_source() -> bool: + """True quando rodando a partir do repositorio (pip install -e .). + + Nesse caso pyproject.toml esta presente ao lado do pacote; num build + empacotado (PyInstaller) ele nao existe, e so ai os metadados + gravados em build_info.py (gerados pra aquele build especifico) sao + confiaveis. + """ + return _pyproject_path().is_file() + + def _load_version() -> str: - pyproject_path = Path(__file__).resolve().parents[2] / "pyproject.toml" - if pyproject_path.is_file(): - with pyproject_path.open("rb") as file_pointer: + if is_running_from_source(): + with _pyproject_path().open("rb") as file_pointer: data = tomllib.load(file_pointer) return str(data["project"]["version"]) from spsvalidator import build_info diff --git a/spsvalidator/src/spsvalidator/web/routes.py b/spsvalidator/src/spsvalidator/web/routes.py index 8bb5e63..ebd23b6 100644 --- a/spsvalidator/src/spsvalidator/web/routes.py +++ b/spsvalidator/src/spsvalidator/web/routes.py @@ -1,5 +1,6 @@ from __future__ import annotations +from datetime import datetime from pathlib import Path from flask import ( @@ -17,8 +18,11 @@ from packtools import catalogs from spsvalidator.db.repository import ( + count_articles, count_validations, + get_package_name, get_validation_details, + list_articles, list_validations, ) from spsvalidator.domain.export import build_validation_csv @@ -70,6 +74,24 @@ def _html_previews_by_article(package_sha256: str) -> list[dict]: return groups +def _short_pdf_label(xml_stem: str, filename: str) -> str: + """Rótulo curto pra diferenciar PDFs de um mesmo artigo na listagem. + + Os nomes de arquivo compartilham o prefixo `xml_stem` (ex.: + "artigo.pdf", "artigo-suppl1.pdf"), o que faz uma lista inteira de + nomes completos parecer repetitiva; aqui extraímos só a parte que + diferencia cada arquivo. + """ + stem = filename[:-4] if filename.lower().endswith(".pdf") else filename + if stem == xml_stem: + return gettext("PDF principal") + if stem.startswith(xml_stem) and stem[len(xml_stem):len(xml_stem) + 1] in ("-", "_"): + suffix = stem[len(xml_stem):].lstrip("-_") + if suffix: + return suffix + return filename + + def _pdf_previews_by_article(package_sha256: str) -> list[dict]: """PDFs extraídos para um pacote, agrupados por artigo (xml_stem). @@ -83,12 +105,30 @@ def _pdf_previews_by_article(package_sha256: str) -> list[dict]: for article_dir in sorted(base_dir.iterdir()): if not article_dir.is_dir(): continue + xml_stem = article_dir.name pdf_names = sorted(p.name for p in (article_dir / "assets").glob("*.pdf")) if pdf_names: - groups.append({"xml_stem": article_dir.name, "pdf_names": pdf_names}) + pdfs = [ + {"filename": name, "label": _short_pdf_label(xml_stem, name)} + for name in pdf_names + ] + groups.append({"xml_stem": xml_stem, "pdfs": pdfs}) return groups +def _format_validated_at(value: str) -> str: + """Formata "validated_at" como "AAAA-MM-DD HH:MM:SS" pra exibicao na tabela. + + O valor e gravado com datetime.now(UTC).isoformat(), que inclui + microssegundos e o offset "+00:00"; ambos sao ruido pra quem esta + lendo a lista de historico. + """ + try: + return datetime.fromisoformat(value).strftime("%Y-%m-%d %H:%M:%S") + except ValueError: + return value + + def _parse_int(value, default: int) -> int: try: return int(value) @@ -96,6 +136,13 @@ def _parse_int(value, default: int) -> int: return default +def _page_range(page: int, total_pages: int, window: int = 2) -> list[int]: + """Janela de numeros de pagina ao redor da pagina atual, tipo Django.""" + start = max(1, page - window) + end = min(total_pages, page + window) + return list(range(start, end + 1)) + + def _paginated_history() -> dict: db_path = current_app.config["DB_PATH"] name_query = request.args.get("q", "").strip() @@ -116,6 +163,7 @@ def _paginated_history() -> dict: offset=(page - 1) * page_size, ) for item in history_items: + item["validated_at"] = _format_validated_at(item["validated_at"]) item["html_previews"] = _html_previews_by_article(item["package_sha256"]) item["pdf_previews"] = _pdf_previews_by_article(item["package_sha256"]) @@ -127,12 +175,64 @@ def _paginated_history() -> dict: "page_size": page_size, "total": total, "total_pages": total_pages, + "page_range": _page_range(page, total_pages), + } + + +def _paginated_articles() -> dict: + db_path = current_app.config["DB_PATH"] + name_query = request.args.get("article_q", "").strip() + doi_query = request.args.get("article_doi", "").strip() + pid_query = request.args.get("article_pid", "").strip() + status_query = request.args.get("article_status", "").strip() + history_id = request.args.get("history_id", "").strip() + page_size = _parse_int(request.args.get("article_page_size"), DEFAULT_PAGE_SIZE) + page_size = min(MAX_PAGE_SIZE, max(1, page_size)) + page = max(1, _parse_int(request.args.get("article_page"), 1)) + + total = count_articles( + db_path, name_query, doi_query, pid_query, status_query, history_id or None + ) + total_pages = max(1, -(-total // page_size)) # ceil division + page = min(page, total_pages) + + articles = list_articles( + db_path, + name_query, + doi_query, + pid_query, + status_query, + history_id or None, + limit=page_size, + offset=(page - 1) * page_size, + ) + for article in articles: + article["validated_at"] = _format_validated_at(article["validated_at"]) + + return { + "articles": articles, + "article_name_query": name_query, + "article_doi_query": doi_query, + "article_pid_query": pid_query, + "article_status_query": status_query, + "article_history_id": history_id, + "article_page": page, + "article_page_size": page_size, + "article_total": total, + "article_total_pages": total_pages, + "article_page_range": _page_range(page, total_pages), + "selected_package_name": ( + get_package_name(db_path, history_id) if history_id else None + ), } def _render_index(**context): context.setdefault("error_message", None) - return render_template("index.html", **_paginated_history(), **context) + context.setdefault("default_tab", "history") + return render_template( + "index.html", **_paginated_history(), **_paginated_articles(), **context + ) @web_blueprint.get("/history-list") @@ -140,15 +240,15 @@ def history_list(): return render_template("_history_list.html", **_paginated_history()) +@web_blueprint.get("/articles-list") +def articles_list(): + return render_template("_articles_list.html", **_paginated_articles()) + + @web_blueprint.get("/") def index(): - selected_id = request.args.get("history_id") - details = ( - get_validation_details(current_app.config["DB_PATH"], selected_id) - if selected_id - else None - ) - return _render_index(latest_result=details) + selected_id = request.args.get("history_id", "").strip() + return _render_index(default_tab="articles" if selected_id else "history") @web_blueprint.post("/validate") @@ -157,7 +257,6 @@ def validate(): if uploaded_file is None or not uploaded_file.filename: return _render_index( - latest_result=None, error_message=gettext("Selecione um arquivo .zip para validar."), ) @@ -170,9 +269,24 @@ def validate(): html_asset_urls=_html_preview_asset_urls(), ) except Exception as exc: - return _render_index(latest_result=None, error_message=str(exc)) - - return redirect(url_for("web.index", history_id=result["history_id"])) + return _render_index(error_message=str(exc)) + + return redirect( + url_for( + "web.index", + history_id=result["history_id"], + q=request.args.get("q") or None, + status=request.args.get("status") or None, + page_size=request.args.get("page_size") or None, + page=request.args.get("page") or None, + article_q=request.args.get("article_q") or None, + article_doi=request.args.get("article_doi") or None, + article_pid=request.args.get("article_pid") or None, + article_status=request.args.get("article_status") or None, + article_page_size=request.args.get("article_page_size") or None, + article_page=request.args.get("article_page") or None, + ) + ) @web_blueprint.get("/validation//report.csv") diff --git a/spsvalidator/src/spsvalidator/web/templates/_articles_list.html b/spsvalidator/src/spsvalidator/web/templates/_articles_list.html new file mode 100644 index 0000000..107b914 --- /dev/null +++ b/spsvalidator/src/spsvalidator/web/templates/_articles_list.html @@ -0,0 +1,85 @@ +{% set article_status_labels = {"ok": _("OK"), "issue": _("Com ocorrências")} %} +{% if article_history_id %} +

+ {{ _("Filtrando por pacote: %(name)s", name=selected_package_name or article_history_id) }} + {{ _("Limpar filtro") }} +

+{% endif %} +{% if articles %} +
+ + + + + + + + + + + + + + + {% for article in articles %} + + + + + + + + + + + {% endfor %} + +
{{ _("Pacote") }}{{ _("Data da validação") }}{{ _("Arquivo XML") }}{{ _("Título") }}{{ _("Autores") }}DOIPID{{ _("Status") }}
{{ article.package_name }}{{ article.validated_at }}{{ article.xml_path }}{{ article.title }}{{ article.authors_text }}{{ article.doi }}{{ article.pid }}{{ article_status_labels.get(article.article_status, article.article_status) }}
+
+{% else %} +{% if article_name_query or article_doi_query or article_pid_query or article_status_query or article_history_id %} +

{{ _("Nenhum artigo encontrado com esse filtro.") }}

+{% else %} +

{{ _("Nenhum artigo validado ainda.") }}

+{% endif %} +{% endif %} +{% if article_total > 0 %} + +{% endif %} \ No newline at end of file diff --git a/spsvalidator/src/spsvalidator/web/templates/_history_list.html b/spsvalidator/src/spsvalidator/web/templates/_history_list.html index 3d741b6..ac0b6ff 100644 --- a/spsvalidator/src/spsvalidator/web/templates/_history_list.html +++ b/spsvalidator/src/spsvalidator/web/templates/_history_list.html @@ -1,5 +1,6 @@ {% if history_items %} {% set status_labels = {"valid": _("Válido"), "invalid": _("Inválido"), "error": _("Erro")} %} +
@@ -10,11 +11,8 @@ - - - - - + + @@ -22,57 +20,95 @@ - + - - - {% endfor %}
{{ _("CRITICAL") }} {{ _("ERROR") }} {{ _("WARNING") }}{{ _("Exceptions") }}{{ _("Relatório") }}{{ _("CSV") }}{{ _("HTML") }}{{ _("PDF") }}{{ _("Exceções") }}{{ _("Ações") }}
{{ item.validated_at }} {{ item.package_name }}{{ status_labels.get(item.status, item.status) }}{{ status_labels.get(item.status, item.status) }} {{ item.xml_count }} {{ item.critical_count }} {{ item.error_count }} {{ item.warning_count }} {{ item.exceptions_count }} - {{ _("Relatório") }} - - {{ _("CSV") }} - - {% for group in item.html_previews %} - {% if item.html_previews|length > 1 %}{{ group.xml_stem }}:{% endif %} - {% for lang in group.langs %} - {{ lang }} - {% endfor %} - {% endfor %} - - {% for group in item.pdf_previews %} - {% if item.pdf_previews|length > 1 %}
{{ group.xml_stem }}:
{% endif %} - {% for pdf_name in group.pdf_names %} -
+
{{ pdf_name }} + class="chip-link" + aria-label="{{ _('Ver relatório de %(name)s', name=item.package_name) }}" + title="{{ _('Relatório') }}" + > + + {{ _("Relatório") }} + + + + + {{ _("CSV") }} + + + {% for group in item.html_previews %} +
+ {% if item.html_previews|length > 1 %}{{ group.xml_stem }}:{% endif %} +
+ {% for lang in group.langs %} + + + HTML {{ lang }} + + {% endfor %} +
+
+ {% endfor %} + + {% for group in item.pdf_previews %} +
+ {% if item.pdf_previews|length > 1 %}{{ group.xml_stem }}:{% endif %} +
+ {% for pdf in group.pdfs %} + + + {{ pdf.label }} + + {% endfor %} +
+
+ {% endfor %}
- {% endfor %} - {% endfor %}
+
{% else %} {% if request.args.get("q") or request.args.get("status") %}

{{ _("Nenhum pacote encontrado com esse filtro.") }}

@@ -81,21 +117,42 @@ {% endif %} {% endif %} {% if total > 0 %} -

- {{ _("Página %(page)s de %(total_pages)s (%(total)s pacotes)", page=page, total_pages=total_pages, total=total) }} - {% if page > 1 %} - {{ _("Anterior") }} - {% endif %} - {% if page < total_pages %} - {{ _("Próxima") }} - {% endif %} -

+ {% endif %} \ No newline at end of file diff --git a/spsvalidator/src/spsvalidator/web/templates/index.html b/spsvalidator/src/spsvalidator/web/templates/index.html index 9d07eea..b446c60 100644 --- a/spsvalidator/src/spsvalidator/web/templates/index.html +++ b/spsvalidator/src/spsvalidator/web/templates/index.html @@ -11,59 +11,294 @@ href="{{ url_for('web.static', filename='img/icon.png') }}" /> @@ -84,9 +319,12 @@

{{ app_display_name }}

{{ _("Validar pacote SPS") }}

-
+ - +
{% if error_message %}

{{ error_message }}

@@ -94,72 +332,89 @@

{{ _("Validar pacote SPS") }}

-

{{ _("Pacotes validados") }}

-
- - - - - - {% if name_query or status_query %} - {{ _("Limpar") }} - {% endif %} -
-
- {% include "_history_list.html" %} +
+ +
- -
- {% if latest_result %} -
-

{{ _("Artigos Considerados") }}

-
- - - - - - - - - - - - - {% for article in latest_result.articles %} - - - - - - - - - {% endfor %} - -
{{ _("Arquivo XML") }}{{ _("Título") }}{{ _("Autores") }}DOIPID{{ _("Status") }}
{{ article.xml_path }}{{ article.title }}{{ article.authors_text }}{{ article.doi }}{{ article.pid }}{{ article.article_status }}
+
+
+ + + + + + {% if name_query or status_query %} + {{ _("Limpar") }} + {% endif %} +
+
+ {% include "_history_list.html" %} +
+
+
+
+ + + + + + + + {% if article_name_query or article_doi_query or article_pid_query or article_status_query %} + {{ _("Limpar") }} + {% endif %} +
+
+ {% include "_articles_list.html" %} +
+
- {% endif %}