@@ -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+
155237def 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 ,
0 commit comments