Commit 1c44fdb3 authored by Pierre Dittgen's avatar Pierre Dittgen
Browse files

Switch from homepageconfig.json to config.yaml

parent f18e56e2
......@@ -12,8 +12,8 @@ BADGE_CONFIG_URL="https://git.opendatafrance.net/validata/validata-badge/raw/mas
# Comment the following line to disable badge display
SHIELDS_IO_BASE_URL="https://img.shields.io/"
# Homepage sections and blocks config file path
HOMEPAGE_CONFIG_FILE=homepage_config.json.example
# Configuration file
CONFIG=config.example.yaml
# Uncomment to enable [Matomo](https://matomo.org/) analytics
# MATOMO_BASE_URL=""
......
......@@ -2,7 +2,6 @@ __pycache__/
validata_ui.egg-info/
.env
.vscode/
homepage_config.json
src/
# Cypress ui tests
......
# Changelog
## next
- replace `homepage_config.json` file by `config.yaml` that contains homepage schemas and catalog
settings but also header and footer links
## 0.4.0a1
- Fix badge display
......
footer:
links:
- title: API
url: https://go.validata.fr/api/v1/apidocs
- title: Codes sources
url: https://git.opendatafrance.net/validata
- title: Salon de discussion public
url: https://riot.im/app/#/room/#validata:jailbreak.paris
header:
links:
- title: Mode d'emploi
url: https://validata.fr/doku.php?id=utilisation
- title: Documentation SCDL
url: https://scdl.opendatafrance.net/docs
- title: Forum
url: https://teamopendata.org/c/socle-commun-des-donnees-locales
homepage:
sections:
- name: scdl
title: Socle Commun des Données Locales
description: Ces schémas respectent <a href='https://scdl.opendatafrance.net/docs/CONTRIBUTING.html' target='_blank'>les standards du SCDL</a>.
catalog: https://git.opendatafrance.net/scdl/catalog/raw/master/catalog.json
- name: other
title: Autres schémas
description: Ces schémas sont proches du SCDL mais n'en font pas encore partie.
catalog:
version: 1
schemas:
- name: lieux-covoiturage
repo_url: https://github.com/etalab/schema-lieux-covoiturage
- name: decp-dpa
repo_url: https://github.com/etalab/schema-decp-dpa
- name: stationnement
repo_url: https://github.com/etalab/schema-stationnement
- name: external,
title: Validateurs externes
description: Sélection d'outils de validation de données complémentaires à Validata.
links:
- name: inspire
type: external
title: INSPIRE
description: proposé par la Commission Européenne pour tester des ressources géographiques (données, services ou métadonnées)
website: http://inspire-sandbox.jrc.ec.europa.eu/validator/
- name: bal
type: external
title: BAL
description: proposé par la mission Etalab pour tester des données Adresse produites localement (format BAL 1.1)
website: https://adresse.data.gouv.fr/bases-locales/validateur
- name: cvdtc
type: external
title: CVDTC
description: proposé par l'AFIMB dans le cadre du projet Chouette pour tester des données de transport collectif (GTFS ou NEPTUNE)
website: http://www.conversion-validation-donnees-tc.org/
footer:
links:
- title: API
url: https://go.validata.fr/api/v1/apidocs
- title: Codes sources
url: https://git.opendatafrance.net/validata
- title: Salon de discussion public
url: https://riot.im/app/#/room/#validata:jailbreak.paris
header:
links:
- title: Mode d'emploi
url: https://validata.fr/doku.php?id=utilisation
- title: Documentation SCDL
url: https://scdl.opendatafrance.net/docs
- title: Forum
url: https://teamopendata.org/c/socle-commun-des-donnees-locales
homepage:
sections:
- name: scdl
title: Socle Commun des Données Locales
description: Ces schémas respectent <a href='https://scdl.opendatafrance.net/docs/CONTRIBUTING.html' target='_blank'>les standards du SCDL</a>.
catalog: https://git.opendatafrance.net/scdl/catalog/raw/master/catalog.json
- name: other
title: Autres schémas
description: Ces schémas sont proches du SCDL mais n'en font pas encore partie.
catalog:
version: 1
schemas:
- name: lieux-covoiturage
repo_url: https://github.com/etalab/schema-lieux-covoiturage
- name: decp-dpa
repo_url: https://github.com/etalab/schema-decp-dpa
- name: stationnement
repo_url: https://github.com/etalab/schema-stationnement
- name: external,
title: Validateurs externes
description: Sélection d'outils de validation de données complémentaires à Validata.
links:
- name: inspire
type: external
title: INSPIRE
description: proposé par la Commission Européenne pour tester des ressources géographiques (données, services ou métadonnées)
website: http://inspire-sandbox.jrc.ec.europa.eu/validator/
- name: bal
type: external
title: BAL
description: proposé par la mission Etalab pour tester des données Adresse produites localement (format BAL 1.1)
website: https://adresse.data.gouv.fr/bases-locales/validateur
- name: cvdtc
type: external
title: CVDTC
description: proposé par l'AFIMB dans le cadre du projet Chouette pour tester des données de transport collectif (GTFS ou NEPTUNE)
website: http://www.conversion-validation-donnees-tc.org/
{
"sections": [
{
"name": "schema-catalog",
"title": "A catalog of schemas",
"description": "This is a catalog of schemas that is published somewhere. (Note: the catalog must be conform to this schema: https://opendataschema.frama.io/catalog/schema-catalog.json",
"catalog": "https://git.opendatafrance.net/scdl/catalog/raw/master/catalog.json"
},
{
"name": "schema-list",
"title": "A list of schemas",
"description": "This is a list of other schemas.",
"catalog": {
"version": 1,
"schemas": [
{
"repo_url": "https://github.com/CharlesNepote/liste-prenoms-nouveaux-nes/",
"schema_filename": "prenom-schema.json",
"doc_url_by_ref": {
"~latest_tag": "https://scdl.opendatafrance.net/docs/schemas/prenoms.html",
"next": "https://scdl.opendatafrance.net/docs-next/schemas/prenoms.html"
}
},
{
"name": "irve",
"repo_url": "https://github.com/etalab/schema-irve/",
"doc_url_by_ref": {
"~latest_tag": "https://scdl.opendatafrance.net/docs/schemas/irve.html",
"next": "https://scdl.opendatafrance.net/docs-next/schemas/irve.html"
}
}
]
}
},
{
"name": "external",
"title": "A list of links to external validators",
"description": "This is a selection of validation tools that complement Validata.",
"links": [
{
"name": "inspire",
"type": "external",
"title": "INSPIRE",
"description": "proposé par la Commission Européenne pour tester des ressources géographiques (données, services ou métadonnées)",
"website": "http://inspire-sandbox.jrc.ec.europa.eu/validator/"
},
{
"name": "bal",
"type": "external",
"title": "BAL",
"description": "proposé par la mission Etalab pour tester des données Adresse produites localement (format BAL 1.1)",
"website": "https://adresse.data.gouv.fr/bases-locales/validateur"
}
]
}
]
}
\ No newline at end of file
......@@ -6,6 +6,7 @@ flask
frictionless >= 3.39.0
lxml
python-dotenv
pyyaml
requests
sentry-sdk[flask] == 0.14.3
toml
......
......@@ -20,6 +20,7 @@ ezodf==0.3.2 # via -r requirements.in, validata-core
flask==1.1.2 # via -r requirements.in, sentry-sdk
frictionless==3.46.0 # via -r requirements.in, validata-core
idna==2.10 # via requests
importlib-metadata==3.3.0 # via jsonschema
importlib-resources==3.3.0 # via validata-core
isodate==0.6.0 # via frictionless
itsdangerous==1.1.0 # via flask
......@@ -43,7 +44,7 @@ python-gitlab==2.5.0 # via opendataschema
python-slugify==4.0.1 # via frictionless
python-stdnum==1.14 # via validata-core
pytz==2020.4 # via pandas
pyyaml==5.3.1 # via frictionless
pyyaml==5.3.1 # via -r requirements.in, frictionless
requests==2.24.0 # via -r requirements.in, cachecontrol, frictionless, opendataschema, pygithub, python-gitlab, validata-core
sentry-sdk[flask]==0.14.3 # via -r requirements.in
shellingham==1.3.2 # via typer
......@@ -55,10 +56,12 @@ text-unidecode==1.3 # via python-slugify
toml==0.10.2 # via -r requirements.in
toolz==0.11.1 # via validata-core
typer[all]==0.3.2 # via frictionless
typing-extensions==3.7.4.3 # via importlib-metadata
urllib3==1.25.11 # via requests, sentry-sdk
validators==0.18.1 # via frictionless
werkzeug==1.0.1 # via flask
wrapt==1.12.1 # via deprecated
zipp==3.4.0 # via importlib-metadata, importlib-resources
# The following packages are considered to be unsafe in a requirements file:
# setuptools
......@@ -53,9 +53,9 @@ fetch_schema = generate_schema_from_url_func(caching_session)
# And load schema catalogs which URLs are found in homepage_config.json
schema_catalog_registry = SchemaCatalogRegistry(caching_session)
if config.HOMEPAGE_CONFIG:
if config.CONFIG:
log.info("Initializing homepage sections...")
for section in config.HOMEPAGE_CONFIG["sections"]:
for section in config.CONFIG["homepage"]["sections"]:
name = section["name"]
log.info('Initializing homepage section "{}"...'.format(name))
catalog_ref = section.get("catalog")
......
import json
import yaml
import logging
import os
import sys
......@@ -44,16 +44,16 @@ SHIELDS_IO_BASE_URL = os.environ.get("SHIELDS_IO_BASE_URL") or None
if SHIELDS_IO_BASE_URL:
SHIELDS_IO_BASE_URL = without_trailing_slash(SHIELDS_IO_BASE_URL)
HOMEPAGE_CONFIG_FILE = os.environ.get("HOMEPAGE_CONFIG_FILE") or None
HOMEPAGE_CONFIG = None
if HOMEPAGE_CONFIG_FILE:
HOMEPAGE_CONFIG_FILE = Path(HOMEPAGE_CONFIG_FILE)
with HOMEPAGE_CONFIG_FILE.open() as fd:
CONFIG_FILE = os.environ.get("CONFIG_FILE") or None
CONFIG = None
if CONFIG_FILE:
CONFIG_FILE = Path(CONFIG_FILE)
with CONFIG_FILE.open() as fd:
try:
HOMEPAGE_CONFIG = json.load(fd)
CONFIG = yaml.full_load(fd)
except ValueError as exc:
raise ValueError(
f"Could not load homepage config JSON file {HOMEPAGE_CONFIG_FILE}"
f"Could not load config YAML file {CONFIG_FILE}"
) from exc
MATOMO_BASE_URL = os.getenv("MATOMO_BASE_URL") or None
......
......@@ -146,8 +146,8 @@ class SchemaInstance:
return {"schema_url": self.url}
def find_section_title(self, section_name):
if config.HOMEPAGE_CONFIG:
for section in config.HOMEPAGE_CONFIG["sections"]:
if config.CONFIG:
for section in config.CONFIG["homepage"]["sections"]:
if section["name"] == section_name:
return section.get("title")
return None
......@@ -720,11 +720,11 @@ def home():
def iter_sections():
"""Yield sections of the home page, filled with schema metadata."""
if not config.HOMEPAGE_CONFIG:
if not config.CONFIG["homepage"]:
return
# Iterate on all sections
for section in config.HOMEPAGE_CONFIG["sections"]:
for section in config.CONFIG["homepage"]["sections"]:
# section with only links to external validators
if "links" in section:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment