From ee7d1599e896f82accac69288edc6ff450a53c83 Mon Sep 17 00:00:00 2001 From: f Date: Tue, 9 Jan 2024 18:27:02 -0300 Subject: [PATCH 01/22] fix: limitar el nombre del archivo #14946 --- app/models/metadata_path.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/models/metadata_path.rb b/app/models/metadata_path.rb index 95fc7dbb..17085e07 100644 --- a/app/models/metadata_path.rb +++ b/app/models/metadata_path.rb @@ -6,7 +6,7 @@ class MetadataPath < MetadataTemplate # # @return [String] def default_value - File.join(site.path, "_#{lang}", "#{date}-#{slug}#{ext}") + File.join(site.path, "_#{lang}", "#{limited_name}#{ext}") end # La ruta del archivo según Jekyll @@ -46,4 +46,12 @@ class MetadataPath < MetadataTemplate def date post.date.value.strftime('%F') end + + # Limita el nombre de archivo a 255 bytes, de forma que siempre + # podemos guardarlo + # + # @return [String] + def limited_name + "#{date}-#{slug}".mb_chars.limit(255 - ext.length) + end end From c2534578400e416d5560ed1344e58a87d1cc6092 Mon Sep 17 00:00:00 2001 From: f Date: Wed, 10 Jan 2024 11:39:07 -0300 Subject: [PATCH 02/22] fix: env para desarrollo --- .env.development | 1 + 1 file changed, 1 insertion(+) create mode 100644 .env.development diff --git a/.env.development b/.env.development new file mode 100644 index 00000000..df2788b0 --- /dev/null +++ b/.env.development @@ -0,0 +1 @@ +HAINISH=../haini.sh/haini.sh From 1fdc3404bef69963a47d475a77b8695f9936a19b Mon Sep 17 00:00:00 2001 From: f Date: Thu, 11 Jan 2024 17:03:37 -0300 Subject: [PATCH 03/22] fix: traer la lista de archivos modificados (cherry picked from commit 76644700d164060079c125148b6a7f62d50ca4ba) --- bin/modified_files | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/modified_files b/bin/modified_files index 37bcabeb..d26e71f3 100755 --- a/bin/modified_files +++ b/bin/modified_files @@ -3,6 +3,6 @@ set -e test -n "${CI_MERGE_REQUEST_DIFF_BASE_SHA}" -git diff --name-status ${CI_MERGE_REQUEST_DIFF_BASE_SHA}...origin/rails \ +git diff --name-status ${CI_MERGE_REQUEST_DIFF_BASE_SHA} \ | grep -v "^D" \ | cut -f 2 From 8f319eba6b11422db520b2debffb36ba273a898c Mon Sep 17 00:00:00 2001 From: f Date: Thu, 11 Jan 2024 17:18:36 -0300 Subject: [PATCH 04/22] fix: instalar dependencias (cherry picked from commit 1fbfd30017079bafaff19021b32d8587f95fa116) --- Taskfile.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Taskfile.yaml b/Taskfile.yaml index 8427db4a..c2d72472 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -24,11 +24,14 @@ tasks: deps: - "credentials" cmds: - - task: "bundle" + - "{{.HAINISH}} bundle config set --local path './vendor'" + - "{{.HAINISH}} bundle install" sources: - "Gemfile" generates: - "Gemfile.lock" + status: + - "test -d vendor/ruby" clean: desc: "Clean" cmds: From 399d904f9efa3128e6e574f564b29ab1f6a891f7 Mon Sep 17 00:00:00 2001 From: f Date: Thu, 11 Jan 2024 17:18:58 -0300 Subject: [PATCH 05/22] =?UTF-8?q?fix:=20agregar=20configuraci=C3=B3n=20de?= =?UTF-8?q?=20bundler=20a=20la=20cach=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit 7e43d8f3326bc91e87b224a4b2eea51058ef4694) --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 38f480c9..fd67b54a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,6 +5,7 @@ .cache-ruby: &cache-ruby - paths: - "vendor/ruby" + - ".bundle" .cache-node: &cache-node - paths: - "node_modules" From c22276f74f9de7fa8fa69d42db2e32b1455b6b1d Mon Sep 17 00:00:00 2001 From: f Date: Thu, 11 Jan 2024 18:13:52 -0300 Subject: [PATCH 06/22] =?UTF-8?q?fix:=20especificar=20qu=C3=A9=20parametro?= =?UTF-8?q?s=20de=20airbrake=20permitimos=20#14956?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/v1/notices_controller.rb | 38 ++++++++++++++++++-- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/app/controllers/api/v1/notices_controller.rb b/app/controllers/api/v1/notices_controller.rb index 3d74a48f..8f384f1a 100644 --- a/app/controllers/api/v1/notices_controller.rb +++ b/app/controllers/api/v1/notices_controller.rb @@ -9,10 +9,10 @@ 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 + 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 render status: 201, json: { id: 1, url: '' } @@ -23,7 +23,39 @@ module Api # XXX: Por alguna razón Airbrake envía los datos con Content-Type: # text/plain. def airbrake_params - @airbrake_params ||= params.merge!(FastJsonparser.parse(request.raw_post) || {}).permit! + @airbrake_params ||= + params.merge!(FastJsonparser.parse(request.raw_post) || {}) + .permit( + { + errors: [ + :type, + :message, + { backtrace: %i[file line column function] } + ] + }, + { + context: [ + :url, + :language, + :severity, + :userAgent, + :windowError, + :rootDirectory, + { + history: [ + :date, + :type, + :severity, + :target, + :method, + :duration, + :statusCode, + { arguments: [] } + ] + } + ] + } + ) end def site From 22bd58054a8f024c11344211c4506386bd7e1ec4 Mon Sep 17 00:00:00 2001 From: f Date: Thu, 11 Jan 2024 18:14:21 -0300 Subject: [PATCH 07/22] fix: deprecar carga de archivo desde el sitio #14956 --- app/controllers/sites_controller.rb | 21 --------------------- app/models/post.rb | 4 +++- config/routes.rb | 3 --- 3 files changed, 3 insertions(+), 25 deletions(-) diff --git a/app/controllers/sites_controller.rb b/app/controllers/sites_controller.rb index 17287eb0..bec42b39 100644 --- a/app/controllers/sites_controller.rb +++ b/app/controllers/sites_controller.rb @@ -110,27 +110,6 @@ class SitesController < ApplicationController redirect_to sites_path end - # Obtiene y streamea archivos estáticos desde el repositorio mismo, - # pero sólo los públicos (es decir los archivos subidos desde Sutty). - def static_file - authorize site - - file = params.require(:file) + '.' + params.require(:format) - - raise ActionController::RoutingError.new(nil, nil) unless file.start_with? 'public/' - - path = site.relative_path file - - raise ActionController::RoutingError.new(nil, nil) unless File.exist? path - - # TODO: Hacer esto usa recursos, pero menos que generar el sitio - # cada vez. Para poder usar X-Accel tendríamos que montar los - # repositorios en el servidor web, cosa que no queremos, o hacer - # links simbólicos desde todos los public, o usar un servidor web - # local que soporte sendfile mejor que Rails (nghttpd?) - send_file path - end - private def site diff --git a/app/models/post.rb b/app/models/post.rb index 9aa0ac61..8885897f 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -103,8 +103,10 @@ class Post src = element.attributes['src'] next unless src&.value&.start_with? 'public/' + file = MetadataFile.new(site: site, post: self, document: document, layout: layout) + file.value['path'] = src.value - src.value = Rails.application.routes.url_helpers.site_static_file_url(site, file: src.value) + src.value = Rails.application.routes.url_helpers.url_for(file.static_file) end # Notificar a les usuaries que están viendo una previsualización diff --git a/config/routes.rb b/config/routes.rb index f2487066..635be07a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -28,9 +28,6 @@ Rails.application.routes.draw do # alias en nginx sin tener que usar expresiones regulares para # detectar el nombre del sitio. get '/sites/private/:site_id(*file)', to: 'private#show', constraints: { site_id: %r{[^/]+} } - # Obtener archivos estáticos desde el directorio público - get '/sites/:site_id/static_file/(*file)', to: 'sites#static_file', as: 'site_static_file', - constraints: { site_id: %r{[^/]+} } get '/env.js', to: 'env#index' match '/api/v3/projects/:site_id/notices' => 'api/v1/notices#create', via: %i[post] From 1bed78345c6a478724fbb6a6525053fc62551d28 Mon Sep 17 00:00:00 2001 From: f Date: Thu, 11 Jan 2024 18:16:38 -0300 Subject: [PATCH 08/22] fix: ignorar alertas de brakeman MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * las redirecciones son necesarias para poder reenviar a las páginas de agradecimiento y no podemos saber la url de antemano. * Site.domain no es un atributo sino una configuración estática * Site#tienda_url es un atributo estático * no sabemos todos los parametros de antemano en los breadcrumbs --- config/brakeman.ignore | 252 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 252 insertions(+) create mode 100644 config/brakeman.ignore diff --git a/config/brakeman.ignore b/config/brakeman.ignore new file mode 100644 index 00000000..137d2090 --- /dev/null +++ b/config/brakeman.ignore @@ -0,0 +1,252 @@ +{ + "ignored_warnings": [ + { + "warning_type": "Redirect", + "warning_code": 18, + "fingerprint": "0ae5c3990d49dfbfd4fd61874451f7a576d5056aca913068adf58c314625f810", + "check_name": "Redirect", + "message": "Possible unprotected redirect", + "file": "app/controllers/api/v1/posts_controller.rb", + "line": 20, + "link": "https://brakemanscanner.org/docs/warning_types/redirect/", + "code": "redirect_to((params[:redirect_to] or origin.to_s))", + "render_path": null, + "location": { + "type": "method", + "class": "Api::V1::PostsController", + "method": "create" + }, + "user_input": "params[:redirect_to]", + "confidence": "High", + "cwe_id": [ + 601 + ], + "note": "" + }, + { + "warning_type": "Denial of Service", + "warning_code": 76, + "fingerprint": "1947d1a2ae6e4bf718d0cc563e660efca96897165e9a8dd18186c1d7abe6ddf6", + "check_name": "RegexDoS", + "message": "Model attribute used in regular expression", + "file": "app/controllers/api/v1/base_controller.rb", + "line": 20, + "link": "https://brakemanscanner.org/docs/warning_types/denial_of_service/", + "code": "/\\.#{Site.domain}\\z/", + "render_path": null, + "location": { + "type": "method", + "class": "Api::V1::BaseController", + "method": "site_id" + }, + "user_input": "Site.domain", + "confidence": "Medium", + "cwe_id": [ + 20, + 185 + ], + "note": "No es un atributo, es una variable de entorno" + }, + { + "warning_type": "Cross-Site Scripting", + "warning_code": 4, + "fingerprint": "28d98d08a15c4b3ad94a2cfa20a12573de12d99f1a30b3ca51074ee1f1886592", + "check_name": "LinkToHref", + "message": "Potentially unsafe model attribute in `link_to` href", + "file": "app/views/layouts/_breadcrumb.haml", + "line": 19, + "link": "https://brakemanscanner.org/docs/warning_types/link_to_href", + "code": "link_to(t(\".tienda\"), Site.find(params[:site_id]).tienda_url, :role => \"button\", :class => \"btn\")", + "render_path": [ + { + "type": "controller", + "class": "Api::V1::NoticesController", + "method": "site", + "line": 31, + "file": "app/controllers/api/v1/notices_controller.rb", + "rendered": { + "name": "layouts/application", + "file": "app/views/layouts/application.html.haml" + } + }, + { + "type": "template", + "name": "layouts/application", + "line": 25, + "file": "app/views/layouts/application.html.haml", + "rendered": { + "name": "layouts/_breadcrumb", + "file": "app/views/layouts/_breadcrumb.haml" + } + } + ], + "location": { + "type": "template", + "template": "layouts/_breadcrumb" + }, + "user_input": "Site.find(params[:site_id]).tienda_url", + "confidence": "Weak", + "cwe_id": [ + 79 + ], + "note": "" + }, + { + "warning_type": "Redirect", + "warning_code": 18, + "fingerprint": "5034e51aaa1bac06d15fdde5956edffbfd65f94f5620a409526bbea896dc7b5f", + "check_name": "Redirect", + "message": "Possible unprotected redirect", + "file": "app/controllers/api/v1/contact_controller.rb", + "line": 26, + "link": "https://brakemanscanner.org/docs/warning_types/redirect/", + "code": "redirect_to((params[:redirect] or origin.to_s))", + "render_path": null, + "location": { + "type": "method", + "class": "Api::V1::ContactController", + "method": "receive" + }, + "user_input": "params[:redirect]", + "confidence": "High", + "cwe_id": [ + 601 + ], + "note": "" + }, + { + "warning_type": "Mass Assignment", + "warning_code": 70, + "fingerprint": "50582f39f8dfa900d3f2b5b9908b1592f8b8bd9e2d0b9d1cc05d77e5ede2d94e", + "check_name": "MassAssignment", + "message": "Specify exact keys allowed for mass assignment instead of using `permit!` which allows any keys", + "file": "app/views/layouts/_link_rel_alternate.haml", + "line": 2, + "link": "https://brakemanscanner.org/docs/warning_types/mass_assignment/", + "code": "params.permit!", + "render_path": [ + { + "type": "controller", + "class": "Api::V1::BaseController", + "method": "site_id", + "line": 20, + "file": "app/controllers/api/v1/base_controller.rb", + "rendered": { + "name": "layouts/application", + "file": "app/views/layouts/application.html.haml" + } + }, + { + "type": "template", + "name": "layouts/application", + "line": 21, + "file": "app/views/layouts/application.html.haml", + "rendered": { + "name": "layouts/_link_rel_alternate", + "file": "app/views/layouts/_link_rel_alternate.haml" + } + } + ], + "location": { + "type": "template", + "template": "layouts/_link_rel_alternate" + }, + "user_input": null, + "confidence": "Medium", + "cwe_id": [ + 915 + ], + "note": "" + }, + { + "warning_type": "Mass Assignment", + "warning_code": 70, + "fingerprint": "b8e0aa898288bebb614ccc1340d169caa196d315c6ac2e4744081cc892c2ae97", + "check_name": "MassAssignment", + "message": "Specify exact keys allowed for mass assignment instead of using `permit!` which allows any keys", + "file": "app/views/layouts/_breadcrumb.haml", + "line": 30, + "link": "https://brakemanscanner.org/docs/warning_types/mass_assignment/", + "code": "params.permit!", + "render_path": [ + { + "type": "controller", + "class": "Api::V1::BaseController", + "method": "site_id", + "line": 20, + "file": "app/controllers/api/v1/base_controller.rb", + "rendered": { + "name": "layouts/application", + "file": "app/views/layouts/application.html.haml" + } + }, + { + "type": "template", + "name": "layouts/application", + "line": 25, + "file": "app/views/layouts/application.html.haml", + "rendered": { + "name": "layouts/_breadcrumb", + "file": "app/views/layouts/_breadcrumb.haml" + } + } + ], + "location": { + "type": "template", + "template": "layouts/_breadcrumb" + }, + "user_input": null, + "confidence": "Medium", + "cwe_id": [ + 915 + ], + "note": "" + }, + { + "warning_type": "Cross-Site Scripting", + "warning_code": 4, + "fingerprint": "c051421c7cf4c2706b8e27bfd2f3b0661ec6a6df873da322a6b634b59e80351b", + "check_name": "LinkToHref", + "message": "Potentially unsafe model attribute in `link_to` href", + "file": "app/views/sites/_form.haml", + "line": 74, + "link": "https://brakemanscanner.org/docs/warning_types/link_to_href", + "code": "link_to(t(\".design.url\"), (Unresolved Model).new.url, :target => \"_blank\", :class => \"btn\")", + "render_path": [ + { + "type": "controller", + "class": "SitesController", + "method": "new", + "line": 31, + "file": "app/controllers/sites_controller.rb", + "rendered": { + "name": "sites/new", + "file": "app/views/sites/new.haml" + } + }, + { + "type": "template", + "name": "sites/new", + "line": 6, + "file": "app/views/sites/new.haml", + "rendered": { + "name": "sites/_form", + "file": "app/views/sites/_form.haml" + } + } + ], + "location": { + "type": "template", + "template": "sites/_form" + }, + "user_input": "(Unresolved Model).new.url", + "confidence": "Weak", + "cwe_id": [ + 79 + ], + "note": "" + } + ], + "updated": "2024-01-11 18:12:14 -0300", + "brakeman_version": "5.4.1" +} From eb2ce9d509fae9da45dd7147d9becc741f48393d Mon Sep 17 00:00:00 2001 From: f Date: Thu, 11 Jan 2024 18:31:55 -0300 Subject: [PATCH 09/22] chore: vincular a #14957 --- config/brakeman.ignore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/brakeman.ignore b/config/brakeman.ignore index 137d2090..2388e4fb 100644 --- a/config/brakeman.ignore +++ b/config/brakeman.ignore @@ -21,7 +21,7 @@ "cwe_id": [ 601 ], - "note": "" + "note": "https://0xacab.org/sutty/sutty/-/issues/14957" }, { "warning_type": "Denial of Service", @@ -112,7 +112,7 @@ "cwe_id": [ 601 ], - "note": "" + "note": "https://0xacab.org/sutty/sutty/-/issues/14957" }, { "warning_type": "Mass Assignment", From 939d07430a2fad65d6a63159e4b3a64b710a3890 Mon Sep 17 00:00:00 2001 From: f Date: Thu, 11 Jan 2024 18:33:30 -0300 Subject: [PATCH 10/22] chore: vincular a #14958 --- config/brakeman.ignore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/brakeman.ignore b/config/brakeman.ignore index 2388e4fb..2f987772 100644 --- a/config/brakeman.ignore +++ b/config/brakeman.ignore @@ -156,7 +156,7 @@ "cwe_id": [ 915 ], - "note": "" + "note": "https://0xacab.org/sutty/sutty/-/issues/14958" }, { "warning_type": "Mass Assignment", @@ -200,7 +200,7 @@ "cwe_id": [ 915 ], - "note": "" + "note": "https://0xacab.org/sutty/sutty/-/issues/14958" }, { "warning_type": "Cross-Site Scripting", From f5e4376f1dc2edafc807c3b2b1d8e0fa46b77120 Mon Sep 17 00:00:00 2001 From: f Date: Fri, 12 Jan 2024 10:25:58 -0300 Subject: [PATCH 11/22] fix: no compilar assets en cronjobs --- .gitlab-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fd67b54a..ddb8e5b6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -22,6 +22,8 @@ assets: stage: "deploy" only: - "rails" + except: + - "schedules" cache: - *cache-ruby - *cache-node From bbc937419415a0fb97746a275b957690ccabb379 Mon Sep 17 00:00:00 2001 From: f Date: Fri, 12 Jan 2024 10:26:52 -0300 Subject: [PATCH 12/22] =?UTF-8?q?fix:=20compilar=20assets=20en=20el=20pane?= =?UTF-8?q?l=20de=20producci=C3=B3n=20tambi=C3=A9n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ddb8e5b6..2ce50d03 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -22,6 +22,7 @@ assets: stage: "deploy" only: - "rails" + - "17.3.alpine.panel.sutty.nl" except: - "schedules" cache: From f8a46d645980e5e580ddccb51eb3c2aade4af63d Mon Sep 17 00:00:00 2001 From: f Date: Fri, 12 Jan 2024 10:29:47 -0300 Subject: [PATCH 13/22] fix: instalar bundler audit --- .gitlab-ci.yml | 1 - Gemfile | 1 + Gemfile.lock | 6 +++++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2ce50d03..cb2766d3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -48,7 +48,6 @@ gem-audit: cache: - *cache-ruby before_script: - - "gem install bundler-audit" - *apk-add - *disable-hainish script: diff --git a/Gemfile b/Gemfile index f97c29ab..466ec079 100644 --- a/Gemfile +++ b/Gemfile @@ -117,6 +117,7 @@ end group :development do gem 'yard' gem 'brakeman' + gem 'bundler-audit' gem 'haml-lint', require: false gem 'letter_opener' gem 'listen' diff --git a/Gemfile.lock b/Gemfile.lock index 5be5a103..78563c84 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -106,6 +106,9 @@ GEM sassc-rails (>= 2.0.0) brakeman (5.4.1) builder (3.2.4) + bundler-audit (0.9.1) + bundler (>= 1.2.0, < 3) + thor (~> 1.0) capybara (2.18.0) addressable mini_mime (>= 0.1.3) @@ -536,7 +539,7 @@ GEM temple (0.10.1) terminal-table (2.0.0) unicode-display_width (~> 1.1, >= 1.1.1) - thor (1.2.2) + thor (1.3.0) tilt (2.1.0) timecop (0.9.6) timeout (0.3.2) @@ -586,6 +589,7 @@ DEPENDENCIES blazer bootstrap (~> 4) brakeman + bundler-audit capybara (~> 2.13) chartkick commonmarker From 56e4684ef1bd937e5fc6bf9f599257206e77d5bf Mon Sep 17 00:00:00 2001 From: f Date: Fri, 12 Jan 2024 14:11:29 -0300 Subject: [PATCH 14/22] fix: todos los botones son secundarios closes #14967 --- app/assets/stylesheets/application.scss | 11 +---- app/assets/stylesheets/dark.scss | 19 +++++++++ app/views/collaborations/collaborate.haml | 2 +- app/views/devise/confirmations/new.haml | 2 +- app/views/devise/invitations/edit.haml | 2 +- app/views/devise/invitations/new.haml | 2 +- app/views/devise/passwords/edit.haml | 2 +- app/views/devise/passwords/new.haml | 2 +- app/views/devise/registrations/edit.haml | 4 +- app/views/devise/registrations/new.haml | 2 +- app/views/devise/sessions/new.haml | 2 +- app/views/devise/unlocks/new.haml | 2 +- app/views/i18n/_form.haml | 10 ++--- app/views/layouts/_breadcrumb.haml | 6 +-- app/views/layouts/_btn_with_tooltip.haml | 2 +- app/views/posts/_submit.haml | 2 +- app/views/posts/attributes/_content.haml | 50 +++++++++++------------ app/views/posts/edit.haml | 5 ++- app/views/posts/index.haml | 30 +++++++------- app/views/posts/show.haml | 2 +- app/views/sites/_build.haml | 2 +- app/views/sites/_form.haml | 8 ++-- app/views/sites/fetch.haml | 2 +- app/views/sites/index.haml | 8 ++-- app/views/stats/index.haml | 6 +-- app/views/usuaries/index.haml | 10 ++--- app/views/usuaries/invite.haml | 2 +- 27 files changed, 106 insertions(+), 91 deletions(-) diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 23e4a899..7f62e658 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -29,11 +29,6 @@ $sizes: ( "70ch": 70ch, ); -.btn { - background-color: var(--foreground); - color: var(--background); -} - @import "bootstrap"; @import "editor"; @@ -195,7 +190,7 @@ fieldset { &[type=button] { @extend .btn; - @extend .btn-info; + @extend .btn-secondary; @extend .m-0; } } @@ -209,8 +204,6 @@ svg { } .btn { - border: none; - border-radius: 0; margin-right: 0.3rem; margin-bottom: 0.3rem; @@ -246,7 +239,7 @@ svg { color: $magenta; } - .btn { + .btn-secondary { background-color: $white; color: $black; border: none; diff --git a/app/assets/stylesheets/dark.scss b/app/assets/stylesheets/dark.scss index 9893c70b..59e15180 100644 --- a/app/assets/stylesheets/dark.scss +++ b/app/assets/stylesheets/dark.scss @@ -7,3 +7,22 @@ $cyan: #13fefe; --background: #{$black}; --color: #{$cyan}; } + +.btn-secondary { + background-color: $white; + color: $black; + border: none; + + &:hover { + color: $black; + background-color: $cyan; + } + + &:active { + background-color: $cyan; + } + + &:focus { + box-shadow: 0 0 0 0.2rem $cyan; + } +} diff --git a/app/views/collaborations/collaborate.haml b/app/views/collaborations/collaborate.haml index 4d43ad7e..cc951b0c 100644 --- a/app/views/collaborations/collaborate.haml +++ b/app/views/collaborations/collaborate.haml @@ -25,4 +25,4 @@ class: 'form-control' .form-group - = f.submit t('.submit'), class: 'btn btn-lg btn-block' + = f.submit t('.submit'), class: 'btn btn-secondary btn-lg btn-block' diff --git a/app/views/devise/confirmations/new.haml b/app/views/devise/confirmations/new.haml index bc2f77bb..c934edc5 100644 --- a/app/views/devise/confirmations/new.haml +++ b/app/views/devise/confirmations/new.haml @@ -30,5 +30,5 @@ placeholder: t('activerecord.attributes.usuarie.email') .actions = f.submit t('.resend_confirmation_instructions'), - class: 'btn btn-lg btn-block' + class: 'btn btn-secondary btn-lg btn-block' = render 'devise/shared/links' diff --git a/app/views/devise/invitations/edit.haml b/app/views/devise/invitations/edit.haml index ed4980ef..3d2f8d76 100644 --- a/app/views/devise/invitations/edit.haml +++ b/app/views/devise/invitations/edit.haml @@ -32,4 +32,4 @@ placeholder: t('activerecord.attributes.usuarie.password') .actions = f.submit t('devise.invitations.edit.submit_button'), - class: 'btn btn-lg btn-block' + class: 'btn btn-secondary btn-lg btn-block' diff --git a/app/views/devise/invitations/new.haml b/app/views/devise/invitations/new.haml index 4ebb8fa7..b8b097d0 100644 --- a/app/views/devise/invitations/new.haml +++ b/app/views/devise/invitations/new.haml @@ -16,4 +16,4 @@ = f.text_field field, class: 'form-control' .actions = f.submit t('devise.invitations.new.submit_button'), - class: 'btn btn-lg btn-block' + class: 'btn btn-secondary btn-lg btn-block' diff --git a/app/views/devise/passwords/edit.haml b/app/views/devise/passwords/edit.haml index 3a8843c0..cd8ab8ad 100644 --- a/app/views/devise/passwords/edit.haml +++ b/app/views/devise/passwords/edit.haml @@ -39,6 +39,6 @@ .actions = f.submit t('.change_my_password'), - class: 'btn btn-lg btn-block' + class: 'btn btn-secondary btn-lg btn-block' = render 'devise/shared/links' diff --git a/app/views/devise/passwords/new.haml b/app/views/devise/passwords/new.haml index 08dd8d2e..4bf7c990 100644 --- a/app/views/devise/passwords/new.haml +++ b/app/views/devise/passwords/new.haml @@ -20,5 +20,5 @@ placeholder: t('activerecord.attributes.usuarie.email') .actions = f.submit t('.send_me_reset_password_instructions'), - class: 'btn btn-lg btn-block' + class: 'btn btn-secondary btn-lg btn-block' = render 'devise/shared/links' diff --git a/app/views/devise/registrations/edit.haml b/app/views/devise/registrations/edit.haml index 92699ab8..8bdc55d9 100644 --- a/app/views/devise/registrations/edit.haml +++ b/app/views/devise/registrations/edit.haml @@ -55,7 +55,7 @@ = t('.we_need_your_current_password_to_confirm_your_changes') .actions = f.submit t('.update'), - class: 'btn btn-lg btn-block' + class: 'btn btn-secondary btn-lg btn-block' %hr/ .sr-only @@ -63,4 +63,4 @@ = button_to t('.cancel_my_account'), registration_path(resource_name), data: { confirm: t('.are_you_sure') }, - method: :delete, class: 'btn btn-block' + method: :delete, class: 'btn btn-secondary btn-block' diff --git a/app/views/devise/registrations/new.haml b/app/views/devise/registrations/new.haml index 26fc8e18..aabc0487 100644 --- a/app/views/devise/registrations/new.haml +++ b/app/views/devise/registrations/new.haml @@ -56,6 +56,6 @@ .actions = f.submit t('.sign_up'), - class: 'btn btn-lg btn-block' + class: 'btn btn-secondary btn-lg btn-block' = render 'devise/shared/links' diff --git a/app/views/devise/sessions/new.haml b/app/views/devise/sessions/new.haml index 9b396187..03c3974b 100644 --- a/app/views/devise/sessions/new.haml +++ b/app/views/devise/sessions/new.haml @@ -35,5 +35,5 @@ remember_for: distance_of_time_in_words(Usuarie.remember_for)) .actions = f.submit t('.sign_in'), - class: 'btn btn-lg btn-block' + class: 'btn btn-secondary btn-lg btn-block' = render 'devise/shared/links' diff --git a/app/views/devise/unlocks/new.haml b/app/views/devise/unlocks/new.haml index 09468a52..34253f44 100644 --- a/app/views/devise/unlocks/new.haml +++ b/app/views/devise/unlocks/new.haml @@ -20,5 +20,5 @@ placeholder: t('activerecord.attributes.usuarie.email') .actions = f.submit t('.resend_unlock_instructions'), - class: 'btn btn-lg btn-block' + class: 'btn btn-secondary btn-lg btn-block' = render 'devise/shared/links' diff --git a/app/views/i18n/_form.haml b/app/views/i18n/_form.haml index c88e8616..31b76932 100644 --- a/app/views/i18n/_form.haml +++ b/app/views/i18n/_form.haml @@ -11,7 +11,7 @@ = select_tag 'to', options_for_select(@options, @lang_to), class: 'form-control' - = submit_tag t('i18n.translate'), class: 'btn', name: nil + = submit_tag t('i18n.translate'), class: 'btn btn-secondary', name: nil - else = t('i18n.translating.from') = select_tag 'from', @@ -21,7 +21,7 @@ = select_tag 'to', options_for_select(@options, @lang_to), class: 'form-control' - = submit_tag t('i18n.change'), class: 'btn', name: nil + = submit_tag t('i18n.change'), class: 'btn btn-secondary', name: nil = render 'layouts/help', help: t('help.i18n.index') @@ -33,16 +33,16 @@ = hidden_field 'i18n', 'lang_to', value: @lang_to .form-group .dropdown.inline - %button.btn.dropdown-toggle{type: 'button', + %button.btn.btn-secondary.dropdown-toggle{type: 'button', data: { toggle: 'dropdown' }, aria: { haspopup: 'true', expanded: 'false' }} = t('i18n.jump') .dropdown-menu{aria: { labelledby: t('i18n.jump') }} - @site.data.dig(@lang_from).each_pair do |section, content| %a.dropdown-item{href: "##{section}"}= t("help.i18n.#{section}") - = submit_tag t('i18n.save'), class: 'btn' + = submit_tag t('i18n.save'), class: 'btn btn-secondary' = render 'i18n/recursive', data: @site.data.dig(@lang_from), superkeys: [] .form-group - = submit_tag t('i18n.save'), class: 'btn' + = submit_tag t('i18n.save'), class: 'btn btn-secondary' diff --git a/app/views/layouts/_breadcrumb.haml b/app/views/layouts/_breadcrumb.haml index 11f7f005..137f086e 100644 --- a/app/views/layouts/_breadcrumb.haml +++ b/app/views/layouts/_breadcrumb.haml @@ -17,15 +17,15 @@ - if @site&.tienda? %li.nav-item = link_to t('.tienda'), @site.tienda_url, - role: 'button', class: 'btn' + role: 'button', class: 'btn btn-secondary' %li.nav-item = link_to t('.contact_us'), t('.contact_us_href'), - class: 'btn', rel: 'me', target: '_blank' + class: 'btn btn-secondary', rel: 'me', target: '_blank' %li.nav-item = link_to t('.logout'), main_app.destroy_usuarie_session_path, - method: :delete, role: 'button', class: 'btn' + method: :delete, role: 'button', class: 'btn btn-secondary' - else - params.permit! - I18n.available_locales.each do |locale| diff --git a/app/views/layouts/_btn_with_tooltip.haml b/app/views/layouts/_btn_with_tooltip.haml index 27eda3c1..9651eae0 100644 --- a/app/views/layouts/_btn_with_tooltip.haml +++ b/app/views/layouts/_btn_with_tooltip.haml @@ -1,2 +1,2 @@ -= link_to text, link, class: 'btn', += link_to text, link, class: 'btn btn-secondary', data: { toggle: 'tooltip' }, 'aria-role': 'button', title: tooltip diff --git a/app/views/posts/_submit.haml b/app/views/posts/_submit.haml index 944694c1..c6c0a68a 100644 --- a/app/views/posts/_submit.haml +++ b/app/views/posts/_submit.haml @@ -1,7 +1,7 @@ - invalid_help = site.config.fetch('invalid_help', t('.invalid_help')) - sending_help = site.config.fetch('sending_help', t('.sending_help')) .form-group - = submit_tag t('.save'), class: 'btn submit-post' + = submit_tag t('.save'), class: 'btn btn-secondary submit-post' = render 'bootstrap/alert', class: 'invalid-help d-none' do = invalid_help = render 'bootstrap/alert', class: 'sending-help d-none' do diff --git a/app/views/posts/attributes/_content.haml b/app/views/posts/attributes/_content.haml index 03867941..872422af 100644 --- a/app/views/posts/attributes/_content.haml +++ b/app/views/posts/attributes/_content.haml @@ -20,82 +20,82 @@ TODO: Eliminar todo el espacio en blanco para minificar HTML .editor-toolbar{ style: 'z-index: 1' } .editor-primary-toolbar.scrollbar-black - %button.btn{ type: 'button', title: t('editor.multimedia'), data: { editor_button: 'multimedia' } }> + %button.btn.btn-secondary{ type: 'button', title: t('editor.multimedia'), data: { editor_button: 'multimedia' } }> %i.fa.fa-fw.fa-upload> %span.sr-only>= t('editor.multimedia') - %button.btn{ type: 'button', title: t('editor.bold'), data: { editor_button: 'mark-bold' } }> + %button.btn.btn-secondary{ type: 'button', title: t('editor.bold'), data: { editor_button: 'mark-bold' } }> %i.fa.fa-fw.fa-bold> %span.sr-only>= t('editor.bold') - %button.btn{ type: 'button', title: t('editor.italic'), data: { editor_button: 'mark-italic' } }> + %button.btn.btn-secondary{ type: 'button', title: t('editor.italic'), data: { editor_button: 'mark-italic' } }> %i.fa.fa-fw.fa-italic> %span.sr-only>= t('editor.italic') - %button.btn{ type: 'button', title: t('editor.mark'), data: { editor_button: 'mark-mark' } }> + %button.btn.btn-secondary{ type: 'button', title: t('editor.mark'), data: { editor_button: 'mark-mark' } }> %i.fa.fa-fw.fa-tint> %span.sr-only>= t('editor.mark') - %button.btn{ type: 'button', title: t('editor.link'), data: { editor_button: 'mark-link' } }> + %button.btn.btn-secondary{ type: 'button', title: t('editor.link'), data: { editor_button: 'mark-link' } }> %i.fa.fa-fw.fa-link> %span.sr-only>= t('editor.link') - %button.btn{ type: 'button', title: t('editor.deleted'), data: { editor_button: 'mark-deleted' } }> + %button.btn.btn-secondary{ type: 'button', title: t('editor.deleted'), data: { editor_button: 'mark-deleted' } }> %i.fa.fa-fw.fa-strikethrough> %span.sr-only>= t('editor.deleted') - %button.btn{ type: 'button', title: t('editor.underline'), data: { editor_button: 'mark-underline' } }> + %button.btn.btn-secondary{ type: 'button', title: t('editor.underline'), data: { editor_button: 'mark-underline' } }> %i.fa.fa-fw.fa-underline> %span.sr-only>= t('editor.underline') - %button.btn{ type: 'button', title: t('editor.super'), data: { editor_button: 'mark-super' } }> + %button.btn.btn-secondary{ type: 'button', title: t('editor.super'), data: { editor_button: 'mark-super' } }> %i.fa.fa-fw.fa-superscript> %span.sr-only>= t('editor.super') - %button.btn{ type: 'button', title: t('editor.sub'), data: { editor_button: 'mark-sub' } }> + %button.btn.btn-secondary{ type: 'button', title: t('editor.sub'), data: { editor_button: 'mark-sub' } }> %i.fa.fa-fw.fa-subscript> %span.sr-only>= t('editor.sub') - %button.btn{ type: 'button', title: t('editor.small'), data: { editor_button: 'mark-small' } }> + %button.btn.btn-secondary{ type: 'button', title: t('editor.small'), data: { editor_button: 'mark-small' } }> %i.fa.fa-fw.fa-subscript> %span.sr-only>= t('editor.small') - %button.btn.mr-0{ type: 'button', title: t('editor.h1'), data: { editor_button: 'block-h1' } }> + %button.btn.btn-secondary.mr-0{ type: 'button', title: t('editor.h1'), data: { editor_button: 'block-h1' } }> %i.fa.fa-fw.fa-heading> 1 %span.sr-only>= t('editor.h1') %details.d-inline> %summary.d-inline> - %span.btn.ml-0{ role: 'button', title: t('editor.more') }> + %span.btn.btn-secondary.ml-0{ role: 'button', title: t('editor.more') }> %i.fa.fa-caret-right> %span.sr-only= t('editor.more') .d-inline> - %button.btn{ type: 'button', title: t('editor.h2'), data: { editor_button: 'block-h2' } }> + %button.btn.btn-secondary{ type: 'button', title: t('editor.h2'), data: { editor_button: 'block-h2' } }> %i.fa.fa-fw.fa-heading> 2 %span.sr-only>= t('editor.h2') - %button.btn{ type: 'button', title: t('editor.h3'), data: { editor_button: 'block-h3' } }> + %button.btn.btn-secondary{ type: 'button', title: t('editor.h3'), data: { editor_button: 'block-h3' } }> %i.fa.fa-fw.fa-heading> 3 %span.sr-only>= t('editor.h3') - %button.btn{ type: 'button', title: t('editor.h4'), data: { editor_button: 'block-h4' } }> + %button.btn.btn-secondary{ type: 'button', title: t('editor.h4'), data: { editor_button: 'block-h4' } }> %i.fa.fa-fw.fa-heading> 4 %span.sr-only>= t('editor.h4') - %button.btn{ type: 'button', title: t('editor.h5'), data: { editor_button: 'block-h5' } }> + %button.btn.btn-secondary{ type: 'button', title: t('editor.h5'), data: { editor_button: 'block-h5' } }> %i.fa.fa-fw.fa-heading> 5 %span.sr-only>= t('editor.h5') - %button.btn{ type: 'button', title: t('editor.h6'), data: { editor_button: 'block-h6' } }> + %button.btn.btn-secondary{ type: 'button', title: t('editor.h6'), data: { editor_button: 'block-h6' } }> %i.fa.fa-fw.fa-heading> 6 %span.sr-only>= t('editor.h6') - %button.btn{ type: 'button', title: t('editor.ul'), data: { editor_button: 'block-unordered_list' } }> + %button.btn.btn-secondary{ type: 'button', title: t('editor.ul'), data: { editor_button: 'block-unordered_list' } }> %i.fa.fa-fw.fa-list-ul> %span.sr-only>= t('editor.ul') - %button.btn{ type: 'button', title: t('editor.ol'), data: { editor_button: 'block-ordered_list' } }> + %button.btn.btn-secondary{ type: 'button', title: t('editor.ol'), data: { editor_button: 'block-ordered_list' } }> %i.fa.fa-fw.fa-list-ol> %span.sr-only>= t('editor.ol') - %button.btn{ type: 'button', title: t('editor.left'), data: { editor_button: 'parentBlock-left' } }> + %button.btn.btn-secondary{ type: 'button', title: t('editor.left'), data: { editor_button: 'parentBlock-left' } }> %i.fa.fa-fw.fa-align-left> %span.sr-only>= t('editor.left') - %button.btn{ type: 'button', title: t('editor.center'), data: { editor_button: 'parentBlock-center' } }> + %button.btn.btn-secondary{ type: 'button', title: t('editor.center'), data: { editor_button: 'parentBlock-center' } }> %i.fa.fa-fw.fa-align-center> %span.sr-only>= t('editor.center') - %button.btn{ type: 'button', title: t('editor.right'), data: { editor_button: 'parentBlock-right' } }> + %button.btn.btn-secondary{ type: 'button', title: t('editor.right'), data: { editor_button: 'parentBlock-right' } }> %i.fa.fa-fw.fa-align-right> %span.sr-only>= t('editor.right') - %button.btn{ type: 'button', title: t('editor.blockquote'), data: { editor_button: 'block-blockquote' } }> + %button.btn.btn-secondary{ type: 'button', title: t('editor.blockquote'), data: { editor_button: 'block-blockquote' } }> %i.fa.fa-fw.fa-quote-left> %span.sr-only>= t('editor.blockquote') @@ -116,8 +116,8 @@ %label{ for: 'multimedia-alt' }= t('editor.description') %input.form-control{ type: 'text', id: 'multimedia-alt', name: 'multimedia-alt' }/ .form-group - %button.btn{ type: 'button', id: 'multimedia-file-upload', name: 'multimedia-file-upload' }= t('editor.multimedia-upload') - %button.btn{ type: 'button', id: 'multimedia-remove', name: 'multimedia-remove' }= t('editor.multimedia-remove') + %button.btn.btn-secondary{ type: 'button', id: 'multimedia-file-upload', name: 'multimedia-file-upload' }= t('editor.multimedia-upload') + %button.btn.btn-secondary{ type: 'button', id: 'multimedia-remove', name: 'multimedia-remove' }= t('editor.multimedia-remove') .form-group{ data: { editor_auxiliary: 'link' } } %label{ for: 'link-url' }= t('editor.url') diff --git a/app/views/posts/edit.haml b/app/views/posts/edit.haml index 6ec252fe..c792ac93 100644 --- a/app/views/posts/edit.haml +++ b/app/views/posts/edit.haml @@ -1,3 +1,6 @@ .row.justify-content-center .col-md-8 - = render 'posts/form', site: @site, post: @post + = render 'layouts/details', summary: "Post" do + = render 'posts/form', site: @site, post: @post + = render 'layouts/details', summary: t('.moderation_queue') do + = render 'posts/moderation_queue', site: @site, post: @post, moderation_queue: @moderation_queue diff --git a/app/views/posts/index.haml b/app/views/posts/index.haml index ae53aa7a..374f06ee 100644 --- a/app/views/posts/index.haml +++ b/app/views/posts/index.haml @@ -15,13 +15,13 @@ = render 'schemas/row', site: @site, schema: schema, filter: @filter_params - if policy(@site_stat).index? - = link_to t('stats.index.title'), site_stats_path(@site), class: 'btn' + = link_to t('stats.index.title'), site_stats_path(@site), class: 'btn btn-secondary' - if policy(@site).edit? - = link_to t('sites.edit.btn', site: @site.title), edit_site_path(@site), class: 'btn' + = link_to t('sites.edit.btn', site: @site.title), edit_site_path(@site), class: 'btn btn-secondary' - if policy(@site).private? - = link_to t('sites.private'), '../private/' + @site.name, class: 'btn', target: '_blank', rel: 'noopener' + = link_to t('sites.private'), '../private/' + @site.name, class: 'btn btn-secondary', target: '_blank', rel: 'noopener' - if policy(SiteUsuarie.new(@site, current_usuarie)).index? = render 'layouts/btn_with_tooltip', @@ -33,9 +33,9 @@ - if @site.design.credits = render 'bootstrap/alert' do = sanitize_markdown @site.design.credits - = link_to t('sites.donations.text'), t('sites.donations.url'), class: 'btn' + = link_to t('sites.donations.text'), t('sites.donations.url'), class: 'btn btn-secondary' - if @site.design.designer_url - = link_to t('sites.designer_url'), @site.design.designer_url, class: 'btn' + = link_to t('sites.designer_url'), @site.design.designer_url, class: 'btn btn-secondary' %section.col .d-flex.justify-content-between.align-items-center.pl-2-plus.pr-2-plus.mb-2 @@ -75,19 +75,19 @@ %th.border-0{ colspan: '4' } .d-flex.flex-row.justify-content-between %div - = submit_tag t('posts.reorder.submit'), class: 'btn' - %button.btn{ data: { action: 'reorder#unselect' } } + = submit_tag t('posts.reorder.submit'), class: 'btn btn-secondary' + %button.btn.btn-secondary{ data: { action: 'reorder#unselect' } } = t('posts.reorder.unselect') %span.badge{ data: { target: 'reorder.counter' } } 0 - %button.btn{ data: { action: 'reorder#up' } }= t('posts.reorder.up') - %button.btn{ data: { action: 'reorder#down' } }= t('posts.reorder.down') - %button.btn{ data: { action: 'reorder#top' } }= t('posts.reorder.top') - %button.btn{ data: { action: 'reorder#bottom' } }= t('posts.reorder.bottom') + %button.btn.btn-secondary{ data: { action: 'reorder#up' } }= t('posts.reorder.up') + %button.btn.btn-secondary{ data: { action: 'reorder#down' } }= t('posts.reorder.down') + %button.btn.btn-secondary{ data: { action: 'reorder#top' } }= t('posts.reorder.top') + %button.btn.btn-secondary{ data: { action: 'reorder#bottom' } }= t('posts.reorder.bottom') - if @site.pagination %div - = link_to_prev_page @posts, t('posts.prev'), class: 'btn' - = link_to_next_page @posts, t('posts.next'), class: 'btn' + = link_to_prev_page @posts, t('posts.prev'), class: 'btn btn-secondary' + = link_to_next_page @posts, t('posts.next'), class: 'btn btn-secondary' %tbody - dir = @site.data.dig(params[:locale], 'dir') - size = @posts.size @@ -126,9 +126,9 @@ = post.order %td.text-nowrap - if @usuarie || policy(post).edit? - = link_to t('posts.edit'), edit_site_post_path(@site, post.path), class: 'btn btn-block' + = link_to t('posts.edit'), edit_site_post_path(@site, post.path), class: 'btn btn-secondary btn-block' - if @usuarie || policy(post).destroy? - = link_to t('posts.destroy'), site_post_path(@site, post.path), class: 'btn btn-block', method: :delete, data: { confirm: t('posts.confirm_destroy') } + = link_to t('posts.destroy'), site_post_path(@site, post.path), class: 'btn btn-secondary btn-block', method: :delete, data: { confirm: t('posts.confirm_destroy') } #footnotes{ hidden: true } - @filter_params.each do |param, value| diff --git a/app/views/posts/show.haml b/app/views/posts/show.haml index 068a6adf..10900d67 100644 --- a/app/views/posts/show.haml +++ b/app/views/posts/show.haml @@ -4,7 +4,7 @@ %article.content.table-responsive-md = link_to t('posts.edit'), edit_site_post_path(@site, @post.id), - class: 'btn btn-block' + class: 'btn btn-secondary btn-block' %table.table.table-condensed %thead diff --git a/app/views/sites/_build.haml b/app/views/sites/_build.haml index 5911e908..b0961e31 100644 --- a/app/views/sites/_build.haml +++ b/app/views/sites/_build.haml @@ -3,7 +3,7 @@ method: :post, class: 'form-inline inline' do = submit_tag site.enqueued? ? t('sites.enqueued') : t('sites.enqueue'), - class: "btn no-border-radius #{local_assigns[:class]}", + class: "btn btn-secondary #{local_assigns[:class]}", title: site.enqueued? ? t('help.sites.enqueued') : t('help.sites.enqueue'), data: { disable_with: t('sites.enqueued') }, disabled: site.enqueued? diff --git a/app/views/sites/_form.haml b/app/views/sites/_form.haml index 0dcccbe3..ec2712bf 100644 --- a/app/views/sites/_form.haml +++ b/app/views/sites/_form.haml @@ -72,10 +72,10 @@ .btn-group{ role: 'group', 'aria-label': t('.design.actions') } - if design.url = link_to t('.design.url'), design.url, - target: '_blank', class: 'btn' + target: '_blank', class: 'btn btn-secondary' - if design.license = link_to t('.design.license'), design.license, - target: '_blank', class: 'btn' + target: '_blank', class: 'btn btn-secondary' %hr/ .form-group.licenses#license_id @@ -99,7 +99,7 @@ tags: %w[p a strong em ul ol li h1 h2 h3 h4 h5 h6] - unless licencia.custom? - = link_to t('.licencia.url'), licencia.url, target: '_blank', class: 'btn', rel: 'noopener' + = link_to t('.licencia.url'), licencia.url, target: '_blank', class: 'btn btn-secondary', rel: 'noopener' %hr/ @@ -163,4 +163,4 @@ deploy: deploy, site: site .form-group - = f.submit submit, class: 'btn btn-lg btn-block' + = f.submit submit, class: 'btn btn-secondary btn-lg btn-block' diff --git a/app/views/sites/fetch.haml b/app/views/sites/fetch.haml index f5d049c8..6d670d6f 100644 --- a/app/views/sites/fetch.haml +++ b/app/views/sites/fetch.haml @@ -27,4 +27,4 @@ .row.justify-content-center .col-md-8 = link_to t('.merge.request'), site_pull_path(@site), - method: 'post', class: 'btn btn-lg' + method: 'post', class: 'btn btn-secondary btn-lg' diff --git a/app/views/sites/index.haml b/app/views/sites/index.haml index b7231292..ed87180a 100644 --- a/app/views/sites/index.haml +++ b/app/views/sites/index.haml @@ -4,7 +4,7 @@ %p.lead= t('.help') - if policy(Site).new? = link_to t('sites.new.title'), new_site_path, - class: 'btn' + class: 'btn btn-secondary' %section.col - if @sites.empty? @@ -29,18 +29,18 @@ = site.title %p.lead= site.description %br - = link_to t('.visit'), site.url, class: 'btn' + = link_to t('.visit'), site.url, class: 'btn btn-secondary' - if rol.temporal = button_to t('sites.invitations.accept'), site_usuaries_accept_invitation_path(site), method: :patch, title: t('help.sites.invitations.accept'), - class: 'btn' + class: 'btn btn-secondary' = button_to t('sites.invitations.reject'), site_usuaries_reject_invitation_path(site), method: :patch, title: t('help.sites.invitations.reject'), - class: 'btn' + class: 'btn btn-secondary' - else - if policy(site).show? = render 'layouts/btn_with_tooltip', diff --git a/app/views/stats/index.haml b/app/views/stats/index.haml index 88e86aa3..1c1a31f1 100644 --- a/app/views/stats/index.haml +++ b/app/views/stats/index.haml @@ -11,11 +11,11 @@ %form.mb-5.form-inline{ method: 'get' } - Stat::INTERVALS.each do |interval| - = link_to t(".#{interval}"), site_stats_path(interval: interval, urls: params[:urls], period_start: params[:period_start].to_date.try(:"beginning_of_#{interval}").to_date, period_end: params[:period_end]), class: "mb-0 btn #{'btn-primary active' if @interval == interval}" + = link_to t(".#{interval}"), site_stats_path(interval: interval, urls: params[:urls], period_start: params[:period_start].to_date.try(:"beginning_of_#{interval}").to_date, period_end: params[:period_end]), class: "mb-0 btn #{@interval == interval ? 'btn-primary active' : 'btn-secondary' }" %input.form-control{ type: 'date', name: :period_start, value: params[:period_start] } %input.form-control{ type: 'date', name: :period_end, value: params[:period_end] } - %button.btn.mb-0{ type: 'submit' }= t('.filter') + %button.btn.btn-secondary.mb-0{ type: 'submit' }= t('.filter') .mb-5 %h2= t('.host.title', count: @hostnames.size) @@ -34,7 +34,7 @@ %textarea#urls.form-control{ name: 'urls', autocomplete: 'on', required: true, rows: @normalized_urls.size + 1, aria_describedby: 'help-urls' }= @normalized_urls.join("\n") %small#help-urls.feedback.form-text.text-muted= t('.urls.help') .form-group - %button.btn{ type: 'submit' }= t('.urls.submit') + %button.btn.btn-secondary{ type: 'submit' }= t('.urls.submit') - if @normalized_urls.present? = line_chart site_stats_uris_path(urls: @normalized_urls, **@chart_params), **@chart_options diff --git a/app/views/usuaries/index.haml b/app/views/usuaries/index.haml index 124fb04b..f972a91f 100644 --- a/app/views/usuaries/index.haml +++ b/app/views/usuaries/index.haml @@ -9,13 +9,13 @@ - if @policy.invite? = link_to t('.invite'), site_usuaries_invite_path(@site, invite_as: u.to_s), - class: 'btn', + class: 'btn btn-secondary', data: { toggle: 'tooltip' }, title: t('.help.invite', invite_as: u.to_s) - if policy(Collaboration.new(@site)).collaborate? = link_to t('.public_invite'), site_collaborate_path(@site), - class: 'btn', + class: 'btn btn-secondary', data: { toggle: 'tooltip' }, title: t('.help.public_invite') %p.lead= t(".help.#{u}") @@ -38,7 +38,7 @@ - if @policy.demote? && @site.usuarie?(cuenta) = link_to t('.demote.text'), site_usuarie_demote_path(@site, cuenta), - class: 'btn', + class: 'btn btn-secondary', data: { toggle: 'tooltip', confirm: t('.demote.confirm') }, title: t('.help.demote'), @@ -46,7 +46,7 @@ - if @policy.promote? && @site.invitade?(cuenta) = link_to t('.promote.text'), site_usuarie_promote_path(@site, cuenta), - class: 'btn', + class: 'btn btn-secondary', data: { toggle: 'tooltip', confirm: t('.promote.confirm') }, title: t('.help.promote'), @@ -54,7 +54,7 @@ - if @policy.destroy? = link_to t('.destroy.text'), site_usuarie_path(@site, cuenta), - class: 'btn', + class: 'btn btn-secondary', data: { toggle: 'tooltip', confirm: t('.destroy.confirm') }, title: t('.help.destroy'), diff --git a/app/views/usuaries/invite.haml b/app/views/usuaries/invite.haml index 26eb5039..2698fb8f 100644 --- a/app/views/usuaries/invite.haml +++ b/app/views/usuaries/invite.haml @@ -13,4 +13,4 @@ invite_as: invite_as) = f.text_area :invitaciones, class: 'form-control' .form-group - = f.submit t('.submit'), class: 'btn' + = f.submit t('.submit'), class: 'btn btn-secondary' From 60fa25e5a86e8bcc5913d4f7a398f1db68055a91 Mon Sep 17 00:00:00 2001 From: f Date: Fri, 12 Jan 2024 17:09:08 -0300 Subject: [PATCH 15/22] fix: no fallar en File#touch --- 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 5fb7bcc3..8810f83b 100644 --- a/app/models/site.rb +++ b/app/models/site.rb @@ -578,7 +578,7 @@ class Site < ApplicationRecord if !gems_installed? || gemfile_updated? || gemfile_lock_updated? deploy_local.bundle touch - File.touch(gemfile_path) + ::File.touch(gemfile_path) end end From 29b0622ea873ab2d820fcdd0a94031863f70c989 Mon Sep 17 00:00:00 2001 From: f Date: Fri, 12 Jan 2024 17:09:27 -0300 Subject: [PATCH 16/22] =?UTF-8?q?fix:=20el=20m=C3=A9todo=20es=20p=C3=BAbli?= =?UTF-8?q?co=20para=20poder=20instalar=20gemas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit closes #14964 --- app/models/deploy_local.rb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/app/models/deploy_local.rb b/app/models/deploy_local.rb index ce4f858c..29a31f8c 100644 --- a/app/models/deploy_local.rb +++ b/app/models/deploy_local.rb @@ -7,6 +7,15 @@ class DeployLocal < Deploy before_destroy :remove_destination! + def bundle(output: false) + run %(bundle config set --local clean 'true'), output: output + run(%(bundle config set --local deployment 'true'), output: output) if site.gemfile_lock_path? + 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 git_lfs(output: false) run %(git lfs fetch), output: output run %(git lfs checkout), output: output @@ -129,15 +138,6 @@ class DeployLocal < Deploy run 'yarn install --production', output: output end - def bundle(output: false) - run %(bundle config set --local clean 'true'), output: output - run(%(bundle config set --local deployment 'true'), output: output) if site.gemfile_lock_path? - 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) with_tempfile(site.private_key_pem) do |file| flags = extra_flags(private_key: file) From 4192e8b8f9272d2f80e88790c7350c078dcdef79 Mon Sep 17 00:00:00 2001 From: f Date: Fri, 12 Jan 2024 17:34:27 -0300 Subject: [PATCH 17/22] fix: cargar distributed press --- app/models/site/social_distributed_press.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/site/social_distributed_press.rb b/app/models/site/social_distributed_press.rb index 5d469f03..3be6404e 100644 --- a/app/models/site/social_distributed_press.rb +++ b/app/models/site/social_distributed_press.rb @@ -16,7 +16,7 @@ class Site # # @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 + self.private_key_pem ||= ::DistributedPress::V1::Social::Client.new(public_key_url: nil, key_size: 2048).private_key.export end end end From 5e6cbba28ef57e43ec7e1aeb547614cc96f22778 Mon Sep 17 00:00:00 2001 From: f Date: Fri, 12 Jan 2024 17:36:31 -0300 Subject: [PATCH 18/22] =?UTF-8?q?fix:=20prevenci=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/site.rb | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/app/models/site.rb b/app/models/site.rb index 8810f83b..dd250e3d 100644 --- a/app/models/site.rb +++ b/app/models/site.rb @@ -159,19 +159,19 @@ class Site < ApplicationRecord # Traer la ruta del sitio def path - File.join(Site.site_path, name) + ::File.join(Site.site_path, name) end # La ruta anterior def path_was - File.join(Site.site_path, name_was) + ::File.join(Site.site_path, name_was) end # Limpiar la ruta y unirla con el separador de directorios del # sistema operativo. Como si algún día fuera a cambiar o # soportáramos Windows :P def relative_path(suspicious_path) - File.join(path, *suspicious_path.gsub('..', '/').gsub('./', '').squeeze('/').split('/')) + ::File.join(path, *suspicious_path.gsub('..', '/').gsub('./', '').squeeze('/').split('/')) end # Obtiene la lista de traducciones actuales @@ -358,7 +358,7 @@ class Site < ApplicationRecord end def jekyll? - File.directory? path + ::File.directory? path end def jekyll @@ -376,7 +376,7 @@ class Site < ApplicationRecord # documentos de Jekyll hacia Sutty para que podamos leer los datos que # necesitamos. def load_jekyll - return unless name.present? && File.directory?(path) + return unless name.present? && ::File.directory?(path) reload_jekyll! end @@ -404,7 +404,7 @@ class Site < ApplicationRecord # metadatos de Document @configuration = ::Jekyll.configuration('source' => path, - 'destination' => File.join(path, '_site'), + 'destination' => ::File.join(path, '_site'), 'safe' => true, 'watch' => false, 'quiet' => true, 'excerpt_separator' => '') @@ -429,7 +429,7 @@ class Site < ApplicationRecord # El directorio donde se almacenan los sitios def self.site_path - @site_path ||= File.realpath(ENV.fetch('SITE_PATH', Rails.root.join('_sites'))) + @site_path ||= ::File.realpath(ENV.fetch('SITE_PATH', Rails.root.join('_sites'))) end def self.default @@ -460,7 +460,7 @@ class Site < ApplicationRecord end def gemfile_lock_path? - File.exist? gemfile_lock_path + ::File.exist? gemfile_lock_path end private @@ -599,16 +599,16 @@ class Site < ApplicationRecord # Detecta si el Gemfile fue modificado def gemfile_updated? - updated_at < File.mtime(gemfile_path) + updated_at < ::File.mtime(gemfile_path) end def gemfile_path - @gemfile_path ||= File.join(path, 'Gemfile') + @gemfile_path ||= ::File.join(path, 'Gemfile') end # @return [String] def gemfile_lock_path - @gemfile_lock_path ||= File.join(path, 'Gemfile.lock') + @gemfile_lock_path ||= ::File.join(path, 'Gemfile.lock') end # Detecta si el Gemfile.lock fue modificado con respecto al sitio o al @@ -616,8 +616,8 @@ class Site < ApplicationRecord def gemfile_lock_updated? return false unless gemfile_lock_path? - [updated_at, File.mtime(File.join(path, 'Gemfile'))].any? do |compare| - compare < File.mtime(gemfile_lock_path) + [updated_at, ::File.mtime(::File.join(path, 'Gemfile'))].any? do |compare| + compare < ::File.mtime(gemfile_lock_path) end end end From 023b23915078fc461be95d90eb2c389311fd1126 Mon Sep 17 00:00:00 2001 From: f Date: Thu, 22 Feb 2024 11:46:39 -0300 Subject: [PATCH 19/22] fix: no hay botones verdes --- app/views/devise/shared/_links.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/devise/shared/_links.haml b/app/views/devise/shared/_links.haml index b4b89175..5d5c0b67 100644 --- a/app/views/devise/shared/_links.haml +++ b/app/views/devise/shared/_links.haml @@ -4,12 +4,12 @@ - if controller_name != 'sessions' = link_to t('.sign_in'), new_session_path(resource_name, params: locale), - class: 'btn btn-lg btn-block btn-success' + class: 'btn btn-lg btn-block btn-secondary' %br/ - if devise_mapping.registerable? && controller_name != 'registrations' = link_to t('.sign_up'), new_registration_path(resource_name, params: locale), - class: 'btn btn-lg btn-block btn-success' + class: 'btn btn-lg btn-block btn-secondary' %br/ - if devise_mapping.recoverable? From 969d641a9194c86dfb68b6ac76398ecc46d7703e Mon Sep 17 00:00:00 2001 From: f Date: Thu, 22 Feb 2024 16:04:10 -0300 Subject: [PATCH 20/22] fix: touch --- 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 dd250e3d..7b93184f 100644 --- a/app/models/site.rb +++ b/app/models/site.rb @@ -578,7 +578,7 @@ class Site < ApplicationRecord if !gems_installed? || gemfile_updated? || gemfile_lock_updated? deploy_local.bundle touch - ::File.touch(gemfile_path) + FileUtils.touch(gemfile_path) end end From 6c3b2ab022b50bb15753d5acdd584f76239142d3 Mon Sep 17 00:00:00 2001 From: jazzari Date: Fri, 1 Mar 2024 12:19:51 -0300 Subject: [PATCH 21/22] fix: movido metodo lfs_cleanup en cleanup_service.rb a site::repository --- app/models/site/repository.rb | 5 +++++ app/services/cleanup_service.rb | 10 ++-------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/app/models/site/repository.rb b/app/models/site/repository.rb index acbf6553..58baa5dd 100644 --- a/app/models/site/repository.rb +++ b/app/models/site/repository.rb @@ -235,5 +235,10 @@ class Site r&.success? end + + def lfs_cleanup + site.repository.git_sh("git", "lfs", "prune") + site.repository.git_sh("git", "lfs", "dedup") + end end end diff --git a/app/services/cleanup_service.rb b/app/services/cleanup_service.rb index 28f6f860..e53fbcb4 100644 --- a/app/services/cleanup_service.rb +++ b/app/services/cleanup_service.rb @@ -31,7 +31,7 @@ class CleanupService site.deploys.find_each(&:cleanup!) site.repository.gc - lfs_cleanup + site.repository.lfs_cleanup site.touch end end @@ -46,14 +46,8 @@ class CleanupService Rails.logger.info "Limpiando repositorio git de #{site.name}" site.repository.gc - lfs_cleanup + site.repository.lfs_cleanup site.touch end end - - private - def lfs_cleanup - site.repository.git_sh("git", "lfs", "prune") - site.repository.git_sh("git", "lfs", "dedup") - end end From 291c477aec286e4cbefca321604c91cdf428c65a Mon Sep 17 00:00:00 2001 From: jazzari Date: Fri, 1 Mar 2024 13:11:04 -0300 Subject: [PATCH 22/22] fix: corregido metodo lfs_cleanup --- 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 58baa5dd..687ced12 100644 --- a/app/models/site/repository.rb +++ b/app/models/site/repository.rb @@ -237,8 +237,8 @@ class Site end def lfs_cleanup - site.repository.git_sh("git", "lfs", "prune") - site.repository.git_sh("git", "lfs", "dedup") + git_sh("git", "lfs", "prune") + git_sh("git", "lfs", "dedup") end end end