Skip to content

Commit a620fd1

Browse files
committed
Merge branch 'features/gobar-theme': sistema de perfiles y personalización
Perfil nacional/apn/subnacional/base, todo lo personalizable vía .ini/env (colores, imagen de fondo, título/subtítulo, Organizaciones, Institucional, logo del footer, /recursos), gate de Series a series_explorer, /group renombrado a Temas, limpieza de duplicación y guía de personalización.
2 parents 6c19a76 + 4517ee6 commit a620fd1

16 files changed

Lines changed: 401 additions & 48 deletions

File tree

README.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,11 @@ To install ckanext-gobar-theme:
5959

6060
## Config settings
6161

62-
None at present
63-
64-
**TODO:** Document any optional config settings here. For example:
65-
66-
# The minimum number of hours to wait before re-checking a resource
67-
# (optional, default: 24).
68-
ckanext.gobar_theme.some_setting = some_default_value
62+
Ver [`docs/personalizacion.md`](docs/personalizacion.md): perfil visual
63+
(`ckanext.gobar_theme.profile`), colores, imagen de fondo, título/subtítulo
64+
de la home, label de "Organizaciones", sección Institucional y logo del
65+
footer, sección /recursos — todo configurable por `.env`/`ckan.ini`, sin
66+
tocar templates ni código.
6967

7068

7169
## Developer installation

ckanext/gobar_theme/assets/css/gobar-base.css

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Cargado en todas las páginas
44
========================================================================== */
55

6-
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500;600;700;800&display=swap');
6+
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500;600;700;800&family=Lora:wght@700&display=swap');
77

88
/* ── VARIABLES ──
99
Paleta e identidad de marca "Datos Abiertos" (Dirección de Datos Abiertos):
@@ -33,6 +33,21 @@
3333
--font-cuerpo: 'Montserrat', 'Helvetica Neue', Arial, sans-serif;
3434
}
3535

36+
/* ── VARIANTE PONCHO (perfiles apn/subnacional/base) ──
37+
Prueba: pisa los mismos tokens con la paleta Poncho estricta (navy + celeste,
38+
Lora+Montserrat), sin mosaico ni índigo/violeta. Todo el resto del CSS ya
39+
consume estas variables, así que no hace falta tocar ningún componente. */
40+
body.theme-profile-apn,
41+
body.theme-profile-subnacional,
42+
body.theme-profile-base {
43+
--gobar-primary: #232D4F; /* navy-poncho */
44+
--gobar-primary-dark: #1A2039;
45+
--gobar-primary-darker: #141A2E;
46+
--gobar-accent: #039BE5; /* celeste */
47+
--gobar-accent-dark: #0767A7; /* enlace */
48+
--font-titulos: 'Lora', Georgia, serif;
49+
}
50+
3651
/* ── BASE ── */
3752
body { font-family: var(--font-cuerpo) !important; color: var(--gobar-negro); line-height: 1.6; }
3853
h1,h2,h3,h4,h5,h6,.page-heading { font-family: var(--font-titulos) !important; font-weight: 600; color: var(--gobar-negro); }

ckanext/gobar_theme/assets/css/gobar-home.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ body.homepage .main { padding: 0; }
1818
.gobar-hero h1 { font-family: var(--font-titulos)!important; font-size: clamp(29px, 4vw, 42px); font-weight: 800; color: var(--gobar-navy); line-height: 1.15; letter-spacing: -.01em; margin: 0 0 16px; }
1919
.gobar-hero h1 .accent { color: var(--gobar-primary); }
2020
.gobar-hero .lead { font-family: var(--font-cuerpo); font-size: 17px; color: var(--gobar-gris-oscuro); line-height: 1.7; margin: 0 auto 30px; max-width: 640px; font-weight: 400; }
21+
/* Perfil apn: sin subtítulo configurado no hay .lead debajo, más aire. */
22+
body.theme-profile-apn .gobar-hero h1 { margin-bottom: 32px; }
2123

2224
/* ── Buscador hero ── */
2325
.gobar-search { max-width: 600px; width: 100%; margin: 0 auto 44px; }

ckanext/gobar_theme/helpers.py

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,88 @@ def gobar_get_config(key: str, default: str = "") -> str:
152152
return toolkit.config.get(key, default)
153153

154154

155+
def gobar_theme_profile() -> str:
156+
return toolkit.config.get("ckanext.gobar_theme.profile", "nacional")
157+
158+
159+
def gobar_is_apn() -> bool:
160+
"""Único lugar que compara contra el literal "apn": todo lo demás
161+
(templates y helpers) llama a esta función en vez de repetir la
162+
comparación de string."""
163+
return gobar_theme_profile() == "apn"
164+
165+
166+
def gobar_show_recursos() -> bool:
167+
raw = str(
168+
toolkit.config.get("ckanext.gobar_theme.show_recursos", "auto")
169+
).strip().lower()
170+
if raw == "auto":
171+
return not gobar_is_apn()
172+
return raw in ("true", "1", "yes", "on")
173+
174+
175+
def gobar_institutional_name() -> str:
176+
configured = toolkit.config.get("ckanext.gobar_theme.institutional_name", "")
177+
if configured:
178+
return configured
179+
return "" if gobar_is_apn() else "Dirección de Datos Abiertos"
180+
181+
182+
def gobar_institutional_url() -> str:
183+
configured = toolkit.config.get("ckanext.gobar_theme.institutional_url", "")
184+
if configured:
185+
return configured
186+
return "" if gobar_is_apn() else "https://www.argentina.gob.ar/datos-abiertos"
187+
188+
189+
def gobar_organizations_label() -> str:
190+
return toolkit.config.get(
191+
"ckanext.gobar_theme.organizations_label", "Organizaciones"
192+
)
193+
194+
195+
def gobar_show_secretariat_logo() -> bool:
196+
return toolkit.config.get("ckanext.gobar_theme.show_secretariat_logo", True)
197+
198+
199+
def gobar_secretariat_logo_url() -> str:
200+
return toolkit.config.get("ckanext.gobar_theme.secretariat_logo_url", "")
201+
202+
203+
def gobar_secretariat_logo_alt() -> str:
204+
return toolkit.config.get(
205+
"ckanext.gobar_theme.secretariat_logo_alt",
206+
"Secretaría de Innovación, Ciencia y Tecnología",
207+
)
208+
209+
210+
def gobar_color_overrides_style() -> str:
211+
"""Construye el atributo style="..." con los overrides de color de
212+
.ini/env (vacíos por defecto). Se aplica en el <body> (base.html) en
213+
vez de un <style>/:root aparte: un atributo style inline le gana en
214+
especificidad a body.theme-profile-* sin necesitar !important."""
215+
overrides = {
216+
"--gobar-primary": toolkit.config.get("ckanext.gobar_theme.color_primary", ""),
217+
"--gobar-primary-dark": toolkit.config.get(
218+
"ckanext.gobar_theme.color_primary_dark", ""
219+
),
220+
"--gobar-accent": toolkit.config.get("ckanext.gobar_theme.color_accent", ""),
221+
}
222+
declarations = [f"{prop}: {value};" for prop, value in overrides.items() if value]
223+
return " ".join(declarations)
224+
225+
226+
def gobar_hero_background_style() -> str:
227+
image_url = toolkit.config.get("ckanext.gobar_theme.hero_background_image", "")
228+
if not image_url:
229+
return ""
230+
return (
231+
"background-image: linear-gradient(180deg, rgba(247,247,250,.88), "
232+
f"rgba(255,255,255,.92)), url('{image_url}'); "
233+
"background-size: cover; background-position: center;"
234+
)
235+
236+
155237
def gobar_is_spatial_enabled() -> bool:
156238
plugins_str: str = toolkit.config.get("ckan.plugins", "")
157239
return any(
@@ -235,6 +317,17 @@ def get_helpers() -> dict[str, Any]:
235317
# Custom pages
236318
"gobar_page_list": gobar_page_list,
237319
"gobar_get_config": gobar_get_config,
320+
"gobar_theme_profile": gobar_theme_profile,
321+
"gobar_is_apn": gobar_is_apn,
322+
"gobar_show_recursos": gobar_show_recursos,
323+
"gobar_institutional_name": gobar_institutional_name,
324+
"gobar_institutional_url": gobar_institutional_url,
325+
"gobar_organizations_label": gobar_organizations_label,
326+
"gobar_show_secretariat_logo": gobar_show_secretariat_logo,
327+
"gobar_secretariat_logo_url": gobar_secretariat_logo_url,
328+
"gobar_secretariat_logo_alt": gobar_secretariat_logo_alt,
329+
"gobar_color_overrides_style": gobar_color_overrides_style,
330+
"gobar_hero_background_style": gobar_hero_background_style,
238331
"gobar_is_spatial_enabled": gobar_is_spatial_enabled,
239332
"gobar_featured_datasets": gobar_featured_datasets,
240333
"gobar_format_date": gobar_format_date,

ckanext/gobar_theme/plugin.py

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,50 @@ def declare_config_options(
9292
key.ckanext.gobar_theme.contact_email,
9393
"datosargentina@sicyt.gob.ar",
9494
)
95+
# base|apn|nacional|subnacional. "nacional" preserva el look actual
96+
# (Datos Abiertos) sin tocar .env en el portal ya desplegado.
97+
declaration.declare(
98+
key.ckanext.gobar_theme.profile, "nacional"
99+
)
100+
# Nombre/link institucional del footer ("Institucional"): vacío por
101+
# defecto (todos los perfiles salvo "apn" usan el default fijo de
102+
# helpers.gobar_institutional_name/url, "Dirección de Datos
103+
# Abiertos"; en "apn" no se muestra el link salvo que se configure
104+
# por .env, porque cada organismo APN tiene el suyo propio).
105+
declaration.declare(key.ckanext.gobar_theme.institutional_name, "")
106+
declaration.declare(key.ckanext.gobar_theme.institutional_url, "")
107+
# true|false|auto. "auto" (default) = ocultar solo en el perfil
108+
# "apn" (la sección /recursos son productos de la Dirección de
109+
# Datos Abiertos, no aplican a un organismo APN individual);
110+
# true/false fuerza el valor sin importar el perfil.
111+
declaration.declare(key.ckanext.gobar_theme.show_recursos, "auto")
112+
# Nombre de "Organizaciones" en nav/footer/home/faceta: algunos
113+
# organismos APN son subdependencias de un ministerio y prefieren
114+
# otro término (p. ej. "Organismos", "Dependencias"). Opcional: el
115+
# default preserva el texto actual en todos los perfiles.
116+
declaration.declare(
117+
key.ckanext.gobar_theme.organizations_label, "Organizaciones"
118+
)
119+
# Subtítulo opcional del hero de la home (perfil apn, que no trae uno
120+
# propio): vacío = no se muestra. Ej. MAGyP: "En este portal podrás
121+
# obtener datos numéricos y estadísticos del sector agropecuario..."
122+
declaration.declare(key.ckanext.gobar_theme.subtitle, "")
123+
# Override puntual de colores (hex) por encima del preset del
124+
# perfil, y de la imagen de fondo del hero de la home. Vacíos por
125+
# defecto: no cambian nada hasta que se configuren por .env.
126+
declaration.declare(key.ckanext.gobar_theme.color_primary, "")
127+
declaration.declare(key.ckanext.gobar_theme.color_primary_dark, "")
128+
declaration.declare(key.ckanext.gobar_theme.color_accent, "")
129+
declaration.declare(key.ckanext.gobar_theme.hero_background_image, "")
130+
# Logo institucional del pie (hoy Secretaría de Innovación, Ciencia y
131+
# Tecnología): vacío = usa la imagen del theme. show=false lo oculta
132+
# por completo para organismos sin ese logo.
133+
declaration.declare_bool(key.ckanext.gobar_theme.show_secretariat_logo, True)
134+
declaration.declare(key.ckanext.gobar_theme.secretariat_logo_url, "")
135+
declaration.declare(
136+
key.ckanext.gobar_theme.secretariat_logo_alt,
137+
"Secretaría de Innovación, Ciencia y Tecnología",
138+
)
95139
declaration.declare_int(
96140
key.ckanext.gobar_theme.featured_datasets_limit, 4
97141
)
@@ -110,7 +154,7 @@ def dataset_facets(
110154
if package_type and package_type != "dataset":
111155
return facets_dict
112156
facets = OrderedDict()
113-
facets["organization"] = toolkit._("Organizaciones")
157+
facets["organization"] = gobar_helpers.gobar_organizations_label()
114158
facets["groups"] = toolkit._("Grupos")
115159
facets["res_format"] = toolkit._("Formato")
116160
facets["vocab_dataset_status"] = toolkit._("Estado")

ckanext/gobar_theme/templates/base.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
{% ckan_extends %}
22

3+
{# Única fuente de atributos del <body>: class (theme-profile-*, homepage,
4+
series-page) y el style inline con los overrides de color de .ini/env
5+
(gobar_color_overrides_style — vacío si no hay overrides configurados).
6+
Un style inline le gana en especificidad a body.theme-profile-* sin
7+
necesitar !important ni un <style>/:root aparte. #}
8+
{% block bodytag %}{{ super() }} class="theme-profile-{{ h.gobar_theme_profile() }}{% if request.path == '/' %} homepage{% endif %}{% if '/series' in request.path %} series-page{% endif %}"{% set color_style = h.gobar_color_overrides_style() %}{% if color_style %} style="{{ color_style }}"{% endif %}{% endblock %}
9+
310
{% block styles %}
411
{{ super() }}
512
{% asset 'gobar_theme/gobar_theme_css' %}

ckanext/gobar_theme/templates/footer.html

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,14 @@
1313
<h3>Explorar</h3>
1414
<ul>
1515
<li><a href="{{ h.url_for('dataset.search') }}">Datasets</a></li>
16-
<li><a href="{{ h.url_for('organization.index') }}">Organizaciones</a></li>
16+
<li><a href="{{ h.url_for('organization.index') }}">{{ h.gobar_organizations_label() }}</a></li>
1717
<li><a href="{{ h.url_for('group.index') }}">Temas</a></li>
18+
{% if h.plugin_loaded('series_explorer') %}
1819
<li><a href="{{ h.url_for('series.series') }}">Series de tiempo</a></li>
20+
{% endif %}
1921
</ul>
2022
</div>
23+
{% if not h.gobar_is_apn() %}
2124
<div>
2225
<h3>Recursos</h3>
2326
<ul>
@@ -27,17 +30,22 @@ <h3>Recursos</h3>
2730
<li><a href="https://github.com/datosgobar/portal-andino-v2">Portal Andino V2</a></li>
2831
</ul>
2932
</div>
33+
{% endif %}
3034
<div>
3135
<h3>Institucional</h3>
3236
<ul>
3337
<li><a href="{{ h.url_for('home.about') }}">Acerca del portal</a></li>
34-
<li><a href="https://www.argentina.gob.ar/datos-abiertos">Dirección de Datos Abiertos</a></li>
38+
{% if h.gobar_institutional_name() %}
39+
<li><a href="{{ h.gobar_institutional_url() }}">{{ h.gobar_institutional_name() }}</a></li>
40+
{% endif %}
3541
</ul>
3642
</div>
3743
</div>
3844
<div class="gobar-footer-legal">
3945
{% snippet "snippets/language_selector.html" %}
40-
<img src="{{ h.url_for_static('images/Logo_Secretaria-Innovacion_Blanco.png') }}"
41-
alt="Secretaría de Innovación, Ciencia y Tecnología" />
46+
{% if h.gobar_show_secretariat_logo() %}
47+
<img src="{{ h.gobar_secretariat_logo_url() or h.url_for_static('images/Logo_Secretaria-Innovacion_Blanco.png') }}"
48+
alt="{{ h.gobar_secretariat_logo_alt() }}" />
49+
{% endif %}
4250
</div>
4351
{% endblock %}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{% ckan_extends %}
2+
3+
{% block subtitle %}Temas{% endblock %}
4+
5+
{% block breadcrumb_content %}
6+
<li class="active">{% link_for "Temas", named_route=group_type+'.index' %}</li>
7+
{% endblock %}
8+
9+
{% block primary_content_inner %}
10+
<h1 class="hide-heading">Temas</h1>
11+
{% block groups_search_form %}
12+
{% snippet 'snippets/search_form.html', form_id='group-search-form', type=group_type, query=q, sorting_selected=sort_by_selected, count=page.item_count, placeholder='Buscar temas...', show_empty=request.args, no_bottom_border=true if page.items, sorting = [(_('Name Ascending'), 'title asc'), (_('Name Descending'), 'title desc')] %}
13+
{% endblock %}
14+
{% endblock %}
15+
16+
{% block secondary_content %}{% endblock %}

ckanext/gobar_theme/templates/header.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,21 @@
1717
<a class="nav-link" href="{{ h.url_for('dataset.search') }}">Datasets</a>
1818
</li>
1919
<li class="nav-item{% if request.path.startswith('/organization') %} active{% endif %}">
20-
<a class="nav-link" href="{{ h.url_for('organization.index') }}">Organizaciones</a>
20+
<a class="nav-link" href="{{ h.url_for('organization.index') }}">{{ h.gobar_organizations_label() }}</a>
2121
</li>
2222
<li class="nav-item{% if request.path.startswith('/group') %} active{% endif %}">
2323
<a class="nav-link" href="{{ h.url_for('group.index') }}">Temas</a>
2424
</li>
25+
{% if h.gobar_show_recursos() %}
2526
<li class="nav-item{% if '/recursos' in request.path %} active{% endif %}">
2627
<a class="nav-link" href="{{ h.url_for('recursos.recursos') }}">Recursos</a>
2728
</li>
29+
{% endif %}
30+
{% if h.plugin_loaded('series_explorer') %}
2831
<li class="nav-item{% if '/series' in request.path %} active{% endif %}">
2932
<a class="nav-link" href="{{ h.url_for('series.series') }}">Series</a>
3033
</li>
34+
{% endif %}
3135
<li class="nav-item{% if request.path.startswith('/about') %} active{% endif %}">
3236
<a class="nav-link" href="{{ h.url_for('home.about') }}">Acerca</a>
3337
</li>

ckanext/gobar_theme/templates/home/about.html

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
{% endblock %}
88

99
{% block about %}
10+
{% if not h.gobar_is_apn() %}
1011
<h2>Datos Abiertos</h2>
1112

1213
<p>
@@ -68,6 +69,39 @@ <h2>¿Qué productos brindamos?</h2>
6869
organismos nacionales, desarrollamos y ponemos a disposición los
6970
siguientes productos.
7071
</p>
72+
{% else %}
73+
<h2>Portal Andino</h2>
74+
75+
<p>
76+
Portal redistribuible de datos abiertos de la República Argentina.
77+
</p>
78+
79+
<p>
80+
Es un portal de código abierto desarrollado por el equipo de Datos
81+
Argentina y con las tecnologías de CKAN (Comprehensive Knowledge Archive
82+
Network) con el fin de ayudar a los organismos públicos a abrir sus
83+
datos.
84+
</p>
85+
86+
<h2>¿Para qué sirve?</h2>
87+
88+
<p>
89+
Andino es un portal diseñado para facilitar el proceso de publicación,
90+
navegación y descarga de los datos que abren los organismos. Permite que
91+
el público en general reutilice los datos y fomenta la transparencia en
92+
las instituciones públicas. Cumple con el Perfil de Aplicación Nacional
93+
de Metadatos para Datos Abiertos.
94+
</p>
95+
96+
<h2>¿Qué son los datos abiertos?</h2>
97+
98+
<p>
99+
Los datos son la materia prima para generar información. Los datos
100+
públicos son aquellos generados en el ámbito gubernamental. Los datos son
101+
abiertos cuando se encuentran publicados con un formato abierto, bajo una
102+
licencia abierta explícita y con sus metadatos asociados.
103+
</p>
104+
{% endif %}
71105

72106
<h2>Sobre CKAN</h2>
73107
{% snippet 'home/snippets/about_text.html' %}

0 commit comments

Comments
 (0)