From 21eea415833895bbf41907e2e835b36b425cd752 Mon Sep 17 00:00:00 2001 From: f Date: Thu, 15 Apr 2021 18:33:37 -0300 Subject: [PATCH 01/32] deprecar la referencia de markdown es una supervivencia de cuando se escribia md a mano --- app/controllers/application_controller.rb | 2 -- config/routes.rb | 2 -- 2 files changed, 4 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 38b2b72c..bc375dcf 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -23,8 +23,6 @@ class ApplicationController < ActionController::Base redirect_to sites_path end - def markdown; end - private def uuid?(string) diff --git a/config/routes.rb b/config/routes.rb index 3a807285..766df50a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -8,8 +8,6 @@ Rails.application.routes.draw do root 'application#index' - get 'markdown', to: 'application#markdown' - constraints(Constraints::ApiSubdomain.new) do scope module: 'api' do namespace :v1 do From 81a565cd0f78b848980b2be5c4e6cae5679932ac Mon Sep 17 00:00:00 2001 From: f Date: Sun, 18 Apr 2021 19:00:21 -0300 Subject: [PATCH 02/32] =?UTF-8?q?renovar=20la=20cach=C3=A9=20de=20formular?= =?UTF-8?q?ios?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit usando la fecha de modificación del post, esto nos permite renovar la caché haciendo `touch _es/*.markdown` en el repositorio. --- app/models/metadata_template.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/models/metadata_template.rb b/app/models/metadata_template.rb index 58000596..33af8192 100644 --- a/app/models/metadata_template.rb +++ b/app/models/metadata_template.rb @@ -19,10 +19,16 @@ MetadataTemplate = Struct.new(:site, :document, :name, :label, :type, @cache_key ||= 'post/' + post.uuid.value + '/' + name.to_s end + # Genera una versión de caché en base a la fecha de modificación del + # Post, el valor actual y los valores posibles, de forma que cualquier + # cambio permita renovar la caché. + # + # @return [String] def cache_version - value.hash.to_s + values.hash.to_s + post.cache_version + value.hash.to_s + values.hash.to_s end + # @return [String] def cache_key_with_version cache_key + '-' + cache_version end From 78a830a0e7502721657603c6f8f7ac84cee9db53 Mon Sep 17 00:00:00 2001 From: f Date: Wed, 21 Apr 2021 10:18:01 -0300 Subject: [PATCH 03/32] =?UTF-8?q?eliminar=20las=20traducciones=20tambi?= =?UTF-8?q?=C3=A9n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/locales/en.yml | 39 --------------------------------------- config/locales/es.yml | 38 -------------------------------------- 2 files changed, 77 deletions(-) diff --git a/config/locales/en.yml b/config/locales/en.yml index 02570b12..c07f302a 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -224,45 +224,6 @@ en: accept: 'Someone invited you to collaborate on their site. If you accept the invitation, you can access the site.' reject: "If you decline, you won't have access." close: 'Close help' - markdown: - intro: 'The text is formatted using a syntax called Markdown, a - simple format that can be easily written just by remembering some - rules, and that can be converted to a web page, or to PDF and ePub - files. You can use the buttons below for basic formatting. If - you need help, here you have a markdown - cheatsheet.' - back: 'Go back' - input: 'If we write...' - output: 'We get...' - bold: 'Bold' - italic: 'Emphasis' - heading: 'Title' - link: - text: 'A link' - url: 'https://example.org' - quote: 'A quote from a text we liked' - ul: 'Our TODO list' - ol: 'Steps for our machiavelic plans' - img: - text: 'Kéfir island' - url: 'https://kefir.red/images/isla.png' - ltr: 'Introduction' - rtl: 'مقدمة' - dir: "These are tricky. If you want to use an expression in a - language using another direction, like using an Arabic expression - on an English text, or viceversa, you have to inform both - direction and language so the markdown processor understands it - has to change it internally. Otherwise you may see out of order - words, specially in the PDF results." - distraction_free_html: 'You can have a distraction free writing session - by clicking the button' - preview_html: 'Click the preview - button to see the results.' - autocomplete_html: "Some of these fields can be auto-completed. If - you know what to put on them, just start writing and the - auto-complete will suggest available options. If the option doesn't - exist, finish writing and press Enter to add a new one. - To empty the field, click the × button on your right." deploys: deploy_local: title: 'Host at Sutty' diff --git a/config/locales/es.yml b/config/locales/es.yml index 5bb4a221..458b5148 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -227,44 +227,6 @@ es: reject: 'Si rechazas la invitación, no tendrás acceso.' pull: 'Tienes actualizaciones pendientes :)' close: 'Cerrar ayuda' - markdown: - intro: 'El formato del texto se llama Markdown. Es un formato - simple que puede ser escrito recordando unas pocas reglas y que - luego puede ser convertido a una página web, o un PDF, o un ePub. - Puedes usar los botones para dar formato básico a tu texto. Para - cuestiones más avanzadas, aquí tienes un recordatorio de markdown.' - back: 'Volver' - input: 'Si escribimos...' - output: 'Obtenemos...' - bold: 'Negrita' - italic: 'Énfasis' - heading: 'Título' - link: - text: 'Un vínculo' - url: 'https://ejemplo.org' - quote: 'Un recorte de texto que nos gustó' - ul: 'Lista de cosas para hacer' - ol: 'Pasos para un plan maquiavélico' - img: - text: 'La isla de Kéfir' - url: 'https://kefir.red/images/isla.png' - ltr: 'Introducción' - rtl: 'مقدمة' - dir: 'Esta sintaxis puede ser complicada. Si quieres mezclar - expresiones en idiomas que usan otra dirección, como usar una - expresión en árabe en medio de un texto en castellano, o - viceversa, tienes que especificar la dirección y el idioma de esta - manera. De otra forma verás palabras fuera de orden, - especialmente en la versión en PDF.' - distraction_free_html: 'Puedes escribir sin distracciones presionando el botón ' - preview_html: 'Utiliza el botón de previsualización para ver el texto generado' - autocomplete_html: 'Algunos de estos campos se autocompletan. Si ya - sabes qué quieres poner, solo empieza a escribir y el autocompletado - te sugerirá las opciones disponibles. Si no existe lo que quieres - poner, termina de escribir y presiona Entrar para agregar - opciones que aun no existen. Para vaciar las opciones, usa el botón - × a la derecha.' deploys: deploy_local: title: 'Alojar en Sutty' From 2fbbb212adacd606e028cb404a91d79f235964fd Mon Sep 17 00:00:00 2001 From: f Date: Sat, 24 Apr 2021 19:55:15 -0300 Subject: [PATCH 04/32] validar el sitio antes de subir una imagen MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit si `Site` no es válido (por ejemplo la `description` es muy corta), no se pueden guardar los archivos estáticos asociados, porque `ActiveStorage::Attached` solo se copia al disco cuando se guardan a través de `Site#static_files`. el error que se producía es que `MetadataFile` no puede vincular el archivo porque todavía no fue copiado al disco. este cambio have que `MetadataFile` no valide cuando `Site` no valida. queda un error pendiente en `Site::StaticFileMigration` con una situación similar. para eso necesitamos identificar el momento en que el archivo se "sube" al disco, es decir se copia el `IO` al directorio, a través de `ActiveStorage::Service::DiskService#upload`. fixes #1197 fixes #1196 fixes #1195 fixes #1194 fixes #1193 fixes #1192 --- app/models/metadata_file.rb | 1 + config/locales/en.yml | 2 ++ config/locales/es.yml | 2 ++ 3 files changed, 5 insertions(+) diff --git a/app/models/metadata_file.rb b/app/models/metadata_file.rb index b4b144e7..80cefa27 100644 --- a/app/models/metadata_file.rb +++ b/app/models/metadata_file.rb @@ -16,6 +16,7 @@ class MetadataFile < MetadataTemplate def validate super + errors << I18n.t("metadata.#{type}.site_invalid") if site.invalid? errors << I18n.t("metadata.#{type}.path_required") if path_missing? errors << I18n.t("metadata.#{type}.no_file_for_description") if no_file_for_description? diff --git a/config/locales/en.yml b/config/locales/en.yml index 02570b12..94ab7e54 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -34,10 +34,12 @@ en: metadata: cant_be_empty: 'This field cannot be empty' image: + site_invalid: 'The image cannot be stored if the site configuration is not valid' not_an_image: 'Not an image' path_required: 'Missing image for upload' no_file_for_description: "There's a description with no associated image" file: + site_invalid: 'The file cannot be stored if the site configuration is not valid' path_required: "Missing file for upload" no_file_for_description: "There's a description with no associated file" event: diff --git a/config/locales/es.yml b/config/locales/es.yml index 5bb4a221..6d84d7ea 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -34,10 +34,12 @@ es: metadata: cant_be_empty: 'El campo no puede estar vacío' image: + site_invalid: 'La imagen no se puede almacenar si la configuración del sitio no es válida' not_an_image: 'No es una imagen' path_required: 'Se necesita una imagen' no_file_for_description: 'Se envió una descripción sin imagen asociada' file: + site_invalid: 'El archivo no se puede almacenar si la configuración del sitio no es válida' path_required: 'Se necesita un archivo' no_file_for_description: 'se envió una descripción sin archivo asociado' event: From 22f61dc31f860f78d2829da6f75948fcf7d5de82 Mon Sep 17 00:00:00 2001 From: f Date: Tue, 27 Apr 2021 11:25:37 -0300 Subject: [PATCH 05/32] eliminar los espacios en el lugar correcto MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit esto hacía que no se puedan enviar los correos de excepciones porque producían una excepción a su vez. --- app/jobs/backtrace_job.rb | 4 +++- app/views/exception_notifier/_data.text.erb | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/jobs/backtrace_job.rb b/app/jobs/backtrace_job.rb index 50ee155b..0f3f5de8 100644 --- a/app/jobs/backtrace_job.rb +++ b/app/jobs/backtrace_job.rb @@ -30,7 +30,9 @@ class BacktraceJob < ApplicationJob # Encuentra el código fuente del error source = data.dig('sourcesContent', data['sources']&.index(backtrace['file']))&.split("\n") - backtrace['function'] = source[backtrace['line'] - 1] if source.present? + # XXX: Elimina la sangría aunque cambie las columnas porque + # eso lo vamos a ver en el archivo fuente directo. + backtrace['function'] = source[backtrace['line'] - 1].strip if source.present? end end end diff --git a/app/views/exception_notifier/_data.text.erb b/app/views/exception_notifier/_data.text.erb index 3493d68b..09313f4c 100644 --- a/app/views/exception_notifier/_data.text.erb +++ b/app/views/exception_notifier/_data.text.erb @@ -3,7 +3,7 @@ # <%= error['type'] %>: <%= error['message'] %> ``` -<%= Terminal::Table.new headings: error['backtrace'].first.keys, rows: error['backtrace'].map(&:values).map(&:strip) %> +<%= Terminal::Table.new headings: error['backtrace'].first.keys, rows: error['backtrace'].map(&:values) %> ``` <% end %> From c8f11186405be70b947b731299d7f7f67774f8eb Mon Sep 17 00:00:00 2001 From: f Date: Tue, 27 Apr 2021 11:27:17 -0300 Subject: [PATCH 06/32] testear el procesamiento de errores de js --- app/jobs/backtrace_job.rb | 7 +- config/environments/test.rb | 9 ++ test/jobs/backtrace_job_test.rb | 147 ++++++++++++++++++++++++++++++++ 3 files changed, 162 insertions(+), 1 deletion(-) create mode 100644 test/jobs/backtrace_job_test.rb diff --git a/app/jobs/backtrace_job.rb b/app/jobs/backtrace_job.rb index 0f3f5de8..eab9f226 100644 --- a/app/jobs/backtrace_job.rb +++ b/app/jobs/backtrace_job.rb @@ -38,7 +38,7 @@ class BacktraceJob < ApplicationJob end begin - raise BacktraceException, "#{origin}: #{params['errors']&.first&.dig('message')}" + raise BacktraceException, "#{origin}: #{message}" rescue BacktraceException => e ExceptionNotifier.notify_exception(e, data: { site: site.name, params: params, _backtrace: true }) end @@ -104,4 +104,9 @@ class BacktraceJob < ApplicationJob rescue URI::Error params.dig('context', 'url') end + + # @return [String,Nil] + def message + @message ||= params['errors']&.first&.dig('message') + end end diff --git a/config/environments/test.rb b/config/environments/test.rb index f8169828..c58a65ca 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -64,4 +64,13 @@ Rails.application.configure do # Annotate rendered view with file names. # config.action_view.annotate_rendered_view_with_filenames = true + + config.middleware.use ExceptionNotification::Rack, + error_grouping: true, + email: { + email_prefix: '', + sender_address: ENV.fetch('DEFAULT_FROM', "noreply@sutty.nl"), + exception_recipients: ENV.fetch('EXCEPTION_TO', "errors@sutty.nl"), + normalize_subject: true + } end diff --git a/test/jobs/backtrace_job_test.rb b/test/jobs/backtrace_job_test.rb new file mode 100644 index 00000000..89c68609 --- /dev/null +++ b/test/jobs/backtrace_job_test.rb @@ -0,0 +1,147 @@ +# frozen_string_literal: true + +require 'test_helper' + +class DeployJobTest < ActiveSupport::TestCase + def site + @site ||= create :site + end + + # Mockup + def job + job = BacktraceJob.new + job.instance_variable_set :@site, site + job.instance_variable_set :@params, notice + + job + end + + # setTimeout(() => { throw('Prueba') }, 1000) + def notice + @notice ||= { + "errors" => [ + { + "type" => "", + "message" => "Prueba", + "backtrace" => [ + { + "function" => "pt "https://tintalimon.com.ar/assets/js/pack.js", + "line" => 89, + "column" => 74094 + }, + { + "function" => "pt "https://tintalimon.com.ar/assets/js/pack.js", + "line" => 89, + "column" => 74731 + }, + { + "function" => "pt "https://tintalimon.com.ar/assets/js/pack.js", + "line" => 89, + "column" => 71925 + }, + { + "function" => "setTimeout handler*", + "file" => "debugger eval code", + "line" => 1, + "column" => 11 + } + ] + } + ], + "context" => { + "severity" => "error", + "history" => [ + { + "type" => "error", + "target" => "html. > head. > script.[type=\"text/javascript\"][src=\"//stats.habitapp.org/piwik.js\"]", + "date" => "2021-04-26T22:06:58.390Z" + }, + { + "type" => "DOMContentLoaded", + "target" => "[object HTMLDocument]", + "date" => "2021-04-26T22:06:58.510Z" + }, + { + "type" => "load", + "target" => "[object HTMLDocument]", + "date" => "2021-04-26T22:06:58.845Z" + }, + { + "type" => "xhr", + "date" => "2021-04-26T22:06:58.343Z", + "method" => "GET", + "url" => "assets/data/site.json", + "statusCode" => 200, + "duration" => 506 + }, + { + "type" => "xhr", + "date" => "2021-04-26T22:06:58.886Z", + "method" => "GET", + "url" => "assets/templates/cart.html", + "statusCode" => 200, + "duration" => 591 + } + ], + "windowError" => true, + "notifier" => { + "name" => "airbrake-js/browser", + "version" => "1.4.2", + "url" => "https://github.com/airbrake/airbrake-js/tree/master/packages/browser" + }, + "userAgent" => "Mozilla/5.0 (Windows NT 6.1; rv:85.0) Gecko/20100101 Firefox/85.0", + "url" => "https://tintalimon.com.ar/carrito/", + "rootDirectory" => "https://tintalimon.com.ar", + "language" => "JavaScript" + }, + "params" => {}, + "environment" => {}, + "session" => {} + } + + # XXX: Siempre devolvemos un duplicado porque BacktraceJob lo + # modifica + @notice.dup + end + + # Asegurarse que el sitio se destruye al terminar de usarlo + teardown do + site&.destroy + end + + test 'al recibir un backtrace enviamos un error' do + ActionMailer::Base.deliveries.clear + + assert BacktraceJob.perform_now site_id: site.id, params: notice + + email = ActionMailer::Base.deliveries.first + + assert email + assert_equal " (BacktraceJob::BacktraceException) \"tintalimon.com.ar: Prueba\"", email.subject + assert (%r{webpack://} =~ email.body.to_s) + end + + test 'los errores se basan en un sitio' do + assert_equal site, job.send(:site) + end + + test 'los errores tienen archivos fuente' do + assert_equal %w[https://tintalimon.com.ar/assets/js/pack.js], job.send(:sources) + end + + test 'los errores tienen una url de origen' do + assert_equal 'tintalimon.com.ar', job.send(:origin) + end + + test 'los errores tienen un sourcemap' do + local_job = job + sourcemap = local_job.send :sourcemap + + assert_equal SourceMap::Map, sourcemap.class + assert_equal 'assets/js/pack.js', sourcemap.filename + assert sourcemap.sources.size.positive? + end +end From 83bf42c2a08fa7555320035ed7ad7c5b537a029f Mon Sep 17 00:00:00 2001 From: Maki Date: Fri, 7 May 2021 15:52:11 -0300 Subject: [PATCH 07/32] designs.yml --- db/seeds/designs.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/db/seeds/designs.yml b/db/seeds/designs.yml index 9d0ddd8a..e6cc31f5 100644 --- a/db/seeds/designs.yml +++ b/db/seeds/designs.yml @@ -6,12 +6,12 @@ disabled: true description_en: "Upload your own theme. [This feature is in development, help us!](https://sutty.nl/en/#contact)" description_es: "Subir tu propio diseño. [Esta posibilidad está en desarrollo, ¡ayudanos!](https://sutty.nl/#contacto)" -- name_en: 'I want you to create a site for me' +- name_en: 'I want you to develop a site for me' name_es: 'Quiero que desarrollen mi sitio' gem: 'sutty-theme-custom' url: 'https://sutty.nl' disabled: true - description_en: "If you want us to create your site, you're welcome to [contact us!](https://sutty.nl/en/#contact) :)" + description_en: "If you want us to develop your site, you're welcome to [contact us!](https://sutty.nl/en/#contact) :)" description_es: "Si querés que desarrollemos tu sitio, [escribinos](https://sutty.nl/#contacto) :)" - name_en: 'Minima' name_es: 'Mínima' @@ -24,7 +24,7 @@ name_es: 'Sutty' gem: 'sutty-jekyll-theme' url: 'https://rubygems.org/gems/sutty-jekyll-theme/' - description_en: "Sutty's design" + description_en: "The Sutty design" description_es: 'El diseño de Sutty' license: 'https://0xacab.org/sutty/jekyll/sutty-jekyll-theme/-/blob/master/LICENSE.txt' credits_es: 'Sutty es parte de la economía solidaria :)' @@ -42,11 +42,11 @@ name_es: 'Donaciones' gem: 'sutty-donaciones-jekyll-theme' url: 'https://donaciones.sutty.nl/' - description_en: "Make your own donations campaign with payment buttons." + description_en: "Make your own donation campaign with payment buttons." description_es: 'Realizá campañas de donaciones con botones de pago.' license: 'https://0xacab.org/sutty/jekyll/sutty-donaciones-jekyll-theme/-/blob/master/LICENSE.txt' credits_es: 'Diseñamos esta plantilla para [visibilizar campañas de donaciones](https://sutty.nl/plantilla-para-donaciones/) durante la cuarentena.' - credits_en: 'We designed this theme to increase [requests for donations visibility](https://sutty.nl/template-for-donations/) during the quarantine.' + credits_en: 'We designed this theme to increase [visibility for donation requests](https://sutty.nl/template-for-donations/) during the quarantine.' - name_en: 'Support campaign' name_es: 'Adhesiones' gem: 'adhesiones-jekyll-theme' @@ -55,29 +55,29 @@ description_es: 'Realizá campañas de adhesión.' license: 'https://0xacab.org/sutty/jekyll/adhesiones-jekyll-theme/-/blob/master/LICENSE.txt' credits_es: 'Desarrollamos esta plantilla junto con [Librenauta](https://sutty.nl/plantilla-para-campa%C3%B1as-de-adhesiones/)' - credits_en: 'We made this template with Librenauta :)' + credits_en: 'This template was made in collaboration with Librenauta' designer_url: 'https://copiona.com/donaunbit/' - name_en: 'Community Radio' name_es: 'Radio comunitaria' gem: 'radios-comunitarias-jekyll-theme' url: 'https://radio.sutty.nl/' - description_en: "A theme with streaming support, designed for community radios" + description_en: "A theme with live streaming support, designed for community radios" description_es: 'Con soporte para transmisión en vivo, pensada para radios comunitarias' license: 'https://0xacab.org/sutty/jekyll/radios-comunitarias-jekyll-theme/-/blob/master/LICENSE.txt' credits_es: 'Desarrollamos esta plantilla junto con Librenauta en 15 horas :)' - credits_en: 'We made this template with Librenauta in 15 hours :)' + credits_en: 'This template was made in collaboration with Librenauta in 15 hours!' designer_url: 'https://copiona.com/donaunbit/' - name_en: 'Resource toolkit' name_es: 'Recursero' gem: 'recursero-jekyll-theme' url: 'https://recursero.info/' disabled: true - description_en: "We're working to add more themes for you to use. [Contact us!](https://sutty.nl/en/#contact)" + description_en: "We're working towards adding more themes for you to use. [Contact us!](https://sutty.nl/en/#contact)" description_es: "Estamos trabajando para que puedas tener más diseños. [¡Escribinos!](https://sutty.nl/#contacto)" - name_en: 'Other themes' name_es: 'Mi propio diseño' gem: 'sutty-theme-own' url: 'https://jekyllthemes.org' disabled: true - description_en: "We're working to add more themes for you to use. [Contact us!](https://sutty.nl/en/#contact)" + description_en: "We're working towards adding more themes for you to use. [Contact us!](https://sutty.nl/en/#contact)" description_es: "Estamos trabajando para que puedas tener más diseños. [¡Escribinos!](https://sutty.nl/#contacto)" From e305c8c9585799cd808418be0b5831e612670f17 Mon Sep 17 00:00:00 2001 From: Maki Date: Fri, 7 May 2021 15:52:27 -0300 Subject: [PATCH 08/32] licencias.yml --- db/seeds/licencias.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/db/seeds/licencias.yml b/db/seeds/licencias.yml index fb5c8f0a..cbe3bace 100644 --- a/db/seeds/licencias.yml +++ b/db/seeds/licencias.yml @@ -104,7 +104,7 @@ description_en: "This license gives everyone the freedom to use, adapt, and redistribute the contents of your site by requiring attribution only. We recommend this license if you're publishing - articles that require maximum diffusion, even in commercial media, but + articles that require maximum dissemination, even in commercial media, but you want to be attributed. Users of the site will have to mention the source and indicate if they made changes to it." url_en: 'https://creativecommons.org/licenses/by/4.0/' @@ -198,13 +198,13 @@ url_es: 'https://creativecommons.org/licenses/by-sa/4.0/deed.es' description_en: "This license is the same as the CC-BY 4.0 but it adds a requirement of sharing the work and its derivatives under the same - license. This is a reciprocitary, _copyleft_, license that keeps + license. This is a reciprocal, _copyleft_, license that keeps culture free. Though commercial uses are allowed, they must be shared under the same license, so any modifications done for profit are free as well." description_es: "Esta licencia es igual que la CC-BY 4.0 con el requisito agregado de compartir la obra y sus obras derivadas con la - misma licencia. Esta es una licencia reciprocitaria, _copyleft_, que + misma licencia. Esta es una licencia recíproca, _copyleft_, que mantiene y profundiza la cultura libre. Aunque los usos comerciales están permitidos, las mejoras hechas con fines de lucro deben ser compartidas bajo la misma licencia." From 47aaf8a5fa7292c98ee0ad40548ede6f6a8a05cc Mon Sep 17 00:00:00 2001 From: Maki Date: Fri, 7 May 2021 15:57:19 -0300 Subject: [PATCH 09/32] designs.yml ajuste --- db/seeds/designs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/seeds/designs.yml b/db/seeds/designs.yml index e6cc31f5..126a9b12 100644 --- a/db/seeds/designs.yml +++ b/db/seeds/designs.yml @@ -28,7 +28,7 @@ description_es: 'El diseño de Sutty' license: 'https://0xacab.org/sutty/jekyll/sutty-jekyll-theme/-/blob/master/LICENSE.txt' credits_es: 'Sutty es parte de la economía solidaria :)' - credits_en: 'Sutty is a solidarity economy project :)' + credits_en: 'Sutty is a solidarity economy project!' - name_en: 'Self-managed Book Publisher' name_es: 'Editorial Autogestiva' gem: 'editorial-autogestiva-jekyll-theme' From edff238a36ddb75e4ab925db66c9a1163cb9f4ff Mon Sep 17 00:00:00 2001 From: f Date: Fri, 7 May 2021 19:02:15 -0300 Subject: [PATCH 10/32] optimizar la lectura de datos desde jekyll MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit durante el proceso de compilación de jekyll se cargan todos los datos en memoria, buscando e interpretando todos los archivos del sitio. en el caso de sutty, solo queremos leer alguna información por vez. trabajando en el buscador me dí cuenta que aunque el panel cargue los posts desde la base de datos, sutty seguía leyendo la información completa del sitio, porque respetaba el proceso de lectura de jekyll. con este cambio podemos leer los _data/ por separado de los _posts/ con lo que la carga del sitio es mucho más rápida. --- app/models/site.rb | 36 ++++++++---------------- config/initializers/core_extensions.rb | 38 ++++++++++++++++++++++++-- 2 files changed, 47 insertions(+), 27 deletions(-) diff --git a/app/models/site.rb b/app/models/site.rb index 7a8b4b4b..901d70c6 100644 --- a/app/models/site.rb +++ b/app/models/site.rb @@ -175,30 +175,17 @@ class Site < ApplicationRecord end alias default_lang default_locale - def read? - @read ||= false - end - - # Lee el sitio y todos los artículos - def read - # No hacer nada si ya se leyó antes - return if read? - - @jekyll.read - @read = true - end - # Trae los datos del directorio _data dentro del sitio - # - # XXX: Leer directamente sin pasar por Jekyll def data - read + unless @jekyll.data.present? + @jekyll.reader.read_data - # Define los valores por defecto según la llave buscada - @jekyll.data.default_proc = proc do |data, key| - data[key] = case key - when 'layout' then {} - end + # Define los valores por defecto según la llave buscada + @jekyll.data.default_proc = proc do |data, key| + data[key] = case key + when 'layout' then {} + end + end end @jekyll.data @@ -207,7 +194,10 @@ class Site < ApplicationRecord # Traer las colecciones. Todos los artículos van a estar dentro de # colecciones. def collections - read + unless @read + @jekyll.reader.read_collections + @read = true + end @jekyll.collections end @@ -221,8 +211,6 @@ class Site < ApplicationRecord # # @param lang: [String|Symbol] traer los artículos de este idioma def posts(lang: nil) - read - # Traemos los posts del idioma actual por defecto o el que haya lang ||= locales.include?(I18n.locale) ? I18n.locale : default_locale lang = lang.to_sym diff --git a/config/initializers/core_extensions.rb b/config/initializers/core_extensions.rb index e37b2be4..8bbcbe71 100644 --- a/config/initializers/core_extensions.rb +++ b/config/initializers/core_extensions.rb @@ -32,31 +32,52 @@ module ActionDispatch end # Lazy Loading de Jekyll, deshabilitando la instanciación de elementos -# que no necesitamos +# que no necesitamos. Esto permite que podamos leer el sitio por partes +# en lugar de todo junto. # # TODO: Aplicar monkey patches en otro lado... module Jekyll Reader.class_eval do + # No necesitamos otros posts def retrieve_posts(_); end + # No necesitamos otros directorios def retrieve_dirs(_, _, _); end + # No necesitamos las páginas def retrieve_pages(_, _); end + # No necesitamos los archivos estáticos def retrieve_static_files(_, _); end + + # Solo lee los datos + def read_data + @site.data = DataReader.new(site).read(site.config["data_dir"]) + end + + # Lee todos los artículos del sitio + def read_collections + read_directories + read_included_excludes + sort_files! + CollectionReader.new(site).read + end end + # No necesitamos los archivos de la plantilla ThemeAssetsReader.class_eval do def read; end end - # Prevenir la lectura del documento + # Aplazar la lectura del documento Document.class_eval do alias_method :read!, :read def read; end end - # https://github.com/jekyll/jekyll/pull/8425 + # Prevenir la instanciación de Time + # + # @see {https://github.com/jekyll/jekyll/pull/8425} Utils.class_eval do def parse_date(input, msg = 'Input could not be parsed.') @parse_date_cache ||= {} @@ -66,3 +87,14 @@ module Jekyll end end end + +# JekyllData::Reader del plugin jekyll-data modifica Jekyll::Site#reader +# para también leer los datos que vienen en el theme. +module JekyllData + Reader.class_eval do + def read_data + super + read_theme_data + end + end +end From 478730e8822bdce353e8131aaa34691fa88a1876 Mon Sep 17 00:00:00 2001 From: Maki Date: Sat, 8 May 2021 17:37:57 +0000 Subject: [PATCH 11/32] =?UTF-8?q?Ajustes=20traducci=C3=B3n=20de=20archivos?= =?UTF-8?q?=20de=20db/seeds?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/seeds/designs.yml | 22 +++++++++++----------- db/seeds/licencias.yml | 6 +++--- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/db/seeds/designs.yml b/db/seeds/designs.yml index 9d0ddd8a..126a9b12 100644 --- a/db/seeds/designs.yml +++ b/db/seeds/designs.yml @@ -6,12 +6,12 @@ disabled: true description_en: "Upload your own theme. [This feature is in development, help us!](https://sutty.nl/en/#contact)" description_es: "Subir tu propio diseño. [Esta posibilidad está en desarrollo, ¡ayudanos!](https://sutty.nl/#contacto)" -- name_en: 'I want you to create a site for me' +- name_en: 'I want you to develop a site for me' name_es: 'Quiero que desarrollen mi sitio' gem: 'sutty-theme-custom' url: 'https://sutty.nl' disabled: true - description_en: "If you want us to create your site, you're welcome to [contact us!](https://sutty.nl/en/#contact) :)" + description_en: "If you want us to develop your site, you're welcome to [contact us!](https://sutty.nl/en/#contact) :)" description_es: "Si querés que desarrollemos tu sitio, [escribinos](https://sutty.nl/#contacto) :)" - name_en: 'Minima' name_es: 'Mínima' @@ -24,11 +24,11 @@ name_es: 'Sutty' gem: 'sutty-jekyll-theme' url: 'https://rubygems.org/gems/sutty-jekyll-theme/' - description_en: "Sutty's design" + description_en: "The Sutty design" description_es: 'El diseño de Sutty' license: 'https://0xacab.org/sutty/jekyll/sutty-jekyll-theme/-/blob/master/LICENSE.txt' credits_es: 'Sutty es parte de la economía solidaria :)' - credits_en: 'Sutty is a solidarity economy project :)' + credits_en: 'Sutty is a solidarity economy project!' - name_en: 'Self-managed Book Publisher' name_es: 'Editorial Autogestiva' gem: 'editorial-autogestiva-jekyll-theme' @@ -42,11 +42,11 @@ name_es: 'Donaciones' gem: 'sutty-donaciones-jekyll-theme' url: 'https://donaciones.sutty.nl/' - description_en: "Make your own donations campaign with payment buttons." + description_en: "Make your own donation campaign with payment buttons." description_es: 'Realizá campañas de donaciones con botones de pago.' license: 'https://0xacab.org/sutty/jekyll/sutty-donaciones-jekyll-theme/-/blob/master/LICENSE.txt' credits_es: 'Diseñamos esta plantilla para [visibilizar campañas de donaciones](https://sutty.nl/plantilla-para-donaciones/) durante la cuarentena.' - credits_en: 'We designed this theme to increase [requests for donations visibility](https://sutty.nl/template-for-donations/) during the quarantine.' + credits_en: 'We designed this theme to increase [visibility for donation requests](https://sutty.nl/template-for-donations/) during the quarantine.' - name_en: 'Support campaign' name_es: 'Adhesiones' gem: 'adhesiones-jekyll-theme' @@ -55,29 +55,29 @@ description_es: 'Realizá campañas de adhesión.' license: 'https://0xacab.org/sutty/jekyll/adhesiones-jekyll-theme/-/blob/master/LICENSE.txt' credits_es: 'Desarrollamos esta plantilla junto con [Librenauta](https://sutty.nl/plantilla-para-campa%C3%B1as-de-adhesiones/)' - credits_en: 'We made this template with Librenauta :)' + credits_en: 'This template was made in collaboration with Librenauta' designer_url: 'https://copiona.com/donaunbit/' - name_en: 'Community Radio' name_es: 'Radio comunitaria' gem: 'radios-comunitarias-jekyll-theme' url: 'https://radio.sutty.nl/' - description_en: "A theme with streaming support, designed for community radios" + description_en: "A theme with live streaming support, designed for community radios" description_es: 'Con soporte para transmisión en vivo, pensada para radios comunitarias' license: 'https://0xacab.org/sutty/jekyll/radios-comunitarias-jekyll-theme/-/blob/master/LICENSE.txt' credits_es: 'Desarrollamos esta plantilla junto con Librenauta en 15 horas :)' - credits_en: 'We made this template with Librenauta in 15 hours :)' + credits_en: 'This template was made in collaboration with Librenauta in 15 hours!' designer_url: 'https://copiona.com/donaunbit/' - name_en: 'Resource toolkit' name_es: 'Recursero' gem: 'recursero-jekyll-theme' url: 'https://recursero.info/' disabled: true - description_en: "We're working to add more themes for you to use. [Contact us!](https://sutty.nl/en/#contact)" + description_en: "We're working towards adding more themes for you to use. [Contact us!](https://sutty.nl/en/#contact)" description_es: "Estamos trabajando para que puedas tener más diseños. [¡Escribinos!](https://sutty.nl/#contacto)" - name_en: 'Other themes' name_es: 'Mi propio diseño' gem: 'sutty-theme-own' url: 'https://jekyllthemes.org' disabled: true - description_en: "We're working to add more themes for you to use. [Contact us!](https://sutty.nl/en/#contact)" + description_en: "We're working towards adding more themes for you to use. [Contact us!](https://sutty.nl/en/#contact)" description_es: "Estamos trabajando para que puedas tener más diseños. [¡Escribinos!](https://sutty.nl/#contacto)" diff --git a/db/seeds/licencias.yml b/db/seeds/licencias.yml index fb5c8f0a..cbe3bace 100644 --- a/db/seeds/licencias.yml +++ b/db/seeds/licencias.yml @@ -104,7 +104,7 @@ description_en: "This license gives everyone the freedom to use, adapt, and redistribute the contents of your site by requiring attribution only. We recommend this license if you're publishing - articles that require maximum diffusion, even in commercial media, but + articles that require maximum dissemination, even in commercial media, but you want to be attributed. Users of the site will have to mention the source and indicate if they made changes to it." url_en: 'https://creativecommons.org/licenses/by/4.0/' @@ -198,13 +198,13 @@ url_es: 'https://creativecommons.org/licenses/by-sa/4.0/deed.es' description_en: "This license is the same as the CC-BY 4.0 but it adds a requirement of sharing the work and its derivatives under the same - license. This is a reciprocitary, _copyleft_, license that keeps + license. This is a reciprocal, _copyleft_, license that keeps culture free. Though commercial uses are allowed, they must be shared under the same license, so any modifications done for profit are free as well." description_es: "Esta licencia es igual que la CC-BY 4.0 con el requisito agregado de compartir la obra y sus obras derivadas con la - misma licencia. Esta es una licencia reciprocitaria, _copyleft_, que + misma licencia. Esta es una licencia recíproca, _copyleft_, que mantiene y profundiza la cultura libre. Aunque los usos comerciales están permitidos, las mejoras hechas con fines de lucro deben ser compartidas bajo la misma licencia." From de92cc117a5b0b33fc8a2bf426d3a5c529f1c0ec Mon Sep 17 00:00:00 2001 From: Maki Date: Sat, 8 May 2021 17:19:13 -0300 Subject: [PATCH 12/32] deselect all en en.yml --- config/locales/en.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/locales/en.yml b/config/locales/en.yml index dd9f8309..645a1e3b 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -435,7 +435,7 @@ en: reorder: submit: 'Save order' select: 'Select this post' - unselect: 'Deselected all' + unselect: 'Deselect all' top: 'Send to top' bottom: 'Send to bottom' up: 'Up' From cb8032d9e10fd5ed8cba3355cabdb6189bddc96a Mon Sep 17 00:00:00 2001 From: f Date: Sun, 9 May 2021 12:59:33 -0300 Subject: [PATCH 13/32] usar loaf para configurar las breadcrumbs --- Gemfile | 1 + Gemfile.lock | 3 +++ 2 files changed, 4 insertions(+) diff --git a/Gemfile b/Gemfile index 63b921c2..3f100e6b 100644 --- a/Gemfile +++ b/Gemfile @@ -48,6 +48,7 @@ gem 'jekyll-commonmark' gem 'jekyll-images' gem 'jekyll-include-cache' gem 'sutty-liquid' +gem 'loaf' gem 'lockbox' gem 'mini_magick' gem 'mobility' diff --git a/Gemfile.lock b/Gemfile.lock index 5c1d0627..e80d3ccf 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -338,6 +338,8 @@ GEM rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) ruby_dep (~> 1.2) + loaf (0.10.0) + railties (>= 3.2) lockbox (0.6.4) lograge (0.11.2) actionpack (>= 4) @@ -691,6 +693,7 @@ DEPENDENCIES jekyll-include-cache letter_opener listen (>= 3.0.5, < 3.2) + loaf lockbox lograge memory_profiler From 0a5908d02d871eeea42390144b35e92603dc26fe Mon Sep 17 00:00:00 2001 From: f Date: Sun, 9 May 2021 13:02:09 -0300 Subject: [PATCH 14/32] eliminar las migas de pan casero --- app/views/devise/confirmations/new.haml | 2 -- app/views/devise/invitations/edit.haml | 2 -- app/views/devise/invitations/new.haml | 2 -- app/views/devise/passwords/edit.haml | 2 -- app/views/devise/passwords/new.haml | 2 -- app/views/devise/registrations/edit.haml | 2 -- app/views/devise/registrations/new.haml | 2 -- app/views/devise/sessions/new.haml | 2 -- app/views/devise/unlocks/new.haml | 2 -- app/views/i18n/edit.haml | 7 ------- app/views/layouts/_breadcrumb.haml | 21 +++++++-------------- app/views/layouts/application.html.haml | 1 + app/views/posts/edit.haml | 7 ------- app/views/posts/index.haml | 7 ------- app/views/posts/new.haml | 6 ------ app/views/posts/show.haml | 6 ------ app/views/sites/edit.haml | 3 --- app/views/sites/fetch.haml | 3 --- app/views/sites/index.haml | 2 -- app/views/sites/new.haml | 3 --- app/views/usuaries/index.haml | 5 ----- app/views/usuaries/invite.haml | 6 ------ 22 files changed, 8 insertions(+), 87 deletions(-) delete mode 100644 app/views/i18n/edit.haml diff --git a/app/views/devise/confirmations/new.haml b/app/views/devise/confirmations/new.haml index b1080788..59568cb7 100644 --- a/app/views/devise/confirmations/new.haml +++ b/app/views/devise/confirmations/new.haml @@ -1,5 +1,3 @@ -= render 'layouts/breadcrumb', crumbs: nil - = content_for :body do - 'black-bg' diff --git a/app/views/devise/invitations/edit.haml b/app/views/devise/invitations/edit.haml index b8bb4315..565429a8 100644 --- a/app/views/devise/invitations/edit.haml +++ b/app/views/devise/invitations/edit.haml @@ -1,5 +1,3 @@ -= render 'layouts/breadcrumb', crumbs: nil - = content_for :body do - 'black-bg' diff --git a/app/views/devise/invitations/new.haml b/app/views/devise/invitations/new.haml index 8a0e318e..44ceec2e 100644 --- a/app/views/devise/invitations/new.haml +++ b/app/views/devise/invitations/new.haml @@ -1,5 +1,3 @@ -= render 'layouts/breadcrumb', crumbs: nil - = content_for :body do - 'black-bg' diff --git a/app/views/devise/passwords/edit.haml b/app/views/devise/passwords/edit.haml index d5e0778c..7f7b16fb 100644 --- a/app/views/devise/passwords/edit.haml +++ b/app/views/devise/passwords/edit.haml @@ -1,5 +1,3 @@ -= render 'layouts/breadcrumb', crumbs: nil - = content_for :body do - 'black-bg' diff --git a/app/views/devise/passwords/new.haml b/app/views/devise/passwords/new.haml index 75e22859..3c80b8a0 100644 --- a/app/views/devise/passwords/new.haml +++ b/app/views/devise/passwords/new.haml @@ -1,5 +1,3 @@ -= render 'layouts/breadcrumb', crumbs: nil - = content_for :body do - 'black-bg' diff --git a/app/views/devise/registrations/edit.haml b/app/views/devise/registrations/edit.haml index ece85540..1db0329c 100644 --- a/app/views/devise/registrations/edit.haml +++ b/app/views/devise/registrations/edit.haml @@ -1,5 +1,3 @@ -= render 'layouts/breadcrumb', - crumbs: [link_to(t('.index'), sites_path), t('.title')] = content_for :body do - 'black-bg' diff --git a/app/views/devise/registrations/new.haml b/app/views/devise/registrations/new.haml index 92a44aec..cb6ff0d1 100644 --- a/app/views/devise/registrations/new.haml +++ b/app/views/devise/registrations/new.haml @@ -1,5 +1,3 @@ -= render 'layouts/breadcrumb', crumbs: nil - = content_for :body do - 'black-bg' diff --git a/app/views/devise/sessions/new.haml b/app/views/devise/sessions/new.haml index 2826be44..b5223e5f 100644 --- a/app/views/devise/sessions/new.haml +++ b/app/views/devise/sessions/new.haml @@ -1,5 +1,3 @@ -= render 'layouts/breadcrumb', crumbs: nil - = content_for :body do - 'black-bg' diff --git a/app/views/devise/unlocks/new.haml b/app/views/devise/unlocks/new.haml index af5bf50b..ac511115 100644 --- a/app/views/devise/unlocks/new.haml +++ b/app/views/devise/unlocks/new.haml @@ -1,5 +1,3 @@ -= render 'layouts/breadcrumb', crumbs: nil - = content_for :body do - 'black-bg' diff --git a/app/views/i18n/edit.haml b/app/views/i18n/edit.haml deleted file mode 100644 index 3e44af6f..00000000 --- a/app/views/i18n/edit.haml +++ /dev/null @@ -1,7 +0,0 @@ -= render 'layouts/breadcrumb', - crumbs: [link_to(t('sites.index.title'), sites_path), - link_to(@site.name, site_path(@site)), - t('i18n.index'), - t('i18n.edit')] - -= render 'i18n/form' diff --git a/app/views/layouts/_breadcrumb.haml b/app/views/layouts/_breadcrumb.haml index 01765d0d..29201b0e 100644 --- a/app/views/layouts/_breadcrumb.haml +++ b/app/views/layouts/_breadcrumb.haml @@ -3,21 +3,14 @@ = inline_svg_tag 'sutty.svg', class: 'black', aria: true, title: t('svg.sutty.title'), desc: t('svg.sutty.desc') - - if crumbs - %nav{ aria: { label: t('.title') }, role: 'navigation' } - %ol.breadcrumb - %li.breadcrumb-item - = link_to edit_usuarie_registration_path, - data: { toggle: 'tooltip' }, - title: t('help.usuarie.edit') do - = current_usuarie.email - - - crumbs.compact.each do |crumb| - - if crumb == crumbs.last - %li.breadcrumb-item.active{ aria: { current: 'page' } } - = crumb + %nav{ aria: { label: t('.title') } } + %ol.breadcrumb + - breadcrumb_trail do |crumb| + %li.breadcrumb-item{ class: crumb.current? ? 'active' : '' } + - if crumb.current? + %span{ aria: { current: 'page' } }= crumb.name - else - %li.breadcrumb-item= crumb + %span= link_to crumb.name, crumb.url - if current_usuarie %ul.navbar-nav diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 891d635c..85d5ab22 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -20,6 +20,7 @@ %body{ class: yield(:body) } .container-fluid#sutty + = render 'layouts/breadcrumb' = yield - if flash[:js] .js-flash.d-none{ data: flash[:js] } diff --git a/app/views/posts/edit.haml b/app/views/posts/edit.haml index 282d9d05..6ec252fe 100644 --- a/app/views/posts/edit.haml +++ b/app/views/posts/edit.haml @@ -1,10 +1,3 @@ -= render 'layouts/breadcrumb', - crumbs: [link_to(t('sites.index.title'), sites_path), - link_to(@site.name, site_posts_path(@site)), - link_to(t('posts.index'), site_posts_path(@site)), - link_to(@post.title.value, site_post_path(@site, @post.id)), - t('posts.edit')] - .row.justify-content-center .col-md-8 = render 'posts/form', site: @site, post: @post diff --git a/app/views/posts/index.haml b/app/views/posts/index.haml index b2f3f661..291945ae 100644 --- a/app/views/posts/index.haml +++ b/app/views/posts/index.haml @@ -1,10 +1,3 @@ -= render 'layouts/breadcrumb', - crumbs: [link_to(t('sites.index.title'), sites_path), - @site.name, - link_to(t('posts.index'), - site_posts_path(@site)), - @category_name] - %main.row %aside.menu.col-md-3 %h1= link_to @site.title, @site.url diff --git a/app/views/posts/new.haml b/app/views/posts/new.haml index adcc843d..6ec252fe 100644 --- a/app/views/posts/new.haml +++ b/app/views/posts/new.haml @@ -1,9 +1,3 @@ -= render 'layouts/breadcrumb', - crumbs: [link_to(t('sites.index.title'), sites_path), - @site.name, - link_to(t('posts.index'), - site_posts_path(@site)), t('posts.new')] - .row.justify-content-center .col-md-8 = render 'posts/form', site: @site, post: @post diff --git a/app/views/posts/show.haml b/app/views/posts/show.haml index 9dd4faa0..9d6f37cd 100644 --- a/app/views/posts/show.haml +++ b/app/views/posts/show.haml @@ -1,9 +1,3 @@ -= render 'layouts/breadcrumb', - crumbs: [link_to(t('sites.index.title'), sites_path), - @site.name, - link_to(t('posts.index'), site_posts_path(@site)), - @post.title.value] - - dir = t("locales.#{@locale}.dir") .row.justify-content-center .col-md-8 diff --git a/app/views/sites/edit.haml b/app/views/sites/edit.haml index cc5977cf..4ae7308d 100644 --- a/app/views/sites/edit.haml +++ b/app/views/sites/edit.haml @@ -1,6 +1,3 @@ -= render 'layouts/breadcrumb', - crumbs: [link_to(t('sites.index.title'), sites_path), - t('.title', site: @site.name)] .row.justify-content-center .col-md-8 %h1= t('.title', site: @site.name) diff --git a/app/views/sites/fetch.haml b/app/views/sites/fetch.haml index 6a16e2e0..f5d049c8 100644 --- a/app/views/sites/fetch.haml +++ b/app/views/sites/fetch.haml @@ -1,6 +1,3 @@ -= render 'layouts/breadcrumb', - crumbs: [link_to(t('sites.index.title'), sites_path), t('.title')] - .row.justify-content-center .col-md-8#pull %h1= t('.title') diff --git a/app/views/sites/index.haml b/app/views/sites/index.haml index 07ea670a..dfcc2203 100644 --- a/app/views/sites/index.haml +++ b/app/views/sites/index.haml @@ -1,5 +1,3 @@ -= render 'layouts/breadcrumb', crumbs: [t('sites.index.title')] - %main.row %aside.col-md-3 %h1= t('.title') diff --git a/app/views/sites/new.haml b/app/views/sites/new.haml index fa724421..68c17882 100644 --- a/app/views/sites/new.haml +++ b/app/views/sites/new.haml @@ -1,6 +1,3 @@ -= render 'layouts/breadcrumb', - crumbs: [link_to(t('sites.index.title'), sites_path), t('.title')] - .row.justify-content-center .col-md-8 %h1= t('.title') diff --git a/app/views/usuaries/index.haml b/app/views/usuaries/index.haml index c3c6c3b4..c0eedefd 100644 --- a/app/views/usuaries/index.haml +++ b/app/views/usuaries/index.haml @@ -1,8 +1,3 @@ -= render 'layouts/breadcrumb', - crumbs: [link_to(t('sites.index.title'), sites_path), - link_to(@site.name, @site), - t('.title')] - .row .col %h1= t('.title') diff --git a/app/views/usuaries/invite.haml b/app/views/usuaries/invite.haml index 62552e70..919ae92b 100644 --- a/app/views/usuaries/invite.haml +++ b/app/views/usuaries/invite.haml @@ -1,11 +1,5 @@ - invite_as = t("usuaries.invite_as.#{params[:invite_as]}") -= render 'layouts/breadcrumb', - crumbs: [link_to(t('sites.index.title'), sites_path), - @site.name, - link_to(t('posts.index'), site_usuaries_path(@site)), - t('.title', invite_as: invite_as)] - .row .col %h1= t('.title', invite_as: invite_as) From 88051425ae18ca29b4641a00151acfadf1beec13 Mon Sep 17 00:00:00 2001 From: f Date: Sun, 9 May 2021 13:08:18 -0300 Subject: [PATCH 15/32] =?UTF-8?q?agregar=20migas=20de=20pan=20comunes=20y?= =?UTF-8?q?=20en=20cada=20acci=C3=B3=C3=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit las migas que van dentro de cada acción son strings vacías porque no las estamos vinculando a nada, así que nos ahorramos el proceso. --- app/controllers/posts_controller.rb | 36 ++++++++++++-------------- app/controllers/sites_controller.rb | 9 +++++++ app/controllers/usuaries_controller.rb | 7 +++++ 3 files changed, 32 insertions(+), 20 deletions(-) diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index a4b47a16..57c6348a 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -7,6 +7,11 @@ class PostsController < ApplicationController before_action :authenticate_usuarie! + # TODO: Traer los comunes desde ApplicationController + breadcrumb -> { current_usuarie.email }, :edit_usuarie_registration_path + breadcrumb 'sites.index', :sites_path, match: :exact + breadcrumb -> { site.title }, -> { site_posts_path(site, locale: locale) }, match: :exact + # Las URLs siempre llevan el idioma actual o el de le usuarie def default_url_options { locale: params[:locale] || current_usuarie&.lang || I18n.locale } @@ -43,44 +48,34 @@ class PostsController < ApplicationController end def show - @site = find_site - @post = @site.posts(lang: locale).find params[:id] - - authorize @post - @locale = locale - - fresh_when @post + authorize post + breadcrumb post.title.value, '' + fresh_when post end # Genera una previsualización del artículo. - # - # TODO: No todos los artículos tienen previsualización! def preview - @site = find_site - @post = @site.posts(lang: locale).find params[:post_id] + authorize post - authorize @post - - render html: @post.render + render html: post.render end def new authorize Post - @site = find_site - @post = @site.posts.build(lang: locale, layout: params[:layout]) - @locale = locale + @post = site.posts.build(lang: locale, layout: params[:layout]) + + breadcrumb I18n.t('loaf.breadcrumbs.posts.new', layout: @post.layout.humanized_name.downcase), '' end def create authorize Post - @site = find_site - service = PostService.new(site: @site, + service = PostService.new(site: site, usuarie: current_usuarie, params: params) @post = service.create if @post.persisted? - @site.touch + site.touch forget_content redirect_to site_post_path(@site, @post) @@ -96,6 +91,7 @@ class PostsController < ApplicationController authorize @post @locale = locale + breadcrumb @post.title.value, site_post_path(@site, @post, locale: locale), match: :exact end def update diff --git a/app/controllers/sites_controller.rb b/app/controllers/sites_controller.rb index d7d2f9f6..f3114d9a 100644 --- a/app/controllers/sites_controller.rb +++ b/app/controllers/sites_controller.rb @@ -7,6 +7,9 @@ class SitesController < ApplicationController before_action :authenticate_usuarie! + breadcrumb -> { current_usuarie.email }, :edit_usuarie_registration_path + breadcrumb 'sites.index', :sites_path, match: :exact + # Ver un listado de sitios def index authorize Site @@ -24,6 +27,8 @@ class SitesController < ApplicationController end def new + breadcrumb 'sites.new', :new_site_path + @site = Site.new authorize @site @@ -43,6 +48,10 @@ class SitesController < ApplicationController def edit authorize site + + breadcrumb site.title, site_posts_path(site), match: :exact + breadcrumb 'sites.edit', site_path(site) + SiteService.new(site: site).build_deploys end diff --git a/app/controllers/usuaries_controller.rb b/app/controllers/usuaries_controller.rb index 71deee91..fdfa66a8 100644 --- a/app/controllers/usuaries_controller.rb +++ b/app/controllers/usuaries_controller.rb @@ -7,12 +7,19 @@ class UsuariesController < ApplicationController include Pundit before_action :authenticate_usuarie! + # TODO: Traer los comunes desde ApplicationController + breadcrumb -> { current_usuarie.email }, :edit_usuarie_registration_path + breadcrumb 'sites.index', :sites_path, match: :exact + breadcrumb -> { site.title }, -> { site_posts_path(site, locale: locale) }, match: :exact + # Mostrar todes les usuaries e invitades de un sitio def index @site = find_site site_usuarie = SiteUsuarie.new(@site, current_usuarie) authorize site_usuarie + breadcrumb 'usuaries.index', '' + @policy = policy(site_usuarie) end From 8fe343ae45338d6434671ea103cf34aaf853c5ff Mon Sep 17 00:00:00 2001 From: f Date: Sun, 9 May 2021 13:10:00 -0300 Subject: [PATCH 16/32] hay migas que van dentro de sus vistas porque modificar el controlador de devise solo para agregar la miga de pan es demasiado trabajo --- app/views/devise/registrations/edit.haml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/devise/registrations/edit.haml b/app/views/devise/registrations/edit.haml index 1db0329c..6a25da65 100644 --- a/app/views/devise/registrations/edit.haml +++ b/app/views/devise/registrations/edit.haml @@ -1,3 +1,4 @@ +- breadcrumb 'sites.index', sites_path = content_for :body do - 'black-bg' From a9da4b3f2c3ef3a298dd4b75ec18752f39538dc3 Mon Sep 17 00:00:00 2001 From: f Date: Sun, 9 May 2021 13:11:15 -0300 Subject: [PATCH 17/32] =?UTF-8?q?ya=20que=20estaba,=20un=20poco=20de=20ref?= =?UTF-8?q?actorizaci=C3=B3n=20para=20no=20escribir=20tantas=20@?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit memoizamos site y post cuando podemos --- app/controllers/posts_controller.rb | 57 +++++++++++++------------- app/controllers/usuaries_controller.rb | 7 +++- 2 files changed, 33 insertions(+), 31 deletions(-) diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index 57c6348a..e8ceeebf 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -85,31 +85,24 @@ class PostsController < ApplicationController end def edit - @site = find_site - @post = @site.posts(lang: locale).find params[:id] - - authorize @post - - @locale = locale - breadcrumb @post.title.value, site_post_path(@site, @post, locale: locale), match: :exact + authorize post + breadcrumb post.title.value, site_post_path(site, post, locale: locale), match: :exact + breadcrumb 'posts.edit', '' end def update - @site = find_site - @post = @site.posts(lang: locale).find params[:id] + authorize post - authorize @post - - service = PostService.new(site: @site, - post: @post, + service = PostService.new(site: site, + post: post, usuarie: current_usuarie, params: params) if service.update.persisted? - @site.touch + site.touch forget_content - redirect_to site_post_path(@site, @post) + redirect_to site_post_path(site, post) else render 'posts/edit' end @@ -117,34 +110,30 @@ class PostsController < ApplicationController # Eliminar artículos def destroy - @site = find_site - @post = @site.posts(lang: locale).find params[:id] + authorize post - authorize @post - - service = PostService.new(site: @site, - post: @post, + service = PostService.new(site: site, + post: post, usuarie: current_usuarie, params: params) # TODO: Notificar si se pudo o no service.destroy - @site.touch - redirect_to site_posts_path(@site) + site.touch + redirect_to site_posts_path(site) end # Reordenar los artículos def reorder - @site = find_site - authorize @site + authorize site - service = PostService.new(site: @site, + service = PostService.new(site: site, usuarie: current_usuarie, params: params) service.reorder - @site.touch - redirect_to site_posts_path(@site) + site.touch + redirect_to site_posts_path(site) end # Devuelve el idioma solicitado a través de un parámetro, validando @@ -155,7 +144,7 @@ class PostsController < ApplicationController # solicite a le usuarie crear el nuevo idioma y que esto lo agregue al # _config.yml del sitio en lugar de mezclar idiomas. def locale - @site&.locales&.find(-> { I18n.locale }) do |l| + @locale ||= site&.locales&.find(-> { I18n.locale }) do |l| l.to_s == params[:locale] end end @@ -165,4 +154,14 @@ class PostsController < ApplicationController def forget_content flash[:js] = { target: 'editor', action: 'forget-content', keys: (params[:storage_keys] || []).to_json } end + + private + + def site + @site ||= find_site + end + + def post + @post ||= site.posts(lang: locale).find(params[:post_id] || params[:id]) + end end diff --git a/app/controllers/usuaries_controller.rb b/app/controllers/usuaries_controller.rb index fdfa66a8..6d02a35a 100644 --- a/app/controllers/usuaries_controller.rb +++ b/app/controllers/usuaries_controller.rb @@ -14,8 +14,7 @@ class UsuariesController < ApplicationController # Mostrar todes les usuaries e invitades de un sitio def index - @site = find_site - site_usuarie = SiteUsuarie.new(@site, current_usuarie) + site_usuarie = SiteUsuarie.new(site, current_usuarie) authorize site_usuarie breadcrumb 'usuaries.index', '' @@ -163,4 +162,8 @@ class UsuariesController < ApplicationController 'invitade' end end + + def site + @site ||= find_site + end end From 1a4d1b13f932fe045966479283e3836d72c38279 Mon Sep 17 00:00:00 2001 From: f Date: Sun, 9 May 2021 13:11:50 -0300 Subject: [PATCH 18/32] traducciones --- config/locales/en.yml | 11 +++++++++++ config/locales/es.yml | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/config/locales/en.yml b/config/locales/en.yml index 192a57c6..7e7f2646 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -579,3 +579,14 @@ en: local_invalid: "format is incorrect" not_allowed: "that email provider is not welcome here" server_not_available: "remote email server not available" + loaf: + breadcrumbs: + sites: + index: 'My sites' + new: 'Create' + edit: 'Configure' + posts: + new: 'New %{layout}' + edit: 'Editing' + usuaries: + index: 'Users' diff --git a/config/locales/es.yml b/config/locales/es.yml index 4cdca67e..c9c42c60 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -608,3 +608,14 @@ es: local_invalid: "el formato es incorrecto" not_allowed: "no es bienvenida" server_not_available: "el proveedor no está disponible" + loaf: + breadcrumbs: + sites: + index: 'Mis sitios' + new: 'Crear' + edit: 'Configurar' + posts: + new: 'Nuevo %{layout}' + edit: 'Editando' + usuaries: + index: 'Usuaries' From c2b150df121b11cb11ad0aa4bda12e3eb059afc7 Mon Sep 17 00:00:00 2001 From: f Date: Sun, 9 May 2021 13:12:06 -0300 Subject: [PATCH 19/32] migas responsivas --- app/assets/stylesheets/application.scss | 7 +++++++ app/views/layouts/_breadcrumb.haml | 6 +++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 0a215c48..5886a2a7 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -355,6 +355,13 @@ $bezier: cubic-bezier(0.75, 0, 0.25, 1); .text-column-#{$size} { column-count: $size; } + + .line-clamp-#{$size} { + overflow: hidden; + display: -webkit-box; + -webkit-line-clamp: $size; + -webkit-box-orient: vertical; + } } /* diff --git a/app/views/layouts/_breadcrumb.haml b/app/views/layouts/_breadcrumb.haml index 29201b0e..c4920bc7 100644 --- a/app/views/layouts/_breadcrumb.haml +++ b/app/views/layouts/_breadcrumb.haml @@ -4,13 +4,13 @@ title: t('svg.sutty.title'), desc: t('svg.sutty.desc') %nav{ aria: { label: t('.title') } } - %ol.breadcrumb + %ol.breadcrumb.m-0.flex-wrap - breadcrumb_trail do |crumb| %li.breadcrumb-item{ class: crumb.current? ? 'active' : '' } - if crumb.current? - %span{ aria: { current: 'page' } }= crumb.name + %span.line-clamp-1{ aria: { current: 'page' } }= crumb.name - else - %span= link_to crumb.name, crumb.url + %span.line-clamp-1= link_to crumb.name, crumb.url - if current_usuarie %ul.navbar-nav From f3fcf11da3155f01208f5205ef94791e42a7abbc Mon Sep 17 00:00:00 2001 From: f Date: Sun, 9 May 2021 13:12:22 -0300 Subject: [PATCH 20/32] =?UTF-8?q?acomodar=20la=20secci=C3=B3n=20de=20usuar?= =?UTF-8?q?ies=20al=20resto=20del=20sitio?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/usuaries/index.haml | 37 ++++++++++++++++------------------ app/views/usuaries/invite.haml | 6 ++---- 2 files changed, 19 insertions(+), 24 deletions(-) diff --git a/app/views/usuaries/index.haml b/app/views/usuaries/index.haml index c0eedefd..124fb04b 100644 --- a/app/views/usuaries/index.haml +++ b/app/views/usuaries/index.haml @@ -1,27 +1,24 @@ -.row - .col +.row.justify-content-center + .col.col-md-8 %h1= t('.title') -.row - .col -# Una tabla de usuaries y otra de invitades, con acciones - %i[usuaries invitades].each do |u| - %h2 - = t(".#{u}") - .btn-group{ role: 'group', 'aria-label': t('.actions') } - - if @policy.invite? - = link_to t('.invite'), - site_usuaries_invite_path(@site, invite_as: u.to_s), - class: 'btn', - data: { toggle: 'tooltip' }, - title: t('.help.invite', invite_as: u.to_s) - - if policy(Collaboration.new(@site)).collaborate? - = link_to t('.public_invite'), - site_collaborate_path(@site), - class: 'btn', - data: { toggle: 'tooltip' }, - title: t('.help.public_invite') - %p= t(".help.#{u}") + %h2.mt-5= t(".#{u}") + .btn-group{ role: 'group', 'aria-label': t('.actions') } + - if @policy.invite? + = link_to t('.invite'), + site_usuaries_invite_path(@site, invite_as: u.to_s), + class: 'btn', + data: { toggle: 'tooltip' }, + title: t('.help.invite', invite_as: u.to_s) + - if policy(Collaboration.new(@site)).collaborate? + = link_to t('.public_invite'), + site_collaborate_path(@site), + class: 'btn', + data: { toggle: 'tooltip' }, + title: t('.help.public_invite') + %p.lead= t(".help.#{u}") %table.table.table-condensed %tbody - @site.send(u).each do |cuenta| diff --git a/app/views/usuaries/invite.haml b/app/views/usuaries/invite.haml index 919ae92b..26eb5039 100644 --- a/app/views/usuaries/invite.haml +++ b/app/views/usuaries/invite.haml @@ -1,11 +1,9 @@ - invite_as = t("usuaries.invite_as.#{params[:invite_as]}") -.row - .col +.row.justify-content-center + .col.col-md-8 %h1= t('.title', invite_as: invite_as) -.row - .col = form_with url: site_usuaries_invite_path(@site), local: true do |f| = f.hidden_field :invited_as, value: params[:invite_as].singularize .form-group From e0eeaf7fc6601b995c6c375102284de12c4e4454 Mon Sep 17 00:00:00 2001 From: f Date: Mon, 10 May 2021 14:27:47 -0300 Subject: [PATCH 21/32] tomar en cuenta el idioma actual al cachear para que al cambiar de idioma no se vean partes en el anterior --- app/controllers/posts_controller.rb | 2 +- app/views/posts/_form.haml | 2 +- app/views/posts/index.haml | 5 +---- app/views/posts/show.haml | 4 ++-- app/views/sites/index.haml | 2 +- 5 files changed, 6 insertions(+), 9 deletions(-) diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index e8ceeebf..5b8f1a16 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -27,7 +27,7 @@ class PostsController < ApplicationController # XXX: Cada vez que cambiamos un Post tocamos el sitio con lo que es # más simple saber si hubo cambios. - if @category || @layout || stale?(@site) + if @category || @layout || stale?([current_usuarie, @site]) @posts = @site.posts(lang: locale) @posts = @posts.where(categories: @category) if @category @posts = @posts.where(layout: @layout) if @layout diff --git a/app/views/posts/_form.haml b/app/views/posts/_form.haml index a9819a1b..e46b2eda 100644 --- a/app/views/posts/_form.haml +++ b/app/views/posts/_form.haml @@ -43,7 +43,7 @@ - metadata = post[attribute] - type = metadata.type - - cache metadata do + - cache [metadata, I18n.locale] do = render("posts/attributes/#{type}", base: 'post', post: post, attribute: attribute, metadata: metadata, site: site, diff --git a/app/views/posts/index.haml b/app/views/posts/index.haml index 291945ae..8d54069c 100644 --- a/app/views/posts/index.haml +++ b/app/views/posts/index.haml @@ -73,10 +73,7 @@ -# TODO: Solo les usuaries cachean porque tenemos que separar les botones por permisos. - - TODO: Verificar qué pasa cuando se gestiona el sitio en - distintos idiomas a la vez - - cache_if @usuarie, post do + - cache_if @usuarie, [post, I18n.locale] do - checkbox_id = "checkbox-#{post.uuid.value}" %tr{ id: post.uuid.value, data: { target: 'reorder.row' } } %td diff --git a/app/views/posts/show.haml b/app/views/posts/show.haml index 9d6f37cd..da6ac9db 100644 --- a/app/views/posts/show.haml +++ b/app/views/posts/show.haml @@ -22,7 +22,7 @@ - metadata = @post[attr] - next unless metadata.front_matter? - - cache metadata do + - cache [metadata, I18n.locale] do = render("posts/attribute_ro/#{metadata.type}", post: @post, attribute: attr, metadata: metadata, @@ -36,6 +36,6 @@ - metadata = @post[attr] - next if metadata.front_matter? - - cache metadata do + - cache [metadata, I18n.locale] do %section.editor{ id: attr, dir: dir } = @post.public_send(attr).to_s.html_safe diff --git a/app/views/sites/index.haml b/app/views/sites/index.haml index dfcc2203..9d831584 100644 --- a/app/views/sites/index.haml +++ b/app/views/sites/index.haml @@ -18,7 +18,7 @@ -# TODO: Solo les usuaries cachean porque tenemos que separar les botones por permisos. - - cache_if (rol.usuarie? && !rol.temporal), site do + - cache_if (rol.usuarie? && !rol.temporal), [site, I18n.locale] do %tr %td %h2 From f417d45a6b732a3b06a127e28f50860dd1ac97b3 Mon Sep 17 00:00:00 2001 From: Maki Date: Mon, 10 May 2021 14:37:41 -0300 Subject: [PATCH 22/32] =?UTF-8?q?bot=C3=B3n=20crear=20cuenta?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/locales/devise.views.es.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/config/locales/devise.views.es.yml b/config/locales/devise.views.es.yml index d0f57934..73166afc 100644 --- a/config/locales/devise.views.es.yml +++ b/config/locales/devise.views.es.yml @@ -102,7 +102,7 @@ es: update: Actualizar mi perfil we_need_your_current_password_to_confirm_your_changes: Necesitamos tu contraseña actual para confirmar los cambios. new: - sign_up: Registrarme por primera vez + sign_up: Registrarme help: Para registrarte solo pedimos una dirección de correo y una contraseña. La contraseña se almacena de forma segura, ¡nadie más que vos la sabe! Recibirás un correo de confirmación de cuenta. signed_up: Bienvenide. Tu cuenta fue creada. signed_up_but_inactive: Tu cuenta ha sido creada correctamente. Sin embargo, no hemos podido iniciar la sesión porque tu cuenta aún no está activada. @@ -124,8 +124,7 @@ es: forgot_your_password: "¿Has olvidado tu contraseña?" sign_in: Iniciar sesión sign_in_with_provider: Iniciar sesión con %{provider} - sign_up: Registrarme por primera vez - i_dont_have_account: ¿Nunca te registraste en LUNAR? + sign_up: Crear cuenta i_have_account: ¿Ya tenés cuenta? minimum_password_length: one: "%{count} caracter como mínimo." From 9faecbc2892eedfcbb8d682772c68cea3d618251 Mon Sep 17 00:00:00 2001 From: f Date: Mon, 10 May 2021 14:48:48 -0300 Subject: [PATCH 23/32] =?UTF-8?q?centralizar=20la=20detecci=C3=B3n=20del?= =?UTF-8?q?=20idioma?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/application_controller.rb | 12 +++++++++++- app/controllers/posts_controller.rb | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index bc375dcf..acd0134d 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -40,11 +40,21 @@ class ApplicationController < ActionController::Base site end + # Devuelve el idioma actual y si no lo encuentra obtiene uno por + # defecto. + # + # Esto se refiere al idioma de la interfaz, no de los artículos. + def current_locale(include_params: true, site: nil) + return params[:locale] if include_params && params[:locale].present? + + current_usuarie&.lang || I18n.locale + end + # El idioma es el preferido por le usuarie, pero no necesariamente se # corresponde con el idioma de los artículos, porque puede querer # traducirlos. def set_locale(&action) - I18n.with_locale(current_usuarie&.lang || I18n.default_locale, &action) + I18n.with_locale(current_locale(include_params: false), &action) end # Muestra una página 404 diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index 5b8f1a16..34055faf 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -14,7 +14,7 @@ class PostsController < ApplicationController # Las URLs siempre llevan el idioma actual o el de le usuarie def default_url_options - { locale: params[:locale] || current_usuarie&.lang || I18n.locale } + { locale: current_locale } end def index From 84e77c1232812def7bb55d6ac29dc6d5954f5a08 Mon Sep 17 00:00:00 2001 From: f Date: Mon, 10 May 2021 14:49:01 -0300 Subject: [PATCH 24/32] si el idioma actual no existe en el sitio mostrar el idioma por defecto --- app/controllers/posts_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index 34055faf..225b0c36 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -144,7 +144,7 @@ class PostsController < ApplicationController # solicite a le usuarie crear el nuevo idioma y que esto lo agregue al # _config.yml del sitio en lugar de mezclar idiomas. def locale - @locale ||= site&.locales&.find(-> { I18n.locale }) do |l| + @locale ||= site&.locales&.find(-> { site&.default_locale }) do |l| l.to_s == params[:locale] end end From cf01fb700ceaa294b2070f77d1af8e6ed2db24b3 Mon Sep 17 00:00:00 2001 From: f Date: Mon, 10 May 2021 14:49:18 -0300 Subject: [PATCH 25/32] siempre empezar por el idioma por defecto --- app/views/sites/index.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/sites/index.haml b/app/views/sites/index.haml index 9d831584..d7eefb95 100644 --- a/app/views/sites/index.haml +++ b/app/views/sites/index.haml @@ -23,7 +23,7 @@ %td %h2 - if policy(site).show? - = link_to site.title, site_path(site) + = link_to site.title, site_posts_path(site, locale: site.default_locale) - else = site.title %p.lead= site.description From 9d91323f496f31599696656a84cddda15c2c1ff0 Mon Sep 17 00:00:00 2001 From: f Date: Mon, 10 May 2021 15:18:04 -0300 Subject: [PATCH 26/32] redirigir a la lista con idioma --- app/controllers/posts_controller.rb | 4 ++-- app/controllers/sites_controller.rb | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index 225b0c36..c578e944 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -120,7 +120,7 @@ class PostsController < ApplicationController # TODO: Notificar si se pudo o no service.destroy site.touch - redirect_to site_posts_path(site) + redirect_to site_posts_path(site, locale: post.locale.value) end # Reordenar los artículos @@ -133,7 +133,7 @@ class PostsController < ApplicationController service.reorder site.touch - redirect_to site_posts_path(site) + redirect_to site_posts_path(site, locale: site.default_locale) end # Devuelve el idioma solicitado a través de un parámetro, validando diff --git a/app/controllers/sites_controller.rb b/app/controllers/sites_controller.rb index f3114d9a..d221628e 100644 --- a/app/controllers/sites_controller.rb +++ b/app/controllers/sites_controller.rb @@ -23,7 +23,7 @@ class SitesController < ApplicationController def show authorize site - redirect_to site_posts_path(site) + redirect_to site_posts_path(site, locale: site.default_locale) end def new @@ -40,7 +40,7 @@ class SitesController < ApplicationController params: site_params) if (@site = service.create).persisted? - redirect_to site_posts_path(@site) + redirect_to site_posts_path(@site, locale: @site.default_locale) else render 'new' end @@ -49,7 +49,7 @@ class SitesController < ApplicationController def edit authorize site - breadcrumb site.title, site_posts_path(site), match: :exact + breadcrumb site.title, site_posts_path(site, locale: site.default_locale), match: :exact breadcrumb 'sites.edit', site_path(site) SiteService.new(site: site).build_deploys @@ -62,7 +62,7 @@ class SitesController < ApplicationController usuarie: current_usuarie) if service.update.valid? - redirect_to site_posts_path(site) + redirect_to site_posts_path(site, locale: site.default_locale) else render 'edit' end @@ -74,7 +74,7 @@ class SitesController < ApplicationController # XXX: Convertir en una máquina de estados? DeployJob.perform_async site.id if site.enqueue! - redirect_to site_posts_path(site) + redirect_to site_posts_path(site, locale: site.default_locale) end def reorder_posts @@ -94,7 +94,7 @@ class SitesController < ApplicationController flash[:danger] = I18n.t('errors.posts.reorder') end - redirect_to site_posts_path(site) + redirect_to site_posts_path(site, locale: site.default_locale) end def fetch From 65a049c0270f35aad6272d961a328fc2c8f68167 Mon Sep 17 00:00:00 2001 From: f Date: Mon, 10 May 2021 15:18:24 -0300 Subject: [PATCH 27/32] traducciones faltantes --- config/locales/en.yml | 56 +++++++++++++++---------------------------- config/locales/es.yml | 40 ------------------------------- 2 files changed, 19 insertions(+), 77 deletions(-) diff --git a/config/locales/en.yml b/config/locales/en.yml index 1ad6cbd3..f1f9b7cb 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -84,10 +84,6 @@ en: title: Link to www success: Success! error: Error - deploy_private: - title: Private version - success: Success! - error: Error deploy_zip: title: Build ZIP file success: Available for download @@ -96,6 +92,10 @@ en: title: Host as Tor Hidden Service success: Success! error: Error + deploy_private: + title: Private version + success: Success! + error: Error deploy_alternative_domain: title: Alternative domain name success: Success! @@ -123,6 +123,7 @@ en: models: usuarie: User licencia: License + design: Design attributes: usuarie: email: 'E-mail address' @@ -130,27 +131,22 @@ en: password_confirmation: 'Password confirmation' current_password: 'Current password' lang: 'Main language' + remember_me: Remember me site: name: 'Name' title: 'Title' description: 'Description' - colaboracion_anonima: Enable anonymous collaboration acepta_invitades: Enable collaboration + colaboracion_anonima: Enable anonymous collaboration contact: Enable contact forms + tienda_url: Store URL + tienda_api_key: Store access key errors: models: site: attributes: deploys: deploy_local_presence: 'We need to be build the site!' - invitadx: - attributes: - email: - taken: 'This e-mail address is already taken, please choose a different one' - password_confirmation: - confirmation: "The passwords don't match" - acepta_politicas_de_privacidad: - no_acepta_politicas_de_privacidad: "Please read and accept the privacy policy" design_id: layout_incompatible: error: "Design can't be changed because there are posts with incompatible layouts" @@ -182,30 +178,6 @@ en: usuarie: edit: Edit my profile category: 'Category' - i18n: - top: 'Back to top' - index: "Here is where you edit the text on your site that doesn't belong to a post, such as its description, sections, buttons... If you change languages up there in the title to be the same, you can edit them. If they're different, you can translate from one into the other." - count: 'This is the amount of texts.' - toc: 'Jump to this section' - meta: 'Metadata' - navegacion: 'Navigation' - inicio: 'Home' - volver: 'Back' - entrar: 'Enter' - cerrar: 'Close' - anchor: 'Internal links' - nav: 'Menu' - nav-lang: 'Language menu' - modulos: 'Modules' - header: 'Header' - sobre: 'About' - metodologia: 'Methodology' - planeando_recursos: 'Planning resources' - rutas: 'Agendas' - complementarios: 'Materials' - recursos: 'Resources' - contacta: 'Contact us' - agradecimientos: 'Acknowledgments' sites: index: 'This is the list of sites you can edit.' enqueued: "The site is on queue to be generated. Once this @@ -217,6 +189,7 @@ en: invitations: accept: "Someone invited you to collaborate on their site. If you accept the invitation, you can access the site's edit mode." reject: "If you decline, you won't have access." + pull: 'You have pending upgrades!' close: 'Close help' deploys: deploy_local: @@ -321,15 +294,19 @@ en: new: title: 'Create site' submit: 'Create site' + help: 'You can edit any of these options after site creation.' edit: title: 'Edit %{site}' submit: 'Save changes' + btn: 'Configuration' form: errors: title: There were errors and we couldn't save your changes :( help: Please, look for the invalid fields to fix them help: name: "The name of your site. It can only include numbers and letters." + title: 'The title can be anything you want' + description: 'You site description that appears in search engines. Between 50 and 160 characters.' design: 'Select the design for your site. You can change it later. We add more designs from time to time!' licencia: 'Everything we publish has automatic copyright. This means nobody can use our works without explicit permission. By @@ -399,6 +376,7 @@ en: en: 'English' ar: 'Arabic' posts: + caption: Post list attribute_ro: file: download: Download file @@ -480,6 +458,10 @@ en: blank: Nothing destroy: Delete confirm_destroy: Are you sure? + form: + errors: + title: There are some errors on the form + help: Please, verify that all values are correct. usuaries: invite_as: usuaries: users diff --git a/config/locales/es.yml b/config/locales/es.yml index c9c42c60..1ce50b09 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -178,45 +178,8 @@ es: usuarie: edit: Editar mi perfil category: 'Categoría' - i18n: - top: 'Volver al principio' - index: 'Aquí puedes editar todos los textos del sitio que no se - corresponden con artículos, como la descripción, secciones, textos - de botones... Si cambias los idiomas arriba para que coincidan, - puedes editar los textos en el mismo idioma. Si los idiomas no - coinciden, puedes traducirlos de uno a otro.' - count: 'Esta es la cantidad de textos.' - toc: 'Saltar hasta esta sección' - meta: 'Metadata' - navegacion: 'Navegación' - inicio: 'Inicio' - volver: 'Volver' - entrar: 'Entrar' - cerrar: 'Cerrar' - anchor: 'Links internos' - nav: 'Menú' - nav-lang: 'Menú de idiomas' - modulos: 'Módulos' - header: 'Portada' - sobre: 'Acerca' - metodologia: 'Metodología' - planeando_recursos: 'Planeando recursos' - rutas: 'Rutas' - complementarios: 'Materiales complementarios' - recursos: 'Recursos' - contacta: 'Contacta' - agradecimientos: 'Agradecimientos' - sesion: 'Sesiones' - sesiones: 'Sesiones' - anexo: 'Anexo' - simple: 'Simple' sites: index: 'Este es el listado de sitios que puedes editar.' - edit_translations: 'Puedes editar los textos que salen en tu sitio - que no corresponden a artículos aquí, además de traducirlos a - otros idiomas.' - edit_posts: 'Aquí verás el listado de todos los artículos y podrás - editarlos o crear nuevos' enqueued: 'El sitio está en la cola de espera para ser generado. Una vez que este proceso termine, recibirás un correo indicando el estado y si todo fue bien, se publicarán los cambios en tu sitio @@ -224,9 +187,6 @@ es: enqueue: 'Cuando termines de hacer cambios en tu sitio, puedes publicarlos con esta acción. Al finalizar recibirás un correo avisándote cómo fue todo.' - build_log: 'Este es el registro de lo que sucedió mientras se - generaba el sitio. Si hubo algún problema, saldrá aquí.' - invitade: 'Les invitades a un sitio solo pueden crear y modificar entradas propias y no pueden publicar sin la revisión de une usuarie' invitations: accept: 'Alguien te invitó a colaborar en su sitio. Si aceptas la invitación, tendrás acceso a este sitio.' reject: 'Si rechazas la invitación, no tendrás acceso.' From 9e935a2c49ce62d32ad716157d817ad759d940f5 Mon Sep 17 00:00:00 2001 From: f Date: Mon, 10 May 2021 15:28:04 -0300 Subject: [PATCH 28/32] poder ver las categorias que son articulos --- app/views/posts/index.haml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/views/posts/index.haml b/app/views/posts/index.haml index 291945ae..35356349 100644 --- a/app/views/posts/index.haml +++ b/app/views/posts/index.haml @@ -99,9 +99,13 @@ - unless post.categories.value.empty? %br %small - - (post.categories.respond_to?(:belongs_to) ? post.categories.belongs_to : post.categories.value).each do |c| + - categories = post.categories.respond_to?(:has_many) ? post.categories.has_many : post.categories.value + - categories.each do |c| + - c.read = link_to site_posts_path(@site, category: (c.respond_to?(:uuid) ? c.uuid.value : c)) do %span{ lang: post.lang.value, dir: dir }= (c.respond_to?(:title) ? c.title.value : c) + - unless categories.last == c + = '/' %td = post.date.value.strftime('%F') From ea12caef9b4ef9d3b7ef63cb1f81dd576552af9a Mon Sep 17 00:00:00 2001 From: f Date: Mon, 10 May 2021 15:28:53 -0300 Subject: [PATCH 29/32] actualizar el recursero para ingles --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index e80d3ccf..73c57a26 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -460,7 +460,7 @@ GEM rb-fsevent (0.10.4) rb-inotify (0.10.1) ffi (~> 1.0) - recursero-jekyll-theme (0.1.2) + recursero-jekyll-theme (0.1.3) jekyll (~> 4.0) jekyll-data (~> 1.1) jekyll-feed (~> 0.9) From 404436e294b4afb8de6cb736e97c9d48b9580795 Mon Sep 17 00:00:00 2001 From: f Date: Tue, 11 May 2021 15:27:54 -0300 Subject: [PATCH 30/32] algunas categorias son de texto fixes #1537 fixes #1538 fixes #1539 fixes #1541 --- app/views/posts/index.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/posts/index.haml b/app/views/posts/index.haml index 67f909f0..33bb5a7c 100644 --- a/app/views/posts/index.haml +++ b/app/views/posts/index.haml @@ -98,7 +98,7 @@ %small - categories = post.categories.respond_to?(:has_many) ? post.categories.has_many : post.categories.value - categories.each do |c| - - c.read + - c.read if c.respond_to? :read = link_to site_posts_path(@site, category: (c.respond_to?(:uuid) ? c.uuid.value : c)) do %span{ lang: post.lang.value, dir: dir }= (c.respond_to?(:title) ? c.title.value : c) - unless categories.last == c From c1d631646225bd32772a82753ebf14a11c827c08 Mon Sep 17 00:00:00 2001 From: f Date: Tue, 11 May 2021 17:59:30 -0300 Subject: [PATCH 31/32] los posts solo tienen lang fixes #1551 fixes #1550 fixes #1549 fixes #1548 --- app/controllers/posts_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index c578e944..da0b28aa 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -120,7 +120,7 @@ class PostsController < ApplicationController # TODO: Notificar si se pudo o no service.destroy site.touch - redirect_to site_posts_path(site, locale: post.locale.value) + redirect_to site_posts_path(site, locale: post.lang.value) end # Reordenar los artículos From 5d248342348ac14d4fb085f81c4859d07b1099b2 Mon Sep 17 00:00:00 2001 From: f Date: Tue, 11 May 2021 18:16:34 -0300 Subject: [PATCH 32/32] =?UTF-8?q?los=20sitios=20pueden=20ser=20m=C3=A1s=20?= =?UTF-8?q?grandes=20que=202GB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fixes #1552 fixes #1553 fixes #1554 fixes #1555 --- db/migrate/20210511211357_change_bytes_to_big_int.rb | 5 +++++ db/schema.rb | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20210511211357_change_bytes_to_big_int.rb diff --git a/db/migrate/20210511211357_change_bytes_to_big_int.rb b/db/migrate/20210511211357_change_bytes_to_big_int.rb new file mode 100644 index 00000000..4db65308 --- /dev/null +++ b/db/migrate/20210511211357_change_bytes_to_big_int.rb @@ -0,0 +1,5 @@ +class ChangeBytesToBigInt < ActiveRecord::Migration[6.1] + def change + change_column :build_stats, :bytes, :bigint + end +end diff --git a/db/schema.rb b/db/schema.rb index 2a93c5f1..eeb90ac6 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2021_04_14_152728) do +ActiveRecord::Schema.define(version: 2021_05_11_211357) do # Could not dump table "access_logs" because of following StandardError # Unknown type '' for column 'id' @@ -57,7 +57,7 @@ ActiveRecord::Schema.define(version: 2021_04_14_152728) do t.datetime "created_at", null: false t.datetime "updated_at", null: false t.integer "deploy_id" - t.integer "bytes" + t.bigint "bytes" t.float "seconds" t.string "action", null: false t.text "log"