From 4b6b422f958e1894d8aeea3e79e002e8eba409fb Mon Sep 17 00:00:00 2001 From: f Date: Mon, 3 Apr 2023 16:34:35 -0300 Subject: [PATCH 001/130] BREAKING CHANGE: clonar el skel en la rama de la plantilla #12760 --- app/models/site.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/site.rb b/app/models/site.rb index 4b2a8eb9..d0557f78 100644 --- a/app/models/site.rb +++ b/app/models/site.rb @@ -470,7 +470,7 @@ class Site < ApplicationRecord def clone_skel! return if jekyll? - Rugged::Repository.clone_at ENV['SKEL_SUTTY'], path + Rugged::Repository.clone_at(ENV['SKEL_SUTTY'], path, checkout_branch: design.gem) end # Elimina el directorio del sitio From 4442338a68a2f130f104b5b5fffdb8d54639440e Mon Sep 17 00:00:00 2001 From: f Date: Wed, 29 Mar 2023 14:57:30 -0300 Subject: [PATCH 002/130] feat: realizar la limpieza en segundo plano --- app/jobs/cleanup_job.rb | 8 ++++++++ lib/tasks/cleanup.rake | 4 +--- 2 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 app/jobs/cleanup_job.rb diff --git a/app/jobs/cleanup_job.rb b/app/jobs/cleanup_job.rb new file mode 100644 index 00000000..13053cb0 --- /dev/null +++ b/app/jobs/cleanup_job.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +# Realiza tareas de limpieza en segundo plano +class CleanupJob < ApplicationJob + def perform(before = nil) + CleanupService.new(before: before).cleanup_everything! + end +end diff --git a/lib/tasks/cleanup.rake b/lib/tasks/cleanup.rake index e14693bc..1c52abaf 100644 --- a/lib/tasks/cleanup.rake +++ b/lib/tasks/cleanup.rake @@ -4,8 +4,6 @@ namespace :cleanup do desc 'Cleanup sites' task everything: :environment do before = ENV.fetch('BEFORE', '30').to_i.days.ago - service = CleanupService.new(before: before) - - service.cleanup_everything! + CleanupJob.perform_later(before) end end From d99f02bd0cd08558621ceaeed7e3b48b565d719b Mon Sep 17 00:00:00 2001 From: f Date: Wed, 29 Mar 2023 15:06:26 -0300 Subject: [PATCH 003/130] =?UTF-8?q?feat:=20informar=20qu=C3=A9=20se=20est?= =?UTF-8?q?=C3=A1=20haciendo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/cleanup_service.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/services/cleanup_service.rb b/app/services/cleanup_service.rb index ad87cf9a..01b42d9e 100644 --- a/app/services/cleanup_service.rb +++ b/app/services/cleanup_service.rb @@ -26,6 +26,8 @@ class CleanupService Site.where('updated_at < ?', before).find_each do |site| next unless File.directory? site.path + Rails.logger.info "Limpiando dependencias, archivos temporales y repositorio git de #{site.name}" + site.deploys.find_each(&:cleanup!) site.repository.gc @@ -40,6 +42,8 @@ class CleanupService Site.where('updated_at >= ?', before).find_each do |site| next unless File.directory? site.path + Rails.logger.info "Limpiando repositorio git de #{site.name}" + site.repository.gc site.touch end From 2fac95d2e8be45eeeea51bdbadbbae71bcd27224 Mon Sep 17 00:00:00 2001 From: f Date: Wed, 29 Mar 2023 15:06:46 -0300 Subject: [PATCH 004/130] =?UTF-8?q?fix:=20obtener=20los=20sitios=20ordenad?= =?UTF-8?q?os=20para=20ir=20actualiz=C3=A1ndolos=20en=20orden?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/cleanup_service.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/services/cleanup_service.rb b/app/services/cleanup_service.rb index 01b42d9e..b0792159 100644 --- a/app/services/cleanup_service.rb +++ b/app/services/cleanup_service.rb @@ -23,7 +23,7 @@ class CleanupService # # @return [nil] def cleanup_older_sites! - Site.where('updated_at < ?', before).find_each do |site| + Site.where('updated_at < ?', before).order(updated_at: :desc).find_each do |site| next unless File.directory? site.path Rails.logger.info "Limpiando dependencias, archivos temporales y repositorio git de #{site.name}" @@ -39,7 +39,7 @@ class CleanupService # # @return [nil] def cleanup_newer_sites! - Site.where('updated_at >= ?', before).find_each do |site| + Site.where('updated_at >= ?', before).order(updated_at: :desc).find_each do |site| next unless File.directory? site.path Rails.logger.info "Limpiando repositorio git de #{site.name}" From cd7aa1d124c3e9b7ca7d9a182dec1fd3b7758608 Mon Sep 17 00:00:00 2001 From: f Date: Wed, 29 Mar 2023 15:10:53 -0300 Subject: [PATCH 005/130] =?UTF-8?q?fix:=20detectar=20cu=C3=A1ndo=20estamos?= =?UTF-8?q?=20en=20hainish?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gemfile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index b2472035..fe2ab1bc 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,9 @@ # frozen_string_literal: true -puts 'Usa haini.sh para generar un entorno de trabajo reproducible' +if ENV['RAILS_ENV'] != 'production' && ENV['HAIN_ENV'].nil? + puts 'Usa haini.sh para generar un entorno de trabajo reproducible' +end + source 'https://gems.sutty.nl' ruby '~> 2.7' From ae7481550a3c6d92c0cbe34df6c2c72cbdcc94fd Mon Sep 17 00:00:00 2001 From: f Date: Wed, 29 Mar 2023 15:12:10 -0300 Subject: [PATCH 006/130] feat: hacer limpieza de emergencia #12854 --- Procfile | 2 +- lib/tasks/cleanup.rake | 3 ++- monit.conf | 7 +++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Procfile b/Procfile index 4cc6e5b3..14bdb0c5 100644 --- a/Procfile +++ b/Procfile @@ -8,4 +8,4 @@ prometheus: bundle exec prometheus_exporter -b 0.0.0.0 --prefix "sutty_" distributed_press_tokens_renew: bundle exec rake distributed_press:tokens:renew cleanup: bundle exec rake cleanup:everything stats: bundle exec rake stats:process_all -distributed_press_renew_tokens: bundle exec rake distributed_press:tokens:renew +emergency_cleanup: bundle exec rake cleanup:everything BEFORE=7 diff --git a/lib/tasks/cleanup.rake b/lib/tasks/cleanup.rake index 1c52abaf..20044871 100644 --- a/lib/tasks/cleanup.rake +++ b/lib/tasks/cleanup.rake @@ -2,8 +2,9 @@ namespace :cleanup do desc 'Cleanup sites' - task everything: :environment do + task everything: :environment do |_, args| before = ENV.fetch('BEFORE', '30').to_i.days.ago + CleanupJob.perform_later(before) end end diff --git a/monit.conf b/monit.conf index 0bd18907..b0aa9884 100644 --- a/monit.conf +++ b/monit.conf @@ -19,7 +19,6 @@ check program stats every "0 1 * * *" if status != 0 then alert -check program distributed_press_tokens_renew - with path "/usr/bin/foreman run -f /srv/Procfile -d /srv distributed_press_tokens_renew" as uid "rails" gid "www-data" - every "0 3 * * *" - if status != 0 then alert +check filesystem root with path / + if space usage > 80% for 5 times within 15 cycles then alert + if space usage > 90% for 5 cycles then exec "/usr/bin/foreman run -f /srv/Procfile -d /srv emergency_cleanup" as uid "rails" gid "www-data" From e504501678096249dea3f170ccede64c7f191cd2 Mon Sep 17 00:00:00 2001 From: f Date: Mon, 10 Apr 2023 19:24:40 -0300 Subject: [PATCH 007/130] fix: deshabilitar el modo oscuro #12994 hasta que lo podamos revisar mejor --- app/assets/stylesheets/application.scss | 8 -------- 1 file changed, 8 deletions(-) diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index bba48558..06c0f8df 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -46,14 +46,6 @@ $sizes: ( --color: #{$magenta}; } -@media (prefers-color-scheme: dark) { - :root { - --foreground: #{$white}; - --background: #{$black}; - --color: #{$cyan}; - } -} - // TODO: Encontrar la forma de generar esto desde los locales de Rails $custom-file-text: ( en: 'Browse', From f041706bc7ccb78ed17681f99f4bb94f3c51d98c Mon Sep 17 00:00:00 2001 From: f Date: Wed, 12 Apr 2023 12:28:03 -0300 Subject: [PATCH 008/130] feat: poder cambiar al tema oscuro en firefox --- app/assets/stylesheets/dark.scss | 9 +++++++++ app/views/layouts/application.html.haml | 1 + config/locales/en.yml | 1 + config/locales/es.yml | 1 + 4 files changed, 12 insertions(+) create mode 100644 app/assets/stylesheets/dark.scss diff --git a/app/assets/stylesheets/dark.scss b/app/assets/stylesheets/dark.scss new file mode 100644 index 00000000..9893c70b --- /dev/null +++ b/app/assets/stylesheets/dark.scss @@ -0,0 +1,9 @@ +$black: black; +$white: white; +$cyan: #13fefe; + +:root { + --foreground: #{$white}; + --background: #{$black}; + --color: #{$cyan}; +} diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 965a856f..a73c74d8 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -14,6 +14,7 @@ %script{ type: 'text/javascript', src: '/env.js' } = csrf_meta_tags = stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' + = stylesheet_link_tag 'dark', rel: 'alternate stylesheet', media: 'all', 'data-turbolinks-track': 'reload', title: t('dark') = javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' = stylesheet_pack_tag 'application', 'data-turbolinks-track': 'reload' = favicon_link_tag 'sutty_cuadrada.png', rel: 'apple-touch-icon', type: 'image/png' diff --git a/config/locales/en.yml b/config/locales/en.yml index 3ddf681d..29f6bcbb 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1,4 +1,5 @@ en: + dark: Dark dir: ltr en: English es: Castellano diff --git a/config/locales/es.yml b/config/locales/es.yml index 01f1085c..c38a5ee0 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -1,4 +1,5 @@ es: + dark: Oscuro es: Castellano en: English es-AR: Castellano Rioplatense From 9e348bfdd81a4b0acce2b660940245ed40b26267 Mon Sep 17 00:00:00 2001 From: f Date: Wed, 19 Apr 2023 14:56:20 -0300 Subject: [PATCH 009/130] fix: los subdominios para los sitios vienen de un certificado wildcard #13159 --- app/controllers/api/v1/sites_controller.rb | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/app/controllers/api/v1/sites_controller.rb b/app/controllers/api/v1/sites_controller.rb index ae64cf74..185d0b24 100644 --- a/app/controllers/api/v1/sites_controller.rb +++ b/app/controllers/api/v1/sites_controller.rb @@ -9,7 +9,7 @@ module Api # Lista de nombres de dominios a emitir certificados def index - render json: sites_names + alternative_names + api_names + www_names + render json: alternative_names + api_names + www_names end private @@ -18,13 +18,6 @@ module Api name.end_with?('.') ? name[0..-2] : "#{name}.#{Site.domain}" end - # Nombres de los sitios - def sites_names - Site.all.order(:name).pluck(:name).map do |name| - canonicalize name - end - end - # Dominios alternativos def alternative_names (DeployAlternativeDomain.all.map(&:hostname) + DeployLocalizedDomain.all.map(&:hostname)).map do |name| From 11fe98ecdc76a25f343414afde8dd1fa86d86c37 Mon Sep 17 00:00:00 2001 From: f Date: Wed, 19 Apr 2023 14:56:56 -0300 Subject: [PATCH 010/130] fix: ignorar los subdominios en los dominios alternativos #13159 --- app/controllers/api/v1/sites_controller.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/controllers/api/v1/sites_controller.rb b/app/controllers/api/v1/sites_controller.rb index 185d0b24..05abc38a 100644 --- a/app/controllers/api/v1/sites_controller.rb +++ b/app/controllers/api/v1/sites_controller.rb @@ -18,10 +18,16 @@ module Api name.end_with?('.') ? name[0..-2] : "#{name}.#{Site.domain}" end + def subdomain?(name) + name.end_with? ".#{Site.domain}" + end + # Dominios alternativos def alternative_names (DeployAlternativeDomain.all.map(&:hostname) + DeployLocalizedDomain.all.map(&:hostname)).map do |name| canonicalize name + end.reject do |name| + subdomain? name end end @@ -34,6 +40,8 @@ module Api .or(Site.where(colaboracion_anonima: true)) .select("'api.' || name as name").map(&:name).map do |name| canonicalize name + end.reject do |name| + subdomain? name end end From 712514bc8c03b0ccd9f0289e3956aeddc8993c0b Mon Sep 17 00:00:00 2001 From: f Date: Thu, 20 Apr 2023 18:11:43 -0300 Subject: [PATCH 011/130] feat: avisar que hay que publicar al cambiar la configuracion #13114 --- app/controllers/sites_controller.rb | 1 + app/views/layouts/_flash.haml | 2 +- config/locales/en.yml | 2 ++ config/locales/es.yml | 2 ++ 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/controllers/sites_controller.rb b/app/controllers/sites_controller.rb index 63865e44..17287eb0 100644 --- a/app/controllers/sites_controller.rb +++ b/app/controllers/sites_controller.rb @@ -57,6 +57,7 @@ class SitesController < ApplicationController usuarie: current_usuarie) if service.update.valid? + flash[:notice] = I18n.t('sites.update.post') redirect_to site_posts_path(site, locale: site.default_locale) else render 'edit' diff --git a/app/views/layouts/_flash.haml b/app/views/layouts/_flash.haml index 7bd7ec0b..2d65ff78 100644 --- a/app/views/layouts/_flash.haml +++ b/app/views/layouts/_flash.haml @@ -1,4 +1,4 @@ - flash.each do |type, message| - unless type == 'js' = render 'bootstrap/alert' do - = message + = sanitize_markdown message, tags: %w[a strong em] diff --git a/config/locales/en.yml b/config/locales/en.yml index 3ddf681d..b37214e5 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -402,6 +402,8 @@ en: title: 'Edit %{site}' submit: 'Save changes' btn: 'Configuration' + update: + post: "Your changes have been saved. **If you enabled a publication method, don't forget to publish changes.**" form: errors: title: There were errors and we couldn't save your changes :( diff --git a/config/locales/es.yml b/config/locales/es.yml index 01f1085c..aaff1a24 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -408,6 +408,8 @@ es: title: 'Editar %{site}' submit: 'Guardar cambios' btn: 'Configuración' + update: + post: "Tus cambios han sido guardados. **Si agregaste un método de publicación, no te olvides de publicar cambios.**" form: errors: title: Hubo errores y no pudimos guardar tus cambios :( From e9d33b625a8843f9fb9a20015b36045a4e7ba010 Mon Sep 17 00:00:00 2001 From: f Date: Tue, 25 Apr 2023 14:51:54 -0300 Subject: [PATCH 012/130] =?UTF-8?q?feat:=20encontrar=20el=20post=20a=20par?= =?UTF-8?q?tir=20de=20su=20indexaci=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/indexed_post.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/models/indexed_post.rb b/app/models/indexed_post.rb index 7f6865f6..184cd05f 100644 --- a/app/models/indexed_post.rb +++ b/app/models/indexed_post.rb @@ -36,6 +36,15 @@ class IndexedPost < ApplicationRecord belongs_to :site + # Encuentra el post original + # + # @return [nil,Post] + def post + return if post_id.blank? + + @post ||= site.posts(lang: locale).find(post_id, uuid: true) + end + # Convertir locale a direccionario de PG # # @param [String,Symbol] From f38251af7a30ca65848c68971fe6aad10a7ef074 Mon Sep 17 00:00:00 2001 From: f Date: Wed, 26 Apr 2023 15:15:56 -0300 Subject: [PATCH 013/130] fix: permisos para posts indexados #13266 --- app/policies/indexed_post_policy.rb | 66 +++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 app/policies/indexed_post_policy.rb diff --git a/app/policies/indexed_post_policy.rb b/app/policies/indexed_post_policy.rb new file mode 100644 index 00000000..e0151c7a --- /dev/null +++ b/app/policies/indexed_post_policy.rb @@ -0,0 +1,66 @@ +# frozen_string_literal: true + +# Política de acceso a artículos +class IndexedPostPolicy + attr_reader :indexed_post, :usuarie, :site + + def initialize(usuarie, indexed_post) + @usuarie = usuarie + @indexed_post = indexed_post + @site = indexed_post.site + end + + def index? + true + end + + # Les invitades solo pueden ver sus propios posts + def show? + site.usuarie?(usuarie) || site.indexed_posts.by_usuarie(usuarie.id).find_by_post_id(indexed_post.post_id).present? + end + + def preview? + show? + end + + def new? + create? + end + + def create? + true + end + + def edit? + update? + end + + # Les invitades solo pueden modificar sus propios artículos + def update? + show? + end + + # Solo las usuarias pueden eliminar artículos. Les invitades pueden + # borrar sus propios artículos + def destroy? + update? + end + + # Las usuarias pueden ver todos los posts + # + # Les invitades solo pueden ver sus propios posts + class Scope + attr_reader :usuarie, :scope + + def initialize(usuarie, scope) + @usuarie = usuarie + @scope = scope + end + + def resolve + return scope if scope&.first&.site&.usuarie? usuarie + + scope.by_usuarie(usuarie.id) + end + end +end From a9bce070e8753c28dc208e650366b30013f5d9fa Mon Sep 17 00:00:00 2001 From: f Date: Wed, 26 Apr 2023 15:25:09 -0300 Subject: [PATCH 014/130] fix: temporalmente deshabilitar el cambio de plantillas #13260 --- app/views/sites/_form.haml | 59 +++++++++++++++++++------------------- config/locales/en.yml | 2 +- config/locales/es.yml | 2 +- 3 files changed, 32 insertions(+), 31 deletions(-) diff --git a/app/views/sites/_form.haml b/app/views/sites/_form.haml index 69997ffa..0dcccbe3 100644 --- a/app/views/sites/_form.haml +++ b/app/views/sites/_form.haml @@ -46,36 +46,37 @@ .invalid-feedback= site.errors.messages[:description].join(', ') %hr/ - .form-group#design_id - %h2= t('.design.title') - %p.lead= t('.help.design') - - if invalid? site, :design_id - = render 'bootstrap/alert' do - = t('activerecord.errors.models.site.attributes.design_id.layout_incompatible.help', - layouts: site.incompatible_layouts.to_sentence) - .row.row-cols-1.row-cols-md-2.designs - -# Demasiado complejo para un f.collection_radio_buttons - - Design.all.order(priority: :desc).each do |design| - .design.col.d-flex.flex-column - .custom-control.custom-radio - = f.radio_button :design_id, design.id, - checked: design.id == site.design_id, - disabled: design.disabled, - required: true, class: 'custom-control-input' - = f.label "design_id_#{design.id}", design.name, - class: 'custom-control-label' - .flex-fill - = sanitize_markdown design.description, - tags: %w[p a strong em] + - unless site.persisted? + .form-group#design_id + %h2= t('.design.title') + %p.lead= t('.help.design') + - if invalid? site, :design_id + = render 'bootstrap/alert' do + = t('activerecord.errors.models.site.attributes.design_id.layout_incompatible.help', + layouts: site.incompatible_layouts.to_sentence) + .row.row-cols-1.row-cols-md-2.designs + -# Demasiado complejo para un f.collection_radio_buttons + - Design.all.order(priority: :desc).each do |design| + .design.col.d-flex.flex-column + .custom-control.custom-radio + = f.radio_button :design_id, design.id, + checked: design.id == site.design_id, + disabled: design.disabled, + required: true, class: 'custom-control-input' + = f.label "design_id_#{design.id}", design.name, + class: 'custom-control-label' + .flex-fill + = sanitize_markdown design.description, + tags: %w[p a strong em] - .btn-group{ role: 'group', 'aria-label': t('.design.actions') } - - if design.url - = link_to t('.design.url'), design.url, - target: '_blank', class: 'btn' - - if design.license - = link_to t('.design.license'), design.license, - target: '_blank', class: 'btn' - %hr/ + .btn-group{ role: 'group', 'aria-label': t('.design.actions') } + - if design.url + = link_to t('.design.url'), design.url, + target: '_blank', class: 'btn' + - if design.license + = link_to t('.design.license'), design.license, + target: '_blank', class: 'btn' + %hr/ .form-group.licenses#license_id %h2= t('.licencia.title') diff --git a/config/locales/en.yml b/config/locales/en.yml index 2628ffb1..1f46ffed 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -410,7 +410,7 @@ en: 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!' + design: 'Select the design for your site. 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 using licenses, we stablish conditions by which we want to share diff --git a/config/locales/es.yml b/config/locales/es.yml index 6ad61228..3630ea25 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -416,7 +416,7 @@ es: name: 'El nombre de tu sitio que formará parte de la dirección (**ejemplo**.sutty.nl). Solo puede contener letras minúsculas, números y guiones.' title: 'El título de tu sitio puede ser lo que quieras.' description: 'La descripción del sitio, que saldrá en buscadores. Entre 50 y 160 caracteres.' - design: 'Elegí el diseño que va a tener tu sitio aquí. Podés cambiarlo luego. De tanto en tanto vamos sumando diseños nuevos.' + design: 'Elegí el diseño que va a tener tu sitio aquí. De tanto en tanto vamos sumando diseños nuevos.' licencia: 'Todo lo que publicamos posee automáticamente derechos de autore. Esto significa que nadie puede hacer uso de nuestras obras sin permiso explícito. Con las licencias establecemos From 1839d48893ca278a71208d40c17f3ed4d009233a Mon Sep 17 00:00:00 2001 From: f Date: Sat, 29 Apr 2023 18:10:28 -0300 Subject: [PATCH 015/130] fix: permitir el atributo start #13321 --- app/models/metadata_template.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/metadata_template.rb b/app/models/metadata_template.rb index 5de54be1..b324e71c 100644 --- a/app/models/metadata_template.rb +++ b/app/models/metadata_template.rb @@ -202,7 +202,7 @@ MetadataTemplate = Struct.new(:site, :document, :name, :label, :type, def allowed_attributes @allowed_attributes ||= %w[style href src alt controls data-align data-multimedia data-multimedia-inner id - name].freeze + name start].freeze end def allowed_tags From 068bed5c0ad58be73949dd9b01304db4295f7002 Mon Sep 17 00:00:00 2001 From: f Date: Fri, 19 May 2023 14:34:24 -0300 Subject: [PATCH 016/130] Revert "deshabilitar el paginado temporalmente" This reverts commit 9c4a0a86f3eeec8f578e3872096896a710e01632. --- app/controllers/posts_controller.rb | 4 ++-- app/views/posts/index.haml | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index 9720fe13..21a6dc06 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -23,7 +23,7 @@ class PostsController < ApplicationController return unless stale?([current_usuarie, site, filter_params]) # Todos los artículos de este sitio para el idioma actual - @posts = site.indexed_posts.where(locale: locale) + @posts = site.indexed_posts.where(locale: locale).page(filter_params.delete(:page)) # De este tipo @posts = @posts.where(layout: filter_params[:layout]) if filter_params[:layout] # Que estén dentro de la categoría @@ -154,7 +154,7 @@ class PostsController < ApplicationController # # @return [Hash] def filter_params - @filter_params ||= params.permit(:q, :category, :layout).to_hash.select do |_, v| + @filter_params ||= params.permit(:q, :category, :layout, :page).to_hash.select do |_, v| v.present? end.transform_keys(&:to_sym) end diff --git a/app/views/posts/index.haml b/app/views/posts/index.haml index e8c3dea7..470e9641 100644 --- a/app/views/posts/index.haml +++ b/app/views/posts/index.haml @@ -85,6 +85,8 @@ %button.btn{ data: { action: 'reorder#bottom' } }= t('posts.reorder.bottom') %div + = link_to_prev_page @posts, t('posts.prev'), class: 'btn' + = link_to_next_page @posts, t('posts.next'), class: 'btn' %tbody - dir = @site.data.dig(params[:locale], 'dir') - size = @posts.size From 3540886554455ac1627b190327d32117e04bf129 Mon Sep 17 00:00:00 2001 From: f Date: Fri, 19 May 2023 14:36:42 -0300 Subject: [PATCH 017/130] feat: poder paginar solo algunos sitios #12714 --- app/controllers/posts_controller.rb | 3 ++- app/views/posts/index.haml | 7 ++++--- db/migrate/20230519143500_add_pagination_to_site.rb | 8 ++++++++ 3 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 db/migrate/20230519143500_add_pagination_to_site.rb diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index 21a6dc06..057c3068 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -23,7 +23,8 @@ class PostsController < ApplicationController return unless stale?([current_usuarie, site, filter_params]) # Todos los artículos de este sitio para el idioma actual - @posts = site.indexed_posts.where(locale: locale).page(filter_params.delete(:page)) + @posts = site.indexed_posts.where(locale: locale) + @posts = @posts.page(filter_params.delete(:page)) if site.pagination # De este tipo @posts = @posts.where(layout: filter_params[:layout]) if filter_params[:layout] # Que estén dentro de la categoría diff --git a/app/views/posts/index.haml b/app/views/posts/index.haml index 470e9641..ae53aa7a 100644 --- a/app/views/posts/index.haml +++ b/app/views/posts/index.haml @@ -84,9 +84,10 @@ %button.btn{ data: { action: 'reorder#top' } }= t('posts.reorder.top') %button.btn{ data: { action: 'reorder#bottom' } }= t('posts.reorder.bottom') - %div - = link_to_prev_page @posts, t('posts.prev'), class: 'btn' - = link_to_next_page @posts, t('posts.next'), class: 'btn' + - if @site.pagination + %div + = link_to_prev_page @posts, t('posts.prev'), class: 'btn' + = link_to_next_page @posts, t('posts.next'), class: 'btn' %tbody - dir = @site.data.dig(params[:locale], 'dir') - size = @posts.size diff --git a/db/migrate/20230519143500_add_pagination_to_site.rb b/db/migrate/20230519143500_add_pagination_to_site.rb new file mode 100644 index 00000000..776fa318 --- /dev/null +++ b/db/migrate/20230519143500_add_pagination_to_site.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +# Agrega la opción de paginación a los sitios +class AddPaginationToSites < ActiveRecord::Migration[6.1] + def change + add_column :sites, :pagination, :boolean, default: false + end +end From d0f7843fbf90ef936afe955b046d8cab1ee6f7d8 Mon Sep 17 00:00:00 2001 From: f Date: Fri, 19 May 2023 14:40:42 -0300 Subject: [PATCH 018/130] fixup! feat: poder paginar solo algunos sitios #12714 --- db/migrate/20230519143500_add_pagination_to_site.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/migrate/20230519143500_add_pagination_to_site.rb b/db/migrate/20230519143500_add_pagination_to_site.rb index 776fa318..387dc588 100644 --- a/db/migrate/20230519143500_add_pagination_to_site.rb +++ b/db/migrate/20230519143500_add_pagination_to_site.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # Agrega la opción de paginación a los sitios -class AddPaginationToSites < ActiveRecord::Migration[6.1] +class AddPaginationToSite < ActiveRecord::Migration[6.1] def change add_column :sites, :pagination, :boolean, default: false end From e35bddf915ea332c0a169556d581d41744b6f0ad Mon Sep 17 00:00:00 2001 From: f Date: Wed, 24 May 2023 10:04:22 -0300 Subject: [PATCH 019/130] fix: no permitir que les usuaries elijan un idioma que no existe MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit porque se les rompe el panel después --- app/models/usuarie.rb | 12 ++++++++++++ config/locales/en.yml | 4 ++++ config/locales/es.yml | 4 ++++ 3 files changed, 20 insertions(+) diff --git a/app/models/usuarie.rb b/app/models/usuarie.rb index 2bc7a1b5..42f20c0b 100644 --- a/app/models/usuarie.rb +++ b/app/models/usuarie.rb @@ -10,6 +10,7 @@ class Usuarie < ApplicationRecord validates_uniqueness_of :email validates_with EmailAddress::ActiveRecordValidator, field: :email + validate :locale_available! before_create :lang_from_locale! before_update :remove_confirmation_invitation_inconsistencies! @@ -78,4 +79,15 @@ class Usuarie < ApplicationRecord self.invitation_accepted_at ||= Time.now.utc end end + + # Muestra un error si el idioma no está disponible al cambiar el + # idioma de la cuenta. + # + # @return [nil] + def locale_available! + return if I18n.locale_available? self.lang + + errors.add(:lang, I18n.t('activerecord.errors.models.usuarie.attributes.lang.not_available')) + nil + end end diff --git a/config/locales/en.yml b/config/locales/en.yml index 5f97a8b9..ab6a9305 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -194,6 +194,10 @@ en: layout_incompatible: error: "Design can't be changed because there are posts with incompatible layouts" help: "Your site has posts with layouts only compatible with the current design. If you change it, the site won't work as you expect. If you're trying out designs, you can delete posts in the following incompatible layouts:: %{layouts}." + usuarie: + attributes: + lang: + not_available: "This language is not yet available, would you help us by translating Sutty into it?" errors: argument_error: 'Argument `%{argument}` must be an instance of %{class}' unknown_locale: 'Unknown %{locale} locale' diff --git a/config/locales/es.yml b/config/locales/es.yml index 9e0b8945..e3c271da 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -194,6 +194,10 @@ es: layout_incompatible: error: 'No se puede cambiar la plantilla porque hay artículos con formatos incompatibles' help: 'En tu sitio hay artículos que solo son compatibles con el diseño actual, si cambias la plantilla el sitio no funcionará como esperas. Si estás probando plantillas, puedes eliminar los artículos en los formatos incompatibles: %{layouts}.' + usuarie: + attributes: + lang: + not_available: "Este idioma todavía no está disponible, ¿nos ayudas a agregarlo y mantenerlo?" errors: argument_error: 'El argumento `%{argument}` debe ser una instancia de %{class}' unknown_locale: 'El idioma %{locale} es desconocido' From 4e002e042bc5b0e5c129ab8cac3df03cf340fefb Mon Sep 17 00:00:00 2001 From: f Date: Wed, 24 May 2023 10:06:11 -0300 Subject: [PATCH 020/130] fix: no permitir idiomas que no existen en el cambio de idioma #13493 --- app/controllers/application_controller.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index ee153394..2746ab10 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -59,7 +59,11 @@ class ApplicationController < ActionController::Base # # @return [String,Symbol] def current_locale - session[:locale] = params[:change_locale_to] if params[:change_locale_to].present? + locale = params[:change_locale_to] + + if locale.present? && I18n.locale_available?(locale) + session[:locale] = params[:change_locale_to] + end session[:locale] || current_usuarie&.lang || I18n.locale end From 28b74492f0d6ec60eaaf7545e36cfb425e5ffeaf Mon Sep 17 00:00:00 2001 From: Sutty Date: Tue, 16 May 2023 16:38:49 +0000 Subject: [PATCH 021/130] =?UTF-8?q?fix:=20dump=20de=20producci=C3=B3n=20#1?= =?UTF-8?q?3498?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/application.rb | 2 + db/schema.rb | 400 -------- db/structure.sql | 2267 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 2269 insertions(+), 400 deletions(-) delete mode 100644 db/schema.rb create mode 100644 db/structure.sql diff --git a/config/application.rb b/config/application.rb index 057a22d3..606ccaf4 100644 --- a/config/application.rb +++ b/config/application.rb @@ -45,6 +45,8 @@ module Sutty config.active_storage.queues.purge = :default config.active_job.queue_adapter = :que + config.active_record.schema_format = :sql + config.to_prepare do # Load application's model / class decorators Dir.glob(File.join(File.dirname(__FILE__), '..', 'app', '**', '*_decorator.rb')).sort.each do |c| diff --git a/db/schema.rb b/db/schema.rb deleted file mode 100644 index fd82d447..00000000 --- a/db/schema.rb +++ /dev/null @@ -1,400 +0,0 @@ -# This file is auto-generated from the current state of the database. Instead -# of editing this file, please use the migrations feature of Active Record to -# incrementally modify your database, and then regenerate this schema definition. -# -# This file is the source Rails uses to define your schema when running `bin/rails -# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to -# be faster and is potentially less error prone than running all of your -# migrations from scratch. Old migrations may fail to apply correctly if those -# migrations use external dependencies or application code. -# -# It's strongly recommended that you check this file into your version control system. - -ActiveRecord::Schema.define(version: 2023_04_15_153231) do - - # These are extensions that must be enabled in order to support this database - enable_extension "pg_trgm" - enable_extension "pgcrypto" - enable_extension "plpgsql" - - create_table "access_logs", id: :uuid, default: nil, force: :cascade do |t| - t.string "host" - t.float "msec" - t.string "server_protocol" - t.string "request_method" - t.string "request_completion" - t.string "uri" - t.string "query_string" - t.integer "status" - t.string "sent_http_content_type" - t.string "sent_http_content_encoding" - t.string "sent_http_etag" - t.string "sent_http_last_modified" - t.string "http_accept" - t.string "http_accept_encoding" - t.string "http_accept_language" - t.string "http_pragma" - t.string "http_cache_control" - t.string "http_if_none_match" - t.string "http_dnt" - t.string "http_user_agent" - t.string "http_origin" - t.float "request_time" - t.integer "bytes_sent" - t.integer "body_bytes_sent" - t.integer "request_length" - t.string "http_connection" - t.string "pipe" - t.integer "connection_requests" - t.string "geoip2_data_country_name" - t.string "geoip2_data_city_name" - t.string "ssl_server_name" - t.string "ssl_protocol" - t.string "ssl_early_data" - t.string "ssl_session_reused" - t.string "ssl_curves" - t.string "ssl_ciphers" - t.string "ssl_cipher" - t.string "sent_http_x_xss_protection" - t.string "sent_http_x_frame_options" - t.string "sent_http_x_content_type_options" - t.string "sent_http_strict_transport_security" - t.string "nginx_version" - t.integer "pid" - t.string "remote_user" - t.boolean "crawler", default: false - t.string "http_referer" - t.datetime "created_at", precision: 6 - t.index ["geoip2_data_city_name"], name: "index_access_logs_on_geoip2_data_city_name" - t.index ["geoip2_data_country_name"], name: "index_access_logs_on_geoip2_data_country_name" - t.index ["host"], name: "index_access_logs_on_host" - t.index ["http_origin"], name: "index_access_logs_on_http_origin" - t.index ["http_user_agent"], name: "index_access_logs_on_http_user_agent" - t.index ["status"], name: "index_access_logs_on_status" - t.index ["uri"], name: "index_access_logs_on_uri" - end - - create_table "action_text_rich_texts", force: :cascade do |t| - t.string "name", null: false - t.text "body" - t.string "record_type", null: false - t.bigint "record_id", null: false - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["record_type", "record_id", "name"], name: "index_action_text_rich_texts_uniqueness", unique: true - end - - create_table "active_storage_attachments", force: :cascade do |t| - t.string "name", null: false - t.string "record_type", null: false - t.bigint "record_id", null: false - t.bigint "blob_id", null: false - t.datetime "created_at", null: false - t.index ["blob_id"], name: "index_active_storage_attachments_on_blob_id" - t.index ["record_type", "record_id", "name", "blob_id"], name: "index_active_storage_attachments_uniqueness", unique: true - end - - create_table "active_storage_blobs", force: :cascade do |t| - t.string "key", null: false - t.string "filename", null: false - t.string "content_type" - t.text "metadata" - t.bigint "byte_size", null: false - t.string "checksum", null: false - t.datetime "created_at", null: false - t.string "service_name", null: false - t.index ["key"], name: "index_active_storage_blobs_on_key", unique: true - end - - create_table "active_storage_variant_records", force: :cascade do |t| - t.bigint "blob_id", null: false - t.string "variation_digest", null: false - t.index ["blob_id", "variation_digest"], name: "index_active_storage_variant_records_uniqueness", unique: true - end - - create_table "blazer_audits", force: :cascade do |t| - t.bigint "user_id" - t.bigint "query_id" - t.text "statement" - t.string "data_source" - t.datetime "created_at" - t.index ["query_id"], name: "index_blazer_audits_on_query_id" - t.index ["user_id"], name: "index_blazer_audits_on_user_id" - end - - create_table "blazer_checks", force: :cascade do |t| - t.bigint "creator_id" - t.bigint "query_id" - t.string "state" - t.string "schedule" - t.text "emails" - t.text "slack_channels" - t.string "check_type" - t.text "message" - t.datetime "last_run_at" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["creator_id"], name: "index_blazer_checks_on_creator_id" - t.index ["query_id"], name: "index_blazer_checks_on_query_id" - end - - create_table "blazer_dashboard_queries", force: :cascade do |t| - t.bigint "dashboard_id" - t.bigint "query_id" - t.integer "position" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["dashboard_id"], name: "index_blazer_dashboard_queries_on_dashboard_id" - t.index ["query_id"], name: "index_blazer_dashboard_queries_on_query_id" - end - - create_table "blazer_dashboards", force: :cascade do |t| - t.bigint "creator_id" - t.text "name" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["creator_id"], name: "index_blazer_dashboards_on_creator_id" - end - - create_table "blazer_queries", force: :cascade do |t| - t.bigint "creator_id" - t.string "name" - t.text "description" - t.text "statement" - t.string "data_source" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.index ["creator_id"], name: "index_blazer_queries_on_creator_id" - end - - create_table "build_stats", force: :cascade do |t| - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.bigint "deploy_id" - t.bigint "bytes" - t.float "seconds" - t.string "action", null: false - t.text "log" - t.boolean "status", default: false - t.index ["deploy_id"], name: "index_build_stats_on_deploy_id" - end - - create_table "csp_reports", id: :uuid, default: nil, force: :cascade do |t| - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.string "disposition" - t.string "referrer" - t.string "blocked_uri" - t.string "document_uri" - t.string "effective_directive" - t.string "original_policy" - t.string "script_sample" - t.string "status_code" - t.string "violated_directive" - t.integer "column_number" - t.integer "line_number" - t.string "source_file" - end - - create_table "deploys", force: :cascade do |t| - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.bigint "site_id" - t.string "type" - t.text "values" - t.index ["site_id"], name: "index_deploys_on_site_id" - t.index ["type"], name: "index_deploys_on_type" - end - - create_table "designs", force: :cascade do |t| - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.string "name" - t.text "description" - t.string "gem" - t.string "url" - t.string "license" - t.boolean "disabled", default: false - t.text "credits" - t.string "designer_url" - t.integer "priority" - end - - create_table "indexed_posts", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| - t.bigint "site_id" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.string "locale", default: "simple" - t.string "layout", null: false - t.string "path", null: false - t.string "title", default: "" - t.jsonb "front_matter", default: "{}" - t.string "content", default: "" - t.tsvector "indexed_content" - t.integer "order", default: 0 - t.string "dictionary" - t.index ["front_matter"], name: "index_indexed_posts_on_front_matter", using: :gin - t.index ["indexed_content"], name: "index_indexed_posts_on_indexed_content", using: :gin - t.index ["layout"], name: "index_indexed_posts_on_layout" - t.index ["locale"], name: "index_indexed_posts_on_locale" - t.index ["site_id"], name: "index_indexed_posts_on_site_id" - end - - create_table "licencias", force: :cascade do |t| - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.string "name" - t.text "description" - t.text "deed" - t.string "url" - t.string "icons" - end - - create_table "log_entries", force: :cascade do |t| - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.bigint "site_id" - t.text "text" - t.boolean "sent", default: false - t.index ["site_id"], name: "index_log_entries_on_site_id" - end - - create_table "maintenances", force: :cascade do |t| - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.text "message" - t.datetime "estimated_from" - t.datetime "estimated_to" - t.boolean "are_we_back", default: false - end - - create_table "mobility_string_translations", force: :cascade do |t| - t.string "locale", null: false - t.string "key", null: false - t.string "value" - t.string "translatable_type" - t.bigint "translatable_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.index ["translatable_id", "translatable_type", "key"], name: "index_mobility_string_translations_on_translatable_attribute" - t.index ["translatable_id", "translatable_type", "locale", "key"], name: "index_mobility_string_translations_on_keys", unique: true - t.index ["translatable_type", "key", "value", "locale"], name: "index_mobility_string_translations_on_query_keys" - end - - create_table "mobility_text_translations", force: :cascade do |t| - t.string "locale", null: false - t.string "key", null: false - t.text "value" - t.string "translatable_type" - t.bigint "translatable_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.index ["translatable_id", "translatable_type", "key"], name: "index_mobility_text_translations_on_translatable_attribute" - t.index ["translatable_id", "translatable_type", "locale", "key"], name: "index_mobility_text_translations_on_keys", unique: true - end - - create_table "roles", force: :cascade do |t| - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.bigint "site_id" - t.bigint "usuarie_id" - t.string "rol" - t.boolean "temporal" - t.index ["site_id", "usuarie_id"], name: "index_roles_on_site_id_and_usuarie_id", unique: true - t.index ["site_id"], name: "index_roles_on_site_id" - t.index ["usuarie_id"], name: "index_roles_on_usuarie_id" - end - - create_table "rollups", force: :cascade do |t| - t.string "name", null: false - t.string "interval", null: false - t.datetime "time", null: false - t.jsonb "dimensions", default: {}, null: false - t.float "value" - t.index ["name", "interval", "time", "dimensions"], name: "index_rollups_on_name_and_interval_and_time_and_dimensions", unique: true - end - - create_table "sites", force: :cascade do |t| - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.string "name" - t.bigint "design_id" - t.bigint "licencia_id" - t.string "status", default: "waiting" - t.text "description" - t.string "title" - t.boolean "colaboracion_anonima", default: false - t.boolean "contact", default: false - t.string "private_key_ciphertext" - t.boolean "acepta_invitades", default: false - t.string "tienda_api_key_ciphertext", default: "" - t.string "tienda_url", default: "" - t.string "api_key_ciphertext" - t.index ["design_id"], name: "index_sites_on_design_id" - t.index ["licencia_id"], name: "index_sites_on_licencia_id" - t.index ["name"], name: "index_sites_on_name", unique: true - end - - create_table "stats", force: :cascade do |t| - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - t.bigint "site_id" - t.string "name", null: false - t.index ["name"], name: "index_stats_on_name", using: :hash - t.index ["site_id"], name: "index_stats_on_site_id" - end - - create_table "usuaries", force: :cascade do |t| - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.string "email", default: "", null: false - t.string "encrypted_password", default: "", null: false - t.string "reset_password_token" - t.datetime "reset_password_sent_at" - t.datetime "remember_created_at" - t.string "confirmation_token" - t.datetime "confirmed_at" - t.datetime "confirmation_sent_at" - t.string "unconfirmed_email" - t.integer "failed_attempts", default: 0, null: false - t.string "unlock_token" - t.datetime "locked_at" - t.boolean "acepta_politicas_de_privacidad", default: false - t.string "invitation_token" - t.datetime "invitation_created_at" - t.datetime "invitation_sent_at" - t.datetime "invitation_accepted_at" - t.integer "invitation_limit" - t.string "invited_by_type" - t.bigint "invited_by_id" - t.integer "invitations_count", default: 0 - t.string "lang", default: "es" - t.index ["confirmation_token"], name: "index_usuaries_on_confirmation_token", unique: true - t.index ["email"], name: "index_usuaries_on_email", unique: true - t.index ["invitation_token"], name: "index_usuaries_on_invitation_token", unique: true - t.index ["invitations_count"], name: "index_usuaries_on_invitations_count" - t.index ["invited_by_id"], name: "index_usuaries_on_invited_by_id" - t.index ["invited_by_type", "invited_by_id"], name: "index_usuaries_on_invited_by" - t.index ["reset_password_token"], name: "index_usuaries_on_reset_password_token", unique: true - t.index ["unlock_token"], name: "index_usuaries_on_unlock_token", unique: true - end - - add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id" - add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id" - - create_trigger("indexed_posts_before_insert_update_row_tr", :compatibility => 1). - on("indexed_posts"). - before(:insert, :update) do - <<-SQL_ACTIONS -new.indexed_content := to_tsvector(('pg_catalog.' || new.dictionary)::regconfig, coalesce(new.title, '') || ' -' || coalesce(new.content,'')); - SQL_ACTIONS - end - - create_trigger("access_logs_before_insert_row_tr", :compatibility => 1). - on("access_logs"). - before(:insert) do - "new.created_at := to_timestamp(new.msec);" - end - -end diff --git a/db/structure.sql b/db/structure.sql new file mode 100644 index 00000000..e50ae337 --- /dev/null +++ b/db/structure.sql @@ -0,0 +1,2267 @@ +-- +-- PostgreSQL database dump +-- + +-- Dumped from database version 15.2 +-- Dumped by pg_dump version 15.2 + +SET statement_timeout = 0; +SET lock_timeout = 0; +SET idle_in_transaction_session_timeout = 0; +SET client_encoding = 'UTF8'; +SET standard_conforming_strings = on; +SELECT pg_catalog.set_config('search_path', '', false); +SET check_function_bodies = false; +SET xmloption = content; +SET client_min_messages = warning; +SET row_security = off; + +-- +-- Name: public; Type: SCHEMA; Schema: -; Owner: - +-- + +-- *not* creating schema, since initdb creates it + + +-- +-- Name: dblink; Type: EXTENSION; Schema: -; Owner: - +-- + +CREATE EXTENSION IF NOT EXISTS dblink WITH SCHEMA public; + + +-- +-- Name: EXTENSION dblink; Type: COMMENT; Schema: -; Owner: - +-- + +COMMENT ON EXTENSION dblink IS 'connect to other PostgreSQL databases from within a database'; + + +-- +-- Name: pg_trgm; Type: EXTENSION; Schema: -; Owner: - +-- + +CREATE EXTENSION IF NOT EXISTS pg_trgm WITH SCHEMA public; + + +-- +-- Name: EXTENSION pg_trgm; Type: COMMENT; Schema: -; Owner: - +-- + +COMMENT ON EXTENSION pg_trgm IS 'text similarity measurement and index searching based on trigrams'; + + +-- +-- Name: pgcrypto; Type: EXTENSION; Schema: -; Owner: - +-- + +CREATE EXTENSION IF NOT EXISTS pgcrypto WITH SCHEMA public; + + +-- +-- Name: EXTENSION pgcrypto; Type: COMMENT; Schema: -; Owner: - +-- + +COMMENT ON EXTENSION pgcrypto IS 'cryptographic functions'; + + +-- +-- Name: que_validate_tags(jsonb); Type: FUNCTION; Schema: public; Owner: - +-- + +CREATE FUNCTION public.que_validate_tags(tags_array jsonb) RETURNS boolean + LANGUAGE sql + AS $$ + SELECT bool_and( + jsonb_typeof(value) = 'string' + AND + char_length(value::text) <= 100 + ) + FROM jsonb_array_elements(tags_array) +$$; + + +SET default_tablespace = ''; + +SET default_table_access_method = heap; + +-- +-- Name: que_jobs; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.que_jobs ( + priority smallint DEFAULT 100 NOT NULL, + run_at timestamp with time zone DEFAULT now() NOT NULL, + id bigint NOT NULL, + job_class text NOT NULL, + error_count integer DEFAULT 0 NOT NULL, + last_error_message text, + queue text DEFAULT 'default'::text NOT NULL, + last_error_backtrace text, + finished_at timestamp with time zone, + expired_at timestamp with time zone, + args jsonb DEFAULT '[]'::jsonb NOT NULL, + data jsonb DEFAULT '{}'::jsonb NOT NULL, + job_schema_version integer NOT NULL, + kwargs jsonb DEFAULT '{}'::jsonb NOT NULL, + CONSTRAINT error_length CHECK (((char_length(last_error_message) <= 500) AND (char_length(last_error_backtrace) <= 10000))), + CONSTRAINT job_class_length CHECK ((char_length( +CASE job_class + WHEN 'ActiveJob::QueueAdapters::QueAdapter::JobWrapper'::text THEN ((args -> 0) ->> 'job_class'::text) + ELSE job_class +END) <= 200)), + CONSTRAINT queue_length CHECK ((char_length(queue) <= 100)), + CONSTRAINT valid_args CHECK ((jsonb_typeof(args) = 'array'::text)), + CONSTRAINT valid_data CHECK (((jsonb_typeof(data) = 'object'::text) AND ((NOT (data ? 'tags'::text)) OR ((jsonb_typeof((data -> 'tags'::text)) = 'array'::text) AND (jsonb_array_length((data -> 'tags'::text)) <= 5) AND public.que_validate_tags((data -> 'tags'::text)))))) +) +WITH (fillfactor='90'); + + +-- +-- Name: TABLE que_jobs; Type: COMMENT; Schema: public; Owner: - +-- + +COMMENT ON TABLE public.que_jobs IS '7'; + + +-- +-- Name: access_logs_before_insert_row_tr(); Type: FUNCTION; Schema: public; Owner: - +-- + +CREATE FUNCTION public.access_logs_before_insert_row_tr() RETURNS trigger + LANGUAGE plpgsql + AS $$ +BEGIN + new.created_at := to_timestamp(new.msec); + RETURN NEW; +END; +$$; + + +-- +-- Name: indexed_posts_before_insert_update_row_tr(); Type: FUNCTION; Schema: public; Owner: - +-- + +CREATE FUNCTION public.indexed_posts_before_insert_update_row_tr() RETURNS trigger + LANGUAGE plpgsql + AS $$ +BEGIN + new.indexed_content := to_tsvector(('pg_catalog.' || new.dictionary)::regconfig, coalesce(new.title, '') || ' + ' || coalesce(new.content,'')); + RETURN NEW; +END; +$$; + + +-- +-- Name: que_determine_job_state(public.que_jobs); Type: FUNCTION; Schema: public; Owner: - +-- + +CREATE FUNCTION public.que_determine_job_state(job public.que_jobs) RETURNS text + LANGUAGE sql + AS $$ + SELECT + CASE + WHEN job.expired_at IS NOT NULL THEN 'expired' + WHEN job.finished_at IS NOT NULL THEN 'finished' + WHEN job.error_count > 0 THEN 'errored' + WHEN job.run_at > CURRENT_TIMESTAMP THEN 'scheduled' + ELSE 'ready' + END +$$; + + +-- +-- Name: que_job_notify(); Type: FUNCTION; Schema: public; Owner: - +-- + +CREATE FUNCTION public.que_job_notify() RETURNS trigger + LANGUAGE plpgsql + AS $$ + DECLARE + locker_pid integer; + sort_key json; + BEGIN + -- Don't do anything if the job is scheduled for a future time. + IF NEW.run_at IS NOT NULL AND NEW.run_at > now() THEN + RETURN null; + END IF; + + -- Pick a locker to notify of the job's insertion, weighted by their number + -- of workers. Should bounce pseudorandomly between lockers on each + -- invocation, hence the md5-ordering, but still touch each one equally, + -- hence the modulo using the job_id. + SELECT pid + INTO locker_pid + FROM ( + SELECT *, last_value(row_number) OVER () + 1 AS count + FROM ( + SELECT *, row_number() OVER () - 1 AS row_number + FROM ( + SELECT * + FROM public.que_lockers ql, generate_series(1, ql.worker_count) AS id + WHERE + listening AND + queues @> ARRAY[NEW.queue] AND + ql.job_schema_version = NEW.job_schema_version + ORDER BY md5(pid::text || id::text) + ) t1 + ) t2 + ) t3 + WHERE NEW.id % count = row_number; + + IF locker_pid IS NOT NULL THEN + -- There's a size limit to what can be broadcast via LISTEN/NOTIFY, so + -- rather than throw errors when someone enqueues a big job, just + -- broadcast the most pertinent information, and let the locker query for + -- the record after it's taken the lock. The worker will have to hit the + -- DB in order to make sure the job is still visible anyway. + SELECT row_to_json(t) + INTO sort_key + FROM ( + SELECT + 'job_available' AS message_type, + NEW.queue AS queue, + NEW.priority AS priority, + NEW.id AS id, + -- Make sure we output timestamps as UTC ISO 8601 + to_char(NEW.run_at AT TIME ZONE 'UTC', 'YYYY-MM-DD"T"HH24:MI:SS.US"Z"') AS run_at + ) t; + + PERFORM pg_notify('que_listener_' || locker_pid::text, sort_key::text); + END IF; + + RETURN null; + END +$$; + + +-- +-- Name: que_state_notify(); Type: FUNCTION; Schema: public; Owner: - +-- + +CREATE FUNCTION public.que_state_notify() RETURNS trigger + LANGUAGE plpgsql + AS $$ + DECLARE + row record; + message json; + previous_state text; + current_state text; + BEGIN + IF TG_OP = 'INSERT' THEN + previous_state := 'nonexistent'; + current_state := public.que_determine_job_state(NEW); + row := NEW; + ELSIF TG_OP = 'DELETE' THEN + previous_state := public.que_determine_job_state(OLD); + current_state := 'nonexistent'; + row := OLD; + ELSIF TG_OP = 'UPDATE' THEN + previous_state := public.que_determine_job_state(OLD); + current_state := public.que_determine_job_state(NEW); + + -- If the state didn't change, short-circuit. + IF previous_state = current_state THEN + RETURN null; + END IF; + + row := NEW; + ELSE + RAISE EXCEPTION 'Unrecognized TG_OP: %', TG_OP; + END IF; + + SELECT row_to_json(t) + INTO message + FROM ( + SELECT + 'job_change' AS message_type, + row.id AS id, + row.queue AS queue, + + coalesce(row.data->'tags', '[]'::jsonb) AS tags, + + to_char(row.run_at AT TIME ZONE 'UTC', 'YYYY-MM-DD"T"HH24:MI:SS.US"Z"') AS run_at, + to_char(now() AT TIME ZONE 'UTC', 'YYYY-MM-DD"T"HH24:MI:SS.US"Z"') AS time, + + CASE row.job_class + WHEN 'ActiveJob::QueueAdapters::QueAdapter::JobWrapper' THEN + coalesce( + row.args->0->>'job_class', + 'ActiveJob::QueueAdapters::QueAdapter::JobWrapper' + ) + ELSE + row.job_class + END AS job_class, + + previous_state AS previous_state, + current_state AS current_state + ) t; + + PERFORM pg_notify('que_state', message::text); + + RETURN null; + END +$$; + + +-- +-- Name: access_logs; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.access_logs ( + id uuid DEFAULT public.gen_random_uuid() NOT NULL, + host character varying, + msec double precision, + server_protocol character varying, + request_method character varying, + request_completion character varying, + uri character varying, + query_string character varying, + status integer, + sent_http_content_type character varying, + sent_http_content_encoding character varying, + sent_http_etag character varying, + sent_http_last_modified character varying, + http_accept character varying, + http_accept_encoding character varying, + http_accept_language character varying, + http_pragma character varying, + http_cache_control character varying, + http_if_none_match character varying, + http_dnt character varying, + http_user_agent character varying, + http_origin character varying, + request_time double precision, + bytes_sent integer, + body_bytes_sent integer, + request_length integer, + http_connection character varying, + pipe character varying, + connection_requests integer, + geoip2_data_country_name character varying, + geoip2_data_city_name character varying, + ssl_server_name character varying, + ssl_protocol character varying, + ssl_early_data character varying, + ssl_session_reused character varying, + ssl_curves character varying, + ssl_ciphers character varying, + ssl_cipher character varying, + sent_http_x_xss_protection character varying, + sent_http_x_frame_options character varying, + sent_http_x_content_type_options character varying, + sent_http_strict_transport_security character varying, + nginx_version character varying, + pid integer, + remote_user character varying, + crawler boolean DEFAULT false, + http_referer character varying, + created_at timestamp(6) without time zone, + request_uri character varying DEFAULT ''::character varying, + datacenter_co2 numeric, + network_co2 numeric, + consumer_device_co2 numeric, + production_co2 numeric, + total_co2 numeric, + node character varying +); + + +-- +-- Name: action_text_rich_texts; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.action_text_rich_texts ( + id bigint NOT NULL, + name character varying NOT NULL, + body text, + record_type character varying NOT NULL, + record_id integer NOT NULL, + created_at timestamp(6) without time zone NOT NULL, + updated_at timestamp(6) without time zone NOT NULL +); + + +-- +-- Name: action_text_rich_texts_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.action_text_rich_texts_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: action_text_rich_texts_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.action_text_rich_texts_id_seq OWNED BY public.action_text_rich_texts.id; + + +-- +-- Name: active_storage_attachments; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.active_storage_attachments ( + id bigint NOT NULL, + name character varying NOT NULL, + record_type character varying NOT NULL, + record_id integer NOT NULL, + blob_id integer NOT NULL, + created_at timestamp without time zone NOT NULL +); + + +-- +-- Name: active_storage_attachments_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.active_storage_attachments_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: active_storage_attachments_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.active_storage_attachments_id_seq OWNED BY public.active_storage_attachments.id; + + +-- +-- Name: active_storage_blobs; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.active_storage_blobs ( + id bigint NOT NULL, + key character varying NOT NULL, + filename character varying NOT NULL, + content_type character varying, + metadata text, + byte_size bigint NOT NULL, + checksum character varying NOT NULL, + created_at timestamp without time zone NOT NULL, + service_name character varying NOT NULL +); + + +-- +-- Name: active_storage_blobs_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.active_storage_blobs_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: active_storage_blobs_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.active_storage_blobs_id_seq OWNED BY public.active_storage_blobs.id; + + +-- +-- Name: active_storage_variant_records; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.active_storage_variant_records ( + id bigint NOT NULL, + blob_id bigint NOT NULL, + variation_digest character varying NOT NULL +); + + +-- +-- Name: active_storage_variant_records_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.active_storage_variant_records_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: active_storage_variant_records_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.active_storage_variant_records_id_seq OWNED BY public.active_storage_variant_records.id; + + +-- +-- Name: ar_internal_metadata; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.ar_internal_metadata ( + key character varying NOT NULL, + value character varying, + created_at timestamp(6) without time zone NOT NULL, + updated_at timestamp(6) without time zone NOT NULL +); + + +-- +-- Name: blazer_audits; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.blazer_audits ( + id bigint NOT NULL, + user_id bigint, + query_id bigint, + statement text, + data_source character varying, + created_at timestamp without time zone +); + + +-- +-- Name: blazer_audits_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.blazer_audits_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: blazer_audits_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.blazer_audits_id_seq OWNED BY public.blazer_audits.id; + + +-- +-- Name: blazer_checks; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.blazer_checks ( + id bigint NOT NULL, + creator_id bigint, + query_id bigint, + state character varying, + schedule character varying, + emails text, + slack_channels text, + check_type character varying, + message text, + last_run_at timestamp without time zone, + created_at timestamp(6) without time zone NOT NULL, + updated_at timestamp(6) without time zone NOT NULL +); + + +-- +-- Name: blazer_checks_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.blazer_checks_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: blazer_checks_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.blazer_checks_id_seq OWNED BY public.blazer_checks.id; + + +-- +-- Name: blazer_dashboard_queries; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.blazer_dashboard_queries ( + id bigint NOT NULL, + dashboard_id bigint, + query_id bigint, + "position" integer, + created_at timestamp(6) without time zone NOT NULL, + updated_at timestamp(6) without time zone NOT NULL +); + + +-- +-- Name: blazer_dashboard_queries_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.blazer_dashboard_queries_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: blazer_dashboard_queries_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.blazer_dashboard_queries_id_seq OWNED BY public.blazer_dashboard_queries.id; + + +-- +-- Name: blazer_dashboards; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.blazer_dashboards ( + id bigint NOT NULL, + creator_id bigint, + name text, + created_at timestamp(6) without time zone NOT NULL, + updated_at timestamp(6) without time zone NOT NULL +); + + +-- +-- Name: blazer_dashboards_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.blazer_dashboards_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: blazer_dashboards_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.blazer_dashboards_id_seq OWNED BY public.blazer_dashboards.id; + + +-- +-- Name: blazer_queries; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.blazer_queries ( + id bigint NOT NULL, + creator_id bigint, + name character varying, + description text, + statement text, + data_source character varying, + created_at timestamp(6) without time zone NOT NULL, + updated_at timestamp(6) without time zone NOT NULL +); + + +-- +-- Name: blazer_queries_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.blazer_queries_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: blazer_queries_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.blazer_queries_id_seq OWNED BY public.blazer_queries.id; + + +-- +-- Name: build_stats; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.build_stats ( + id bigint NOT NULL, + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL, + deploy_id integer, + bytes bigint, + seconds double precision, + action character varying NOT NULL, + log text, + status boolean DEFAULT false +); + + +-- +-- Name: build_stats_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.build_stats_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: build_stats_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.build_stats_id_seq OWNED BY public.build_stats.id; + + +-- +-- Name: codes_of_conduct; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.codes_of_conduct ( + id bigint NOT NULL, + created_at timestamp(6) without time zone NOT NULL, + updated_at timestamp(6) without time zone NOT NULL, + title character varying, + description text, + content text +); + + +-- +-- Name: codes_of_conduct_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.codes_of_conduct_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: codes_of_conduct_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.codes_of_conduct_id_seq OWNED BY public.codes_of_conduct.id; + + +-- +-- Name: csp_reports; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.csp_reports ( + id uuid DEFAULT public.gen_random_uuid() NOT NULL, + created_at timestamp(6) without time zone NOT NULL, + updated_at timestamp(6) without time zone NOT NULL, + disposition character varying, + referrer character varying, + blocked_uri character varying, + document_uri character varying, + effective_directive character varying, + original_policy character varying, + script_sample character varying, + status_code character varying, + violated_directive character varying, + column_number integer, + line_number integer, + source_file character varying +); + + +-- +-- Name: deploys; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.deploys ( + id bigint NOT NULL, + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL, + site_id integer, + type character varying, + "values" text +); + + +-- +-- Name: deploys_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.deploys_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: deploys_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.deploys_id_seq OWNED BY public.deploys.id; + + +-- +-- Name: designs; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.designs ( + id bigint NOT NULL, + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL, + name character varying, + description text, + gem character varying, + url character varying, + license character varying, + disabled boolean DEFAULT false, + credits text, + designer_url character varying, + priority integer +); + + +-- +-- Name: designs_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.designs_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: designs_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.designs_id_seq OWNED BY public.designs.id; + + +-- +-- Name: distributed_press_publishers; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.distributed_press_publishers ( + id bigint NOT NULL, + created_at timestamp(6) without time zone NOT NULL, + updated_at timestamp(6) without time zone NOT NULL, + instance character varying, + token_ciphertext text NOT NULL, + expires_at timestamp without time zone +); + + +-- +-- Name: distributed_press_publishers_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.distributed_press_publishers_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: distributed_press_publishers_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.distributed_press_publishers_id_seq OWNED BY public.distributed_press_publishers.id; + + +-- +-- Name: indexed_posts; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.indexed_posts ( + id uuid DEFAULT public.gen_random_uuid() NOT NULL, + site_id bigint, + created_at timestamp(6) without time zone NOT NULL, + updated_at timestamp(6) without time zone NOT NULL, + locale character varying DEFAULT 'simple'::character varying, + layout character varying NOT NULL, + path character varying NOT NULL, + title character varying DEFAULT ''::character varying, + front_matter jsonb DEFAULT '"{}"'::jsonb, + content character varying DEFAULT ''::character varying, + indexed_content tsvector, + "order" integer DEFAULT 0, + dictionary character varying, + post_id uuid +); + + +-- +-- Name: licencias; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.licencias ( + id bigint NOT NULL, + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL, + name character varying, + description text, + deed text, + url character varying, + icons character varying, + short_description character varying +); + + +-- +-- Name: licencias_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.licencias_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: licencias_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.licencias_id_seq OWNED BY public.licencias.id; + + +-- +-- Name: log_entries; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.log_entries ( + id bigint NOT NULL, + created_at timestamp(6) without time zone NOT NULL, + updated_at timestamp(6) without time zone NOT NULL, + site_id bigint, + text text, + sent boolean DEFAULT false +); + + +-- +-- Name: log_entries_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.log_entries_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: log_entries_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.log_entries_id_seq OWNED BY public.log_entries.id; + + +-- +-- Name: maintenances; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.maintenances ( + id bigint NOT NULL, + created_at timestamp(6) without time zone NOT NULL, + updated_at timestamp(6) without time zone NOT NULL, + message text, + estimated_from timestamp without time zone, + estimated_to timestamp without time zone, + are_we_back boolean DEFAULT false +); + + +-- +-- Name: maintenances_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.maintenances_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: maintenances_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.maintenances_id_seq OWNED BY public.maintenances.id; + + +-- +-- Name: mobility_string_translations; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.mobility_string_translations ( + id bigint NOT NULL, + locale character varying NOT NULL, + key character varying NOT NULL, + value character varying, + translatable_type character varying, + translatable_id integer, + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL +); + + +-- +-- Name: mobility_string_translations_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.mobility_string_translations_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: mobility_string_translations_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.mobility_string_translations_id_seq OWNED BY public.mobility_string_translations.id; + + +-- +-- Name: mobility_text_translations; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.mobility_text_translations ( + id bigint NOT NULL, + locale character varying NOT NULL, + key character varying NOT NULL, + value text, + translatable_type character varying, + translatable_id integer, + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL +); + + +-- +-- Name: mobility_text_translations_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.mobility_text_translations_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: mobility_text_translations_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.mobility_text_translations_id_seq OWNED BY public.mobility_text_translations.id; + + +-- +-- Name: privacy_policies; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.privacy_policies ( + id bigint NOT NULL, + created_at timestamp(6) without time zone NOT NULL, + updated_at timestamp(6) without time zone NOT NULL, + title character varying, + description text, + content text +); + + +-- +-- Name: privacy_policies_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.privacy_policies_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: privacy_policies_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.privacy_policies_id_seq OWNED BY public.privacy_policies.id; + + +-- +-- Name: que_jobs_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.que_jobs_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: que_jobs_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.que_jobs_id_seq OWNED BY public.que_jobs.id; + + +-- +-- Name: que_lockers; Type: TABLE; Schema: public; Owner: - +-- + +CREATE UNLOGGED TABLE public.que_lockers ( + pid integer NOT NULL, + worker_count integer NOT NULL, + worker_priorities integer[] NOT NULL, + ruby_pid integer NOT NULL, + ruby_hostname text NOT NULL, + queues text[] NOT NULL, + listening boolean NOT NULL, + job_schema_version integer DEFAULT 1, + CONSTRAINT valid_queues CHECK (((array_ndims(queues) = 1) AND (array_length(queues, 1) IS NOT NULL))), + CONSTRAINT valid_worker_priorities CHECK (((array_ndims(worker_priorities) = 1) AND (array_length(worker_priorities, 1) IS NOT NULL))) +); + + +-- +-- Name: que_values; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.que_values ( + key text NOT NULL, + value jsonb DEFAULT '{}'::jsonb NOT NULL, + CONSTRAINT valid_value CHECK ((jsonb_typeof(value) = 'object'::text)) +) +WITH (fillfactor='90'); + + +-- +-- Name: roles; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.roles ( + id bigint NOT NULL, + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL, + site_id integer, + usuarie_id integer, + rol character varying, + temporal boolean +); + + +-- +-- Name: roles_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.roles_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: roles_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.roles_id_seq OWNED BY public.roles.id; + + +-- +-- Name: rollups; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.rollups ( + id bigint NOT NULL, + name character varying NOT NULL, + "interval" character varying NOT NULL, + "time" timestamp without time zone NOT NULL, + dimensions jsonb DEFAULT '{}'::jsonb NOT NULL, + value double precision +); + + +-- +-- Name: rollups_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.rollups_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: rollups_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.rollups_id_seq OWNED BY public.rollups.id; + + +-- +-- Name: schema_migrations; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.schema_migrations ( + version character varying NOT NULL +); + + +-- +-- Name: sites; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.sites ( + id bigint NOT NULL, + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL, + name character varying, + design_id integer, + licencia_id integer, + status character varying DEFAULT 'waiting'::character varying, + description text, + title character varying, + colaboracion_anonima boolean DEFAULT false, + contact boolean DEFAULT false, + private_key_ciphertext character varying, + acepta_invitades boolean DEFAULT false, + tienda_api_key_ciphertext character varying DEFAULT ''::character varying, + tienda_url character varying DEFAULT ''::character varying, + api_key_ciphertext character varying, + slugify_mode character varying DEFAULT 'default'::character varying +); + + +-- +-- Name: sites_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.sites_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: sites_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.sites_id_seq OWNED BY public.sites.id; + + +-- +-- Name: stats; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.stats ( + id bigint NOT NULL, + created_at timestamp(6) without time zone NOT NULL, + updated_at timestamp(6) without time zone NOT NULL, + site_id bigint, + name character varying NOT NULL +); + + +-- +-- Name: stats_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.stats_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: stats_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.stats_id_seq OWNED BY public.stats.id; + + +-- +-- Name: usuaries; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.usuaries ( + id bigint NOT NULL, + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL, + email character varying DEFAULT ''::character varying NOT NULL, + encrypted_password character varying DEFAULT ''::character varying NOT NULL, + reset_password_token character varying, + reset_password_sent_at timestamp without time zone, + remember_created_at timestamp without time zone, + confirmation_token character varying, + confirmed_at timestamp without time zone, + confirmation_sent_at timestamp without time zone, + unconfirmed_email character varying, + failed_attempts integer DEFAULT 0 NOT NULL, + unlock_token character varying, + locked_at timestamp without time zone, + invitation_token character varying, + invitation_created_at timestamp without time zone, + invitation_sent_at timestamp without time zone, + invitation_accepted_at timestamp without time zone, + invitation_limit integer, + invited_by_type character varying, + invited_by_id integer, + invitations_count integer DEFAULT 0, + lang character varying DEFAULT 'es'::character varying, + privacy_policy_accepted_at timestamp without time zone, + terms_of_service_accepted_at timestamp without time zone, + code_of_conduct_accepted_at timestamp without time zone, + available_for_feedback_accepted_at timestamp without time zone +); + + +-- +-- Name: usuaries_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.usuaries_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: usuaries_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.usuaries_id_seq OWNED BY public.usuaries.id; + + +-- +-- Name: action_text_rich_texts id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.action_text_rich_texts ALTER COLUMN id SET DEFAULT nextval('public.action_text_rich_texts_id_seq'::regclass); + + +-- +-- Name: active_storage_attachments id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.active_storage_attachments ALTER COLUMN id SET DEFAULT nextval('public.active_storage_attachments_id_seq'::regclass); + + +-- +-- Name: active_storage_blobs id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.active_storage_blobs ALTER COLUMN id SET DEFAULT nextval('public.active_storage_blobs_id_seq'::regclass); + + +-- +-- Name: active_storage_variant_records id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.active_storage_variant_records ALTER COLUMN id SET DEFAULT nextval('public.active_storage_variant_records_id_seq'::regclass); + + +-- +-- Name: blazer_audits id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.blazer_audits ALTER COLUMN id SET DEFAULT nextval('public.blazer_audits_id_seq'::regclass); + + +-- +-- Name: blazer_checks id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.blazer_checks ALTER COLUMN id SET DEFAULT nextval('public.blazer_checks_id_seq'::regclass); + + +-- +-- Name: blazer_dashboard_queries id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.blazer_dashboard_queries ALTER COLUMN id SET DEFAULT nextval('public.blazer_dashboard_queries_id_seq'::regclass); + + +-- +-- Name: blazer_dashboards id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.blazer_dashboards ALTER COLUMN id SET DEFAULT nextval('public.blazer_dashboards_id_seq'::regclass); + + +-- +-- Name: blazer_queries id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.blazer_queries ALTER COLUMN id SET DEFAULT nextval('public.blazer_queries_id_seq'::regclass); + + +-- +-- Name: build_stats id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.build_stats ALTER COLUMN id SET DEFAULT nextval('public.build_stats_id_seq'::regclass); + + +-- +-- Name: codes_of_conduct id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.codes_of_conduct ALTER COLUMN id SET DEFAULT nextval('public.codes_of_conduct_id_seq'::regclass); + + +-- +-- Name: deploys id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.deploys ALTER COLUMN id SET DEFAULT nextval('public.deploys_id_seq'::regclass); + + +-- +-- Name: designs id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.designs ALTER COLUMN id SET DEFAULT nextval('public.designs_id_seq'::regclass); + + +-- +-- Name: distributed_press_publishers id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.distributed_press_publishers ALTER COLUMN id SET DEFAULT nextval('public.distributed_press_publishers_id_seq'::regclass); + + +-- +-- Name: licencias id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.licencias ALTER COLUMN id SET DEFAULT nextval('public.licencias_id_seq'::regclass); + + +-- +-- Name: log_entries id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.log_entries ALTER COLUMN id SET DEFAULT nextval('public.log_entries_id_seq'::regclass); + + +-- +-- Name: maintenances id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.maintenances ALTER COLUMN id SET DEFAULT nextval('public.maintenances_id_seq'::regclass); + + +-- +-- Name: mobility_string_translations id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.mobility_string_translations ALTER COLUMN id SET DEFAULT nextval('public.mobility_string_translations_id_seq'::regclass); + + +-- +-- Name: mobility_text_translations id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.mobility_text_translations ALTER COLUMN id SET DEFAULT nextval('public.mobility_text_translations_id_seq'::regclass); + + +-- +-- Name: privacy_policies id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.privacy_policies ALTER COLUMN id SET DEFAULT nextval('public.privacy_policies_id_seq'::regclass); + + +-- +-- Name: que_jobs id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.que_jobs ALTER COLUMN id SET DEFAULT nextval('public.que_jobs_id_seq'::regclass); + + +-- +-- Name: roles id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.roles ALTER COLUMN id SET DEFAULT nextval('public.roles_id_seq'::regclass); + + +-- +-- Name: rollups id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.rollups ALTER COLUMN id SET DEFAULT nextval('public.rollups_id_seq'::regclass); + + +-- +-- Name: sites id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.sites ALTER COLUMN id SET DEFAULT nextval('public.sites_id_seq'::regclass); + + +-- +-- Name: stats id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.stats ALTER COLUMN id SET DEFAULT nextval('public.stats_id_seq'::regclass); + + +-- +-- Name: usuaries id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.usuaries ALTER COLUMN id SET DEFAULT nextval('public.usuaries_id_seq'::regclass); + + +-- +-- Name: access_logs access_logs_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.access_logs + ADD CONSTRAINT access_logs_pkey PRIMARY KEY (id); + + +-- +-- Name: action_text_rich_texts action_text_rich_texts_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.action_text_rich_texts + ADD CONSTRAINT action_text_rich_texts_pkey PRIMARY KEY (id); + + +-- +-- Name: active_storage_attachments active_storage_attachments_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.active_storage_attachments + ADD CONSTRAINT active_storage_attachments_pkey PRIMARY KEY (id); + + +-- +-- Name: active_storage_blobs active_storage_blobs_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.active_storage_blobs + ADD CONSTRAINT active_storage_blobs_pkey PRIMARY KEY (id); + + +-- +-- Name: active_storage_variant_records active_storage_variant_records_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.active_storage_variant_records + ADD CONSTRAINT active_storage_variant_records_pkey PRIMARY KEY (id); + + +-- +-- Name: blazer_audits blazer_audits_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.blazer_audits + ADD CONSTRAINT blazer_audits_pkey PRIMARY KEY (id); + + +-- +-- Name: blazer_checks blazer_checks_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.blazer_checks + ADD CONSTRAINT blazer_checks_pkey PRIMARY KEY (id); + + +-- +-- Name: blazer_dashboard_queries blazer_dashboard_queries_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.blazer_dashboard_queries + ADD CONSTRAINT blazer_dashboard_queries_pkey PRIMARY KEY (id); + + +-- +-- Name: blazer_dashboards blazer_dashboards_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.blazer_dashboards + ADD CONSTRAINT blazer_dashboards_pkey PRIMARY KEY (id); + + +-- +-- Name: blazer_queries blazer_queries_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.blazer_queries + ADD CONSTRAINT blazer_queries_pkey PRIMARY KEY (id); + + +-- +-- Name: build_stats build_stats_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.build_stats + ADD CONSTRAINT build_stats_pkey PRIMARY KEY (id); + + +-- +-- Name: codes_of_conduct codes_of_conduct_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.codes_of_conduct + ADD CONSTRAINT codes_of_conduct_pkey PRIMARY KEY (id); + + +-- +-- Name: csp_reports csp_reports_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.csp_reports + ADD CONSTRAINT csp_reports_pkey PRIMARY KEY (id); + + +-- +-- Name: deploys deploys_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.deploys + ADD CONSTRAINT deploys_pkey PRIMARY KEY (id); + + +-- +-- Name: designs designs_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.designs + ADD CONSTRAINT designs_pkey PRIMARY KEY (id); + + +-- +-- Name: distributed_press_publishers distributed_press_publishers_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.distributed_press_publishers + ADD CONSTRAINT distributed_press_publishers_pkey PRIMARY KEY (id); + + +-- +-- Name: indexed_posts indexed_posts_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.indexed_posts + ADD CONSTRAINT indexed_posts_pkey PRIMARY KEY (id); + + +-- +-- Name: licencias licencias_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.licencias + ADD CONSTRAINT licencias_pkey PRIMARY KEY (id); + + +-- +-- Name: log_entries log_entries_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.log_entries + ADD CONSTRAINT log_entries_pkey PRIMARY KEY (id); + + +-- +-- Name: maintenances maintenances_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.maintenances + ADD CONSTRAINT maintenances_pkey PRIMARY KEY (id); + + +-- +-- Name: mobility_string_translations mobility_string_translations_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.mobility_string_translations + ADD CONSTRAINT mobility_string_translations_pkey PRIMARY KEY (id); + + +-- +-- Name: mobility_text_translations mobility_text_translations_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.mobility_text_translations + ADD CONSTRAINT mobility_text_translations_pkey PRIMARY KEY (id); + + +-- +-- Name: privacy_policies privacy_policies_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.privacy_policies + ADD CONSTRAINT privacy_policies_pkey PRIMARY KEY (id); + + +-- +-- Name: que_jobs que_jobs_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.que_jobs + ADD CONSTRAINT que_jobs_pkey PRIMARY KEY (id); + + +-- +-- Name: que_lockers que_lockers_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.que_lockers + ADD CONSTRAINT que_lockers_pkey PRIMARY KEY (pid); + + +-- +-- Name: que_values que_values_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.que_values + ADD CONSTRAINT que_values_pkey PRIMARY KEY (key); + + +-- +-- Name: roles roles_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.roles + ADD CONSTRAINT roles_pkey PRIMARY KEY (id); + + +-- +-- Name: rollups rollups_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.rollups + ADD CONSTRAINT rollups_pkey PRIMARY KEY (id); + + +-- +-- Name: schema_migrations schema_migrations_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.schema_migrations + ADD CONSTRAINT schema_migrations_pkey PRIMARY KEY (version); + + +-- +-- Name: sites sites_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.sites + ADD CONSTRAINT sites_pkey PRIMARY KEY (id); + + +-- +-- Name: stats stats_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.stats + ADD CONSTRAINT stats_pkey PRIMARY KEY (id); + + +-- +-- Name: usuaries usuaries_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.usuaries + ADD CONSTRAINT usuaries_pkey PRIMARY KEY (id); + + +-- +-- Name: index_access_logs_on_geoip2_data_city_name; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_access_logs_on_geoip2_data_city_name ON public.access_logs USING btree (geoip2_data_city_name); + + +-- +-- Name: index_access_logs_on_geoip2_data_country_name; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_access_logs_on_geoip2_data_country_name ON public.access_logs USING btree (geoip2_data_country_name); + + +-- +-- Name: index_access_logs_on_host; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_access_logs_on_host ON public.access_logs USING btree (host); + + +-- +-- Name: index_access_logs_on_http_origin; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_access_logs_on_http_origin ON public.access_logs USING btree (http_origin); + + +-- +-- Name: index_access_logs_on_http_user_agent; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_access_logs_on_http_user_agent ON public.access_logs USING btree (http_user_agent); + + +-- +-- Name: index_access_logs_on_status; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_access_logs_on_status ON public.access_logs USING btree (status); + + +-- +-- Name: index_access_logs_on_uri; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_access_logs_on_uri ON public.access_logs USING btree (uri); + + +-- +-- Name: index_action_text_rich_texts_uniqueness; Type: INDEX; Schema: public; Owner: - +-- + +CREATE UNIQUE INDEX index_action_text_rich_texts_uniqueness ON public.action_text_rich_texts USING btree (record_type, record_id, name); + + +-- +-- Name: index_active_storage_attachments_on_blob_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_active_storage_attachments_on_blob_id ON public.active_storage_attachments USING btree (blob_id); + + +-- +-- Name: index_active_storage_attachments_uniqueness; Type: INDEX; Schema: public; Owner: - +-- + +CREATE UNIQUE INDEX index_active_storage_attachments_uniqueness ON public.active_storage_attachments USING btree (record_type, record_id, name, blob_id); + + +-- +-- Name: index_active_storage_blobs_on_key_and_service_name; Type: INDEX; Schema: public; Owner: - +-- + +CREATE UNIQUE INDEX index_active_storage_blobs_on_key_and_service_name ON public.active_storage_blobs USING btree (key, service_name); + + +-- +-- Name: index_active_storage_variant_records_uniqueness; Type: INDEX; Schema: public; Owner: - +-- + +CREATE UNIQUE INDEX index_active_storage_variant_records_uniqueness ON public.active_storage_variant_records USING btree (blob_id, variation_digest); + + +-- +-- Name: index_blazer_audits_on_query_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_blazer_audits_on_query_id ON public.blazer_audits USING btree (query_id); + + +-- +-- Name: index_blazer_audits_on_user_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_blazer_audits_on_user_id ON public.blazer_audits USING btree (user_id); + + +-- +-- Name: index_blazer_checks_on_creator_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_blazer_checks_on_creator_id ON public.blazer_checks USING btree (creator_id); + + +-- +-- Name: index_blazer_checks_on_query_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_blazer_checks_on_query_id ON public.blazer_checks USING btree (query_id); + + +-- +-- Name: index_blazer_dashboard_queries_on_dashboard_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_blazer_dashboard_queries_on_dashboard_id ON public.blazer_dashboard_queries USING btree (dashboard_id); + + +-- +-- Name: index_blazer_dashboard_queries_on_query_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_blazer_dashboard_queries_on_query_id ON public.blazer_dashboard_queries USING btree (query_id); + + +-- +-- Name: index_blazer_dashboards_on_creator_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_blazer_dashboards_on_creator_id ON public.blazer_dashboards USING btree (creator_id); + + +-- +-- Name: index_blazer_queries_on_creator_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_blazer_queries_on_creator_id ON public.blazer_queries USING btree (creator_id); + + +-- +-- Name: index_build_stats_on_deploy_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_build_stats_on_deploy_id ON public.build_stats USING btree (deploy_id); + + +-- +-- Name: index_deploys_on_site_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_deploys_on_site_id ON public.deploys USING btree (site_id); + + +-- +-- Name: index_deploys_on_type; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_deploys_on_type ON public.deploys USING btree (type); + + +-- +-- Name: index_designs_on_gem; Type: INDEX; Schema: public; Owner: - +-- + +CREATE UNIQUE INDEX index_designs_on_gem ON public.designs USING btree (gem); + + +-- +-- Name: index_designs_on_name; Type: INDEX; Schema: public; Owner: - +-- + +CREATE UNIQUE INDEX index_designs_on_name ON public.designs USING btree (name); + + +-- +-- Name: index_indexed_posts_on_front_matter; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_indexed_posts_on_front_matter ON public.indexed_posts USING gin (front_matter); + + +-- +-- Name: index_indexed_posts_on_indexed_content; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_indexed_posts_on_indexed_content ON public.indexed_posts USING gin (indexed_content); + + +-- +-- Name: index_indexed_posts_on_layout; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_indexed_posts_on_layout ON public.indexed_posts USING btree (layout); + + +-- +-- Name: index_indexed_posts_on_locale; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_indexed_posts_on_locale ON public.indexed_posts USING btree (locale); + + +-- +-- Name: index_indexed_posts_on_site_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_indexed_posts_on_site_id ON public.indexed_posts USING btree (site_id); + + +-- +-- Name: index_licencias_on_name; Type: INDEX; Schema: public; Owner: - +-- + +CREATE UNIQUE INDEX index_licencias_on_name ON public.licencias USING btree (name); + + +-- +-- Name: index_log_entries_on_site_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_log_entries_on_site_id ON public.log_entries USING btree (site_id); + + +-- +-- Name: index_mobility_string_translations_on_keys; Type: INDEX; Schema: public; Owner: - +-- + +CREATE UNIQUE INDEX index_mobility_string_translations_on_keys ON public.mobility_string_translations USING btree (translatable_id, translatable_type, locale, key); + + +-- +-- Name: index_mobility_string_translations_on_query_keys; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_mobility_string_translations_on_query_keys ON public.mobility_string_translations USING btree (translatable_type, key, value, locale); + + +-- +-- Name: index_mobility_string_translations_on_translatable_attribute; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_mobility_string_translations_on_translatable_attribute ON public.mobility_string_translations USING btree (translatable_id, translatable_type, key); + + +-- +-- Name: index_mobility_text_translations_on_keys; Type: INDEX; Schema: public; Owner: - +-- + +CREATE UNIQUE INDEX index_mobility_text_translations_on_keys ON public.mobility_text_translations USING btree (translatable_id, translatable_type, locale, key); + + +-- +-- Name: index_mobility_text_translations_on_translatable_attribute; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_mobility_text_translations_on_translatable_attribute ON public.mobility_text_translations USING btree (translatable_id, translatable_type, key); + + +-- +-- Name: index_roles_on_site_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_roles_on_site_id ON public.roles USING btree (site_id); + + +-- +-- Name: index_roles_on_site_id_and_usuarie_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE UNIQUE INDEX index_roles_on_site_id_and_usuarie_id ON public.roles USING btree (site_id, usuarie_id); + + +-- +-- Name: index_roles_on_usuarie_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_roles_on_usuarie_id ON public.roles USING btree (usuarie_id); + + +-- +-- Name: index_rollups_on_name_and_interval_and_time_and_dimensions; Type: INDEX; Schema: public; Owner: - +-- + +CREATE UNIQUE INDEX index_rollups_on_name_and_interval_and_time_and_dimensions ON public.rollups USING btree (name, "interval", "time", dimensions); + + +-- +-- Name: index_sites_on_design_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_sites_on_design_id ON public.sites USING btree (design_id); + + +-- +-- Name: index_sites_on_licencia_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_sites_on_licencia_id ON public.sites USING btree (licencia_id); + + +-- +-- Name: index_sites_on_name; Type: INDEX; Schema: public; Owner: - +-- + +CREATE UNIQUE INDEX index_sites_on_name ON public.sites USING btree (name); + + +-- +-- Name: index_stats_on_name; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_stats_on_name ON public.stats USING hash (name); + + +-- +-- Name: index_stats_on_site_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_stats_on_site_id ON public.stats USING btree (site_id); + + +-- +-- Name: index_usuaries_on_confirmation_token; Type: INDEX; Schema: public; Owner: - +-- + +CREATE UNIQUE INDEX index_usuaries_on_confirmation_token ON public.usuaries USING btree (confirmation_token); + + +-- +-- Name: index_usuaries_on_email; Type: INDEX; Schema: public; Owner: - +-- + +CREATE UNIQUE INDEX index_usuaries_on_email ON public.usuaries USING btree (email); + + +-- +-- Name: index_usuaries_on_invitation_token; Type: INDEX; Schema: public; Owner: - +-- + +CREATE UNIQUE INDEX index_usuaries_on_invitation_token ON public.usuaries USING btree (invitation_token); + + +-- +-- Name: index_usuaries_on_invitations_count; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_usuaries_on_invitations_count ON public.usuaries USING btree (invitations_count); + + +-- +-- Name: index_usuaries_on_invited_by_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_usuaries_on_invited_by_id ON public.usuaries USING btree (invited_by_id); + + +-- +-- Name: index_usuaries_on_invited_by_type_and_invited_by_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_usuaries_on_invited_by_type_and_invited_by_id ON public.usuaries USING btree (invited_by_type, invited_by_id); + + +-- +-- Name: index_usuaries_on_reset_password_token; Type: INDEX; Schema: public; Owner: - +-- + +CREATE UNIQUE INDEX index_usuaries_on_reset_password_token ON public.usuaries USING btree (reset_password_token); + + +-- +-- Name: index_usuaries_on_unlock_token; Type: INDEX; Schema: public; Owner: - +-- + +CREATE UNIQUE INDEX index_usuaries_on_unlock_token ON public.usuaries USING btree (unlock_token); + + +-- +-- Name: que_jobs_args_gin_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX que_jobs_args_gin_idx ON public.que_jobs USING gin (args jsonb_path_ops); + + +-- +-- Name: que_jobs_data_gin_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX que_jobs_data_gin_idx ON public.que_jobs USING gin (data jsonb_path_ops); + + +-- +-- Name: que_jobs_kwargs_gin_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX que_jobs_kwargs_gin_idx ON public.que_jobs USING gin (kwargs jsonb_path_ops); + + +-- +-- Name: que_poll_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX que_poll_idx ON public.que_jobs USING btree (job_schema_version, queue, priority, run_at, id) WHERE ((finished_at IS NULL) AND (expired_at IS NULL)); + + +-- +-- Name: access_logs access_logs_before_insert_row_tr; Type: TRIGGER; Schema: public; Owner: - +-- + +CREATE TRIGGER access_logs_before_insert_row_tr BEFORE INSERT ON public.access_logs FOR EACH ROW EXECUTE FUNCTION public.access_logs_before_insert_row_tr(); + + +-- +-- Name: indexed_posts indexed_posts_before_insert_update_row_tr; Type: TRIGGER; Schema: public; Owner: - +-- + +CREATE TRIGGER indexed_posts_before_insert_update_row_tr BEFORE INSERT OR UPDATE ON public.indexed_posts FOR EACH ROW EXECUTE FUNCTION public.indexed_posts_before_insert_update_row_tr(); + + +-- +-- Name: que_jobs que_job_notify; Type: TRIGGER; Schema: public; Owner: - +-- + +CREATE TRIGGER que_job_notify AFTER INSERT ON public.que_jobs FOR EACH ROW WHEN ((NOT (COALESCE(current_setting('que.skip_notify'::text, true), ''::text) = 'true'::text))) EXECUTE FUNCTION public.que_job_notify(); + + +-- +-- Name: que_jobs que_state_notify; Type: TRIGGER; Schema: public; Owner: - +-- + +CREATE TRIGGER que_state_notify AFTER INSERT OR DELETE OR UPDATE ON public.que_jobs FOR EACH ROW WHEN ((NOT (COALESCE(current_setting('que.skip_notify'::text, true), ''::text) = 'true'::text))) EXECUTE FUNCTION public.que_state_notify(); + + +-- +-- Name: active_storage_variant_records fk_rails_993965df05; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.active_storage_variant_records + ADD CONSTRAINT fk_rails_993965df05 FOREIGN KEY (blob_id) REFERENCES public.active_storage_blobs(id); + + +-- +-- Name: active_storage_attachments fk_rails_c3b3935057; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.active_storage_attachments + ADD CONSTRAINT fk_rails_c3b3935057 FOREIGN KEY (blob_id) REFERENCES public.active_storage_blobs(id); + + +-- +-- Name: publisher; Type: PUBLICATION; Schema: -; Owner: - +-- + +CREATE PUBLICATION publisher FOR ALL TABLES WITH (publish = 'insert, update, delete, truncate'); + + +-- +-- PostgreSQL database dump complete +-- + From 707695f97d935f2ddc6e006233e993f623690c6a Mon Sep 17 00:00:00 2001 From: f Date: Wed, 24 May 2023 15:52:41 -0300 Subject: [PATCH 022/130] =?UTF-8?q?fix:=20la=20replicaci=C3=B3n=20la=20con?= =?UTF-8?q?figuramos=20en=20otro=20lado?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/structure.sql | 7 ------- 1 file changed, 7 deletions(-) diff --git a/db/structure.sql b/db/structure.sql index e50ae337..ab92db9a 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -2254,13 +2254,6 @@ ALTER TABLE ONLY public.active_storage_attachments ADD CONSTRAINT fk_rails_c3b3935057 FOREIGN KEY (blob_id) REFERENCES public.active_storage_blobs(id); --- --- Name: publisher; Type: PUBLICATION; Schema: -; Owner: - --- - -CREATE PUBLICATION publisher FOR ALL TABLES WITH (publish = 'insert, update, delete, truncate'); - - -- -- PostgreSQL database dump complete -- From 11d0431b3455e827b6f19f065ec402286a1a50ca Mon Sep 17 00:00:00 2001 From: f Date: Wed, 24 May 2023 15:53:01 -0300 Subject: [PATCH 023/130] =?UTF-8?q?fix:=20dblink=20no=20es=20una=20extensi?= =?UTF-8?q?=C3=B3n=20que=20usemos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/structure.sql | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/db/structure.sql b/db/structure.sql index ab92db9a..97aec2d1 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -23,20 +23,6 @@ SET row_security = off; -- *not* creating schema, since initdb creates it --- --- Name: dblink; Type: EXTENSION; Schema: -; Owner: - --- - -CREATE EXTENSION IF NOT EXISTS dblink WITH SCHEMA public; - - --- --- Name: EXTENSION dblink; Type: COMMENT; Schema: -; Owner: - --- - -COMMENT ON EXTENSION dblink IS 'connect to other PostgreSQL databases from within a database'; - - -- -- Name: pg_trgm; Type: EXTENSION; Schema: -; Owner: - -- From eba42c9b7914aeaae04d9c155eee5a1185f2c99a Mon Sep 17 00:00:00 2001 From: f Date: Wed, 24 May 2023 16:52:29 -0300 Subject: [PATCH 024/130] fix: hacer el dump desde rails --- db/structure.sql | 93 +++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 85 insertions(+), 8 deletions(-) diff --git a/db/structure.sql b/db/structure.sql index 97aec2d1..e0d8f710 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -1,10 +1,3 @@ --- --- PostgreSQL database dump --- - --- Dumped from database version 15.2 --- Dumped by pg_dump version 15.2 - SET statement_timeout = 0; SET lock_timeout = 0; SET idle_in_transaction_session_timeout = 0; @@ -1242,7 +1235,8 @@ CREATE TABLE public.sites ( tienda_api_key_ciphertext character varying DEFAULT ''::character varying, tienda_url character varying DEFAULT ''::character varying, api_key_ciphertext character varying, - slugify_mode character varying DEFAULT 'default'::character varying + slugify_mode character varying DEFAULT 'default'::character varying, + pagination boolean DEFAULT false ); @@ -2244,3 +2238,86 @@ ALTER TABLE ONLY public.active_storage_attachments -- PostgreSQL database dump complete -- +SET search_path TO "$user", public; + +INSERT INTO "schema_migrations" (version) VALUES +('20180925183241'), +('20190211184815'), +('20190703190859'), +('20190703200455'), +('20190705195758'), +('20190705215536'), +('20190706000159'), +('20190706002615'), +('20190711183726'), +('20190712165059'), +('20190716195155'), +('20190716195449'), +('20190716195811'), +('20190716195812'), +('20190716202024'), +('20190717214308'), +('20190718185817'), +('20190719221653'), +('20190723220002'), +('20190725185427'), +('20190726003756'), +('20190730211624'), +('20190730211756'), +('20190820225238'), +('20190829163530'), +('20190829180743'), +('20200118155319'), +('20200126175158'), +('20200130193655'), +('20200205173039'), +('20200206151057'), +('20200206163257'), +('20200527221900'), +('20200529154040'), +('20200615171026'), +('20200616133218'), +('20200801230101'), +('20200801233025'), +('20200810230944'), +('20200811210507'), +('20200816003344'), +('20200820165316'), +('20200822204920'), +('20201111203031'), +('20201207152354'), +('20201224162153'), +('20201224162154'), +('20210414152728'), +('20210504224144'), +('20210504224343'), +('20210506212356'), +('20210507221120'), +('20210511211357'), +('20210722191718'), +('20210807003928'), +('20210807004941'), +('20210926205448'), +('20211008201239'), +('20211022224008'), +('20211022225449'), +('20220406211042'), +('20220428135113'), +('20220712135053'), +('20220802153308'), +('20230119165420'), +('20230318183722'), +('20230322214924'), +('20230322231344'), +('20230325163802'), +('20230328200129'), +('20230328213242'), +('20230328231029'), +('20230411185406'), +('20230415153231'), +('20230421182627'), +('20230424174544'), +('20230519143500'), +('20230524190240'); + + From 8d7d1c10b18cd4725f994c9f5900517947f3f9d3 Mon Sep 17 00:00:00 2001 From: f Date: Thu, 15 Jun 2023 12:04:44 -0300 Subject: [PATCH 025/130] fix: indexar posts luego de crear el sitio #13610 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit se producía una condición donde el sitio se quería indexar sin haber terminado de instalar las gemas y todo fallaba. no tenemos que usar más callbacks, solo servicios --- app/models/site/index.rb | 2 -- app/services/site_service.rb | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/app/models/site/index.rb b/app/models/site/index.rb index e11095e3..c2c55ade 100644 --- a/app/models/site/index.rb +++ b/app/models/site/index.rb @@ -8,8 +8,6 @@ class Site extend ActiveSupport::Concern included do - # TODO: Debería ser un Job? - after_create :index_posts! has_many :indexed_posts, dependent: :destroy def index_posts! diff --git a/app/services/site_service.rb b/app/services/site_service.rb index 2c29538c..367d3b08 100644 --- a/app/services/site_service.rb +++ b/app/services/site_service.rb @@ -33,6 +33,7 @@ SiteService = Struct.new(:site, :usuarie, :params, keyword_init: true) do add_licencias && add_code_of_conduct && add_privacy_policy && + site.index_posts! && deploy end From 6e4247206719c8330f6229139df17858e8de734c Mon Sep 17 00:00:00 2001 From: f Date: Thu, 15 Jun 2023 13:33:25 -0300 Subject: [PATCH 026/130] =?UTF-8?q?fix:=20darle=20bola=20a=20los=20mensaje?= =?UTF-8?q?s=20de=20deprecaci=C3=B3n=20de=20bundler=20#13610?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit se configuraban las opciones que le pasábamos pero no se aplicaban en el comando actual, con lo que quería instalar las gemas globalmente y fallaba la creación de sitios. --- app/models/deploy_local.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/models/deploy_local.rb b/app/models/deploy_local.rb index 75ea8b1c..ed5f1919 100644 --- a/app/models/deploy_local.rb +++ b/app/models/deploy_local.rb @@ -138,7 +138,12 @@ class DeployLocal < Deploy end def bundle(output: false) - run %(bundle install --deployment --no-cache --path="#{gems_dir}" --clean --without test development), output: output + run %(bundle config set --local clean 'true'), output: output + run %(bundle config set --local deployment 'true'), output: output + run %(bundle config set --local path '#{gems_dir}'), output: output + run %(bundle config set --local without 'test development'), output: output + run %(bundle config set --local cache_all 'false'), output: output + run %(bundle install), output: output end def jekyll_build(output: false) From d17db5428abb9df95ddf32bf8cdbd7189a60fec5 Mon Sep 17 00:00:00 2001 From: f Date: Thu, 15 Jun 2023 18:28:34 -0300 Subject: [PATCH 027/130] fix: deprecar Dir#chdir #13619 --- app/models/deploy.rb | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/app/models/deploy.rb b/app/models/deploy.rb index a92708c0..515a8530 100644 --- a/app/models/deploy.rb +++ b/app/models/deploy.rb @@ -65,22 +65,20 @@ class Deploy < ApplicationRecord lines = [] time_start - Dir.chdir(site.path) do - Open3.popen2e(env, cmd, unsetenv_others: true) do |_, o, t| - # TODO: Enviar a un websocket para ver el proceso en vivo? - Thread.new do - o.each do |line| - lines << line + Open3.popen2e(env, cmd, unsetenv_others: true, chdir: site.path) do |_, o, t| + # TODO: Enviar a un websocket para ver el proceso en vivo? + Thread.new do + o.each do |line| + lines << line - puts line if output - end - rescue IOError => e - lines << e.message - puts e.message if output + puts line if output end - - r = t.value + rescue IOError => e + lines << e.message + puts e.message if output end + + r = t.value end time_stop From 6d64fa144392d0b011ca56ec677f99f095857a27 Mon Sep 17 00:00:00 2001 From: f Date: Thu, 15 Jun 2023 18:51:16 -0300 Subject: [PATCH 028/130] fix: generar un registro cuando falla distributed press #13628 --- app/models/deploy_distributed_press.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/models/deploy_distributed_press.rb b/app/models/deploy_distributed_press.rb index 889d8e34..2c892b55 100644 --- a/app/models/deploy_distributed_press.rb +++ b/app/models/deploy_distributed_press.rb @@ -52,7 +52,12 @@ class DeployDistributedPress < Deploy end end - status = c.publish(publishing_site, deploy_local.destination) + begin + status = c.publish(publishing_site, deploy_local.destination) + rescue DistributedPress::V1::Error => e + ExceptionNotifier.notify_exception(e, data: { site: site.name }) + status = false + end if status self.remote_info[:distributed_press] = c.show(publishing_site).to_h From bb7487e941f86fb74a3be4dbc7383ebd5384c721 Mon Sep 17 00:00:00 2001 From: f Date: Thu, 6 Jul 2023 12:43:28 -0300 Subject: [PATCH 029/130] fix: correr chdir de a uno por thread MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit como jekyll no es multi-threaded, pero rails si, es posible que se produzca una excepción en Dir.chdir si se intenta leer sitios concurrentemente (por ejemplo, abrir dos pestañas del mismo sitio). closes #13717 closes #13716 closes #13715 closes #13619 --- app/models/site.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/models/site.rb b/app/models/site.rb index 24644b9c..81264a24 100644 --- a/app/models/site.rb +++ b/app/models/site.rb @@ -447,6 +447,10 @@ class Site < ApplicationRecord find_by(name: "#{Site.domain}.") end + def self.one_at_a_time + @@one_at_a_time ||= Thread::Mutex.new + end + def reset @read = false @layouts = nil @@ -553,7 +557,9 @@ class Site < ApplicationRecord end def run_in_path(&block) - Dir.chdir path, &block + Site.one_at_a_time.synchronize do + Dir.chdir path, &block + end end # Instala las gemas cuando es necesario: From 42b6744f81c8b3399893fba9cf561ef6f96b2b4b Mon Sep 17 00:00:00 2001 From: jazzari Date: Tue, 18 Jul 2023 15:47:26 -0300 Subject: [PATCH 030/130] feat: Job para hacer push #12919 --- app/jobs/git_push_job.rb | 12 ++++++++++++ app/models/site/repository.rb | 31 ++++++++++++++++++++----------- 2 files changed, 32 insertions(+), 11 deletions(-) create mode 100644 app/jobs/git_push_job.rb diff --git a/app/jobs/git_push_job.rb b/app/jobs/git_push_job.rb new file mode 100644 index 00000000..fb3ca662 --- /dev/null +++ b/app/jobs/git_push_job.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +# Permite pushear los cambios cada vez que se +# hacen commits en un sitio +class GitPushJob < ApplicationJob + # @param :site [Site] + # @return [nil] + def perform(site) + #detectar que el repo local tiene repo remoto + site.repository.push if site.repository.origin + end +end \ No newline at end of file diff --git a/app/models/site/repository.rb b/app/models/site/repository.rb index 62e4c45e..10ab481d 100644 --- a/app/models/site/repository.rb +++ b/app/models/site/repository.rb @@ -29,7 +29,7 @@ class Site # Obtiene el origin # - # @return [Rugged::Remote] + # @return [Rugged::Remote, nil] def origin @origin ||= rugged.remotes.find do |remote| remote.name == 'origin' @@ -154,17 +154,15 @@ class Site # # @return [Boolean] def gc - env = { 'PATH' => '/usr/bin', 'LANG' => ENV['LANG'], 'HOME' => path } - cmd = 'git gc' + git_sh("git gc") + end - r = nil - Dir.chdir(path) do - Open3.popen2e(env, cmd, unsetenv_others: true) do |_, _, t| - r = t.value - end - end - - r&.success? + # Pushea cambios al repositorio remoto + # + # @return [Boolean, nil] + def push + origin.push(rugged.head.canonical_name, credentials: credentials) + git_sh("git lfs push") end private @@ -192,5 +190,16 @@ class Site def relativize(file) Pathname.new(file).relative_path_from(Pathname.new(path)).to_s end + + def git_sh(cmd) + env = { 'PATH' => '/usr/bin', 'LANG' => ENV['LANG'], 'HOME' => path } + + r = nil + Open3.popen2e(env, cmd, unsetenv_others: true, chdir: path) do |_, _, t| + r = t.value + end + + r&.success? + end end end From d77b8ba67be5d4955cfaeb141197a1ab0ab86963 Mon Sep 17 00:00:00 2001 From: jazzari Date: Thu, 20 Jul 2023 14:58:21 -0300 Subject: [PATCH 031/130] feat: created job to make git pull #12980 --- app/jobs/git_pull_job.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 app/jobs/git_pull_job.rb diff --git a/app/jobs/git_pull_job.rb b/app/jobs/git_pull_job.rb new file mode 100644 index 00000000..0c9ef237 --- /dev/null +++ b/app/jobs/git_pull_job.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +# Permite traer los cambios cada vez que se +# hace un push al repositorio +class GitPullJob < ApplicationJob + # @param :site [Site] + # @return [nil] + def perform(site) + # hace un fetch para ver cambios + site.repository.fetch + + # hace un merge + site.repository.merge(site.usuarie) + site.repository.git_sh("git lfs fetch") + + end + end \ No newline at end of file From ca9fa31cf135d79e0204aad24d716a7f04c917c7 Mon Sep 17 00:00:00 2001 From: jazzari Date: Thu, 20 Jul 2023 15:31:38 -0300 Subject: [PATCH 032/130] fix: change git_sh method to accept array of params #12919 --- app/jobs/git_push_job.rb | 1 - app/models/site/repository.rb | 12 ++++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/jobs/git_push_job.rb b/app/jobs/git_push_job.rb index fb3ca662..3c62bee2 100644 --- a/app/jobs/git_push_job.rb +++ b/app/jobs/git_push_job.rb @@ -6,7 +6,6 @@ class GitPushJob < ApplicationJob # @param :site [Site] # @return [nil] def perform(site) - #detectar que el repo local tiene repo remoto site.repository.push if site.repository.origin end end \ No newline at end of file diff --git a/app/models/site/repository.rb b/app/models/site/repository.rb index 10ab481d..6306730e 100644 --- a/app/models/site/repository.rb +++ b/app/models/site/repository.rb @@ -154,7 +154,7 @@ class Site # # @return [Boolean] def gc - git_sh("git gc") + git_sh("git", "gc") end # Pushea cambios al repositorio remoto @@ -162,7 +162,7 @@ class Site # @return [Boolean, nil] def push origin.push(rugged.head.canonical_name, credentials: credentials) - git_sh("git lfs push") + git_sh("git", "lfs", "push", "origin", "#{default_branch}") end private @@ -191,11 +191,15 @@ class Site Pathname.new(file).relative_path_from(Pathname.new(path)).to_s end - def git_sh(cmd) + # Ejecuta un comando de git + # + # @param :args [Array] + # @return [Boolean] + def git_sh(*args) env = { 'PATH' => '/usr/bin', 'LANG' => ENV['LANG'], 'HOME' => path } r = nil - Open3.popen2e(env, cmd, unsetenv_others: true, chdir: path) do |_, _, t| + Open3.popen2e(env, args, unsetenv_others: true, chdir: path) do |_, _, t| r = t.value end From c2d64e11d7c0c6fb414e6970f6c933db19442561 Mon Sep 17 00:00:00 2001 From: jazzari Date: Thu, 20 Jul 2023 16:26:43 -0300 Subject: [PATCH 033/130] fix: missing splat in git_sh method #12919 --- app/models/site/repository.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/site/repository.rb b/app/models/site/repository.rb index 6306730e..a900fea2 100644 --- a/app/models/site/repository.rb +++ b/app/models/site/repository.rb @@ -162,7 +162,7 @@ class Site # @return [Boolean, nil] def push origin.push(rugged.head.canonical_name, credentials: credentials) - git_sh("git", "lfs", "push", "origin", "#{default_branch}") + git_sh("git", "lfs", "push", "origin", "default_branch") end private @@ -199,7 +199,7 @@ class Site env = { 'PATH' => '/usr/bin', 'LANG' => ENV['LANG'], 'HOME' => path } r = nil - Open3.popen2e(env, args, unsetenv_others: true, chdir: path) do |_, _, t| + Open3.popen2e(env, *args, unsetenv_others: true, chdir: path) do |_, _, t| r = t.value end From 3e12bfbe9ec950ec4dfd639717664742bc0491b6 Mon Sep 17 00:00:00 2001 From: jazzari Date: Fri, 21 Jul 2023 17:12:26 -0300 Subject: [PATCH 034/130] fix: add git lfs fetch to repository#fetch method #12980 --- app/jobs/git_pull_job.rb | 12 ++++-------- app/models/site/repository.rb | 6 +++++- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/jobs/git_pull_job.rb b/app/jobs/git_pull_job.rb index 0c9ef237..de263403 100644 --- a/app/jobs/git_pull_job.rb +++ b/app/jobs/git_pull_job.rb @@ -4,14 +4,10 @@ # hace un push al repositorio class GitPullJob < ApplicationJob # @param :site [Site] + # @param :usuarie [Usuarie] # @return [nil] - def perform(site) - # hace un fetch para ver cambios + def perform(site, usuarie) site.repository.fetch - - # hace un merge - site.repository.merge(site.usuarie) - site.repository.git_sh("git lfs fetch") - + site.repository.merge(usuarie) end - end \ No newline at end of file +end \ No newline at end of file diff --git a/app/models/site/repository.rb b/app/models/site/repository.rb index 62e4c45e..d2832091 100644 --- a/app/models/site/repository.rb +++ b/app/models/site/repository.rb @@ -45,7 +45,9 @@ class Site # @return [Integer] def fetch if origin.check_connection(:fetch, credentials: credentials) - rugged.fetch(origin, credentials: credentials)[:received_objects] + rugged.fetch(origin, credentials: credentials)[:received_objects].tap do |objects| + git_sh("git", "lfs", "fetch", "origin", default_branch) if objects&.positive? + end else 0 end @@ -75,6 +77,8 @@ class Site # Forzamos el checkout para mover el HEAD al último commit y # escribir los cambios rugged.checkout 'HEAD', strategy: :force + # reemplaza los pointers por los archivos correspondientes + git_sh("git", "lfs", "checkout") commit end From b7dc448daaec35c2e45045ab2272fe0f82ada948 Mon Sep 17 00:00:00 2001 From: jazzari Date: Fri, 21 Jul 2023 17:15:36 -0300 Subject: [PATCH 035/130] fix: fix git_sh method in site.repository.rb #12919 --- app/models/site/repository.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/site/repository.rb b/app/models/site/repository.rb index a900fea2..1ce10ed5 100644 --- a/app/models/site/repository.rb +++ b/app/models/site/repository.rb @@ -162,7 +162,7 @@ class Site # @return [Boolean, nil] def push origin.push(rugged.head.canonical_name, credentials: credentials) - git_sh("git", "lfs", "push", "origin", "default_branch") + git_sh("git", "lfs", "push", "origin", default_branch) end private From ae794322787548a79e6416663c45f3e8dd9cad62 Mon Sep 17 00:00:00 2001 From: f Date: Fri, 21 Jul 2023 17:33:23 -0300 Subject: [PATCH 036/130] fix: renombrar el skel a upstream MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit si lo mantenemos como origin por defecto, el GitPushJob va a querer enviar cambios a un repositorio común, rompiendo todo. --- app/models/site.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/site.rb b/app/models/site.rb index 24644b9c..0fddeff5 100644 --- a/app/models/site.rb +++ b/app/models/site.rb @@ -473,7 +473,7 @@ class Site < ApplicationRecord def clone_skel! return if jekyll? - Rugged::Repository.clone_at ENV['SKEL_SUTTY'], path + Rugged::Repository.clone_at ENV['SKEL_SUTTY'], path, remote: 'upstream' end # Elimina el directorio del sitio From b7e93cd8c8e8a9cbccc40d865571e21ecf0abfc3 Mon Sep 17 00:00:00 2001 From: jazzari Date: Wed, 26 Jul 2023 14:44:11 -0300 Subject: [PATCH 037/130] feat: controlador para gestionar los webhooks #13903 --- app/controllers/api/v1/webhooks_controller.rb | 17 +++++++++++++++++ app/models/site/repository.rb | 4 ++-- config/locales/en.yml | 3 +++ config/locales/es.yml | 3 +++ config/routes.rb | 2 ++ 5 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 app/controllers/api/v1/webhooks_controller.rb diff --git a/app/controllers/api/v1/webhooks_controller.rb b/app/controllers/api/v1/webhooks_controller.rb new file mode 100644 index 00000000..4811d792 --- /dev/null +++ b/app/controllers/api/v1/webhooks_controller.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +module Api + module V1 + # Recibe webhooks y lanza jobs + class WebhooksController < BaseController + def pull + # encontrar el sitio + site = Site.find_by_name(params[:site_id]) + usuarie = GitAuthor.new email: "webhook@#{Site.domain}", name: 'Webhook' + message = I18n.t('webhooks.pull.message') + + GitPullJob.perform_later(site, usuarie, message) + end + end + end +end \ No newline at end of file diff --git a/app/models/site/repository.rb b/app/models/site/repository.rb index 404cde3e..a3487bc5 100644 --- a/app/models/site/repository.rb +++ b/app/models/site/repository.rb @@ -56,7 +56,7 @@ class Site # Incorpora los cambios en el repositorio actual # # @return [Rugged::Commit] - def merge(usuarie) + def merge(usuarie, message) merge = rugged.merge_commits(head_commit, remote_head_commit) # No hacemos nada si hay conflictos, pero notificarnos @@ -71,7 +71,7 @@ class Site .create(rugged, update_ref: 'HEAD', parents: [head_commit, remote_head_commit], tree: merge.write_tree(rugged), - message: I18n.t('sites.fetch.merge.message'), + message: message, author: author(usuarie), committer: committer) # Forzamos el checkout para mover el HEAD al último commit y diff --git a/config/locales/en.yml b/config/locales/en.yml index 5f97a8b9..05fcf1e5 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -466,6 +466,9 @@ en: success: 'Site upgrade has been completed. Your next build will run this upgrade :)' error: "There was an error when trying to upgrade your site. This could be due to conflicts that couldn't be solved automatically. A report of the issue has already been sent to our admins. Sorry for the inconvenience! :(" message: 'Skeleton upgrade' + webhooks_controller: + pull: + message: 'Webhooks upgrade' footer: powered_by: 'is developed by' i18n: diff --git a/config/locales/es.yml b/config/locales/es.yml index 9e0b8945..af5a7db7 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -474,6 +474,9 @@ es: success: 'Ya se incorporaron los cambios en el sitio, se aplicarán en la próxima compilación que hagas :)' error: 'Hubo un error al incorporar los cambios en el sitio. Esto puede deberse a conflictos entre cambios que no se pueden resolver automáticamente. Hemos enviado un reporte del problema a les administradores de Sutty para que estén al tanto de la situación. ¡Lo sentimos! :(' message: 'Actualización del esqueleto' + webhooks_controller: + pull: + message: 'Actualización desde Webhooks' footer: powered_by: 'es desarrollada por' i18n: diff --git a/config/routes.rb b/config/routes.rb index 3828915c..f2487066 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -17,6 +17,8 @@ Rails.application.routes.draw do get :'contact/cookie', to: 'invitades#contact_cookie' post :'contact/:form', to: 'contact#receive', as: :contact + + post :'webhooks/pull', to: 'webhooks#pull' end end end From 8947942cb9066f2775faf4b0864e2874a1c39907 Mon Sep 17 00:00:00 2001 From: jazzari Date: Thu, 27 Jul 2023 16:46:32 -0300 Subject: [PATCH 038/130] fix: commit message fixed #13903 --- app/controllers/api/v1/webhooks_controller.rb | 9 ++++++--- app/jobs/git_pull_job.rb | 4 ++-- app/models/site/repository.rb | 2 +- config/locales/en.yml | 2 +- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/app/controllers/api/v1/webhooks_controller.rb b/app/controllers/api/v1/webhooks_controller.rb index 4811d792..40187915 100644 --- a/app/controllers/api/v1/webhooks_controller.rb +++ b/app/controllers/api/v1/webhooks_controller.rb @@ -4,11 +4,14 @@ module Api module V1 # Recibe webhooks y lanza jobs class WebhooksController < BaseController + # Trae los cambios a partir de un post de Webhooks: + # (Gitlab, Github, Guitea, etc) def pull - # encontrar el sitio - site = Site.find_by_name(params[:site_id]) + site = Site.find_by_name!(params[:site_id]) usuarie = GitAuthor.new email: "webhook@#{Site.domain}", name: 'Webhook' - message = I18n.t('webhooks.pull.message') + message = I18n.with_locale(site.default_locale) do + I18n.t('webhooks.pull.message') + end GitPullJob.perform_later(site, usuarie, message) end diff --git a/app/jobs/git_pull_job.rb b/app/jobs/git_pull_job.rb index de263403..5cd86981 100644 --- a/app/jobs/git_pull_job.rb +++ b/app/jobs/git_pull_job.rb @@ -6,8 +6,8 @@ class GitPullJob < ApplicationJob # @param :site [Site] # @param :usuarie [Usuarie] # @return [nil] - def perform(site, usuarie) + def perform(site, usuarie, message) site.repository.fetch - site.repository.merge(usuarie) + site.repository.merge(usuarie, message) if site.repository.fetch&.positive? end end \ No newline at end of file diff --git a/app/models/site/repository.rb b/app/models/site/repository.rb index a3487bc5..a864e8b9 100644 --- a/app/models/site/repository.rb +++ b/app/models/site/repository.rb @@ -56,7 +56,7 @@ class Site # Incorpora los cambios en el repositorio actual # # @return [Rugged::Commit] - def merge(usuarie, message) + def merge(usuarie, message= I18n.t('sites.fetch.merge.message')) merge = rugged.merge_commits(head_commit, remote_head_commit) # No hacemos nada si hay conflictos, pero notificarnos diff --git a/config/locales/en.yml b/config/locales/en.yml index 05fcf1e5..8ae8cce5 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -468,7 +468,7 @@ en: message: 'Skeleton upgrade' webhooks_controller: pull: - message: 'Webhooks upgrade' + message: 'Webhooks pull' footer: powered_by: 'is developed by' i18n: From 9f5364a738825e7dc17b8482ecdd882f069d1ba4 Mon Sep 17 00:00:00 2001 From: jazzari Date: Thu, 27 Jul 2023 17:02:48 -0300 Subject: [PATCH 039/130] fix: add documentation to pull job #13903 --- app/jobs/git_pull_job.rb | 2 +- app/models/site/repository.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/jobs/git_pull_job.rb b/app/jobs/git_pull_job.rb index 5cd86981..a0c15950 100644 --- a/app/jobs/git_pull_job.rb +++ b/app/jobs/git_pull_job.rb @@ -5,9 +5,9 @@ class GitPullJob < ApplicationJob # @param :site [Site] # @param :usuarie [Usuarie] + # @param :message [String] # @return [nil] def perform(site, usuarie, message) - site.repository.fetch site.repository.merge(usuarie, message) if site.repository.fetch&.positive? end end \ No newline at end of file diff --git a/app/models/site/repository.rb b/app/models/site/repository.rb index a864e8b9..c0607d84 100644 --- a/app/models/site/repository.rb +++ b/app/models/site/repository.rb @@ -56,7 +56,7 @@ class Site # Incorpora los cambios en el repositorio actual # # @return [Rugged::Commit] - def merge(usuarie, message= I18n.t('sites.fetch.merge.message')) + def merge(usuarie, message = I18n.t('sites.fetch.merge.message')) merge = rugged.merge_commits(head_commit, remote_head_commit) # No hacemos nada si hay conflictos, pero notificarnos From 9f94ee3bc704dfe9a7787ce6be0b8015a2fcb676 Mon Sep 17 00:00:00 2001 From: jazzari Date: Thu, 27 Jul 2023 17:23:40 -0300 Subject: [PATCH 040/130] fix: add response status to pull method #13903 --- app/controllers/api/v1/webhooks_controller.rb | 2 ++ config/locales/es.yml | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/v1/webhooks_controller.rb b/app/controllers/api/v1/webhooks_controller.rb index 40187915..a538d99f 100644 --- a/app/controllers/api/v1/webhooks_controller.rb +++ b/app/controllers/api/v1/webhooks_controller.rb @@ -14,6 +14,8 @@ module Api end GitPullJob.perform_later(site, usuarie, message) + + head :ok end end end diff --git a/config/locales/es.yml b/config/locales/es.yml index af5a7db7..b03a222f 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -476,7 +476,7 @@ es: message: 'Actualización del esqueleto' webhooks_controller: pull: - message: 'Actualización desde Webhooks' + message: 'Pull de webhooks' footer: powered_by: 'es desarrollada por' i18n: From 9a78c628b4aac8bffe44e4dffb80d0c268be6b83 Mon Sep 17 00:00:00 2001 From: jazzari Date: Mon, 31 Jul 2023 12:29:27 -0300 Subject: [PATCH 041/130] fix: fix typo in es.yml #13864 --- config/locales/es.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/locales/es.yml b/config/locales/es.yml index 9e0b8945..eabddcc9 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -693,7 +693,7 @@ es: new: 'Crear' edit: 'Configurar' posts: - new: 'Nuevo %{layout}' + new: 'Agregar %{layout}' edit: 'Editando' usuaries: index: 'Usuaries' From 06ebb63d9389c260e547c73487eb89c108dacb0b Mon Sep 17 00:00:00 2001 From: jazzari Date: Mon, 31 Jul 2023 14:18:07 -0300 Subject: [PATCH 042/130] =?UTF-8?q?fix:=20movido=20git=20lfs=20a=20m=C3=A9?= =?UTF-8?q?todo=20merge=20en=20repository.rb=20#13903?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/jobs/git_pull_job.rb | 4 ++-- app/models/site/repository.rb | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/jobs/git_pull_job.rb b/app/jobs/git_pull_job.rb index a0c15950..dc4a285c 100644 --- a/app/jobs/git_pull_job.rb +++ b/app/jobs/git_pull_job.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -# Permite traer los cambios cada vez que se -# hace un push al repositorio +# Permite traer los cambios desde webhooks + class GitPullJob < ApplicationJob # @param :site [Site] # @param :usuarie [Usuarie] diff --git a/app/models/site/repository.rb b/app/models/site/repository.rb index c0607d84..9c4d873f 100644 --- a/app/models/site/repository.rb +++ b/app/models/site/repository.rb @@ -45,9 +45,7 @@ class Site # @return [Integer] def fetch if origin.check_connection(:fetch, credentials: credentials) - rugged.fetch(origin, credentials: credentials)[:received_objects].tap do |objects| - git_sh("git", "lfs", "fetch", "origin", default_branch) if objects&.positive? - end + rugged.fetch(origin, credentials: credentials)[:received_objects] else 0 end @@ -77,6 +75,8 @@ class Site # Forzamos el checkout para mover el HEAD al último commit y # escribir los cambios rugged.checkout 'HEAD', strategy: :force + + git_sh("git", "lfs", "fetch", "origin", default_branch) # reemplaza los pointers por los archivos correspondientes git_sh("git", "lfs", "checkout") commit From 579e1776842774733c036b6b621ccf087b2b06cc Mon Sep 17 00:00:00 2001 From: jazzari Date: Mon, 31 Jul 2023 17:32:14 -0300 Subject: [PATCH 043/130] feat: agregada columna token a model rol #13903 --- app/models/rol.rb | 10 ++++++++++ db/migrate/20230731195050_add_token_to_roles.rb | 5 +++++ db/migrate/20230731202003_change_token_name.rb | 5 +++++ 3 files changed, 20 insertions(+) create mode 100644 db/migrate/20230731195050_add_token_to_roles.rb create mode 100644 db/migrate/20230731202003_change_token_name.rb diff --git a/app/models/rol.rb b/app/models/rol.rb index fcd07037..f17bf418 100644 --- a/app/models/rol.rb +++ b/app/models/rol.rb @@ -14,6 +14,9 @@ class Rol < ApplicationRecord validates_inclusion_of :rol, in: ROLES + encrypts :token + before_save :add_token_if_missing! + def invitade? rol == INVITADE end @@ -25,4 +28,11 @@ class Rol < ApplicationRecord def self.role?(rol) ROLES.include? rol end + + private + + # Asegurarse que tenga un token + def add_token_if_missing! + self.token ||= SecureRandom.hex(64) + end end diff --git a/db/migrate/20230731195050_add_token_to_roles.rb b/db/migrate/20230731195050_add_token_to_roles.rb new file mode 100644 index 00000000..635e065c --- /dev/null +++ b/db/migrate/20230731195050_add_token_to_roles.rb @@ -0,0 +1,5 @@ +class AddTokenToRoles < ActiveRecord::Migration[6.1] + def change + add_column :roles, :token, :text + end +end diff --git a/db/migrate/20230731202003_change_token_name.rb b/db/migrate/20230731202003_change_token_name.rb new file mode 100644 index 00000000..50fc0c40 --- /dev/null +++ b/db/migrate/20230731202003_change_token_name.rb @@ -0,0 +1,5 @@ +class ChangeTokenName < ActiveRecord::Migration[6.1] + def change + rename_column :roles, :token, :token_cyphertext + end +end From c19c834f10962e3c58d2b08418ee7790430318c9 Mon Sep 17 00:00:00 2001 From: jazzari Date: Mon, 31 Jul 2023 18:46:07 -0300 Subject: [PATCH 044/130] =?UTF-8?q?fix:=20cambio=20nombre=20comuna=20token?= =?UTF-8?q?=5Fcyphertext=20en=20modelo=20rol=20y=20asignaci=C3=B3n=20retro?= =?UTF-8?q?activa=20#13903?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/migrate/20230731202003_change_token_name.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/db/migrate/20230731202003_change_token_name.rb b/db/migrate/20230731202003_change_token_name.rb index 50fc0c40..c3fce3c0 100644 --- a/db/migrate/20230731202003_change_token_name.rb +++ b/db/migrate/20230731202003_change_token_name.rb @@ -1,5 +1,6 @@ class ChangeTokenName < ActiveRecord::Migration[6.1] def change rename_column :roles, :token, :token_cyphertext + Rol.find_each { |m| m.update_column( :token_cyphertext, SecureRandom.hex(64) ) } end end From 705d15c0c1959d3e50b2f8646830a15372c4797e Mon Sep 17 00:00:00 2001 From: jazzari Date: Thu, 10 Aug 2023 16:05:14 -0300 Subject: [PATCH 045/130] fix: change token attribute from encrypted to normal in Rol model #13903 --- app/controllers/api/v1/webhooks_controller.rb | 22 ++++++++++++++----- app/models/rol.rb | 1 - 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/app/controllers/api/v1/webhooks_controller.rb b/app/controllers/api/v1/webhooks_controller.rb index a538d99f..1933f24e 100644 --- a/app/controllers/api/v1/webhooks_controller.rb +++ b/app/controllers/api/v1/webhooks_controller.rb @@ -2,19 +2,31 @@ module Api module V1 - # Recibe webhooks y lanza jobs + # Recibe webhooks y lanza un PullJob class WebhooksController < BaseController + rescue_from ActiveRecord::RecordNotFound, with: :platforms_answer + + def site + @site ||= Site.find_by_name!(params[:site_id]) + end + + # valida la plataforma del webhook + def usuarie + # Gitlab + token = request.headers["X-Gitlab-Token"] + @usuarie = site.roles.find_by!(temporal: false, rol: 'usuarie', token: token).usuarie + end + # Trae los cambios a partir de un post de Webhooks: # (Gitlab, Github, Guitea, etc) def pull - site = Site.find_by_name!(params[:site_id]) - usuarie = GitAuthor.new email: "webhook@#{Site.domain}", name: 'Webhook' message = I18n.with_locale(site.default_locale) do I18n.t('webhooks.pull.message') end - GitPullJob.perform_later(site, usuarie, message) - + end + + def platforms_answer head :ok end end diff --git a/app/models/rol.rb b/app/models/rol.rb index f17bf418..37332400 100644 --- a/app/models/rol.rb +++ b/app/models/rol.rb @@ -14,7 +14,6 @@ class Rol < ApplicationRecord validates_inclusion_of :rol, in: ROLES - encrypts :token before_save :add_token_if_missing! def invitade? From 63fd91ee48f3a9cab4417f6e9bd21be6604440f0 Mon Sep 17 00:00:00 2001 From: jazzari Date: Thu, 10 Aug 2023 16:13:13 -0300 Subject: [PATCH 046/130] feat: add token to existing records #13903 --- db/migrate/20230731195050_add_token_to_roles.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/db/migrate/20230731195050_add_token_to_roles.rb b/db/migrate/20230731195050_add_token_to_roles.rb index 635e065c..620c9fef 100644 --- a/db/migrate/20230731195050_add_token_to_roles.rb +++ b/db/migrate/20230731195050_add_token_to_roles.rb @@ -1,5 +1,6 @@ class AddTokenToRoles < ActiveRecord::Migration[6.1] def change add_column :roles, :token, :text + Rol.find_each { |m| m.update_column( :token, SecureRandom.hex(64) ) } end end From 23732bbfe0ed8c4920bd7188b700f63ed5612b51 Mon Sep 17 00:00:00 2001 From: jazzari Date: Mon, 14 Aug 2023 12:50:18 -0300 Subject: [PATCH 047/130] feat: add method to validate token from diff platforms in webhooks controller #13903 --- app/controllers/api/v1/webhooks_controller.rb | 29 +++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/app/controllers/api/v1/webhooks_controller.rb b/app/controllers/api/v1/webhooks_controller.rb index 1933f24e..091d467e 100644 --- a/app/controllers/api/v1/webhooks_controller.rb +++ b/app/controllers/api/v1/webhooks_controller.rb @@ -10,10 +10,32 @@ module Api @site ||= Site.find_by_name!(params[:site_id]) end - # valida la plataforma del webhook + # valida el token que envía la plataforma del webhook + def token + @token ||= + begin + # Gitlab + if request.headers['X-Gitlab-Token'] + request.headers["X-Gitlab-Token"] + # Github + elsif request.headers['X-HUB-SIGNATURE-256'] + signature(request.env['HTTP_X_HUB_SIGNATURE_256']) + # Guitea + else + signature(request.env['HTTP_X_GITEA_SIGNATURE']) + end + end + end + + def token_from_signature(signature) + payload = request.body.read + site.roles.where(temporal: false, rol: 'usuarie').pluck(:token).find do |token| + new_signature = hash_mac(OpenSSL::Digest.new('sha256'), token, payload) + @token ||= Rack::Utils.secure_compare(new_signature, signature) + end + end + def usuarie - # Gitlab - token = request.headers["X-Gitlab-Token"] @usuarie = site.roles.find_by!(temporal: false, rol: 'usuarie', token: token).usuarie end @@ -23,6 +45,7 @@ module Api message = I18n.with_locale(site.default_locale) do I18n.t('webhooks.pull.message') end + GitPullJob.perform_later(site, usuarie, message) end From f2236bb305573e7a471e1b3a94ab50d486bc0d63 Mon Sep 17 00:00:00 2001 From: jazzari Date: Mon, 14 Aug 2023 16:49:24 -0300 Subject: [PATCH 048/130] feat: move methods to private #13903 --- app/controllers/api/v1/webhooks_controller.rb | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/app/controllers/api/v1/webhooks_controller.rb b/app/controllers/api/v1/webhooks_controller.rb index 091d467e..b356d20a 100644 --- a/app/controllers/api/v1/webhooks_controller.rb +++ b/app/controllers/api/v1/webhooks_controller.rb @@ -6,6 +6,19 @@ module Api class WebhooksController < BaseController rescue_from ActiveRecord::RecordNotFound, with: :platforms_answer + # Trae los cambios a partir de un post de Webhooks: + # (Gitlab, Github, Guitea, etc) + def pull + message = I18n.with_locale(site.default_locale) do + I18n.t('webhooks.pull.message') + end + + GitPullJob.perform_later(site, usuarie, message) + platforms_answer + end + + private + def site @site ||= Site.find_by_name!(params[:site_id]) end @@ -37,17 +50,7 @@ module Api def usuarie @usuarie = site.roles.find_by!(temporal: false, rol: 'usuarie', token: token).usuarie - end - - # Trae los cambios a partir de un post de Webhooks: - # (Gitlab, Github, Guitea, etc) - def pull - message = I18n.with_locale(site.default_locale) do - I18n.t('webhooks.pull.message') - end - - GitPullJob.perform_later(site, usuarie, message) - end + end def platforms_answer head :ok From a098e1baa7d2e7e96b18bc16be7a21cc413c8f38 Mon Sep 17 00:00:00 2001 From: jazzari Date: Tue, 15 Aug 2023 16:14:34 -0300 Subject: [PATCH 049/130] fix: change migration methods to add token to roles #13903 --- db/migrate/20230731195050_add_token_to_roles.rb | 12 +++++++++--- db/migrate/20230731202003_change_token_name.rb | 6 ------ 2 files changed, 9 insertions(+), 9 deletions(-) delete mode 100644 db/migrate/20230731202003_change_token_name.rb diff --git a/db/migrate/20230731195050_add_token_to_roles.rb b/db/migrate/20230731195050_add_token_to_roles.rb index 620c9fef..c38b0526 100644 --- a/db/migrate/20230731195050_add_token_to_roles.rb +++ b/db/migrate/20230731195050_add_token_to_roles.rb @@ -1,6 +1,12 @@ class AddTokenToRoles < ActiveRecord::Migration[6.1] - def change - add_column :roles, :token, :text - Rol.find_each { |m| m.update_column( :token, SecureRandom.hex(64) ) } + def up + add_column :roles, :token, :string + Rol.find_each do |m| + m.update_column( :token, SecureRandom.hex(64) ) + end + end + + def down + remove_column :roles, :token end end diff --git a/db/migrate/20230731202003_change_token_name.rb b/db/migrate/20230731202003_change_token_name.rb deleted file mode 100644 index c3fce3c0..00000000 --- a/db/migrate/20230731202003_change_token_name.rb +++ /dev/null @@ -1,6 +0,0 @@ -class ChangeTokenName < ActiveRecord::Migration[6.1] - def change - rename_column :roles, :token, :token_cyphertext - Rol.find_each { |m| m.update_column( :token_cyphertext, SecureRandom.hex(64) ) } - end -end From c5406acb26221e591804d481ac6547072dd38952 Mon Sep 17 00:00:00 2001 From: jazzari Date: Tue, 15 Aug 2023 16:59:16 -0300 Subject: [PATCH 050/130] fix: add documentation and fix typos #13903 --- app/controllers/api/v1/webhooks_controller.rb | 101 ++++++++++-------- config/locales/es.yml | 2 +- 2 files changed, 56 insertions(+), 47 deletions(-) diff --git a/app/controllers/api/v1/webhooks_controller.rb b/app/controllers/api/v1/webhooks_controller.rb index b356d20a..20cc0ddc 100644 --- a/app/controllers/api/v1/webhooks_controller.rb +++ b/app/controllers/api/v1/webhooks_controller.rb @@ -1,60 +1,69 @@ # frozen_string_literal: true module Api - module V1 - # Recibe webhooks y lanza un PullJob - class WebhooksController < BaseController - rescue_from ActiveRecord::RecordNotFound, with: :platforms_answer + module V1 + # Recibe webhooks y lanza un PullJob + class WebhooksController < BaseController + # responde con forbidden si falla la validación del token + rescue_from ActiveRecord::RecordNotFound, with: :platforms_answer - # Trae los cambios a partir de un post de Webhooks: - # (Gitlab, Github, Guitea, etc) - def pull - message = I18n.with_locale(site.default_locale) do - I18n.t('webhooks.pull.message') - end - - GitPullJob.perform_later(site, usuarie, message) - platforms_answer + # Trae los cambios a partir de un post de Webhooks: + # (Gitlab, Github, Gitea, etc) + def pull + message = I18n.with_locale(site.default_locale) do + I18n.t('webhooks.pull.message') end - private + GitPullJob.perform_later(site, usuarie, message) + head :ok + end - def site - @site ||= Site.find_by_name!(params[:site_id]) - end + private - # valida el token que envía la plataforma del webhook - def token - @token ||= - begin - # Gitlab - if request.headers['X-Gitlab-Token'] - request.headers["X-Gitlab-Token"] - # Github - elsif request.headers['X-HUB-SIGNATURE-256'] - signature(request.env['HTTP_X_HUB_SIGNATURE_256']) - # Guitea - else - signature(request.env['HTTP_X_GITEA_SIGNATURE']) - end - end - end + # encuentra el sitio a partir de la url + def site + @site ||= Site.find_by_name!(params[:site_id]) + end - def token_from_signature(signature) - payload = request.body.read - site.roles.where(temporal: false, rol: 'usuarie').pluck(:token).find do |token| - new_signature = hash_mac(OpenSSL::Digest.new('sha256'), token, payload) - @token ||= Rack::Utils.secure_compare(new_signature, signature) - end - end + # valida el token que envía la plataforma del webhook + # + # @return [String] + def token + @token ||= + begin + # Gitlab + if request.headers['X-Gitlab-Token'] + request.headers['X-Gitlab-Token'] + # Github + elsif request.headers['X-HUB-SIGNATURE-256'] + request.env['HTTP_X_HUB_SIGNATURE_256'] + # Gitea + else + request.env['HTTP_X_GITEA_SIGNATURE'] + end + end + end - def usuarie - @usuarie = site.roles.find_by!(temporal: false, rol: 'usuarie', token: token).usuarie - end - - def platforms_answer - head :ok + # valida token a partir de firma de webhook + # + # @return [String] + def token_from_signature(signature) + payload = request.body.read + site.roles.where(temporal: false, rol: 'usuarie').pluck(:token).find do |token| + new_signature = 'sha256=' + OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), token, payload) + ActiveSupport::SecurityUtils.secure_compare(new_signature, signature) end end + + # encuentra le usuarie + def usuarie + @usuarie ||= site.roles.find_by!(temporal: false, rol: 'usuarie', token: token).usuarie + end + + # respuesta de error a plataformas + def platforms_answer + head :forbidden + end end + end end \ No newline at end of file diff --git a/config/locales/es.yml b/config/locales/es.yml index b03a222f..7a83483f 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -476,7 +476,7 @@ es: message: 'Actualización del esqueleto' webhooks_controller: pull: - message: 'Pull de webhooks' + message: 'Traer los cambios a partir de un evento remoto' footer: powered_by: 'es desarrollada por' i18n: From aeb2105dc7273cf603ab8e86f7bc90780f96093f Mon Sep 17 00:00:00 2001 From: jazzari Date: Tue, 15 Aug 2023 19:25:06 -0300 Subject: [PATCH 051/130] fix: add rescue in token_from_signature method #13903 --- app/controllers/api/v1/webhooks_controller.rb | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/app/controllers/api/v1/webhooks_controller.rb b/app/controllers/api/v1/webhooks_controller.rb index 20cc0ddc..0ecca9d7 100644 --- a/app/controllers/api/v1/webhooks_controller.rb +++ b/app/controllers/api/v1/webhooks_controller.rb @@ -9,6 +9,8 @@ module Api # Trae los cambios a partir de un post de Webhooks: # (Gitlab, Github, Gitea, etc) + # + # @return [nil] def pull message = I18n.with_locale(site.default_locale) do I18n.t('webhooks.pull.message') @@ -36,22 +38,27 @@ module Api request.headers['X-Gitlab-Token'] # Github elsif request.headers['X-HUB-SIGNATURE-256'] - request.env['HTTP_X_HUB_SIGNATURE_256'] + token_from_signature(request.env['HTTP_X_HUB_SIGNATURE_256']) # Gitea else - request.env['HTTP_X_GITEA_SIGNATURE'] + token_from_signatureq(request.env['HTTP_X_GITEA_SIGNATURE']) end end end # valida token a partir de firma de webhook # - # @return [String] + # @return [String, Boolean] def token_from_signature(signature) payload = request.body.read site.roles.where(temporal: false, rol: 'usuarie').pluck(:token).find do |token| new_signature = 'sha256=' + OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), token, payload) ActiveSupport::SecurityUtils.secure_compare(new_signature, signature) + end.tap do |t| + raise ArgumentError, 'token no encontrado' if t.nil? + rescue ArgumentError => e + ExceptionNotifier.notify_exception(e, data: { params: params.to_h }) + raise ActiveRecord::RecordNotFound end end From 5ac628b38a0032a26e0f9d29f1c4e1266069360b Mon Sep 17 00:00:00 2001 From: jazzari Date: Wed, 16 Aug 2023 12:58:14 -0300 Subject: [PATCH 052/130] fix: fix typo and change response to platforms #13903 --- app/controllers/api/v1/webhooks_controller.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/controllers/api/v1/webhooks_controller.rb b/app/controllers/api/v1/webhooks_controller.rb index 0ecca9d7..40f2f06d 100644 --- a/app/controllers/api/v1/webhooks_controller.rb +++ b/app/controllers/api/v1/webhooks_controller.rb @@ -40,8 +40,10 @@ module Api elsif request.headers['X-HUB-SIGNATURE-256'] token_from_signature(request.env['HTTP_X_HUB_SIGNATURE_256']) # Gitea + elsif + token_from_signature(request.env['HTTP_X_GITEA_SIGNATURE']) else - token_from_signatureq(request.env['HTTP_X_GITEA_SIGNATURE']) + raise ActiveRecord::RecordNotFound end end end @@ -55,10 +57,7 @@ module Api new_signature = 'sha256=' + OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), token, payload) ActiveSupport::SecurityUtils.secure_compare(new_signature, signature) end.tap do |t| - raise ArgumentError, 'token no encontrado' if t.nil? - rescue ArgumentError => e - ExceptionNotifier.notify_exception(e, data: { params: params.to_h }) - raise ActiveRecord::RecordNotFound + raise ActiveRecord::RecordNotFound if t.nil? end end @@ -70,6 +69,9 @@ module Api # respuesta de error a plataformas def platforms_answer head :forbidden + raise ArgumentError, 'token no encontrado' + rescue ArgumentError => e + ExceptionNotifier.notify_exception(e, data: { params: params.to_h }) end end end From 35dca9d7565f40f2a037b095ea8005cd2a953232 Mon Sep 17 00:00:00 2001 From: jazzari Date: Wed, 16 Aug 2023 13:39:29 -0300 Subject: [PATCH 053/130] fix: fix exception in platforms_answer method #13903 --- app/controllers/api/v1/webhooks_controller.rb | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/app/controllers/api/v1/webhooks_controller.rb b/app/controllers/api/v1/webhooks_controller.rb index 40f2f06d..13a227ce 100644 --- a/app/controllers/api/v1/webhooks_controller.rb +++ b/app/controllers/api/v1/webhooks_controller.rb @@ -57,7 +57,7 @@ module Api new_signature = 'sha256=' + OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), token, payload) ActiveSupport::SecurityUtils.secure_compare(new_signature, signature) end.tap do |t| - raise ActiveRecord::RecordNotFound if t.nil? + raise ActiveRecord::RecordNotFound, 'token no encontrado' if t.nil? end end @@ -67,12 +67,9 @@ module Api end # respuesta de error a plataformas - def platforms_answer + def platforms_answer(exception) head :forbidden - raise ArgumentError, 'token no encontrado' - rescue ArgumentError => e - ExceptionNotifier.notify_exception(e, data: { params: params.to_h }) - end + ExceptionNotifier.notify_exception(exception, data: { params: params.to_h }) end end end \ No newline at end of file From cefd053d1d7f70233f07cd047fd1dc5d321dd8b5 Mon Sep 17 00:00:00 2001 From: jazzari Date: Wed, 16 Aug 2023 14:57:01 -0300 Subject: [PATCH 054/130] fix: add condition in elsif in token method #13903 --- app/controllers/api/v1/webhooks_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/api/v1/webhooks_controller.rb b/app/controllers/api/v1/webhooks_controller.rb index 13a227ce..3af9abee 100644 --- a/app/controllers/api/v1/webhooks_controller.rb +++ b/app/controllers/api/v1/webhooks_controller.rb @@ -40,7 +40,7 @@ module Api elsif request.headers['X-HUB-SIGNATURE-256'] token_from_signature(request.env['HTTP_X_HUB_SIGNATURE_256']) # Gitea - elsif + elsif request.headers['HTTP_X_GITEA_SIGNATURE'] token_from_signature(request.env['HTTP_X_GITEA_SIGNATURE']) else raise ActiveRecord::RecordNotFound From 114fe4b2d5dce83874735cf1de97af6e89b925d5 Mon Sep 17 00:00:00 2001 From: jazzari Date: Wed, 16 Aug 2023 15:43:57 -0300 Subject: [PATCH 055/130] fix: fix in es.yml & en.yml and missing end #13903 --- app/controllers/api/v1/webhooks_controller.rb | 11 ++++++----- config/locales/en.yml | 2 +- config/locales/es.yml | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/controllers/api/v1/webhooks_controller.rb b/app/controllers/api/v1/webhooks_controller.rb index 3af9abee..8ef943be 100644 --- a/app/controllers/api/v1/webhooks_controller.rb +++ b/app/controllers/api/v1/webhooks_controller.rb @@ -38,12 +38,12 @@ module Api request.headers['X-Gitlab-Token'] # Github elsif request.headers['X-HUB-SIGNATURE-256'] - token_from_signature(request.env['HTTP_X_HUB_SIGNATURE_256']) + token_from_signature(request.env['HTTP_X_HUB_SIGNATURE_256'], 'sha256=') # Gitea elsif request.headers['HTTP_X_GITEA_SIGNATURE'] token_from_signature(request.env['HTTP_X_GITEA_SIGNATURE']) else - raise ActiveRecord::RecordNotFound + raise ActiveRecord::RecordNotFound, 'proveedor no soportado' end end end @@ -51,10 +51,10 @@ module Api # valida token a partir de firma de webhook # # @return [String, Boolean] - def token_from_signature(signature) + def token_from_signature(signature. prepend = '') payload = request.body.read site.roles.where(temporal: false, rol: 'usuarie').pluck(:token).find do |token| - new_signature = 'sha256=' + OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), token, payload) + new_signature = prepend + OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), token, payload) ActiveSupport::SecurityUtils.secure_compare(new_signature, signature) end.tap do |t| raise ActiveRecord::RecordNotFound, 'token no encontrado' if t.nil? @@ -69,7 +69,8 @@ module Api # respuesta de error a plataformas def platforms_answer(exception) head :forbidden - ExceptionNotifier.notify_exception(exception, data: { params: params.to_h }) + ExceptionNotifier.notify_exception(exception, env: request.env) + end end end end \ No newline at end of file diff --git a/config/locales/en.yml b/config/locales/en.yml index 8ae8cce5..c9a723bc 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -466,7 +466,7 @@ en: success: 'Site upgrade has been completed. Your next build will run this upgrade :)' error: "There was an error when trying to upgrade your site. This could be due to conflicts that couldn't be solved automatically. A report of the issue has already been sent to our admins. Sorry for the inconvenience! :(" message: 'Skeleton upgrade' - webhooks_controller: + webhooks: pull: message: 'Webhooks pull' footer: diff --git a/config/locales/es.yml b/config/locales/es.yml index 7a83483f..857217ec 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -474,7 +474,7 @@ es: success: 'Ya se incorporaron los cambios en el sitio, se aplicarán en la próxima compilación que hagas :)' error: 'Hubo un error al incorporar los cambios en el sitio. Esto puede deberse a conflictos entre cambios que no se pueden resolver automáticamente. Hemos enviado un reporte del problema a les administradores de Sutty para que estén al tanto de la situación. ¡Lo sentimos! :(' message: 'Actualización del esqueleto' - webhooks_controller: + webhooks: pull: message: 'Traer los cambios a partir de un evento remoto' footer: From 5ef601139fab2f99952dcda124a6a06bd10dc054 Mon Sep 17 00:00:00 2001 From: f Date: Wed, 16 Aug 2023 16:21:48 -0300 Subject: [PATCH 056/130] fix: eliminar espacio en blanco --- app/controllers/api/v1/webhooks_controller.rb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/app/controllers/api/v1/webhooks_controller.rb b/app/controllers/api/v1/webhooks_controller.rb index 8ef943be..fb4a710c 100644 --- a/app/controllers/api/v1/webhooks_controller.rb +++ b/app/controllers/api/v1/webhooks_controller.rb @@ -11,7 +11,7 @@ module Api # (Gitlab, Github, Gitea, etc) # # @return [nil] - def pull + def pull message = I18n.with_locale(site.default_locale) do I18n.t('webhooks.pull.message') end @@ -20,17 +20,17 @@ module Api head :ok end - private + private # encuentra el sitio a partir de la url - def site + def site @site ||= Site.find_by_name!(params[:site_id]) end # valida el token que envía la plataforma del webhook # # @return [String] - def token + def token @token ||= begin # Gitlab @@ -45,14 +45,14 @@ module Api else raise ActiveRecord::RecordNotFound, 'proveedor no soportado' end - end + end end # valida token a partir de firma de webhook # # @return [String, Boolean] def token_from_signature(signature. prepend = '') - payload = request.body.read + payload = request.body.read site.roles.where(temporal: false, rol: 'usuarie').pluck(:token).find do |token| new_signature = prepend + OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), token, payload) ActiveSupport::SecurityUtils.secure_compare(new_signature, signature) @@ -61,10 +61,10 @@ module Api end end - # encuentra le usuarie + # encuentra le usuarie def usuarie @usuarie ||= site.roles.find_by!(temporal: false, rol: 'usuarie', token: token).usuarie - end + end # respuesta de error a plataformas def platforms_answer(exception) @@ -73,4 +73,4 @@ module Api end end end -end \ No newline at end of file +end From 690efe329c571c0d8c601645735d186b7890a572 Mon Sep 17 00:00:00 2001 From: f Date: Wed, 16 Aug 2023 16:22:57 -0300 Subject: [PATCH 057/130] fix: llamar a los headers consistentemente --- app/controllers/api/v1/webhooks_controller.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/api/v1/webhooks_controller.rb b/app/controllers/api/v1/webhooks_controller.rb index fb4a710c..1d1258fd 100644 --- a/app/controllers/api/v1/webhooks_controller.rb +++ b/app/controllers/api/v1/webhooks_controller.rb @@ -37,11 +37,11 @@ module Api if request.headers['X-Gitlab-Token'] request.headers['X-Gitlab-Token'] # Github - elsif request.headers['X-HUB-SIGNATURE-256'] - token_from_signature(request.env['HTTP_X_HUB_SIGNATURE_256'], 'sha256=') + elsif request.headers['X-Hub-Signature-256'] + token_from_signature(request.headers['X_Hub_Signature_256'], 'sha256=') # Gitea - elsif request.headers['HTTP_X_GITEA_SIGNATURE'] - token_from_signature(request.env['HTTP_X_GITEA_SIGNATURE']) + elsif request.headers['X_Gitea_Signature'] + token_from_signature(request.headers['X_Gitea_Signature']) else raise ActiveRecord::RecordNotFound, 'proveedor no soportado' end From a99e03ce15d13122f36e2aab976fd5229156300e Mon Sep 17 00:00:00 2001 From: f Date: Wed, 16 Aug 2023 16:23:39 -0300 Subject: [PATCH 058/130] feat: enviar los headers en el reporte --- app/controllers/api/v1/webhooks_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/v1/webhooks_controller.rb b/app/controllers/api/v1/webhooks_controller.rb index 1d1258fd..6be6c2dc 100644 --- a/app/controllers/api/v1/webhooks_controller.rb +++ b/app/controllers/api/v1/webhooks_controller.rb @@ -68,8 +68,9 @@ module Api # respuesta de error a plataformas def platforms_answer(exception) + ExceptionNotifier.notify_exception(exception, env: request.env, data: { headers: request.headers.to_h }) + head :forbidden - ExceptionNotifier.notify_exception(exception, env: request.env) end end end From 42e6a0b6eb5432773d2337ed33ac154defd2c042 Mon Sep 17 00:00:00 2001 From: f Date: Wed, 16 Aug 2023 16:24:33 -0300 Subject: [PATCH 059/130] fix: typo --- app/controllers/api/v1/webhooks_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/api/v1/webhooks_controller.rb b/app/controllers/api/v1/webhooks_controller.rb index 6be6c2dc..ab2fce6b 100644 --- a/app/controllers/api/v1/webhooks_controller.rb +++ b/app/controllers/api/v1/webhooks_controller.rb @@ -51,7 +51,7 @@ module Api # valida token a partir de firma de webhook # # @return [String, Boolean] - def token_from_signature(signature. prepend = '') + def token_from_signature(signature, prepend = '') payload = request.body.read site.roles.where(temporal: false, rol: 'usuarie').pluck(:token).find do |token| new_signature = prepend + OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), token, payload) From b9083c492cd3e50971bbbca9a549b81c4781efe3 Mon Sep 17 00:00:00 2001 From: f Date: Wed, 16 Aug 2023 16:26:39 -0300 Subject: [PATCH 060/130] fix: presencia --- app/controllers/api/v1/webhooks_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/api/v1/webhooks_controller.rb b/app/controllers/api/v1/webhooks_controller.rb index ab2fce6b..23bfae22 100644 --- a/app/controllers/api/v1/webhooks_controller.rb +++ b/app/controllers/api/v1/webhooks_controller.rb @@ -34,13 +34,13 @@ module Api @token ||= begin # Gitlab - if request.headers['X-Gitlab-Token'] + if request.headers['X-Gitlab-Token'].present? request.headers['X-Gitlab-Token'] # Github - elsif request.headers['X-Hub-Signature-256'] + elsif request.headers['X-Hub-Signature-256'].present? token_from_signature(request.headers['X_Hub_Signature_256'], 'sha256=') # Gitea - elsif request.headers['X_Gitea_Signature'] + elsif request.headers['X_Gitea_Signature'].present? token_from_signature(request.headers['X_Gitea_Signature']) else raise ActiveRecord::RecordNotFound, 'proveedor no soportado' From a2678c3e81f7943368edf9a51e9de80354af603f Mon Sep 17 00:00:00 2001 From: f Date: Wed, 16 Aug 2023 16:35:36 -0300 Subject: [PATCH 061/130] fix: no ignorar excepciones como record not found --- config/environments/production.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/environments/production.rb b/config/environments/production.rb index 4cc1cb39..5e089ff9 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -142,7 +142,7 @@ Rails.application.configure do } config.action_mailer.default_options = { from: ENV.fetch('DEFAULT_FROM', "noreply@sutty.nl") } - config.middleware.use ExceptionNotification::Rack, gitlab: {}, ignore_exceptions: (['DeployJob::DeployAlreadyRunningException'] + ExceptionNotifier.ignored_exceptions) + config.middleware.use ExceptionNotification::Rack, gitlab: {}, ignore_exceptions: ['DeployJob::DeployAlreadyRunningException'] Rails.application.routes.default_url_options[:host] = "panel.#{ENV.fetch('SUTTY', 'sutty.nl')}" Rails.application.routes.default_url_options[:protocol] = 'https' From ef8ed271d75dd1e4bdf079c11f8bcaf450af25ac Mon Sep 17 00:00:00 2001 From: f Date: Wed, 16 Aug 2023 16:46:11 -0300 Subject: [PATCH 062/130] fix: consistencia al llamar a headers --- app/controllers/api/v1/webhooks_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/api/v1/webhooks_controller.rb b/app/controllers/api/v1/webhooks_controller.rb index 23bfae22..95439cd4 100644 --- a/app/controllers/api/v1/webhooks_controller.rb +++ b/app/controllers/api/v1/webhooks_controller.rb @@ -38,10 +38,10 @@ module Api request.headers['X-Gitlab-Token'] # Github elsif request.headers['X-Hub-Signature-256'].present? - token_from_signature(request.headers['X_Hub_Signature_256'], 'sha256=') + token_from_signature(request.headers['X-Hub-Signature-256'], 'sha256=') # Gitea - elsif request.headers['X_Gitea_Signature'].present? - token_from_signature(request.headers['X_Gitea_Signature']) + elsif request.headers['X-Gitea-Signature'].present? + token_from_signature(request.headers['X-Gitea-Signature']) else raise ActiveRecord::RecordNotFound, 'proveedor no soportado' end From 4a7ac981e5029ce8c23fa0c54c5ba99268dcb3ee Mon Sep 17 00:00:00 2001 From: f Date: Wed, 16 Aug 2023 17:04:34 -0300 Subject: [PATCH 063/130] fix: no fallar si la firma es nil closes #14089 --- app/controllers/api/v1/webhooks_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/api/v1/webhooks_controller.rb b/app/controllers/api/v1/webhooks_controller.rb index 95439cd4..1730034e 100644 --- a/app/controllers/api/v1/webhooks_controller.rb +++ b/app/controllers/api/v1/webhooks_controller.rb @@ -55,7 +55,7 @@ module Api payload = request.body.read site.roles.where(temporal: false, rol: 'usuarie').pluck(:token).find do |token| new_signature = prepend + OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), token, payload) - ActiveSupport::SecurityUtils.secure_compare(new_signature, signature) + ActiveSupport::SecurityUtils.secure_compare(new_signature, signature.to_s) end.tap do |t| raise ActiveRecord::RecordNotFound, 'token no encontrado' if t.nil? end From 6bae3a68f167956a7799d1252833ab2f7b0e694a Mon Sep 17 00:00:00 2001 From: f Date: Wed, 16 Aug 2023 17:35:20 -0300 Subject: [PATCH 064/130] feat: enviar cambios luego de commitearlos --- app/services/post_service.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/services/post_service.rb b/app/services/post_service.rb index 7b31867d..601915f8 100644 --- a/app/services/post_service.rb +++ b/app/services/post_service.rb @@ -96,6 +96,8 @@ PostService = Struct.new(:site, :usuarie, :post, :params, keyword_init: true) do remove: action == :destroyed, message: I18n.t("post_service.#{action}", title: post&.title&.value)) + + GitPushJob.perform_later(site) end # Solo permitir cambiar estos atributos de cada articulo From 5a004b1cad1734af695a37d92d4a271603b818f1 Mon Sep 17 00:00:00 2001 From: f Date: Wed, 16 Aug 2023 17:35:33 -0300 Subject: [PATCH 065/130] =?UTF-8?q?feat:=20enviar=20configuraci=C3=B3n=20l?= =?UTF-8?q?uego=20de=20comitearla?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/site_service.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/services/site_service.rb b/app/services/site_service.rb index 2c29538c..fc82ae84 100644 --- a/app/services/site_service.rb +++ b/app/services/site_service.rb @@ -97,6 +97,8 @@ SiteService = Struct.new(:site, :usuarie, :params, keyword_init: true) do file: site.config.path, message: I18n.t("site_service.#{action}", name: site.name)) + + GitPushJob.perform_later(site) end def add_role(temporal: true, rol: 'invitade') From 1be1977c343a6d6b6a9a379d9414872db9830f8b Mon Sep 17 00:00:00 2001 From: jazzari Date: Wed, 23 Aug 2023 14:13:25 -0300 Subject: [PATCH 066/130] fix: fix minima design's link to demostration site #14131 --- 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 a04c99c1..46f1cd0d 100644 --- a/db/seeds/designs.yml +++ b/db/seeds/designs.yml @@ -18,7 +18,7 @@ - name_en: 'Minima' name_es: 'Mínima' gem: 'sutty-minima' - url: 'https://0xacab.org/sutty/jekyll/minima' + url: 'https://minima.sutty.nl/' description_en: "Sutty Minima is based on [Minima](https://jekyll.github.io/minima/), a blog-focused theme for Jekyll." description_es: 'Sutty Mínima es una plantilla para blogs basada en [Mínima](https://jekyll.github.io/minima/).' license: 'https://0xacab.org/sutty/jekyll/minima/-/blob/master/LICENSE.txt' From c6c638fb60edf3d8f7a6eddbc7dab819b01e1d15 Mon Sep 17 00:00:00 2001 From: f Date: Tue, 29 Aug 2023 17:43:19 -0300 Subject: [PATCH 067/130] feat: almacenar la llave privada --- app/models/site.rb | 1 + app/models/site/social_distributed_press.rb | 12 ++++++++++++ ...204127_add_private_key_pem_ciphertext_to_sites.rb | 9 +++++++++ 3 files changed, 22 insertions(+) create mode 100644 app/models/site/social_distributed_press.rb create mode 100644 db/migrate/20230829204127_add_private_key_pem_ciphertext_to_sites.rb diff --git a/app/models/site.rb b/app/models/site.rb index 24644b9c..9ec21561 100644 --- a/app/models/site.rb +++ b/app/models/site.rb @@ -10,6 +10,7 @@ class Site < ApplicationRecord include Site::DeployDependencies include Site::BuildStats include Site::LayoutOrdering + include Site::SocialDistributedPress include Tienda # Cifrar la llave privada que cifra y decifra campos ocultos. Sutty diff --git a/app/models/site/social_distributed_press.rb b/app/models/site/social_distributed_press.rb new file mode 100644 index 00000000..9d283103 --- /dev/null +++ b/app/models/site/social_distributed_press.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +class Site + # Agrega soporte para Social Distributed Press en los sitios + module SocialDistributedPress + extend ActiveSupport::Concern + + included do + encrypts :private_key_pem + end + end +end diff --git a/db/migrate/20230829204127_add_private_key_pem_ciphertext_to_sites.rb b/db/migrate/20230829204127_add_private_key_pem_ciphertext_to_sites.rb new file mode 100644 index 00000000..9f26f21a --- /dev/null +++ b/db/migrate/20230829204127_add_private_key_pem_ciphertext_to_sites.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +# Almacena las llaves privadas de cada sitio +class AddPrivateKeyPemCiphertextToSites < ActiveRecord::Migration[6.1] + # Agrega la columna cifrada + def change + add_column :sites, :private_key_pem_ciphertext, :text + end +end From 4de3352950f700bd303d2f5e472f5045a06c1810 Mon Sep 17 00:00:00 2001 From: f Date: Tue, 29 Aug 2023 17:49:25 -0300 Subject: [PATCH 068/130] feat: generar la llave privada #14169 --- app/models/site/social_distributed_press.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/models/site/social_distributed_press.rb b/app/models/site/social_distributed_press.rb index 9d283103..5d469f03 100644 --- a/app/models/site/social_distributed_press.rb +++ b/app/models/site/social_distributed_press.rb @@ -7,6 +7,17 @@ class Site included do encrypts :private_key_pem + + before_save :generate_private_key_pem!, unless: :private_key_pem? + + private + + # Genera la llave privada y la almacena + # + # @return [nil] + def generate_private_key_pem! + self.private_key_pem ||= DistributedPress::V1::Social::Client.new(public_key_url: nil, key_size: 2048).private_key.export + end end end end From 8b0b0199f60ad67b733c781fbc3425d5f6546fba Mon Sep 17 00:00:00 2001 From: f Date: Tue, 29 Aug 2023 18:26:03 -0300 Subject: [PATCH 069/130] feat: correr un comando obteniendo la llave dentro de un archivo temporal --- app/models/deploy.rb | 15 +++++++++++++++ app/models/deploy_local.rb | 6 +++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/app/models/deploy.rb b/app/models/deploy.rb index a92708c0..77e5b8d8 100644 --- a/app/models/deploy.rb +++ b/app/models/deploy.rb @@ -109,6 +109,21 @@ class Deploy < ApplicationRecord private + # Escribe el contenido en un archivo temporal y ejecuta el bloque + # provisto con el archivo como parámetro + # + # @param :content [String] + def with_tempfile(content, &block) + Tempfile.create(SecureRandom.hex) do |file| + file.write content.to_s + file.rewind + file.close + + # @yieldparam :file [File] + yield file + end + end + # @param [String] # @return [String] def readable_cmd(cmd) diff --git a/app/models/deploy_local.rb b/app/models/deploy_local.rb index 75ea8b1c..e66bb003 100644 --- a/app/models/deploy_local.rb +++ b/app/models/deploy_local.rb @@ -141,8 +141,12 @@ class DeployLocal < Deploy run %(bundle install --deployment --no-cache --path="#{gems_dir}" --clean --without test development), output: output end + # TODO: Esto significa que todos los sitios van a tener activity pub + # activado def jekyll_build(output: false) - run %(bundle exec jekyll build --trace --profile --destination "#{escaped_destination}"), output: output + with_tempfile(site.private_key_pem) do |file| + run %(bundle exec jekyll build --trace --profile --key #{file.path} --destination "#{escaped_destination}"), output: output + end end # no debería haber espacios ni caracteres especiales, pero por si From 9ac404ae06286e69e8981c5322c2a9256ff04f99 Mon Sep 17 00:00:00 2001 From: f Date: Wed, 30 Aug 2023 10:47:08 -0300 Subject: [PATCH 070/130] feat: habilitar/deshabilitar activity pub --- .../_deploy_social_distributed_press.haml | 21 +++++++++++++++++++ config/locales/en.yml | 12 +++++++++++ config/locales/es.yml | 12 +++++++++++ 3 files changed, 45 insertions(+) create mode 100644 app/views/deploys/_deploy_social_distributed_press.haml diff --git a/app/views/deploys/_deploy_social_distributed_press.haml b/app/views/deploys/_deploy_social_distributed_press.haml new file mode 100644 index 00000000..5c73b262 --- /dev/null +++ b/app/views/deploys/_deploy_social_distributed_press.haml @@ -0,0 +1,21 @@ +-# Publicar a la web distribuida + +.row + .col + = deploy.hidden_field :id + = deploy.hidden_field :type + .custom-control.custom-switch + -# + El checkbox invierte la lógica de destrucción porque queremos + crear el deploy si está activado y destruirlo si está + desactivado. + = deploy.check_box :_destroy, + { checked: deploy.object.persisted?, class: 'custom-control-input' }, + '0', '1' + = deploy.label :_destroy, class: 'custom-control-label' do + %h3= t('.title') + = sanitize_markdown t('.help'), + tags: %w[p strong em a] + + +%hr/ diff --git a/config/locales/en.yml b/config/locales/en.yml index 5f97a8b9..0dad2e68 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -123,6 +123,10 @@ en: title: Distributed Web success: Success! error: Error + deploy_social_distributed_press: + title: Fediverse + success: Success! + error: Error deploy_reindex: title: Reindex success: Success! @@ -307,6 +311,14 @@ en: indefinitely. [Learn more](https://sutty.nl/learn-more-about-publish-to-dweb-functionality/) + deploy_social_distributed_press: + title: 'Publish on the Fediverse' + help: | + By using the ActivityPub protocol, people on the Fediverse + ([Mastodon](https://joinmastodon.org/servers), + [Pixelfed](https://pixelfed.social/site/about), and + [others](https://fediverse.party/)) can follow your site, + receive news and interact with them. stats: index: title: Statistics diff --git a/config/locales/es.yml b/config/locales/es.yml index 9e0b8945..d899b99c 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -123,6 +123,10 @@ es: title: Web distribuida success: ¡Éxito! error: Hubo un error + deploy_social_distributed_press: + title: Fediverso + success: ¡Éxito! + error: Hubo un error deploy_reindex: title: Reindexación success: ¡Éxito! @@ -312,6 +316,14 @@ es: copias de tu contenido indefinidamente. [Saber más](https://sutty.nl/saber-mas-sobre-publicar-a-la-web-distribuida/) + deploy_social_distributed_press: + title: 'Publicar al Fediverso' + help: | + Utilizando el protocolo ActivityPub, otras personas en el + Fediverso ([Mastodon](https://joinmastodon.org/servers), + [Pixelfed](https://pixelfed.social/site/about) y + [otros](https://fediverse.party/)) pueden seguir a tu sitio, + recibir novedades e interactuar con ellas. stats: index: title: Estadísticas From f019805314735c813847043fadf051961ad5837a Mon Sep 17 00:00:00 2001 From: f Date: Wed, 30 Aug 2023 10:47:27 -0300 Subject: [PATCH 071/130] =?UTF-8?q?fix:=20generar=20todos=20los=20deploys?= =?UTF-8?q?=20autom=C3=A1ticamente?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/site.rb | 4 ---- app/services/site_service.rb | 5 ++--- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/app/models/site.rb b/app/models/site.rb index 9ec21561..961831d5 100644 --- a/app/models/site.rb +++ b/app/models/site.rb @@ -19,10 +19,6 @@ class Site < ApplicationRecord # protege de acceso al panel de Sutty! encrypts :private_key - # TODO: Hacer que los diferentes tipos de deploy se auto registren - # @see app/services/site_service.rb - DEPLOYS = %i[local private www zip hidden_service distributed_press].freeze - validates :name, uniqueness: true, hostname: { allow_root_label: true } diff --git a/app/services/site_service.rb b/app/services/site_service.rb index b1df3d10..5bd89888 100644 --- a/app/services/site_service.rb +++ b/app/services/site_service.rb @@ -54,9 +54,8 @@ SiteService = Struct.new(:site, :usuarie, :params, keyword_init: true) do # Genera los Deploy necesarios para el sitio a menos que ya los tenga. def build_deploys - Site::DEPLOYS.map { |deploy| "Deploy#{deploy.to_s.camelcase}" } - .each do |deploy| - next if site.deploys.find_by type: deploy + Deploy.subclasses.each do |deploy| + next if site.deploys.find_by type: deploy.name site.deploys.build type: deploy end From 4ade0944def7484ddcbee854c63ed184067b0f1c Mon Sep 17 00:00:00 2001 From: f Date: Wed, 30 Aug 2023 10:58:52 -0300 Subject: [PATCH 072/130] =?UTF-8?q?feat:=20los=20deploys=20pueden=20pasar?= =?UTF-8?q?=20opciones=20de=20compilaci=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/deploy.rb | 5 ++++ app/models/deploy_local.rb | 16 ++++++++++--- app/models/deploy_social_distributed_press.rb | 24 +++++++++++++++++++ 3 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 app/models/deploy_social_distributed_press.rb diff --git a/app/models/deploy.rb b/app/models/deploy.rb index 77e5b8d8..abf5591f 100644 --- a/app/models/deploy.rb +++ b/app/models/deploy.rb @@ -100,6 +100,11 @@ class Deploy < ApplicationRecord @local_env ||= {} end + # Devuelve opciones para jekyll build + # + # @return [String,nil] + def flags_for_build(**args); end + # Trae todas las dependencias # # @return [Array] diff --git a/app/models/deploy_local.rb b/app/models/deploy_local.rb index e66bb003..9228581f 100644 --- a/app/models/deploy_local.rb +++ b/app/models/deploy_local.rb @@ -141,11 +141,11 @@ class DeployLocal < Deploy run %(bundle install --deployment --no-cache --path="#{gems_dir}" --clean --without test development), output: output end - # TODO: Esto significa que todos los sitios van a tener activity pub - # activado def jekyll_build(output: false) with_tempfile(site.private_key_pem) do |file| - run %(bundle exec jekyll build --trace --profile --key #{file.path} --destination "#{escaped_destination}"), output: output + flags = extra_flags(private_key: file) + + run %(bundle exec jekyll build --trace --profile #{flags} --destination "#{escaped_destination}"), output: output end end @@ -173,4 +173,14 @@ class DeployLocal < Deploy end end end + + # Genera opciones extra desde los otros deploys + # + # @param :args [Hash] + # @return [String] + def extra_flags(**args) + non_local_deploys.map do |deploy| + deploy.flags_for_build(**args) + end.compact.join(' ') + end end diff --git a/app/models/deploy_social_distributed_press.rb b/app/models/deploy_social_distributed_press.rb new file mode 100644 index 00000000..47464ea9 --- /dev/null +++ b/app/models/deploy_social_distributed_press.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +require 'distributed_press/v1/social/client' + +# Publicar novedades al Fediverso +class DeploySocialDistributedPress < Deploy + # Solo luego de publicar remotamente + DEPENDENCIES = %i[deploy_distributed_press deploy_rsync deploy_full_rsync] + + # Envía las notificaciones + def deploy(output: false) + with_tempfile(site.private_key_pem) do |file| + run %(bundle exec jekyll notify --trace --key #{file.path} --destination "#{escaped_destination}"), output: output + end + end + + # Genera la opción de llave privada para jekyll build + # + # @params :args [Hash] + # @return [String] + def flags_for_build(**args) + "--key #{Shellwords.escape args[:private_key].path}" + end +end From 26f57a8467241e825b87fefcccdf76c4e9c3561d Mon Sep 17 00:00:00 2001 From: f Date: Wed, 30 Aug 2023 11:09:08 -0300 Subject: [PATCH 073/130] =?UTF-8?q?feat:=20m=C3=A9todos=20de=20deploy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/deploy_social_distributed_press.rb | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/app/models/deploy_social_distributed_press.rb b/app/models/deploy_social_distributed_press.rb index 47464ea9..db555ab7 100644 --- a/app/models/deploy_social_distributed_press.rb +++ b/app/models/deploy_social_distributed_press.rb @@ -10,10 +10,41 @@ class DeploySocialDistributedPress < Deploy # Envía las notificaciones def deploy(output: false) with_tempfile(site.private_key_pem) do |file| - run %(bundle exec jekyll notify --trace --key #{file.path} --destination "#{escaped_destination}"), output: output + key = Shellwords.escape file.path + dest = Shellwords.escape destination + + run %(bundle exec jekyll notify --trace --key #{key} --destination "#{dest}"), output: output end end + # Igual que DeployLocal + # + # @return [String] + def destination + File.join(Rails.root, '_deploy', site.hostname) + end + + # Solo uno + # + # @return [Integer] + def limit + 1 + end + + # Espacio ocupado, pero no podemos calcularlo + # + # @return [Integer] + def size + 0 + end + + # El perfil de actor + # + # @return [String,nil] + def url + site.data.dig('activity_pub', 'actor') + end + # Genera la opción de llave privada para jekyll build # # @params :args [Hash] From 2a4073178a7b431e6f1ea1b7798fcfc1d7b8a10b Mon Sep 17 00:00:00 2001 From: f Date: Wed, 30 Aug 2023 11:13:49 -0300 Subject: [PATCH 074/130] fix: actualizar la gema --- Gemfile | 2 +- Gemfile.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index dd880219..5ccee727 100644 --- a/Gemfile +++ b/Gemfile @@ -39,7 +39,7 @@ gem 'commonmarker' gem 'devise' gem 'devise-i18n' gem 'devise_invitable' -gem 'distributed-press-api-client', '~> 0.2.3' +gem 'distributed-press-api-client', '~> 0.3.0rc0' gem 'njalla-api-client', '~> 0.2.0' gem 'email_address', git: 'https://github.com/fauno/email_address', branch: 'i18n' gem 'exception_notification' diff --git a/Gemfile.lock b/Gemfile.lock index f71053d7..6c3dae96 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -153,7 +153,7 @@ GEM devise_invitable (2.0.8) actionmailer (>= 5.0) devise (>= 4.6) - distributed-press-api-client (0.2.4) + distributed-press-api-client (0.3.0rc0) addressable (~> 2.3, >= 2.3.0) climate_control dry-schema @@ -595,7 +595,7 @@ DEPENDENCIES devise devise-i18n devise_invitable - distributed-press-api-client (~> 0.2.3) + distributed-press-api-client (~> 0.3.0rc0) dotenv-rails down ed25519 From c9866a0eecfca61d5c3136ffa412045687728dc3 Mon Sep 17 00:00:00 2001 From: f Date: Wed, 30 Aug 2023 15:33:48 -0300 Subject: [PATCH 075/130] =?UTF-8?q?fix:=20mover=20m=C3=A9todos=20a=20deplo?= =?UTF-8?q?y?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/deploy.rb | 36 ++++++++++++++++++++++++++++++++++++ app/models/deploy_local.rb | 36 ------------------------------------ 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/app/models/deploy.rb b/app/models/deploy.rb index abf5591f..c01a378f 100644 --- a/app/models/deploy.rb +++ b/app/models/deploy.rb @@ -55,6 +55,28 @@ class Deploy < ApplicationRecord @gems_dir ||= Rails.root.join('_storage', 'gems', site.name) end + # Un entorno que solo tiene lo que necesitamos + # + # @return [Hash] + def env + # XXX: This doesn't support Windows paths :B + paths = [File.dirname(`which bundle`), '/usr/local/bin', '/usr/bin', '/bin'] + + # Las variables de entorno extra no pueden superponerse al local. + extra_env.merge({ + 'HOME' => home_dir, + 'PATH' => paths.join(':'), + 'SPREE_API_KEY' => site.tienda_api_key, + 'SPREE_URL' => site.tienda_url, + 'AIRBRAKE_PROJECT_ID' => site.id.to_s, + 'AIRBRAKE_PROJECT_KEY' => site.airbrake_api_key, + 'JEKYLL_ENV' => Rails.env, + 'LANG' => ENV['LANG'], + 'YARN_CACHE_FOLDER' => yarn_cache_dir, + 'GEMS_SOURCE' => ENV['GEMS_SOURCE'] + }) + end + # Corre un comando, lo registra en la base de datos y devuelve el # estado. # @@ -142,4 +164,18 @@ class Deploy < ApplicationRecord def non_local_deploys @non_local_deploys ||= site.deploys.where.not(type: 'DeployLocal') end + + # Consigue todas las variables de entorno configuradas por otros + # deploys. + # + # @deprecated Solo tenía sentido para Distributed Press v0 + # @return [Hash] + def extra_env + @extra_env ||= + non_local_deploys.reduce({}) do |extra_env, deploy| + extra_env.tap do |e| + e.merge! deploy.local_env + end + end + end end diff --git a/app/models/deploy_local.rb b/app/models/deploy_local.rb index 9228581f..edf85bf5 100644 --- a/app/models/deploy_local.rb +++ b/app/models/deploy_local.rb @@ -68,28 +68,6 @@ class DeployLocal < Deploy FileUtils.mkdir_p destination end - # Un entorno que solo tiene lo que necesitamos - # - # @return [Hash] - def env - # XXX: This doesn't support Windows paths :B - paths = [File.dirname(`which bundle`), '/usr/local/bin', '/usr/bin', '/bin'] - - # Las variables de entorno extra no pueden superponerse al local. - extra_env.merge({ - 'HOME' => home_dir, - 'PATH' => paths.join(':'), - 'SPREE_API_KEY' => site.tienda_api_key, - 'SPREE_URL' => site.tienda_url, - 'AIRBRAKE_PROJECT_ID' => site.id.to_s, - 'AIRBRAKE_PROJECT_KEY' => site.airbrake_api_key, - 'JEKYLL_ENV' => Rails.env, - 'LANG' => ENV['LANG'], - 'YARN_CACHE_FOLDER' => yarn_cache_dir, - 'GEMS_SOURCE' => ENV['GEMS_SOURCE'] - }) - end - def yarn_cache_dir Rails.root.join('_yarn_cache').to_s end @@ -160,20 +138,6 @@ class DeployLocal < Deploy FileUtils.rm_rf destination end - # Consigue todas las variables de entorno configuradas por otros - # deploys. - # - # @deprecated Solo tenía sentido para Distributed Press v0 - # @return [Hash] - def extra_env - @extra_env ||= - non_local_deploys.reduce({}) do |extra_env, deploy| - extra_env.tap do |e| - e.merge! deploy.local_env - end - end - end - # Genera opciones extra desde los otros deploys # # @param :args [Hash] From f337e4967b1ac422062b696a8fc705f9f49d9e34 Mon Sep 17 00:00:00 2001 From: f Date: Wed, 30 Aug 2023 16:40:33 -0300 Subject: [PATCH 076/130] fix: recolectar variables de entorno --- app/models/deploy.rb | 17 ++--------------- app/models/deploy_local.rb | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/app/models/deploy.rb b/app/models/deploy.rb index c01a378f..55ec46f6 100644 --- a/app/models/deploy.rb +++ b/app/models/deploy.rb @@ -66,14 +66,8 @@ class Deploy < ApplicationRecord extra_env.merge({ 'HOME' => home_dir, 'PATH' => paths.join(':'), - 'SPREE_API_KEY' => site.tienda_api_key, - 'SPREE_URL' => site.tienda_url, - 'AIRBRAKE_PROJECT_ID' => site.id.to_s, - 'AIRBRAKE_PROJECT_KEY' => site.airbrake_api_key, 'JEKYLL_ENV' => Rails.env, 'LANG' => ENV['LANG'], - 'YARN_CACHE_FOLDER' => yarn_cache_dir, - 'GEMS_SOURCE' => ENV['GEMS_SOURCE'] }) end @@ -161,21 +155,14 @@ class Deploy < ApplicationRecord @deploy_local ||= site.deploys.find_by(type: 'DeployLocal') end - def non_local_deploys - @non_local_deploys ||= site.deploys.where.not(type: 'DeployLocal') - end - # Consigue todas las variables de entorno configuradas por otros # deploys. # - # @deprecated Solo tenía sentido para Distributed Press v0 # @return [Hash] def extra_env @extra_env ||= - non_local_deploys.reduce({}) do |extra_env, deploy| - extra_env.tap do |e| - e.merge! deploy.local_env - end + site.deployment_list.reduce({}) do |extra, deploy| + extra.merge deploy.local_env end end end diff --git a/app/models/deploy_local.rb b/app/models/deploy_local.rb index edf85bf5..0bb3958f 100644 --- a/app/models/deploy_local.rb +++ b/app/models/deploy_local.rb @@ -62,6 +62,20 @@ class DeployLocal < Deploy FileUtils.rm_rf(File.join(site.path, '.jekyll-cache')) end + # Opciones necesarias para la compilación del sitio + # + # @return [Hash] + def local_env + @local_env ||= { + 'SPREE_API_KEY' => site.tienda_api_key, + 'SPREE_URL' => site.tienda_url, + 'AIRBRAKE_PROJECT_ID' => site.id.to_s, + 'AIRBRAKE_PROJECT_KEY' => site.airbrake_api_key, + 'YARN_CACHE_FOLDER' => yarn_cache_dir, + 'GEMS_SOURCE' => ENV['GEMS_SOURCE'] + } + end + private def mkdir @@ -143,7 +157,7 @@ class DeployLocal < Deploy # @param :args [Hash] # @return [String] def extra_flags(**args) - non_local_deploys.map do |deploy| + site.deployment_list.map do |deploy| deploy.flags_for_build(**args) end.compact.join(' ') end From cd7c21792063c815adb4886540d6a64fe9c0ecf3 Mon Sep 17 00:00:00 2001 From: f Date: Wed, 30 Aug 2023 17:17:04 -0300 Subject: [PATCH 077/130] fix: poder asignar valor por defecto a los campos boolean --- app/models/metadata_boolean.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/models/metadata_boolean.rb b/app/models/metadata_boolean.rb index 90c002a7..9932c6fd 100644 --- a/app/models/metadata_boolean.rb +++ b/app/models/metadata_boolean.rb @@ -4,8 +4,12 @@ # # Esto es increíblemente difícil de lograr que salga bien! class MetadataBoolean < MetadataTemplate + # El valor por defecto es una versión booleana de lo que diga (o no + # diga) el esquema + # + # @return [Boolean] def default_value - false + !!super end # Los checkboxes son especiales porque la especificación de HTML From d8e21c97e2efcc6ffbfdc294119545b58b538cd0 Mon Sep 17 00:00:00 2001 From: f Date: Thu, 31 Aug 2023 14:41:34 -0300 Subject: [PATCH 078/130] fix: solo vincular urls que tienen protocolo --- app/controllers/build_stats_controller.rb | 7 ++++++- app/jobs/deploy_job.rb | 6 +++++- app/mailers/deploy_mailer.rb | 2 +- app/views/build_stats/index.haml | 2 +- app/views/deploy_mailer/deployed.html.haml | 2 +- 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/app/controllers/build_stats_controller.rb b/app/controllers/build_stats_controller.rb index 31a4c5d6..6961cf45 100644 --- a/app/controllers/build_stats_controller.rb +++ b/app/controllers/build_stats_controller.rb @@ -22,7 +22,12 @@ class BuildStatsController < ApplicationController @table = site.deployment_list.map do |deploy| type = deploy.class.name.underscore - urls = deploy.respond_to?(:urls) ? deploy.urls : [deploy.url].compact + urls = (deploy.respond_to?(:urls) ? deploy.urls : [deploy.url].compact).map do |url| + URI.parse(url) + rescue URI::Error + nil + end.compact + urls = [nil] if urls.empty? build_stat = deploy.build_stats.where(status: true).last seconds = build_stat&.seconds || 0 diff --git a/app/jobs/deploy_job.rb b/app/jobs/deploy_job.rb index a5cda360..6f486f29 100644 --- a/app/jobs/deploy_job.rb +++ b/app/jobs/deploy_job.rb @@ -51,7 +51,11 @@ class DeployJob < ApplicationJob status = d.deploy(output: @output) seconds = d.build_stats.last.try(:seconds) || 0 size = d.size - urls = d.respond_to?(:urls) ? d.urls : [d.url].compact + urls = (d.respond_to?(:urls) ? d.urls : [d.url].compact).map do |url| + URI.parse url + rescue URI::Error + nil + end.compact rescue StandardError => e status = false seconds ||= 0 diff --git a/app/mailers/deploy_mailer.rb b/app/mailers/deploy_mailer.rb index b7b464cb..37748b42 100644 --- a/app/mailers/deploy_mailer.rb +++ b/app/mailers/deploy_mailer.rb @@ -52,7 +52,7 @@ class DeployMailer < ApplicationMailer t << (row.map do |k, v| case k when :seconds then v[:human] - when :urls then url + when :urls then url.to_s else v end end) diff --git a/app/views/build_stats/index.haml b/app/views/build_stats/index.haml index 27c063f9..0b0e7755 100644 --- a/app/views/build_stats/index.haml +++ b/app/views/build_stats/index.haml @@ -14,7 +14,7 @@ - row[:urls].each do |url| %tr %th{ scope: 'row' }= row[:title] - %td= link_to_if url.present?, url, url, class: 'word-break-all' + %td= link_to_if (url.present? && uri.scheme.present?), url.to_s, url.to_s, class: 'word-break-all' %td %time{ datetime: row[:seconds][:machine] }= row[:seconds][:human] %td= row[:size] diff --git a/app/views/deploy_mailer/deployed.html.haml b/app/views/deploy_mailer/deployed.html.haml index f5afe5de..b3463db6 100644 --- a/app/views/deploy_mailer/deployed.html.haml +++ b/app/views/deploy_mailer/deployed.html.haml @@ -13,7 +13,7 @@ %tr %td= row[:title] %td= row[:status] - %td= link_to_if url.present?, url, url + %td= link_to_if (url.present? && uri.scheme.present?), url.to_s, url.to_s %td %time{ datetime: row[:seconds][:machine] }= row[:seconds][:human] %td= row[:size] From f076838be5137821ca2a2ca18f9e89c53047ea5f Mon Sep 17 00:00:00 2001 From: f Date: Thu, 31 Aug 2023 14:47:44 -0300 Subject: [PATCH 079/130] fixup! fix: solo vincular urls que tienen protocolo --- app/jobs/deploy_job.rb | 2 +- app/views/deploy_mailer/deployed.html.haml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/jobs/deploy_job.rb b/app/jobs/deploy_job.rb index 6f486f29..00ae7585 100644 --- a/app/jobs/deploy_job.rb +++ b/app/jobs/deploy_job.rb @@ -70,7 +70,7 @@ class DeployJob < ApplicationJob status: status, seconds: seconds, size: size, - urls: urls + urls: urls.map(&:to_s) } end diff --git a/app/views/deploy_mailer/deployed.html.haml b/app/views/deploy_mailer/deployed.html.haml index b3463db6..762bf4db 100644 --- a/app/views/deploy_mailer/deployed.html.haml +++ b/app/views/deploy_mailer/deployed.html.haml @@ -13,7 +13,7 @@ %tr %td= row[:title] %td= row[:status] - %td= link_to_if (url.present? && uri.scheme.present?), url.to_s, url.to_s + %td= link_to_if (url.present? && url.scheme.present?), url.to_s, url.to_s %td %time{ datetime: row[:seconds][:machine] }= row[:seconds][:human] %td= row[:size] From a6195fbcccf80e47245429228f6631b9139aced4 Mon Sep 17 00:00:00 2001 From: f Date: Thu, 31 Aug 2023 14:52:49 -0300 Subject: [PATCH 080/130] fix: simplificar --- app/controllers/build_stats_controller.rb | 2 +- app/jobs/deploy_job.rb | 2 +- app/models/deploy.rb | 5 +++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/controllers/build_stats_controller.rb b/app/controllers/build_stats_controller.rb index 6961cf45..339f17f0 100644 --- a/app/controllers/build_stats_controller.rb +++ b/app/controllers/build_stats_controller.rb @@ -22,7 +22,7 @@ class BuildStatsController < ApplicationController @table = site.deployment_list.map do |deploy| type = deploy.class.name.underscore - urls = (deploy.respond_to?(:urls) ? deploy.urls : [deploy.url].compact).map do |url| + urls = deploy.urls.map do |url| URI.parse(url) rescue URI::Error nil diff --git a/app/jobs/deploy_job.rb b/app/jobs/deploy_job.rb index 00ae7585..0870b827 100644 --- a/app/jobs/deploy_job.rb +++ b/app/jobs/deploy_job.rb @@ -51,7 +51,7 @@ class DeployJob < ApplicationJob status = d.deploy(output: @output) seconds = d.build_stats.last.try(:seconds) || 0 size = d.size - urls = (d.respond_to?(:urls) ? d.urls : [d.url].compact).map do |url| + urls = d.urls.map do |url| URI.parse url rescue URI::Error nil diff --git a/app/models/deploy.rb b/app/models/deploy.rb index 55ec46f6..811047f1 100644 --- a/app/models/deploy.rb +++ b/app/models/deploy.rb @@ -23,6 +23,11 @@ class Deploy < ApplicationRecord raise NotImplementedError end + # @return [Array] + def urls + [url].compact + end + def limit raise NotImplementedError end From 927f92d985e7b1af86424cb332e48f900d988a83 Mon Sep 17 00:00:00 2001 From: f Date: Thu, 31 Aug 2023 14:56:00 -0300 Subject: [PATCH 081/130] fix: typo --- app/views/build_stats/index.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/build_stats/index.haml b/app/views/build_stats/index.haml index 0b0e7755..de04d84d 100644 --- a/app/views/build_stats/index.haml +++ b/app/views/build_stats/index.haml @@ -14,7 +14,7 @@ - row[:urls].each do |url| %tr %th{ scope: 'row' }= row[:title] - %td= link_to_if (url.present? && uri.scheme.present?), url.to_s, url.to_s, class: 'word-break-all' + %td= link_to_if (url.present? && url.scheme.present?), url.to_s, url.to_s, class: 'word-break-all' %td %time{ datetime: row[:seconds][:machine] }= row[:seconds][:human] %td= row[:size] From 3dedd84db78512e017706cd90610318c677879d4 Mon Sep 17 00:00:00 2001 From: f Date: Thu, 31 Aug 2023 14:58:16 -0300 Subject: [PATCH 082/130] fix: enviar urls parseadas --- app/jobs/deploy_job.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/jobs/deploy_job.rb b/app/jobs/deploy_job.rb index 0870b827..291991c7 100644 --- a/app/jobs/deploy_job.rb +++ b/app/jobs/deploy_job.rb @@ -70,7 +70,7 @@ class DeployJob < ApplicationJob status: status, seconds: seconds, size: size, - urls: urls.map(&:to_s) + urls: urls } end From 6aa0f7d6cf6a54f4f0cee94d27d3c8206a849c86 Mon Sep 17 00:00:00 2001 From: f Date: Fri, 1 Sep 2023 20:11:46 -0300 Subject: [PATCH 083/130] =?UTF-8?q?feat:=20guardar=20la=20fecha=20de=20cre?= =?UTF-8?q?aci=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/post.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/post.rb b/app/models/post.rb index 5cc1c5ea..6265a313 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -267,6 +267,7 @@ class Post # Y que no se procese liquid yaml['liquid'] = false yaml['usuaries'] = usuaries.map(&:id).uniq + yaml['created_at'] ||= Time.now yaml['last_modified_at'] = modified_at "#{yaml.to_yaml}---\n\n#{body}" From 10d958e50aed0f92dfae7140bde7650d371b1d22 Mon Sep 17 00:00:00 2001 From: f Date: Mon, 4 Sep 2023 12:44:57 -0300 Subject: [PATCH 084/130] =?UTF-8?q?fix:=20compartir=20la=20misma=20fecha?= =?UTF-8?q?=20de=20creaci=C3=B3n=20y=20de=20actualizaci=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/post.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/post.rb b/app/models/post.rb index 6265a313..f31c33b6 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -267,7 +267,7 @@ class Post # Y que no se procese liquid yaml['liquid'] = false yaml['usuaries'] = usuaries.map(&:id).uniq - yaml['created_at'] ||= Time.now + yaml['created_at'] ||= modified_at yaml['last_modified_at'] = modified_at "#{yaml.to_yaml}---\n\n#{body}" From 8ae5dd597501d81d4e266bedbbf62edbe7778761 Mon Sep 17 00:00:00 2001 From: f Date: Tue, 12 Sep 2023 14:49:17 -0300 Subject: [PATCH 085/130] fix: no compartir la misma instancia sutty/jekyll/jekyll-activitypub#42 --- app/models/post.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/post.rb b/app/models/post.rb index f31c33b6..36a0b02e 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -267,7 +267,7 @@ class Post # Y que no se procese liquid yaml['liquid'] = false yaml['usuaries'] = usuaries.map(&:id).uniq - yaml['created_at'] ||= modified_at + yaml['created_at'] ||= modified_at.dup yaml['last_modified_at'] = modified_at "#{yaml.to_yaml}---\n\n#{body}" From 6b1eccade35aec862160950549123f59be7d1fe7 Mon Sep 17 00:00:00 2001 From: f Date: Wed, 13 Sep 2023 17:52:21 -0300 Subject: [PATCH 086/130] =?UTF-8?q?feat:=20fecha=20de=20creaci=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/metadata_created_at.rb | 14 ++++++++++++++ app/models/post.rb | 8 ++++++-- app/views/posts/attribute_ro/_created_at.haml | 4 ++++ app/views/posts/attributes/_created_at.haml | 1 + config/locales/en.yml | 2 ++ config/locales/es.yml | 2 ++ 6 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 app/models/metadata_created_at.rb create mode 100644 app/views/posts/attribute_ro/_created_at.haml create mode 100644 app/views/posts/attributes/_created_at.haml diff --git a/app/models/metadata_created_at.rb b/app/models/metadata_created_at.rb new file mode 100644 index 00000000..2a7c07ed --- /dev/null +++ b/app/models/metadata_created_at.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +# Fecha y hora de creación +class MetadataCreatedAt < MetadataTemplate + # Por defecto la hora actual + def default_value + Time.now + end + + # Nunca cambia + def value=(new_value) + value + end +end diff --git a/app/models/post.rb b/app/models/post.rb index 36a0b02e..8bd5dab3 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -12,7 +12,7 @@ class Post DEFAULT_ATTRIBUTES = %i[site document layout].freeze # Otros atributos que no vienen en los metadatos PRIVATE_ATTRIBUTES = %i[path slug attributes errors].freeze - PUBLIC_ATTRIBUTES = %i[lang date uuid].freeze + PUBLIC_ATTRIBUTES = %i[lang date uuid created_at].freeze ATTR_SUFFIXES = %w[? =].freeze attr_reader :attributes, :errors, :layout, :site, :document @@ -217,6 +217,11 @@ class Post post: self, required: true) end + # La fecha de creación inmodificable del post + def created_at + @metadata[:created_at] ||= MetadataCreatedAt.new(document: document, site: site, layout: layout, name: :created_at, type: :timestamp, post: self, required: true) + end + # Detecta si es un atributo válido o no, a partir de la tabla de la # plantilla def attribute?(mid) @@ -267,7 +272,6 @@ class Post # Y que no se procese liquid yaml['liquid'] = false yaml['usuaries'] = usuaries.map(&:id).uniq - yaml['created_at'] ||= modified_at.dup yaml['last_modified_at'] = modified_at "#{yaml.to_yaml}---\n\n#{body}" diff --git a/app/views/posts/attribute_ro/_created_at.haml b/app/views/posts/attribute_ro/_created_at.haml new file mode 100644 index 00000000..04f6d716 --- /dev/null +++ b/app/views/posts/attribute_ro/_created_at.haml @@ -0,0 +1,4 @@ +%tr{ id: attribute } + %th= post_label_t(attribute, post: post) + %td{ dir: dir, lang: locale } + %time{ datetime: metadata.value.xmlschema }= l metadata.value diff --git a/app/views/posts/attributes/_created_at.haml b/app/views/posts/attributes/_created_at.haml new file mode 100644 index 00000000..0aab9802 --- /dev/null +++ b/app/views/posts/attributes/_created_at.haml @@ -0,0 +1 @@ +-# nada diff --git a/config/locales/en.yml b/config/locales/en.yml index 0dad2e68..5c00701c 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -524,6 +524,8 @@ en: feedback: 'This field cannot be empty!' uuid: label: 'Unique identifier' + created_at: + label: 'Created at' geo: uri: 'Open in app' osm: 'Open in web map' diff --git a/config/locales/es.yml b/config/locales/es.yml index d899b99c..0ff7e1c8 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -532,6 +532,8 @@ es: feedback: '¡Este campo no puede estar vacío!' uuid: label: 'Identificador único' + created_at: + label: 'Fecha de creación' geo: uri: 'Abrir en aplicación' osm: 'Abrir en mapa web' From 35e8a087163683c77de16fd398006d8b71c5bec8 Mon Sep 17 00:00:00 2001 From: f Date: Wed, 13 Sep 2023 17:53:51 -0300 Subject: [PATCH 087/130] =?UTF-8?q?fixup!=20feat:=20fecha=20de=20creaci?= =?UTF-8?q?=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/post.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/post.rb b/app/models/post.rb index 8bd5dab3..73785cad 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -219,7 +219,7 @@ class Post # La fecha de creación inmodificable del post def created_at - @metadata[:created_at] ||= MetadataCreatedAt.new(document: document, site: site, layout: layout, name: :created_at, type: :timestamp, post: self, required: true) + @metadata[:created_at] ||= MetadataCreatedAt.new(document: document, site: site, layout: layout, name: :created_at, type: :created_at, post: self, required: true) end # Detecta si es un atributo válido o no, a partir de la tabla de la From d27717ed3b7a21413361e86030ef59f4c3b84b3c Mon Sep 17 00:00:00 2001 From: f Date: Wed, 13 Sep 2023 17:59:50 -0300 Subject: [PATCH 088/130] fix: agregar created_at al front matter --- app/models/post.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/post.rb b/app/models/post.rb index 73785cad..fab9ab06 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -272,6 +272,7 @@ class Post # Y que no se procese liquid yaml['liquid'] = false yaml['usuaries'] = usuaries.map(&:id).uniq + yaml['created_at'] = created_at.value yaml['last_modified_at'] = modified_at "#{yaml.to_yaml}---\n\n#{body}" From 99c919e5e6cfca0e6affcd138da52a0565b6fd32 Mon Sep 17 00:00:00 2001 From: f Date: Wed, 13 Sep 2023 18:07:25 -0300 Subject: [PATCH 089/130] fix: retrocompatibilidad --- app/models/metadata_created_at.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/models/metadata_created_at.rb b/app/models/metadata_created_at.rb index 2a7c07ed..d31b3a1c 100644 --- a/app/models/metadata_created_at.rb +++ b/app/models/metadata_created_at.rb @@ -2,9 +2,14 @@ # Fecha y hora de creación class MetadataCreatedAt < MetadataTemplate - # Por defecto la hora actual + # Por defecto la hora actual, pero por retrocompatibilidad, queremos + # la fecha de publicación def default_value - Time.now + if post.date.value.to_date < Time.now.to_date + post.date.value + else + Time.now + end end # Nunca cambia From a2d84bfa96a375bd8c0ce79cda4a2ec20f0f5e9d Mon Sep 17 00:00:00 2001 From: f Date: Thu, 21 Sep 2023 12:25:23 -0300 Subject: [PATCH 090/130] fix: renombrar el remote correctamente --- app/models/site.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/models/site.rb b/app/models/site.rb index 0fddeff5..fa1d7b46 100644 --- a/app/models/site.rb +++ b/app/models/site.rb @@ -473,7 +473,10 @@ class Site < ApplicationRecord def clone_skel! return if jekyll? - Rugged::Repository.clone_at ENV['SKEL_SUTTY'], path, remote: 'upstream' + Rugged::Repository.clone_at ENV['SKEL_SUTTY'], path + + # Necesita un bloque + repository.rugged.remotes.rename('origin', 'upstream') {} end # Elimina el directorio del sitio From 69e1664084cd2b1cfb4fa71dfee745883f546c2d Mon Sep 17 00:00:00 2001 From: f Date: Thu, 21 Sep 2023 13:02:15 -0300 Subject: [PATCH 091/130] fix: renombrar todos los repositorios remotos --- ...921155401_site_rename_origin_to_upstream.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 db/migrate/20230921155401_site_rename_origin_to_upstream.rb diff --git a/db/migrate/20230921155401_site_rename_origin_to_upstream.rb b/db/migrate/20230921155401_site_rename_origin_to_upstream.rb new file mode 100644 index 00000000..c27d7747 --- /dev/null +++ b/db/migrate/20230921155401_site_rename_origin_to_upstream.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +# Renombrar todos los repositorios que apunten a skel como su origin +class SiteRenameOriginToUpstream < ActiveRecord::Migration[6.1] + # Renombrar + def up + Site.find_each do |site| + next unless site.repository.origin&.url == ENV['SKEL_SUTTY'] + + site.repository.rugged.remotes.rename('origin', 'upstream') + rescue Rugged::Error => e + Rails.logger.warn "#{site.name}: #{e.message}" + end + end + + # No se puede deshacer + def down; end +end From e4dc6588f925756d9523b6d344668c099f17b382 Mon Sep 17 00:00:00 2001 From: f Date: Thu, 21 Sep 2023 13:04:25 -0300 Subject: [PATCH 092/130] =?UTF-8?q?fix:=20informar=20qu=C3=A9=20est=C3=A1?= =?UTF-8?q?=20pasando?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/migrate/20230921155401_site_rename_origin_to_upstream.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/db/migrate/20230921155401_site_rename_origin_to_upstream.rb b/db/migrate/20230921155401_site_rename_origin_to_upstream.rb index c27d7747..e32ca6fc 100644 --- a/db/migrate/20230921155401_site_rename_origin_to_upstream.rb +++ b/db/migrate/20230921155401_site_rename_origin_to_upstream.rb @@ -8,6 +8,7 @@ class SiteRenameOriginToUpstream < ActiveRecord::Migration[6.1] next unless site.repository.origin&.url == ENV['SKEL_SUTTY'] site.repository.rugged.remotes.rename('origin', 'upstream') + Rails.logger.info "#{site.name}: renamed origin to upstream" rescue Rugged::Error => e Rails.logger.warn "#{site.name}: #{e.message}" end From 7709b9f79803ccdda400526f5b2dfb9f49ad6cc8 Mon Sep 17 00:00:00 2001 From: f Date: Thu, 21 Sep 2023 13:09:10 -0300 Subject: [PATCH 093/130] =?UTF-8?q?fix:=20capturar=20m=C3=A1s=20errores?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/migrate/20230921155401_site_rename_origin_to_upstream.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/migrate/20230921155401_site_rename_origin_to_upstream.rb b/db/migrate/20230921155401_site_rename_origin_to_upstream.rb index e32ca6fc..4ad53f1b 100644 --- a/db/migrate/20230921155401_site_rename_origin_to_upstream.rb +++ b/db/migrate/20230921155401_site_rename_origin_to_upstream.rb @@ -9,7 +9,7 @@ class SiteRenameOriginToUpstream < ActiveRecord::Migration[6.1] site.repository.rugged.remotes.rename('origin', 'upstream') Rails.logger.info "#{site.name}: renamed origin to upstream" - rescue Rugged::Error => e + rescue Rugged::Error, Rugged::OSError => e Rails.logger.warn "#{site.name}: #{e.message}" end end From b06b829357a607a9567d75fbf3bded07d7002a53 Mon Sep 17 00:00:00 2001 From: f Date: Thu, 21 Sep 2023 13:10:26 -0300 Subject: [PATCH 094/130] fix: necesita un bloque --- db/migrate/20230921155401_site_rename_origin_to_upstream.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/db/migrate/20230921155401_site_rename_origin_to_upstream.rb b/db/migrate/20230921155401_site_rename_origin_to_upstream.rb index 4ad53f1b..864f4c4a 100644 --- a/db/migrate/20230921155401_site_rename_origin_to_upstream.rb +++ b/db/migrate/20230921155401_site_rename_origin_to_upstream.rb @@ -7,8 +7,9 @@ class SiteRenameOriginToUpstream < ActiveRecord::Migration[6.1] Site.find_each do |site| next unless site.repository.origin&.url == ENV['SKEL_SUTTY'] - site.repository.rugged.remotes.rename('origin', 'upstream') - Rails.logger.info "#{site.name}: renamed origin to upstream" + site.repository.rugged.remotes.rename('origin', 'upstream') do |_| + Rails.logger.info "#{site.name}: renamed origin to upstream" + end rescue Rugged::Error, Rugged::OSError => e Rails.logger.warn "#{site.name}: #{e.message}" end From 4689d10e8dbfb612e03f4fb922d61010fb10f24c Mon Sep 17 00:00:00 2001 From: jazzari Date: Thu, 21 Sep 2023 16:22:45 -0300 Subject: [PATCH 095/130] feat: instalada gema device_detector #14334 --- Gemfile | 1 + config/initializers/device_detector.rb | 3 +++ 2 files changed, 4 insertions(+) create mode 100644 config/initializers/device_detector.rb diff --git a/Gemfile b/Gemfile index dd880219..7e1beda9 100644 --- a/Gemfile +++ b/Gemfile @@ -78,6 +78,7 @@ gem 'validates_hostname' gem 'webpacker' gem 'yaml_db', git: 'https://0xacab.org/sutty/yaml_db.git' gem 'kaminari' +gem 'device_detector' # database gem 'hairtrigger' diff --git a/config/initializers/device_detector.rb b/config/initializers/device_detector.rb new file mode 100644 index 00000000..95500315 --- /dev/null +++ b/config/initializers/device_detector.rb @@ -0,0 +1,3 @@ +DeviceDetector.configure do |config| + config.max_cache_keys = 5_000 # to check if not too much + end \ No newline at end of file From 84f82cbb0fccde12f51cc69678ccdafe151b96b3 Mon Sep 17 00:00:00 2001 From: f Date: Fri, 22 Sep 2023 12:21:55 -0300 Subject: [PATCH 096/130] fix: obtener el usuario del repositorio --- Gemfile | 1 + Gemfile.lock | 4 ++++ app/models/site/repository.rb | 16 +++++++++++++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index dd880219..6edeac5a 100644 --- a/Gemfile +++ b/Gemfile @@ -70,6 +70,7 @@ gem 'redis-rails' gem 'rollups', git: 'https://github.com/fauno/rollup.git', branch: 'update' gem 'rubyzip' gem 'rugged' +gem 'git_clone_url' gem 'concurrent-ruby-ext' gem 'que' gem 'symbol-fstring', require: 'fstring/all' diff --git a/Gemfile.lock b/Gemfile.lock index f71053d7..9549a51d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -217,6 +217,8 @@ GEM activerecord (>= 4.0.0) get_process_mem (0.2.7) ffi (~> 1.0) + git_clone_url (2.0.0) + uri-ssh_git (>= 2.0) globalid (1.1.0) activesupport (>= 5.0) groupdate (6.2.1) @@ -553,6 +555,7 @@ GEM unf_ext unf_ext (0.0.8.2-x86_64-linux-musl) unicode-display_width (1.8.0) + uri-ssh_git (2.0.0) validates_hostname (1.0.13) activerecord (>= 3.0) activesupport (>= 3.0) @@ -606,6 +609,7 @@ DEPENDENCIES fast_jsonparser (~> 0.5.0) flamegraph friendly_id + git_clone_url hairtrigger haml-lint hamlit-rails diff --git a/app/models/site/repository.rb b/app/models/site/repository.rb index 74d874c1..d776efa4 100644 --- a/app/models/site/repository.rb +++ b/app/models/site/repository.rb @@ -173,7 +173,21 @@ class Site def credentials return unless File.exist? private_key - @credentials ||= Rugged::Credentials::SshKey.new username: 'git', publickey: public_key, privatekey: private_key + @credentials ||= + begin + username = parse_url(origin.url)&.user || 'git' + + Rugged::Credentials::SshKey.new username: username, publickey: public_key, privatekey: private_key + end + end + + # @param :url [String] + # @return [URI, nil] + def parse_url(url) + GitCloneUrl.parse(url) + rescue URI::Error => e + ExceptionNotifier.notify_exception(e, data: { site: site.name, url: url }) + nil end # @return [String] From 0c7a37a1d82e7035b05cfb4fb96614c36fd38369 Mon Sep 17 00:00:00 2001 From: f Date: Fri, 22 Sep 2023 12:46:32 -0300 Subject: [PATCH 097/130] fix: mantener rugged 1.5.0.1 versiones posteriores se rompen con urls ssh:// https://github.com/libgit2/libgit2/issues/6496 --- Gemfile | 2 +- Gemfile.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index 6edeac5a..ce776647 100644 --- a/Gemfile +++ b/Gemfile @@ -69,7 +69,7 @@ gem 'redis', '~> 4.0', require: %w[redis redis/connection/hiredis] gem 'redis-rails' gem 'rollups', git: 'https://github.com/fauno/rollup.git', branch: 'update' gem 'rubyzip' -gem 'rugged' +gem 'rugged', '1.5.0.1' gem 'git_clone_url' gem 'concurrent-ruby-ext' gem 'que' diff --git a/Gemfile.lock b/Gemfile.lock index 9549a51d..11561776 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -496,7 +496,7 @@ GEM ruby_parser (3.20.1) sexp_processor (~> 4.16) rubyzip (2.3.2) - rugged (1.6.3-x86_64-linux-musl) + rugged (1.5.0.1-x86_64-linux-musl) safe_yaml (1.0.6) safely_block (0.3.0) errbase (>= 0.1.1) @@ -654,7 +654,7 @@ DEPENDENCIES rollups! rubocop-rails rubyzip - rugged + rugged (= 1.5.0.1) safe_yaml safely_block (~> 0.3.0) sassc-rails From 52e22a53bfd3f8bed30a01820ca522304384b619 Mon Sep 17 00:00:00 2001 From: f Date: Fri, 22 Sep 2023 12:47:18 -0300 Subject: [PATCH 098/130] fix: no sabemos el sitio --- app/models/site/repository.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/site/repository.rb b/app/models/site/repository.rb index d776efa4..128a557a 100644 --- a/app/models/site/repository.rb +++ b/app/models/site/repository.rb @@ -186,7 +186,7 @@ class Site def parse_url(url) GitCloneUrl.parse(url) rescue URI::Error => e - ExceptionNotifier.notify_exception(e, data: { site: site.name, url: url }) + ExceptionNotifier.notify_exception(e, data: { path: path, url: url }) nil end From 7793c5f96d63bad20243b6eb3bb0d8bc79e92e6d Mon Sep 17 00:00:00 2001 From: f Date: Fri, 22 Sep 2023 13:03:28 -0300 Subject: [PATCH 099/130] =?UTF-8?q?fix:=20no=20enviar=20el=20env=20en=20la?= =?UTF-8?q?=20notificaci=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/v1/webhooks_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/api/v1/webhooks_controller.rb b/app/controllers/api/v1/webhooks_controller.rb index 1730034e..36e6a6d1 100644 --- a/app/controllers/api/v1/webhooks_controller.rb +++ b/app/controllers/api/v1/webhooks_controller.rb @@ -68,7 +68,7 @@ module Api # respuesta de error a plataformas def platforms_answer(exception) - ExceptionNotifier.notify_exception(exception, env: request.env, data: { headers: request.headers.to_h }) + ExceptionNotifier.notify_exception(exception, data: { headers: request.headers.to_h } head :forbidden end From c176a8a4b44b5b62ffe01fb7708c39abf4eecbd9 Mon Sep 17 00:00:00 2001 From: f Date: Fri, 22 Sep 2023 13:19:21 -0300 Subject: [PATCH 100/130] feat: poder obtener el usuario de cualquier remoto --- app/models/site/repository.rb | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/app/models/site/repository.rb b/app/models/site/repository.rb index 128a557a..119a1495 100644 --- a/app/models/site/repository.rb +++ b/app/models/site/repository.rb @@ -173,12 +173,18 @@ class Site def credentials return unless File.exist? private_key - @credentials ||= - begin - username = parse_url(origin.url)&.user || 'git' + Rugged::Credentials::SshKey.new username: username_for(origin), publickey: public_key, privatekey: private_key + end - Rugged::Credentials::SshKey.new username: username, publickey: public_key, privatekey: private_key - end + # Obtiene el nombre de usuario para el repositorio remoto, por + # defecto git + # + # @param :remote [Rugged::Remote] + # @return [String] + def username_for(remote) + username = parse_url(remote.url)&.user if remote.respond_to? :url + + username || 'git' end # @param :url [String] From aeaf72c27036753b52087acac6c2fd523e923f78 Mon Sep 17 00:00:00 2001 From: f Date: Fri, 22 Sep 2023 13:20:20 -0300 Subject: [PATCH 101/130] feat: poder pushear a cualquier remoto --- app/models/site/repository.rb | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/app/models/site/repository.rb b/app/models/site/repository.rb index 119a1495..2eafb92e 100644 --- a/app/models/site/repository.rb +++ b/app/models/site/repository.rb @@ -158,22 +158,29 @@ class Site # Pushea cambios al repositorio remoto # + # @param :remote [Rugged::Remote] # @return [Boolean, nil] - def push - origin.push(rugged.head.canonical_name, credentials: credentials) - git_sh("git", "lfs", "push", "origin", default_branch) + def push(remote = origin) + remote.push(rugged.head.canonical_name, credentials: credentials_for(remote)) + git_sh('git', 'lfs', 'push', remote.name, default_branch) end private + # @deprecated + def credentials + @credentials ||= credentials_for(origin) + end + # Si Sutty tiene una llave privada de tipo ED25519, devuelve las # credenciales necesarias para trabajar con repositorios remotos. # + # @param :remote [Rugged::Remote] # @return [Nil, Rugged::Credentials::SshKey] - def credentials + def credentials_for(remote) return unless File.exist? private_key - Rugged::Credentials::SshKey.new username: username_for(origin), publickey: public_key, privatekey: private_key + Rugged::Credentials::SshKey.new username: username_for(remote), publickey: public_key, privatekey: private_key end # Obtiene el nombre de usuario para el repositorio remoto, por From 74e371eb36c6b9d4714e0cfba98851ec1a36a65c Mon Sep 17 00:00:00 2001 From: jazzari Date: Fri, 22 Sep 2023 13:51:36 -0300 Subject: [PATCH 102/130] feat: ignorar reportes de bots con device_detector #14334 --- app/controllers/api/v1/notices_controller.rb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/controllers/api/v1/notices_controller.rb b/app/controllers/api/v1/notices_controller.rb index 436c78b5..c5b88e28 100644 --- a/app/controllers/api/v1/notices_controller.rb +++ b/app/controllers/api/v1/notices_controller.rb @@ -9,10 +9,11 @@ module Api # Generar un stacktrace en segundo plano y enviarlo por correo # solo si la API key es verificable. Del otro lado siempre # respondemos con lo mismo. - def create - if site&.airbrake_valid? airbrake_token + def create + if site&.airbrake_valid? airbrake_token && !detected_device.bot? BacktraceJob.perform_later site_id: params[:site_id], - params: airbrake_params.to_h + params: airbrake_params.to_h + end end render status: 201, json: { id: 1, url: '' } @@ -34,6 +35,11 @@ module Api def airbrake_token @airbrake_token ||= params[:key] end + + # @return [DeviceDetector] + def detected_device + @detected_device ||= DeviceDetector.new(request.headers) + end end end end From f19a9fa42fcbaa1d37344c852ba9f239448d1f2b Mon Sep 17 00:00:00 2001 From: f Date: Fri, 22 Sep 2023 14:31:53 -0300 Subject: [PATCH 103/130] style: usar .editorconfig sutty/jekyll/sutty-base-jekyll-theme#60 --- .editorconfig | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..b0bc1626 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,11 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true +charset = utf-8 +indent_style = space +indent_size = 2 + +[Makefile] +indent_style = tab From 6866f827f6547655709405ad258783464bb72b06 Mon Sep 17 00:00:00 2001 From: jazzari Date: Fri, 22 Sep 2023 15:10:46 -0300 Subject: [PATCH 104/130] =?UTF-8?q?fix:=20error=20de=20sintaxis=20y=20par?= =?UTF-8?q?=C3=A1metros=20a=20device=5Fdetector=20#14334?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gemfile.lock | 18 ++++++++++-------- app/controllers/api/v1/notices_controller.rb | 5 ++--- config/initializers/device_detector.rb | 4 ++-- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index f71053d7..5e6d09f9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -86,7 +86,7 @@ GEM minitest (>= 5.1) tzinfo (~> 2.0) zeitwerk (~> 2.3) - addressable (2.8.4) + addressable (2.8.5) public_suffix (>= 2.0.2, < 6.0) ast (2.4.2) autoprefixer-rails (10.4.13.0) @@ -142,6 +142,7 @@ GEM rake (> 10, < 14) ruby-statistics (>= 2.1) thor (>= 0.19, < 2) + device_detector (1.1.1) devise (4.9.2) bcrypt (~> 3.0) orm_adapter (~> 0.1) @@ -166,10 +167,10 @@ GEM railties (>= 3.2) down (5.4.1) addressable (~> 2.8) - dry-configurable (1.0.1) + dry-configurable (1.1.0) dry-core (~> 1.0, < 2) zeitwerk (~> 2.6) - dry-core (1.0.0) + dry-core (1.0.1) concurrent-ruby (~> 1.0) zeitwerk (~> 2.6) dry-inflector (1.0.0) @@ -178,7 +179,7 @@ GEM concurrent-ruby (~> 1.0) dry-core (~> 1.0, < 2) zeitwerk (~> 2.6) - dry-schema (1.13.1) + dry-schema (1.13.3) concurrent-ruby (~> 1.0) dry-configurable (~> 1.0, >= 1.0.1) dry-core (~> 1.0, < 2) @@ -344,7 +345,7 @@ GEM method_source (1.0.0) mini_histogram (0.3.1) mini_magick (4.12.0) - mini_mime (1.1.2) + mini_mime (1.1.5) mini_portile2 (2.8.2) minitest (5.18.0) mobility (1.2.9) @@ -461,7 +462,7 @@ GEM responders (3.1.0) actionpack (>= 5.2) railties (>= 5.2) - rexml (3.2.5) + rexml (3.2.6) rgl (0.6.3) pairing_heap (>= 0.3.0) rexml (~> 3.2, >= 3.2.4) @@ -526,7 +527,7 @@ GEM actionpack (>= 5.2) activesupport (>= 5.2) sprockets (>= 3.0.0) - sqlite3 (1.6.3-x86_64-linux-musl) + sqlite3 (1.6.4-x86_64-linux-musl) mini_portile2 (~> 2.8.0) stackprof (0.2.25-x86_64-linux-musl) stream (0.5.5) @@ -575,7 +576,7 @@ GEM websocket-extensions (0.1.5) xpath (3.2.0) nokogiri (~> 1.8) - zeitwerk (2.6.8) + zeitwerk (2.6.11) PLATFORMS x86_64-linux-musl @@ -592,6 +593,7 @@ DEPENDENCIES concurrent-ruby-ext database_cleaner derailed_benchmarks + device_detector devise devise-i18n devise_invitable diff --git a/app/controllers/api/v1/notices_controller.rb b/app/controllers/api/v1/notices_controller.rb index c5b88e28..3d74a48f 100644 --- a/app/controllers/api/v1/notices_controller.rb +++ b/app/controllers/api/v1/notices_controller.rb @@ -10,10 +10,9 @@ module Api # solo si la API key es verificable. Del otro lado siempre # respondemos con lo mismo. def create - if site&.airbrake_valid? airbrake_token && !detected_device.bot? + if (site&.airbrake_valid? airbrake_token) && !detected_device.bot? BacktraceJob.perform_later site_id: params[:site_id], params: airbrake_params.to_h - end end render status: 201, json: { id: 1, url: '' } @@ -38,7 +37,7 @@ module Api # @return [DeviceDetector] def detected_device - @detected_device ||= DeviceDetector.new(request.headers) + @detected_device ||= DeviceDetector.new(request.headers['User-Agent'], request.headers) end end end diff --git a/config/initializers/device_detector.rb b/config/initializers/device_detector.rb index 95500315..e6f6118a 100644 --- a/config/initializers/device_detector.rb +++ b/config/initializers/device_detector.rb @@ -1,3 +1,3 @@ DeviceDetector.configure do |config| - config.max_cache_keys = 5_000 # to check if not too much - end \ No newline at end of file + config.max_cache_keys = 5_000 # to check if not too much +end \ No newline at end of file From de59cd9f34b8e346df111643f11482df9647bd15 Mon Sep 17 00:00:00 2001 From: f Date: Mon, 25 Sep 2023 14:08:37 -0300 Subject: [PATCH 105/130] fix: informar cuando la plantilla no tiene gema #14309 --- config/initializers/core_extensions.rb | 14 ++++++++++++++ config/locales/en.yml | 1 + config/locales/es.yml | 1 + 3 files changed, 16 insertions(+) diff --git a/config/initializers/core_extensions.rb b/config/initializers/core_extensions.rb index 1516a43a..837fbd18 100644 --- a/config/initializers/core_extensions.rb +++ b/config/initializers/core_extensions.rb @@ -91,6 +91,15 @@ module Jekyll spec.name == name end + unless spec + I18n.with_locale(locale) do + raise ArgumentError, I18n.t('activerecord.errors.models.site.attributes.design_id.missing_gem', theme: name) + rescue ArgumentError => e + ExceptionNotifier.notify_exception(e, data: { theme: name, site: site.path }) + raise + end + end + ruby_version = Gem::Version.new(RUBY_VERSION) ruby_version.canonical_segments[2] = 0 base_path = Rails.root.join('_storage', 'gems', File.basename(site.source), 'ruby', @@ -114,6 +123,11 @@ module Jekyll private def gemspec; end + + # @return [Symbol] + def locale + @locale ||= (site.config['locale'] || site.config['lang'] || I18n.locale).to_sym + end end # No necesitamos los archivos de la plantilla diff --git a/config/locales/en.yml b/config/locales/en.yml index 5f97a8b9..56b8c213 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -191,6 +191,7 @@ en: deploys: deploy_local_presence: 'We need to be build the site!' design_id: + missing_gem: "Site is configured to use %{theme} theme, but the corresponding gem is missing from Gemfile" layout_incompatible: error: "Design can't be changed because there are posts with incompatible layouts" help: "Your site has posts with layouts only compatible with the current design. If you change it, the site won't work as you expect. If you're trying out designs, you can delete posts in the following incompatible layouts:: %{layouts}." diff --git a/config/locales/es.yml b/config/locales/es.yml index 9e0b8945..b4fde8a3 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -191,6 +191,7 @@ es: deploys: deploy_local_presence: '¡Necesitamos poder generar el sitio!' design_id: + missing_gem: "El sitio usa la plantilla %{theme} pero la gema correspondiente no se encuentra en el Gemfile" layout_incompatible: error: 'No se puede cambiar la plantilla porque hay artículos con formatos incompatibles' help: 'En tu sitio hay artículos que solo son compatibles con el diseño actual, si cambias la plantilla el sitio no funcionará como esperas. Si estás probando plantillas, puedes eliminar los artículos en los formatos incompatibles: %{layouts}.' From 01e7436576c1060d38dd47a0ef0e4aca656c02f8 Mon Sep 17 00:00:00 2001 From: f Date: Mon, 25 Sep 2023 14:10:34 -0300 Subject: [PATCH 106/130] fix: obtener el nombre del sitio --- config/initializers/core_extensions.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/initializers/core_extensions.rb b/config/initializers/core_extensions.rb index 837fbd18..2e9ed7e1 100644 --- a/config/initializers/core_extensions.rb +++ b/config/initializers/core_extensions.rb @@ -95,7 +95,7 @@ module Jekyll I18n.with_locale(locale) do raise ArgumentError, I18n.t('activerecord.errors.models.site.attributes.design_id.missing_gem', theme: name) rescue ArgumentError => e - ExceptionNotifier.notify_exception(e, data: { theme: name, site: site.path }) + ExceptionNotifier.notify_exception(e, data: { theme: name, site: File.basename(site.source) }) raise end end From bfd31d051fb002e303ddcd0f253b1e2a7aa50f49 Mon Sep 17 00:00:00 2001 From: f Date: Mon, 25 Sep 2023 14:15:32 -0300 Subject: [PATCH 107/130] =?UTF-8?q?fix:=20lanzar=20una=20excepci=C3=B3n=20?= =?UTF-8?q?contundente?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/initializers/core_extensions.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/initializers/core_extensions.rb b/config/initializers/core_extensions.rb index 2e9ed7e1..d6039e16 100644 --- a/config/initializers/core_extensions.rb +++ b/config/initializers/core_extensions.rb @@ -93,8 +93,8 @@ module Jekyll unless spec I18n.with_locale(locale) do - raise ArgumentError, I18n.t('activerecord.errors.models.site.attributes.design_id.missing_gem', theme: name) - rescue ArgumentError => e + raise Jekyll::Errors::InvalidThemeName, I18n.t('activerecord.errors.models.site.attributes.design_id.missing_gem', theme: name) + rescue Jekyll::Errors::InvalidThemeName => e ExceptionNotifier.notify_exception(e, data: { theme: name, site: File.basename(site.source) }) raise end From 5c43214e46a06f125459c89df9568c1986dd01ea Mon Sep 17 00:00:00 2001 From: jazzari Date: Mon, 25 Sep 2023 14:32:28 -0300 Subject: [PATCH 108/130] fix: arreglados cambios en Gemfile.lock #14334 --- Gemfile.lock | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 5e6d09f9..a786e060 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -86,7 +86,7 @@ GEM minitest (>= 5.1) tzinfo (~> 2.0) zeitwerk (~> 2.3) - addressable (2.8.5) + addressable (2.8.4) public_suffix (>= 2.0.2, < 6.0) ast (2.4.2) autoprefixer-rails (10.4.13.0) @@ -167,10 +167,10 @@ GEM railties (>= 3.2) down (5.4.1) addressable (~> 2.8) - dry-configurable (1.1.0) + dry-configurable (1.0.1) dry-core (~> 1.0, < 2) zeitwerk (~> 2.6) - dry-core (1.0.1) + dry-core (1.0.0) concurrent-ruby (~> 1.0) zeitwerk (~> 2.6) dry-inflector (1.0.0) @@ -179,7 +179,7 @@ GEM concurrent-ruby (~> 1.0) dry-core (~> 1.0, < 2) zeitwerk (~> 2.6) - dry-schema (1.13.3) + dry-schema (1.13.1) concurrent-ruby (~> 1.0) dry-configurable (~> 1.0, >= 1.0.1) dry-core (~> 1.0, < 2) @@ -345,7 +345,7 @@ GEM method_source (1.0.0) mini_histogram (0.3.1) mini_magick (4.12.0) - mini_mime (1.1.5) + mini_mime (1.1.2) mini_portile2 (2.8.2) minitest (5.18.0) mobility (1.2.9) @@ -462,7 +462,7 @@ GEM responders (3.1.0) actionpack (>= 5.2) railties (>= 5.2) - rexml (3.2.6) + rexml (3.2.5) rgl (0.6.3) pairing_heap (>= 0.3.0) rexml (~> 3.2, >= 3.2.4) @@ -527,7 +527,7 @@ GEM actionpack (>= 5.2) activesupport (>= 5.2) sprockets (>= 3.0.0) - sqlite3 (1.6.4-x86_64-linux-musl) + sqlite3 (1.6.3-x86_64-linux-musl) mini_portile2 (~> 2.8.0) stackprof (0.2.25-x86_64-linux-musl) stream (0.5.5) @@ -576,7 +576,7 @@ GEM websocket-extensions (0.1.5) xpath (3.2.0) nokogiri (~> 1.8) - zeitwerk (2.6.11) + zeitwerk (2.6.8) PLATFORMS x86_64-linux-musl From 59f8f8aabbab3ef93572dacae14e56ea724364c8 Mon Sep 17 00:00:00 2001 From: jazzari Date: Wed, 27 Sep 2023 14:29:28 -0300 Subject: [PATCH 109/130] fix: arreglado typo en breadcrumbs en en.yml #13864 --- 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 5f97a8b9..6b73205a 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -685,7 +685,7 @@ en: new: 'Create' edit: 'Configure' posts: - new: 'New %{layout}' + new: 'Add %{layout}' edit: 'Editing' usuaries: index: 'Users' From 134d1105f62256b23d64ff4fb88582a880882ec9 Mon Sep 17 00:00:00 2001 From: jazzari Date: Wed, 27 Sep 2023 15:48:53 -0300 Subject: [PATCH 110/130] =?UTF-8?q?fix:=20agregada=20la=20fecha=20de=20cre?= =?UTF-8?q?acion=20del=20post=20para=20seleccionar=20posts=20por=20t=C3=AD?= =?UTF-8?q?tulo=20si=20est=C3=A1n=20duplicados=20#14179?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/metadata_related_posts.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/metadata_related_posts.rb b/app/models/metadata_related_posts.rb index 092f219a..f20ea85c 100644 --- a/app/models/metadata_related_posts.rb +++ b/app/models/metadata_related_posts.rb @@ -34,7 +34,7 @@ class MetadataRelatedPosts < MetadataArray end def title(post) - "#{post&.title&.value || post&.slug&.value} (#{post.layout.humanized_name})" + "#{post&.title&.value || post&.slug&.value} #{post&.date&.values.trftime('%F')} (#{post.layout.humanized_name})" end # Encuentra el filtro From 5e05ba7d7b4dcffbb05bf54a2276619ea4de366f Mon Sep 17 00:00:00 2001 From: jazzari Date: Wed, 27 Sep 2023 15:52:33 -0300 Subject: [PATCH 111/130] fix: fix typo #14179 --- app/models/metadata_related_posts.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/metadata_related_posts.rb b/app/models/metadata_related_posts.rb index f20ea85c..25eb3fd1 100644 --- a/app/models/metadata_related_posts.rb +++ b/app/models/metadata_related_posts.rb @@ -34,7 +34,7 @@ class MetadataRelatedPosts < MetadataArray end def title(post) - "#{post&.title&.value || post&.slug&.value} #{post&.date&.values.trftime('%F')} (#{post.layout.humanized_name})" + "#{post&.title&.value || post&.slug&.value} #{post&.date&.values.strftime('%F')} (#{post.layout.humanized_name})" end # Encuentra el filtro From 8376e663ced7c232d18e3575ce4b6d68abc4af89 Mon Sep 17 00:00:00 2001 From: f Date: Wed, 27 Sep 2023 15:39:12 -0300 Subject: [PATCH 112/130] =?UTF-8?q?feat:=20almacenar=20el=20=C3=BAltimo=20?= =?UTF-8?q?commit=20indexado=20#13780?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20230927153926_add_last_indexed_commit_to_sites.rb | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 db/migrate/20230927153926_add_last_indexed_commit_to_sites.rb diff --git a/db/migrate/20230927153926_add_last_indexed_commit_to_sites.rb b/db/migrate/20230927153926_add_last_indexed_commit_to_sites.rb new file mode 100644 index 00000000..2d22cbd7 --- /dev/null +++ b/db/migrate/20230927153926_add_last_indexed_commit_to_sites.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +# Almacenar el último commit indexado +class AddLastIndexedCommitToSites < ActiveRecord::Migration[6.1] + def change + add_column :sites, :last_indexed_commit, :string, null: true + end +end From f18d0213dfc4d769ce58fc8ad3d898fd8a65f508 Mon Sep 17 00:00:00 2001 From: f Date: Wed, 27 Sep 2023 15:40:14 -0300 Subject: [PATCH 113/130] =?UTF-8?q?feat:=20guardar=20el=20=C3=BAltimo=20co?= =?UTF-8?q?mmit=20indexado?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/site/index.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/models/site/index.rb b/app/models/site/index.rb index e11095e3..f728b48b 100644 --- a/app/models/site/index.rb +++ b/app/models/site/index.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -# Indexa todos los artículos de un sitio -# -# TODO: Hacer opcional class Site + # Indexa todos los artículos de un sitio + # + # TODO: Hacer opcional module Index extend ActiveSupport::Concern @@ -15,6 +15,8 @@ class Site def index_posts! Site.transaction do docs.each(&:index!) + + update(last_indexed_commit: repository.head_commit.oid) end end end From 074cb49752fcbbacd8a3ab9424a4210b062ffbc4 Mon Sep 17 00:00:00 2001 From: f Date: Wed, 27 Sep 2023 16:20:57 -0300 Subject: [PATCH 114/130] feat: reindexar cambios #13780 --- app/models/site/index.rb | 100 +++++++++++++++++++++++++++++++++++++++ config/locales/en.yml | 3 ++ config/locales/es.yml | 3 ++ 3 files changed, 106 insertions(+) diff --git a/app/models/site/index.rb b/app/models/site/index.rb index f728b48b..ed0932bb 100644 --- a/app/models/site/index.rb +++ b/app/models/site/index.rb @@ -12,6 +12,10 @@ class Site after_create :index_posts! has_many :indexed_posts, dependent: :destroy + MODIFIED_STATUSES = %i[added modified].freeze + DELETED_STATUSES = %i[deleted].freeze + LOCALE_FROM_PATH = /\A_/.freeze + def index_posts! Site.transaction do docs.each(&:index!) @@ -19,6 +23,102 @@ class Site update(last_indexed_commit: repository.head_commit.oid) end end + + # Encuentra los artículos modificados entre dos commits y los + # reindexa. + def reindex_changes! + return unless reindexable? + + Site.transaction do + remove_deleted_posts! + reindex_modified_posts! + + update(last_indexed_commit: repository.head_commit.oid) + end + end + + # No hacer nada si el repositorio no cambió o no hubo cambios + # necesarios + def reindexable? + return false if last_indexed_commit.blank? + return false if last_indexed_commit == repository.head_commit.oid + + !indexable_posts.empty? + end + + private + + # Trae el último commit indexado desde el repositorio + # + # @return [Rugged::Commit] + def indexed_commit + @indexed_commit ||= repository.rugged.lookup(last_indexed_commit) + end + + # Calcula la diferencia entre el último commit indexado y el + # actual + # + # XXX: Esto no tiene en cuenta modificaciones en la historia como + # cambio de ramas, reverts y etc, solo asume que se mueve hacia + # adelante en la misma rama o las dos ramas están relacionadas. + # + # @return [Rugged::Diff] + def diff_with_head + @diff_with_head ||= indexed_commit.diff(repository.head_commit) + end + + # Obtiene todos los archivos a reindexar + # + # @return [Array] + def indexable_posts + @indexable_posts ||= + diff_with_head.each_delta.select do |delta| + locales.any? do |locale| + delta.old_file[:path].start_with? "_#{locale}/" + end + end + end + + # Elimina los artículos eliminados o que cambiaron de ubicación + # del índice + def remove_deleted_posts! + indexable_posts.select do |delta| + DELETED_STATUSES.include? delta.status + end.each do |delta| + locale, path = locale_and_path_from(delta.old_file[:path]) + + indexed_posts.destroy_by(locale: locale, path: path).tap do |destroyed_posts| + next unless destroyed_posts.empty? + + Rails.logger.info I18n.t('indexed_posts.deleted', site: name, path: path, records: destroyed_posts.count) + end + end + end + + # Reindexa artículos que cambiaron de ubicación, se agregaron + # o fueron modificados + def reindex_modified_posts! + indexable_posts.select do |delta| + MODIFIED_STATUSES.include? delta.status + end.each do |delta| + locale, path = locale_and_path_from(delta.new_file[:path]) + + site.posts(lang: locale).find(path).index! + end + end + + # Obtiene el idioma y la ruta del post a partir de la ubicación en + # el disco + # + # @return [Array] + def locale_and_path_from(path) + locale, path = path.split(File::SEPARATOR, 2) + + [ + locale.sub(LOCALE_FROM_PATH, ''), + File.basename(path, '.*') + ] + end end end end diff --git a/config/locales/en.yml b/config/locales/en.yml index 5f97a8b9..f2c0d94c 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -167,6 +167,7 @@ en: usuarie: User licencia: License design: Design + indexed_post: Indexed post attributes: usuarie: email: 'E-mail address' @@ -709,3 +710,5 @@ en: build_stats: index: title: "Publications" + indexed_posts: + deleted: "Deleted indexed post %{path} from %{site} (records: %{records})" diff --git a/config/locales/es.yml b/config/locales/es.yml index 9e0b8945..73de7b18 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -167,6 +167,7 @@ es: usuarie: Usuarie licencia: Licencia design: Diseño + indexed_post: Artículo indexado attributes: usuarie: email: 'Correo electrónico' @@ -717,3 +718,5 @@ es: build_stats: index: title: "Publicaciones" + indexed_posts: + deleted: "Eliminado artículo %{path} de %{site} (filas: %{records})" From 1e13985ef82c0dde7068db2bd0e027e8f8419434 Mon Sep 17 00:00:00 2001 From: f Date: Wed, 27 Sep 2023 16:31:23 -0300 Subject: [PATCH 115/130] =?UTF-8?q?fix:=20asumir=20que=20todos=20los=20sit?= =?UTF-8?q?ios=20ya=20est=C3=A1n=20indexados?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0230927153926_add_last_indexed_commit_to_sites.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/db/migrate/20230927153926_add_last_indexed_commit_to_sites.rb b/db/migrate/20230927153926_add_last_indexed_commit_to_sites.rb index 2d22cbd7..71e08f37 100644 --- a/db/migrate/20230927153926_add_last_indexed_commit_to_sites.rb +++ b/db/migrate/20230927153926_add_last_indexed_commit_to_sites.rb @@ -2,7 +2,17 @@ # Almacenar el último commit indexado class AddLastIndexedCommitToSites < ActiveRecord::Migration[6.1] - def change + def up add_column :sites, :last_indexed_commit, :string, null: true + + Site.find_each do |site| + site.update_columns(last_indexed_commit: site.repository.head_commit.oid) + rescue Rugged::Error, Rugged::OSError => e + puts "Falló #{site.name}, ignorando: #{e.message}" + end + end + + def down + remove_column :sites, :last_indexed_commit end end From 997114a89688bb735347f2c12966c24097662a5c Mon Sep 17 00:00:00 2001 From: f Date: Wed, 27 Sep 2023 16:38:19 -0300 Subject: [PATCH 116/130] fix: ya estamos en el contexto del sitio --- app/models/site/index.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/site/index.rb b/app/models/site/index.rb index ed0932bb..06c8821b 100644 --- a/app/models/site/index.rb +++ b/app/models/site/index.rb @@ -103,7 +103,7 @@ class Site end.each do |delta| locale, path = locale_and_path_from(delta.new_file[:path]) - site.posts(lang: locale).find(path).index! + posts(lang: locale).find(path).index! end end From 85e528e660b2482d6a3b71b39b0f57544135b749 Mon Sep 17 00:00:00 2001 From: f Date: Wed, 27 Sep 2023 16:46:33 -0300 Subject: [PATCH 117/130] fix: solo hacer merge si hubo cambios para traer --- app/jobs/git_pull_job.rb | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/app/jobs/git_pull_job.rb b/app/jobs/git_pull_job.rb index de263403..41a2ec2c 100644 --- a/app/jobs/git_pull_job.rb +++ b/app/jobs/git_pull_job.rb @@ -3,11 +3,12 @@ # Permite traer los cambios cada vez que se # hace un push al repositorio class GitPullJob < ApplicationJob - # @param :site [Site] - # @param :usuarie [Usuarie] - # @return [nil] - def perform(site, usuarie) - site.repository.fetch - site.repository.merge(usuarie) - end -end \ No newline at end of file + # @param :site [Site] + # @param :usuarie [Usuarie] + # @return [nil] + def perform(site, usuarie) + return unless site.repository.fetch.positive? + + site.repository.merge(usuarie) + end +end From b119cba7e10afcbb4a665c26b4e7ad4d61afff8f Mon Sep 17 00:00:00 2001 From: f Date: Wed, 27 Sep 2023 16:47:00 -0300 Subject: [PATCH 118/130] feat: reindexar los cambios luego de traerlos #13780 --- app/jobs/git_pull_job.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/jobs/git_pull_job.rb b/app/jobs/git_pull_job.rb index 41a2ec2c..203e5698 100644 --- a/app/jobs/git_pull_job.rb +++ b/app/jobs/git_pull_job.rb @@ -10,5 +10,6 @@ class GitPullJob < ApplicationJob return unless site.repository.fetch.positive? site.repository.merge(usuarie) + site.reindex_changes! end end From 0538b3bbfd832a03bf108fd069ba23f442894244 Mon Sep 17 00:00:00 2001 From: f Date: Wed, 27 Sep 2023 16:54:38 -0300 Subject: [PATCH 119/130] fix: no fallar si no hay origin --- app/jobs/git_pull_job.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/jobs/git_pull_job.rb b/app/jobs/git_pull_job.rb index 203e5698..949a2cdd 100644 --- a/app/jobs/git_pull_job.rb +++ b/app/jobs/git_pull_job.rb @@ -7,6 +7,7 @@ class GitPullJob < ApplicationJob # @param :usuarie [Usuarie] # @return [nil] def perform(site, usuarie) + return unless site.repository.origin return unless site.repository.fetch.positive? site.repository.merge(usuarie) From cb2c1b0e7daeab32fdc3f01fca9f7158eaf6918e Mon Sep 17 00:00:00 2001 From: f Date: Fri, 29 Sep 2023 10:10:18 -0300 Subject: [PATCH 120/130] =?UTF-8?q?fix:=20usar=20la=20codificaci=C3=B3n=20?= =?UTF-8?q?correcta?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit los archivos con tildes fallaban --- app/models/site/index.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/models/site/index.rb b/app/models/site/index.rb index 06c8821b..6f4714c6 100644 --- a/app/models/site/index.rb +++ b/app/models/site/index.rb @@ -108,11 +108,14 @@ class Site end # Obtiene el idioma y la ruta del post a partir de la ubicación en - # el disco + # el disco. + # + # Las rutas vienen en ASCII-9BIT desde Rugged, pero en realidad + # son UTF-8 # # @return [Array] def locale_and_path_from(path) - locale, path = path.split(File::SEPARATOR, 2) + locale, path = path.force_encoding('utf-8').split(File::SEPARATOR, 2) [ locale.sub(LOCALE_FROM_PATH, ''), From 86436aafd70ba21b385e40b5b07a4001552adf64 Mon Sep 17 00:00:00 2001 From: jazzari Date: Mon, 2 Oct 2023 14:36:36 -0300 Subject: [PATCH 121/130] fix: typo en metadata_related_posts.rb #14179 --- app/models/metadata_related_posts.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/metadata_related_posts.rb b/app/models/metadata_related_posts.rb index 25eb3fd1..42d1381b 100644 --- a/app/models/metadata_related_posts.rb +++ b/app/models/metadata_related_posts.rb @@ -34,7 +34,7 @@ class MetadataRelatedPosts < MetadataArray end def title(post) - "#{post&.title&.value || post&.slug&.value} #{post&.date&.values.strftime('%F')} (#{post.layout.humanized_name})" + "#{post&.title&.value || post&.slug&.value} #{post&.date&.value.strftime('%F')} (#{post.layout.humanized_name})" end # Encuentra el filtro From 9709f419ca6756d21ba21bb41cad6fce0cb0bb08 Mon Sep 17 00:00:00 2001 From: f Date: Fri, 17 Nov 2023 18:19:13 -0300 Subject: [PATCH 122/130] =?UTF-8?q?fix:=20notificar=20cuando=20falla=20la?= =?UTF-8?q?=20=C3=BAltima=20compilaci=C3=B3n=20#14555?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/jobs/deploy_job.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/jobs/deploy_job.rb b/app/jobs/deploy_job.rb index 291991c7..adba1815 100644 --- a/app/jobs/deploy_job.rb +++ b/app/jobs/deploy_job.rb @@ -56,6 +56,10 @@ class DeployJob < ApplicationJob rescue URI::Error nil end.compact + + unless d == @site.deployment_list.last && !status + raise DeployException, 'Falló la compilación' + end rescue StandardError => e status = false seconds ||= 0 From c8e1d502324f427382e74dc97b7b227fccb7c493 Mon Sep 17 00:00:00 2001 From: f Date: Fri, 17 Nov 2023 18:40:34 -0300 Subject: [PATCH 123/130] fix: reversed logic --- app/jobs/deploy_job.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/jobs/deploy_job.rb b/app/jobs/deploy_job.rb index adba1815..3044b59f 100644 --- a/app/jobs/deploy_job.rb +++ b/app/jobs/deploy_job.rb @@ -57,7 +57,7 @@ class DeployJob < ApplicationJob nil end.compact - unless d == @site.deployment_list.last && !status + if d == @site.deployment_list.last && !status raise DeployException, 'Falló la compilación' end rescue StandardError => e From aaf2ca8757e32cc4d0cd567105ecfd46abf18388 Mon Sep 17 00:00:00 2001 From: f Date: Thu, 23 Nov 2023 18:41:49 -0300 Subject: [PATCH 124/130] fix: deshabilitar njalla #14696 --- Gemfile | 1 - Gemfile.lock | 4 -- app/models/deploy_distributed_press.rb | 60 +------------------------- 3 files changed, 2 insertions(+), 63 deletions(-) diff --git a/Gemfile b/Gemfile index 972560b4..bf9e875c 100644 --- a/Gemfile +++ b/Gemfile @@ -40,7 +40,6 @@ gem 'devise' gem 'devise-i18n' gem 'devise_invitable' gem 'distributed-press-api-client', '~> 0.3.0rc0' -gem 'njalla-api-client', '~> 0.2.0' gem 'email_address', git: 'https://github.com/fauno/email_address', branch: 'i18n' gem 'exception_notification' gem 'fast_blank' diff --git a/Gemfile.lock b/Gemfile.lock index 39394a8c..3faad5e8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -366,9 +366,6 @@ GEM net-ssh (7.1.0) netaddr (2.0.6) nio4r (2.5.9-x86_64-linux-musl) - njalla-api-client (0.2.0) - dry-schema - httparty (~> 0.18) nokogiri (1.15.4-x86_64-linux-musl) mini_portile2 (~> 2.8.2) racc (~> 1.4) @@ -636,7 +633,6 @@ DEPENDENCIES mini_magick mobility net-ssh - njalla-api-client (~> 0.2.0) nokogiri pg pg_search diff --git a/app/models/deploy_distributed_press.rb b/app/models/deploy_distributed_press.rb index 2c892b55..da8fe209 100644 --- a/app/models/deploy_distributed_press.rb +++ b/app/models/deploy_distributed_press.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true require 'distributed_press/v1/client/site' -require 'njalla/v1' # Soportar Distributed Press APIv1 # @@ -15,8 +14,8 @@ require 'njalla/v1' class DeployDistributedPress < Deploy store :values, accessors: %i[hostname remote_site_id remote_info], coder: JSON - before_create :create_remote_site!, :create_njalla_records! - before_destroy :delete_remote_site!, :delete_njalla_records! + before_create :create_remote_site! + before_destroy :delete_remote_site! DEPENDENCIES = %i[deploy_local] @@ -31,17 +30,12 @@ class DeployDistributedPress < Deploy time_start create_remote_site! if remote_site_id.blank? - create_njalla_records! save if remote_site_id.blank? raise DeployJob::DeployException, 'El sitio no se creó en Distributed Press' end - if create_njalla_records? && remote_info[:njalla].blank? - raise DeployJob::DeployException, 'No se pudieron crear los registros necesarios en Njalla' - end - site_client.tap do |c| stdout = Thread.new(publisher.logger_out) do |io| until io.eof? @@ -145,29 +139,6 @@ class DeployDistributedPress < Deploy nil end - # Crea los registros en Njalla - # - # XXX: Esto depende de nuestro DNS actual, cuando lo migremos hay - # que eliminarlo. - # - # @return [nil] - def create_njalla_records! - return unless create_njalla_records? - - self.remote_info ||= {} - self.remote_info[:njalla] ||= {} - self.remote_info[:njalla][:a] ||= njalla.add_record(name: site.name, type: 'CNAME', content: "#{Site.domain}.").to_h - self.remote_info[:njalla][:cname] ||= njalla.add_record(name: "www.#{site.name}", type: 'CNAME', content: "#{Site.domain}.").to_h - self.remote_info[:njalla][:ns] ||= njalla.add_record(name: "_dnslink.#{site.name}", type: 'NS', content: "#{publisher.hostname}.").to_h - - nil - rescue HTTParty::Error => e - ExceptionNotifier.notify_exception(e, data: { site: site.name }) - self.remote_info.delete :njalla - ensure - nil - end - # Registra lo que sucedió # # @param status [Bool] @@ -185,31 +156,4 @@ class DeployDistributedPress < Deploy ExceptionNotifier.notify_exception(e, data: { site: site.name }) nil end - - def delete_njalla_records! - return unless create_njalla_records? - - %w[a ns cname].each do |type| - next if (id = remote_info.dig('njalla', type, 'id')).blank? - - njalla.remove_record(id: id.to_i) - end - end - - # Actualizar registros en Njalla - # - # @return [Njalla::V1::Domain] - def njalla - @njalla ||= - begin - client = Njalla::V1::Client.new(token: Rails.application.credentials.njalla) - - Njalla::V1::Domain.new(domain: Site.domain, client: client) - end - end - - # Detecta si tenemos que crear registros en Njalla - def create_njalla_records? - !site.name.end_with?('.') - end end From 89063d50c02a3627da5b1e820764dabe9dfe5e7f Mon Sep 17 00:00:00 2001 From: f Date: Mon, 4 Dec 2023 17:50:53 -0300 Subject: [PATCH 125/130] fix: no cambiar el nombre de dominio #14746 --- app/models/site.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/site.rb b/app/models/site.rb index a8c5e376..c40dd6f9 100644 --- a/app/models/site.rb +++ b/app/models/site.rb @@ -501,8 +501,8 @@ class Site < ApplicationRecord config.theme = design.gem unless design.no_theme? config.description = description config.title = title - config.url = url(slash: false) - config.hostname = hostname + config.url ||= url(slash: false) + config.hostname ||= hostname config.locales = locales.map(&:to_s) end From 1a3c6a77ce931371eb18d7a0563790f3285cc386 Mon Sep 17 00:00:00 2001 From: f Date: Tue, 19 Dec 2023 14:33:17 -0300 Subject: [PATCH 126/130] fix: correr psql dentro de hain --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 5d6c066b..7b40d941 100644 --- a/Makefile +++ b/Makefile @@ -76,7 +76,7 @@ copy-table: ssh $(delegate) docker exec postgresql pg_dump -U sutty -d sutty -t $(table) | $(psql) psql: - $(psql) + $(hain) $(psql) rubocop: ## Yutea el código que está por ser commiteado git status --porcelain \ From c5cece436dc63f6340d6310d61ae4e8c26bc127a Mon Sep 17 00:00:00 2001 From: f Date: Tue, 19 Dec 2023 14:36:47 -0300 Subject: [PATCH 127/130] fix: usar la url de la base de datos en psql --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 7b40d941..f295a3e0 100644 --- a/Makefile +++ b/Makefile @@ -69,7 +69,7 @@ rake: ## Corre rake dentro del entorno de desarrollo (pasar argumentos con args= bundle: ## Corre bundle dentro del entorno de desarrollo (pasar argumentos con args=). $(hain) 'bundle $(args)' -psql := psql -h $(PG_HOST) -U $(PG_USER) -p $(PG_PORT) -d sutty +psql := psql $(DATABASE_URL) copy-table: test -n "$(table)" echo "truncate $(table) $(cascade);" | $(psql) From c007f3b0e3c0864aeb6360bde92e4c0bcb11cacf Mon Sep 17 00:00:00 2001 From: f Date: Tue, 19 Jul 2022 13:50:30 -0300 Subject: [PATCH 128/130] no actualizar al cargar el listado de sitios hace que todo tarde demasiado tiempo (cherry picked from commit 15454596f21fe2a0059e71d573a84fbc937a6a36) --- app/views/sites/index.haml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/app/views/sites/index.haml b/app/views/sites/index.haml index 56178775..b7231292 100644 --- a/app/views/sites/index.haml +++ b/app/views/sites/index.haml @@ -54,10 +54,4 @@ text: t('usuaries.index.title'), type: 'info', link: site_usuaries_path(site) - - if policy(site).pull? && site.repository.needs_pull? - = render 'layouts/btn_with_tooltip', - tooltip: t('help.sites.pull'), - text: t('.pull'), - type: 'info', - link: site_pull_path(site) = render 'sites/build', site: site From c1874af5bf1bca3d762e904ec419eaf9660ad687 Mon Sep 17 00:00:00 2001 From: f Date: Tue, 2 Jan 2024 15:00:43 -0300 Subject: [PATCH 129/130] Revert "fix: deshabilitar el modo oscuro #12994" This reverts commit e504501678096249dea3f170ccede64c7f191cd2. --- app/assets/stylesheets/application.scss | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 06c0f8df..bba48558 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -46,6 +46,14 @@ $sizes: ( --color: #{$magenta}; } +@media (prefers-color-scheme: dark) { + :root { + --foreground: #{$white}; + --background: #{$black}; + --color: #{$cyan}; + } +} + // TODO: Encontrar la forma de generar esto desde los locales de Rails $custom-file-text: ( en: 'Browse', From c1187943e32f0b34d0982f2cbcdcc8160e9cc7a8 Mon Sep 17 00:00:00 2001 From: f Date: Tue, 2 Jan 2024 15:15:37 -0300 Subject: [PATCH 130/130] BREAKING CHANGE: deprecar jekyll-data --- Gemfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Gemfile b/Gemfile index 5f1f6268..4c7cab37 100644 --- a/Gemfile +++ b/Gemfile @@ -53,7 +53,6 @@ gem 'inline_svg' gem 'httparty' gem 'safe_yaml' gem 'jekyll', '~> 4.2.0' -gem 'jekyll-data' gem 'jekyll-commonmark' gem 'jekyll-images' gem 'jekyll-include-cache'