From efea1fe88d1f262237461a0028168b0f803d789e Mon Sep 17 00:00:00 2001 From: f Date: Wed, 27 Oct 2021 15:09:48 -0300 Subject: [PATCH 1/7] =?UTF-8?q?los=20elementos=20con=20la=20clase=20conten?= =?UTF-8?q?t=20tienen=20m=C3=A1rgenes=20internos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _sass/content.scss | 11 +++++++++++ assets/css/styles.scss | 1 + 2 files changed, 12 insertions(+) create mode 100644 _sass/content.scss diff --git a/_sass/content.scss b/_sass/content.scss new file mode 100644 index 0000000..6914190 --- /dev/null +++ b/_sass/content.scss @@ -0,0 +1,11 @@ +/// Todos los elementos dentro de .content tienen margen inferior, salvo +/// el último, para no modificar el padding y margin del contenedor. +.content { + & > * { + margin-bottom: 1rem; + + &:last-child { + margin-bottom: 0; + } + } +} diff --git a/assets/css/styles.scss b/assets/css/styles.scss index 406eb99..7ab6cf4 100644 --- a/assets/css/styles.scss +++ b/assets/css/styles.scss @@ -132,6 +132,7 @@ $label-margin-bottom: 0; @import "snap"; @import "editor"; @import "menu"; +@import "content"; /// La barra de progreso de Turbo tiene el color primario /// de la paleta, definido por Bootstrap o por nosotres. From 8ee4dc7cf67f81cf924329e9af6c349cba908655 Mon Sep 17 00:00:00 2001 From: f Date: Wed, 27 Oct 2021 15:22:44 -0300 Subject: [PATCH 2/7] incorporar las traducciones en env.js --- env.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/env.js b/env.js index 6210493..b38f2f9 100644 --- a/env.js +++ b/env.js @@ -6,3 +6,7 @@ window.env = { AIRBRAKE_PROJECT_KEY: '{{ site.env.AIRBRAKE_PROJECT_KEY }}', JEKYLL_ENV: '{{ site.env.JEKYLL_ENV }}' } + +window.site = { + "i18n": {{ site.i18n | jsonify }} +} From d452a85d09129877fa0fe313f7004944decbd45c Mon Sep 17 00:00:00 2001 From: f Date: Wed, 27 Oct 2021 15:23:50 -0300 Subject: [PATCH 3/7] buscar las traducciones en window --- _packs/controllers/notification_controller.js | 16 +--------------- _packs/controllers/search_controller.js | 11 +---------- 2 files changed, 2 insertions(+), 25 deletions(-) diff --git a/_packs/controllers/notification_controller.js b/_packs/controllers/notification_controller.js index 17eaaa7..d00bfd4 100644 --- a/_packs/controllers/notification_controller.js +++ b/_packs/controllers/notification_controller.js @@ -19,7 +19,7 @@ export default class extends Controller { if (!response.ok) return - data.site = await this.site() + data.site = window.site const template = await response.text() const html = await this.engine.parseAndRender(template, data) @@ -63,18 +63,4 @@ export default class extends Controller { return window.liquid } - - /* - * Site config (actually just translation strings) - * - * @return [Object] - */ - async site () { - if (!window.site) { - const data = await fetch('assets/data/site.json') - window.site = await data.json() - } - - return window.site - } } diff --git a/_packs/controllers/search_controller.js b/_packs/controllers/search_controller.js index e85de43..0303601 100644 --- a/_packs/controllers/search_controller.js +++ b/_packs/controllers/search_controller.js @@ -47,7 +47,7 @@ export default class extends Controller { const main = document.querySelector('main') const results = window.index.search(q).map(r => window.data.find(a => a.id == r.ref)) - const site = await this.site() + const site = window.site const request = await fetch('assets/templates/results.html') const template = await request.text() const html = await this.engine.parseAndRender(template, { q, site, results }) @@ -98,13 +98,4 @@ export default class extends Controller { return window.liquid } - - async site () { - if (!window.site) { - const data = await fetch('assets/data/site.json') - window.site = await data.json() - } - - return window.site - } } From 8bcb4f066f8ae8b17dc70e6238708e5a97422c0c Mon Sep 17 00:00:00 2001 From: f Date: Wed, 27 Oct 2021 15:18:05 -0300 Subject: [PATCH 4/7] las plantillas de liquid.js se incorporan en env.js --- assets/templates/alert.html | 14 ++++++++------ assets/templates/results.html | 34 ++++++++++++++++++---------------- env.js | 17 +++++++++++++++++ 3 files changed, 43 insertions(+), 22 deletions(-) diff --git a/assets/templates/alert.html b/assets/templates/alert.html index b520708..1ef923d 100644 --- a/assets/templates/alert.html +++ b/assets/templates/alert.html @@ -1,7 +1,9 @@ - +{%- endraw -%} diff --git a/assets/templates/results.html b/assets/templates/results.html index 2473966..65c0e11 100644 --- a/assets/templates/results.html +++ b/assets/templates/results.html @@ -1,17 +1,19 @@ -
-
- {% for item in results %} - + {% endfor %} +
+
+{%- endraw -%} diff --git a/env.js b/env.js index b38f2f9..711fa4f 100644 --- a/env.js +++ b/env.js @@ -10,3 +10,20 @@ window.env = { window.site = { "i18n": {{ site.i18n | jsonify }} } + +{%- comment -%} + Para agregar plantillas que se procesan con JS, las agregamos en + Liquid dentro de assets/templates/ y luego las importamos acá, de forma + que estén disponibles para JS sin tener que descargarlas. + + Es importante que la plantilla esté envuelta por el tag `{% raw %}`, + para que no sea procesado en el momento de generar env.js, sino en el + navegador. +{%- endcomment -%} +{%- capture alert %}{% include_relative assets/templates/alert.html %}{% endcapture -%} +{%- capture results %}{% include_relative assets/templates/results.html %}{% endcapture -%} + +window.templates = { + "alert": {{ alert | markdownify }}, + "results": {{ results | markdownify }}, +} From e0d6870fd7a5f5c0add95d95856d084e7a2e31f4 Mon Sep 17 00:00:00 2001 From: f Date: Wed, 27 Oct 2021 15:18:35 -0300 Subject: [PATCH 5/7] no cachear env.js --- _layouts/default.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_layouts/default.html b/_layouts/default.html index 3aec209..e7ccf9f 100644 --- a/_layouts/default.html +++ b/_layouts/default.html @@ -24,7 +24,7 @@ si no existe. {% endcomment %} - + {% include_cached pack.html %} {% comment %} From c41e9df446253724bb6cdb8c7141dc337cd253d3 Mon Sep 17 00:00:00 2001 From: f Date: Wed, 27 Oct 2021 15:21:16 -0300 Subject: [PATCH 6/7] buscar las plantillas en window --- _packs/controllers/notification_controller.js | 6 +----- _packs/controllers/search_controller.js | 3 +-- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/_packs/controllers/notification_controller.js b/_packs/controllers/notification_controller.js index d00bfd4..edb3299 100644 --- a/_packs/controllers/notification_controller.js +++ b/_packs/controllers/notification_controller.js @@ -15,13 +15,9 @@ export default class extends Controller { * nothing if the template isn't found. */ async render (name, data = {}) { - const response = await fetch(this.template(name)) - - if (!response.ok) return - data.site = window.site - const template = await response.text() + const template = window.templates.alert const html = await this.engine.parseAndRender(template, data) this.element.innerHTML = html diff --git a/_packs/controllers/search_controller.js b/_packs/controllers/search_controller.js index 0303601..5608ab2 100644 --- a/_packs/controllers/search_controller.js +++ b/_packs/controllers/search_controller.js @@ -48,8 +48,7 @@ export default class extends Controller { const main = document.querySelector('main') const results = window.index.search(q).map(r => window.data.find(a => a.id == r.ref)) const site = window.site - const request = await fetch('assets/templates/results.html') - const template = await request.text() + const template = window.templates.results const html = await this.engine.parseAndRender(template, { q, site, results }) const title = `${site.i18n.search.title} - ${q}` const query = new URLSearchParams({ q }) From cefd4765f7c3977e36b8f71781168d5692be80f6 Mon Sep 17 00:00:00 2001 From: f Date: Wed, 27 Oct 2021 16:47:18 -0300 Subject: [PATCH 7/7] jsonify --- env.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/env.js b/env.js index 711fa4f..fa90467 100644 --- a/env.js +++ b/env.js @@ -24,6 +24,6 @@ window.site = { {%- capture results %}{% include_relative assets/templates/results.html %}{% endcapture -%} window.templates = { - "alert": {{ alert | markdownify }}, - "results": {{ results | markdownify }}, + "alert": {{ alert | jsonify }}, + "results": {{ results | jsonify }}, }