From 70528aa6028d6a1a9e903289f7f2043b93b6ac47 Mon Sep 17 00:00:00 2001 From: maki Date: Tue, 4 Jun 2024 12:49:37 -0300 Subject: [PATCH 1/6] fix: lints --- app/assets/stylesheets/application.scss | 13 ++ app/controllers/application_controller.rb | 4 +- app/controllers/stats_controller.rb | 2 +- app/helpers/application_helper.rb | 3 +- app/models/deploy_distributed_press.rb | 15 +- app/models/deploy_local.rb | 2 +- app/models/deploy_rsync.rb | 8 +- app/models/indexed_post.rb | 8 +- app/models/metadata_belongs_to.rb | 2 +- app/models/metadata_content.rb | 33 ++-- app/models/metadata_related_posts.rb | 5 +- app/models/post.rb | 4 +- app/models/post/indexable.rb | 1 - app/models/site.rb | 1 - app/models/site/index.rb | 4 +- app/models/site/repository.rb | 10 +- app/services/post_service.rb | 6 +- .../bootstrap/_custom_checkbox_for_field.haml | 2 +- app/views/collaborations/collaborate.haml | 12 +- app/views/devise/confirmations/new.haml | 27 ++- app/views/devise/invitations/edit.haml | 24 +-- app/views/devise/invitations/new.haml | 8 +- app/views/devise/passwords/edit.haml | 29 ++- app/views/devise/passwords/new.haml | 12 +- app/views/devise/registrations/edit.haml | 39 ++-- app/views/devise/registrations/new.haml | 31 ++-- app/views/devise/sessions/new.haml | 20 +-- app/views/devise/unlocks/new.haml | 12 +- app/views/layouts/_breadcrumb.haml | 9 +- app/views/layouts/_details.haml | 5 +- .../posts/attribute_ro/_related_posts.haml | 1 + app/views/posts/attributes/_draft.haml | 13 ++ app/views/posts/attributes/_file.haml | 60 ++++--- app/views/posts/attributes/_has_one.haml | 6 +- app/views/posts/attributes/_image.haml | 48 +++-- app/views/posts/attributes/_locales.haml | 7 +- app/views/posts/index.haml | 166 +++++++++++------- app/views/posts/show.haml | 4 +- app/views/schemas/_add.haml | 4 +- app/views/schemas/_filter.haml | 14 +- app/views/schemas/_row.haml | 8 +- app/views/sites/_form.haml | 47 ++--- app/views/sites/_header.haml | 17 +- app/views/sites/fetch.haml | 4 +- app/views/sites/index.haml | 1 + app/views/stats/index.haml | 44 +++-- app/views/usuaries/index.haml | 54 +++--- app/views/usuaries/invite.haml | 4 +- config/environments/test.rb | 6 +- test/controllers/posts_controller_test.rb | 4 +- 50 files changed, 492 insertions(+), 371 deletions(-) create mode 100644 app/views/posts/attributes/_draft.haml diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 94f37b4f..f90e967a 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -670,3 +670,16 @@ a.black { } } +.break-all { + word-break: break-all; +} + +.details-agregar { + @extend .d-flex; + @extend .border; + @extend .border-magenta; + @extend .justify-content-between; + @extend .align-items-center; + @extend .w-100; + @extend .mb-3; +} \ No newline at end of file diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index a96d1ec0..f9d1a246 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -86,9 +86,7 @@ class ApplicationController < ActionController::Base end def site - @site ||= find_site.tap do |s| - s.reindex_changes! - end + @site ||= find_site.tap(&:reindex_changes!) end protected diff --git a/app/controllers/stats_controller.rb b/app/controllers/stats_controller.rb index 893a16c9..6934b7aa 100644 --- a/app/controllers/stats_controller.rb +++ b/app/controllers/stats_controller.rb @@ -175,7 +175,7 @@ class StatsController < ApplicationController locale: I18n.locale, empty: I18n.t('stats.index.empty', **please_return_at), loading: I18n.t('stats.index.loading'), - html: %(
%{loading}
) + html: %(
%s
) } end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 684c5a7f..7b609c03 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -30,10 +30,9 @@ module ApplicationHelper if k == key case v when Array then [k, v - [value]] - else nil end else - [ k, v ] + [k, v] end end.compact.to_h end diff --git a/app/models/deploy_distributed_press.rb b/app/models/deploy_distributed_press.rb index d2c6ec5f..9fb356dc 100644 --- a/app/models/deploy_distributed_press.rb +++ b/app/models/deploy_distributed_press.rb @@ -17,7 +17,7 @@ class DeployDistributedPress < Deploy before_create :create_remote_site! before_destroy :delete_remote_site! - DEPENDENCIES = %i[deploy_local] + DEPENDENCIES = %i[deploy_local].freeze # Actualiza la información y luego envía los cambios # @@ -32,9 +32,7 @@ class DeployDistributedPress < Deploy create_remote_site! if remote_site_id.blank? save - if remote_site_id.blank? - raise DeployJob::DeployException, 'El sitio no se creó en Distributed Press' - end + raise DeployJob::DeployException, 'El sitio no se creó en Distributed Press' if remote_site_id.blank? site_client.tap do |c| stdout = Thread.new(publisher.logger_out) do |io| @@ -54,7 +52,7 @@ class DeployDistributedPress < Deploy end if status - self.remote_info[:distributed_press] = c.show(publishing_site).to_h + remote_info[:distributed_press] = c.show(publishing_site).to_h save end @@ -123,7 +121,10 @@ class DeployDistributedPress < Deploy # # @return [DistributedPressPublisher::V1::Schemas::NewSite] def create_site - DistributedPress::V1::Schemas::NewSite.new.call(domain: hostname, protocols: { http: true, ipfs: true, hyper: true }) + DistributedPress::V1::Schemas::NewSite.new.call(domain: hostname, + protocols: { + http: true, ipfs: true, hyper: true + }) end # Crea el sitio en la instancia con el hostname especificado @@ -149,7 +150,7 @@ class DeployDistributedPress < Deploy # @param log [String] # @return [nil] def create_stat!(status, log) - build_stats.create action: publisher.to_s,log: log, seconds: time_spent_in_seconds, bytes: size, status: status + build_stats.create action: publisher.to_s, log: log, seconds: time_spent_in_seconds, bytes: size, status: status nil end diff --git a/app/models/deploy_local.rb b/app/models/deploy_local.rb index a3b783ca..6a959246 100644 --- a/app/models/deploy_local.rb +++ b/app/models/deploy_local.rb @@ -86,7 +86,7 @@ class DeployLocal < Deploy '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'] + 'GEMS_SOURCE' => ENV.fetch('GEMS_SOURCE', nil) } end diff --git a/app/models/deploy_rsync.rb b/app/models/deploy_rsync.rb index 5ebea162..4e8e3366 100644 --- a/app/models/deploy_rsync.rb +++ b/app/models/deploy_rsync.rb @@ -5,7 +5,7 @@ class DeployRsync < Deploy store :values, accessors: %i[hostname destination host_keys], coder: JSON - DEPENDENCIES = %i[deploy_local deploy_zip] + DEPENDENCIES = %i[deploy_local deploy_zip].freeze def deploy(output: false) ssh? && rsync(output: output) @@ -39,6 +39,7 @@ class DeployRsync < Deploy # @return [Boolean] def ssh? return true if destination.start_with? 'rsync://' + user, host = user_host ssh_available = false @@ -66,7 +67,7 @@ class DeployRsync < Deploy { 'HOME' => home_dir, 'PATH' => '/usr/bin', - 'LANG' => ENV['LANG'] + 'LANG' => ENV.fetch('LANG', nil) } end @@ -92,7 +93,8 @@ class DeployRsync < Deploy # # @return [Boolean] def rsync(output: false) - run %(rsync -aviH --delete-after --timeout=5 #{Shellwords.escape source}/ #{Shellwords.escape destination}/), output: output + run %(rsync -aviH --delete-after --timeout=5 #{Shellwords.escape source}/ #{Shellwords.escape destination}/), + output: output end # El origen es el destino de la compilación diff --git a/app/models/indexed_post.rb b/app/models/indexed_post.rb index 992c07c8..2ad1d459 100644 --- a/app/models/indexed_post.rb +++ b/app/models/indexed_post.rb @@ -38,15 +38,15 @@ class IndexedPost < ApplicationRecord # # @param :attribute [String,Symbol] # @return [Array] - scope :everything_of, ->(attribute) do + scope :everything_of, lambda { |attribute| where('front_matter ? :attribute', attribute: attribute) .pluck( Arel.sql( - ActiveRecord::Base::sanitize_sql(['front_matter -> :attribute', attribute: attribute]) + ActiveRecord::Base.sanitize_sql(['front_matter -> :attribute', { attribute: attribute }]) ) ) - .flatten.uniq - end + .flatten.uniq + } validates_presence_of :layout, :path, :locale diff --git a/app/models/metadata_belongs_to.rb b/app/models/metadata_belongs_to.rb index 93a1f710..eec3ca5a 100644 --- a/app/models/metadata_belongs_to.rb +++ b/app/models/metadata_belongs_to.rb @@ -29,6 +29,6 @@ class MetadataBelongsTo < MetadataRelatedPosts private def sanitize(uuid) - uuid.to_s.gsub(/[^a-f0-9\-]/i, '') + uuid.to_s.gsub(/[^a-f0-9-]/i, '') end end diff --git a/app/models/metadata_content.rb b/app/models/metadata_content.rb index 0fc32221..43f8f5ea 100644 --- a/app/models/metadata_content.rb +++ b/app/models/metadata_content.rb @@ -53,25 +53,21 @@ class MetadataContent < MetadataTemplate # Eliminar elementos sin src y comprobar su origen html.css(elements).each do |element| - begin - raise URI::Error unless element['src'].present? + raise URI::Error unless element['src'].present? - uri = URI element['src'] + uri = URI element['src'] - # No permitimos recursos externos, solo si sabemos cuales son - # los recursos locales - if Rails.application.config.hosts.present? - unless Rails.application.config.hosts.include?(uri.hostname) - raise URI::Error - end - end - - element['src'] = convert_src_to_internal_path uri - - raise URI::Error if element['src'].blank? - rescue URI::Error - element.remove + # No permitimos recursos externos, solo si sabemos cuales son + # los recursos locales + if Rails.application.config.hosts.present? && !Rails.application.config.hosts.include?(uri.hostname) + raise URI::Error end + + element['src'] = convert_src_to_internal_path uri + + raise URI::Error if element['src'].blank? + rescue URI::Error + element.remove end # Eliminar figure sin contenido @@ -101,11 +97,10 @@ class MetadataContent < MetadataTemplate # @param style [String] # @return [String] def sanitize_style(style) - style.split(';').reduce({}) do |style_hash, style_string| + style.split(';').each_with_object({}) do |style_string, style_hash| key, value = style_string.split(':', 2) style_hash[key] ||= value - style_hash end.slice(*allowed_styles).map do |style_pair| style_pair.join(':') end.join(';') @@ -121,7 +116,7 @@ class MetadataContent < MetadataTemplate # Convierte una ubicación local al sitio en una URL de ActiveStorage # # XXX: Por qué son tan díficiles de encontrar las rutas de AS - # + # # @param path [String] # @return [String] def convert_internal_path_to_src(path) diff --git a/app/models/metadata_related_posts.rb b/app/models/metadata_related_posts.rb index 6d52096e..56665fc3 100644 --- a/app/models/metadata_related_posts.rb +++ b/app/models/metadata_related_posts.rb @@ -10,7 +10,8 @@ class MetadataRelatedPosts < MetadataArray def values @values ||= posts.pluck(:title, :created_at, :layout, :post_id).to_h do |row| row.tap do |value| - value[0] = "#{value[0]} #{value.delete_at(1).strftime('%F')} (#{site.layouts[value.delete_at(1)].humanized_name})" + value[0] = + "#{value[0]} #{value.delete_at(1).strftime('%F')} (#{site.layouts[value.delete_at(1)].humanized_name})" end end end @@ -46,7 +47,7 @@ class MetadataRelatedPosts < MetadataArray def sanitize(uuid) super(uuid.map do |u| - u.to_s.gsub(/[^a-f0-9\-]/i, '') + u.to_s.gsub(/[^a-f0-9-]/i, '') end) end end diff --git a/app/models/post.rb b/app/models/post.rb index 6307e259..4118e9c7 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -132,6 +132,7 @@ 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 @@ -250,7 +251,8 @@ 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: :created_at, 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 diff --git a/app/models/post/indexable.rb b/app/models/post/indexable.rb index 38a98c2b..51a78f15 100644 --- a/app/models/post/indexable.rb +++ b/app/models/post/indexable.rb @@ -6,7 +6,6 @@ class Post extend ActiveSupport::Concern included do - # @return [IndexedPost,nil] def indexed_post site.indexed_posts.find_by_post_id(uuid.value) diff --git a/app/models/site.rb b/app/models/site.rb index 9cc42cd0..0e1f562c 100644 --- a/app/models/site.rb +++ b/app/models/site.rb @@ -419,7 +419,6 @@ class Site < ApplicationRecord FileUtils.rm_rf path end - # Sincroniza algunos atributos del sitio con su configuración y # guarda los cambios # diff --git a/app/models/site/index.rb b/app/models/site/index.rb index 213ef0bb..c663fbdf 100644 --- a/app/models/site/index.rb +++ b/app/models/site/index.rb @@ -104,8 +104,8 @@ class Site indexable_posts.select do |delta| MODIFIED_STATUSES.include? delta.status end.each do |delta| - locale, _ = locale_and_path_from(delta.new_file[:path]) - full_path = File.join(self.path, delta.new_file[:path]) + locale, = locale_and_path_from(delta.new_file[:path]) + full_path = File.join(path, delta.new_file[:path]) Post.build(path: full_path, site: self, layout: Post.find_layout(full_path), locale: locale).index! end diff --git a/app/models/site/repository.rb b/app/models/site/repository.rb index d41e76f5..1376fb82 100644 --- a/app/models/site/repository.rb +++ b/app/models/site/repository.rb @@ -148,7 +148,7 @@ class Site # @param :rm [Array] Archivos a eliminar # @param :usuarie [Usuarie] Quién hace el commit # @param :message [String] Mensaje - def commit(add: [], rm: [], usuarie:, message:) + def commit(usuarie:, message:, add: [], rm: []) # Cargar el árbol actual rugged.index.read_tree rugged.head.target.tree @@ -182,7 +182,7 @@ class Site # # @return [Boolean] def gc - git_sh("git", "gc") + git_sh('git', 'gc') end # Pushea cambios al repositorio remoto @@ -196,8 +196,8 @@ class Site # Hace limpieza de LFS def lfs_cleanup - git_sh("git", "lfs", "prune") - git_sh("git", "lfs", "dedup") + git_sh('git', 'lfs', 'prune') + git_sh('git', 'lfs', 'dedup') end private @@ -257,7 +257,7 @@ class Site # @param :args [Array] # @return [Boolean] def git_sh(*args) - env = { 'PATH' => '/usr/bin', 'LANG' => ENV['LANG'], 'HOME' => path } + env = { 'PATH' => '/usr/bin', 'LANG' => ENV.fetch('LANG', nil), 'HOME' => path } r = nil Open3.popen2e(env, *args, unsetenv_others: true, chdir: path) do |_, _, t| diff --git a/app/services/post_service.rb b/app/services/post_service.rb index 6f42bb22..5eca8466 100644 --- a/app/services/post_service.rb +++ b/app/services/post_service.rb @@ -145,9 +145,9 @@ PostService = Struct.new(:site, :usuarie, :post, :params, keyword_init: true) do # Si les usuaries modifican o crean una licencia, considerarla # personalizada en el panel. def update_site_license! - if site.usuarie?(usuarie) && post.layout.name == :license && !site.licencia.custom? - site.update licencia: Licencia.find_by_icons('custom') - end + return unless site.usuarie?(usuarie) && post.layout.name == :license && !site.licencia.custom? + + site.update licencia: Licencia.find_by_icons('custom') end # @return [Set] diff --git a/app/views/bootstrap/_custom_checkbox_for_field.haml b/app/views/bootstrap/_custom_checkbox_for_field.haml index cbbc0079..a6d85879 100644 --- a/app/views/bootstrap/_custom_checkbox_for_field.haml +++ b/app/views/bootstrap/_custom_checkbox_for_field.haml @@ -2,5 +2,5 @@ - id = "#{field.object_name}_#{name}" - name = "#{field.object_name}[#{name}]" -= render 'bootstrap/custom_checkbox', id: id, name: name, content: content, required: local_assigns[:required], value: "1" do += render 'bootstrap/custom_checkbox', id: id, name: name, content: content, required: local_assigns[:required], value: '1' do = yield diff --git a/app/views/collaborations/collaborate.haml b/app/views/collaborations/collaborate.haml index bbdc977e..f0036c17 100644 --- a/app/views/collaborations/collaborate.haml +++ b/app/views/collaborations/collaborate.haml @@ -1,28 +1,28 @@ .row.align-items-center.justify-content-center.full-height .col-12.col-lg-10.align-self-center - welcome = @site.config.dig('welcome', 'message') || t('.welcome', - site: @site.hostname) + site: @site.hostname) = sanitize_markdown welcome .col-12.col-lg-6.align-self-center -# Copiado y pegado de app/views/devise/registrations/new.haml - resource = resource_name = @invitade = form_for(resource, as: resource_name, - url: site_collaborate_path(@site), - method: :post) do |f| + url: site_collaborate_path(@site), + method: :post) do |f| - unless current_usuarie .form-group = f.label :email = f.email_field :email, autofocus: true, autocomplete: 'email', - class: 'form-control' + class: 'form-control' .form-group = f.label :password - if @minimum_password_length %em = t('devise.shared.minimum_password_length', - count: @minimum_password_length) + count: @minimum_password_length) = f.password_field :password, autocomplete: 'new-password', - class: 'form-control' + class: 'form-control' .form-group = 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 fed7523a..d976e7cc 100644 --- a/app/views/devise/confirmations/new.haml +++ b/app/views/devise/confirmations/new.haml @@ -9,26 +9,25 @@ %h2= t('.resend_confirmation_instructions') = form_for(resource, - as: resource_name, - url: confirmation_path(resource_name), - html: { method: :post }) do |f| - + as: resource_name, + url: confirmation_path(resource_name), + html: { method: :post }) do |f| :ruby value = if resource.pending_reconfirmation? - resource.unconfirmed_email - else - resource.email - end + resource.unconfirmed_email + else + resource.email + end .form-group = f.label :email, class: 'sr-only' = f.email_field :email, - autofocus: true, - autocomplete: 'email', - class: 'form-control', - value: value, - placeholder: t('activerecord.attributes.usuarie.email') + autofocus: true, + autocomplete: 'email', + class: 'form-control', + value: value, + placeholder: t('activerecord.attributes.usuarie.email') .actions = f.submit t('.resend_confirmation_instructions'), - class: 'btn btn-secondary 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 8039d281..536848b6 100644 --- a/app/views/devise/invitations/edit.haml +++ b/app/views/devise/invitations/edit.haml @@ -7,29 +7,29 @@ .col-12.col-lg-5.align-self-center %h2= t 'devise.invitations.edit.header' = form_for(resource, - as: resource_name, - url: invitation_path(resource_name), - html: { method: :put }) do |f| + as: resource_name, + url: invitation_path(resource_name), + html: { method: :put }) do |f| = f.hidden_field :invitation_token, readonly: true - if f.object.class.require_password_on_accepting .form-group = f.label :password, class: 'sr-only' = f.password_field :password, class: 'form-control', - min: @minimum_password_length, - aria: { describedby: 'minimum-password-length' }, - placeholder: t('activerecord.attributes.usuarie.password') + min: @minimum_password_length, + aria: { describedby: 'minimum-password-length' }, + placeholder: t('activerecord.attributes.usuarie.password') - if @minimum_password_length %small.text-muted.form-text#minimum-password-length = t('devise.shared.minimum_password_length', - count: @minimum_password_length) + count: @minimum_password_length) .form-group = f.label :password_confirmation, class: 'sr-only' = f.password_field :password_confirmation, - class: 'form-control', - min: @minimum_password_length, - aria: { describedby: 'minimum-password-length' }, - placeholder: t('activerecord.attributes.usuarie.password') + class: 'form-control', + min: @minimum_password_length, + aria: { describedby: 'minimum-password-length' }, + placeholder: t('activerecord.attributes.usuarie.password') .actions = f.submit t('devise.invitations.edit.submit_button'), - class: 'btn btn-secondary 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 5fb6e0d0..c0a85c4d 100644 --- a/app/views/devise/invitations/new.haml +++ b/app/views/devise/invitations/new.haml @@ -7,13 +7,13 @@ .col-12.col-lg-5.align-self-center %h2= t 'devise.invitations.new.header' = form_for(resource, - as: resource_name, - url: invitation_path(resource_name), - html: { method: :post }) do |f| + as: resource_name, + url: invitation_path(resource_name), + html: { method: :post }) do |f| - resource.class.invite_key_fields.each do |field| .form-group = f.label field = f.text_field field, class: 'form-control' .actions = f.submit t('devise.invitations.new.submit_button'), - class: 'btn btn-secondary 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 3fab3727..4eb4a054 100644 --- a/app/views/devise/passwords/edit.haml +++ b/app/views/devise/passwords/edit.haml @@ -10,35 +10,34 @@ %p= t('.help') = form_for(resource, as: resource_name, - url: password_path(resource_name), - html: { method: :put }) do |f| - + url: password_path(resource_name), + html: { method: :put }) do |f| = f.hidden_field :reset_password_token .form-group = f.label :password, t('.new_password'), class: 'sr-only' = f.password_field :password, - autofocus: true, - autocomplete: 'new-password', - class: 'form-control', min: @minimum_password_length, - aria: { describedby: 'minimum_password_length' }, - placeholder: t('.new_password') + autofocus: true, + autocomplete: 'new-password', + class: 'form-control', min: @minimum_password_length, + aria: { describedby: 'minimum_password_length' }, + placeholder: t('.new_password') - if @minimum_password_length %small.form-text.text-muted = t('devise.shared.minimum_password_length', - count: @minimum_password_length) + count: @minimum_password_length) .form-group = f.label :password_confirmation, t('.confirm_new_password'), - class: 'sr-only' + class: 'sr-only' = f.password_field :password_confirmation, autocomplete: 'off', - class: 'form-control', - min: @minimum_password_length, - aria: { describedby: 'minimum_password_length' }, - placeholder: t('.confirm_new_password') + class: 'form-control', + min: @minimum_password_length, + aria: { describedby: 'minimum_password_length' }, + placeholder: t('.confirm_new_password') .actions = f.submit t('.change_my_password'), - class: 'btn btn-secondary 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 3ef1b624..102f49cd 100644 --- a/app/views/devise/passwords/new.haml +++ b/app/views/devise/passwords/new.haml @@ -10,15 +10,15 @@ %p= t('.help') = form_for(resource, - as: resource_name, - url: password_path(resource_name), - html: { method: :post }) do |f| + as: resource_name, + url: password_path(resource_name), + html: { method: :post }) do |f| .form-group = f.label :email, class: 'sr-only' = f.email_field :email, autofocus: true, autocomplete: 'email', - class: 'form-control', - placeholder: t('activerecord.attributes.usuarie.email') + class: 'form-control', + placeholder: t('activerecord.attributes.usuarie.email') .actions = f.submit t('.send_me_reset_password_instructions'), - class: 'btn btn-secondary 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 495a6dea..98b883fb 100644 --- a/app/views/devise/registrations/edit.haml +++ b/app/views/devise/registrations/edit.haml @@ -9,58 +9,57 @@ .col-12.col-lg-6.align-self-center %h2= t('.title') = form_for(resource, - as: resource_name, - url: registration_path(resource_name), - html: { method: :put }) do |f| - + as: resource_name, + url: registration_path(resource_name), + html: { method: :put }) do |f| .form-group = f.label :email = f.email_field :email, autofocus: true, autocomplete: 'email', - class: 'form-control' + class: 'form-control' - if devise_mapping.confirmable? && resource.pending_reconfirmation? %div = t('.currently_waiting_confirmation_for_email', - email: resource.unconfirmed_email) + email: resource.unconfirmed_email) .form-group = f.label :lang = f.select :lang, - I18n.available_locales.map { |lang| [t(lang), lang] }, {}, - class: 'form-control' + I18n.available_locales.map { |lang| [t(lang), lang] }, {}, + class: 'form-control' .form-group = f.label :password = f.password_field :password, autocomplete: 'new-password', - class: 'form-control', aria: { describedby: 'password-help' } + class: 'form-control', aria: { describedby: 'password-help' } %small.text-muted.form-text#password-help = t('.leave_blank_if_you_don_t_want_to_change_it') - if @minimum_password_length = t('devise.shared.minimum_password_length', - count: @minimum_password_length) + count: @minimum_password_length) .form-group = f.label :password_confirmation = f.password_field :password_confirmation, - autocomplete: 'new-password', - class: 'form-control' + autocomplete: 'new-password', + class: 'form-control' .form-group = f.label :current_password = f.password_field :current_password, - autocomplete: 'current-password', - required: true, - class: 'form-control', - aria: { describedby: 'current-password-help' } + autocomplete: 'current-password', + required: true, + class: 'form-control', + aria: { describedby: 'current-password-help' } %small.text-muted.form-text#current-password-help = t('.we_need_your_current_password_to_confirm_your_changes') .actions = f.submit t('.update'), - class: 'btn btn-secondary btn-lg btn-block' + class: 'btn btn-secondary btn-lg btn-block' %hr/ .sr-only %h3= t('.cancel_my_account') = button_to t('.cancel_my_account'), - registration_path(resource_name), - data: { confirm: t('.are_you_sure') }, - method: :delete, class: 'btn btn-secondary btn-block' + registration_path(resource_name), + data: { confirm: t('.are_you_sure') }, + 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 cc08c630..0c800a1f 100644 --- a/app/views/devise/registrations/new.haml +++ b/app/views/devise/registrations/new.haml @@ -9,36 +9,35 @@ %p= t('.help') = form_for(resource, - as: resource_name, - url: registration_path(resource_name, params: { locale: params[:locale] })) do |f| - + as: resource_name, + url: registration_path(resource_name, params: { locale: params[:locale] })) do |f| .form-group = f.label :email, class: 'sr-only' = f.email_field :email, autofocus: true, autocomplete: 'email', - class: 'form-control', - placeholder: t('activerecord.attributes.usuarie.email') + class: 'form-control', + placeholder: t('activerecord.attributes.usuarie.email') - password = 'activerecord.attributes.usuarie.password' .form-group = f.label :password, class: 'sr-only' = f.password_field :password, autocomplete: 'new-password', - class: 'form-control', min: @minimum_password_length, - aria: { describedby: 'minimum-password-length' }, - placeholder: t(password) + class: 'form-control', min: @minimum_password_length, + aria: { describedby: 'minimum-password-length' }, + placeholder: t(password) - if @minimum_password_length %small.text-muted.form-text#minimum-password-length = t('devise.shared.minimum_password_length', - count: @minimum_password_length) + count: @minimum_password_length) .form-group = f.label :password_confirmation, class: 'sr-only' = f.password_field :password_confirmation, - autocomplete: 'new-password', - class: 'form-control', - min: @minimum_password_length, - aria: { describedby: 'minimum-password-length' }, - placeholder: t("#{password}_confirmation") + autocomplete: 'new-password', + class: 'form-control', + min: @minimum_password_length, + aria: { describedby: 'minimum-password-length' }, + placeholder: t("#{password}_confirmation") .form-group - Usuarie::CONSENT_FIELDS.each do |field| @@ -48,7 +47,7 @@ - content = t(".#{field}.label") - href = t(".#{field}.href", default: '') - help_content = t(".#{field}.help") - = render 'bootstrap/custom_checkbox', id: id, name: name, content: content, required: required, value: "1" do + = render 'bootstrap/custom_checkbox', id: id, name: name, content: content, required: required, value: '1' do - if href.present? = link_to help_content, href, target: '_blank', rel: 'noopener' - else @@ -56,6 +55,6 @@ .actions = f.submit t('.sign_up'), - class: 'btn btn-secondary 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 cd205e70..be1e01f8 100644 --- a/app/views/devise/sessions/new.haml +++ b/app/views/devise/sessions/new.haml @@ -8,29 +8,29 @@ %p= t('.help') = form_for(resource, - as: resource_name, - url: session_path(resource_name)) do |f| + as: resource_name, + url: session_path(resource_name)) do |f| - if @site = hidden_field :referer, value: site_path(@site) .form-group = f.label :email, class: 'sr-only' = f.email_field :email, - autofocus: true, - autocomplete: 'email', - class: 'form-control', - placeholder: t('login.email') + autofocus: true, + autocomplete: 'email', + class: 'form-control', + placeholder: t('login.email') .form-group = f.label :password, class: 'sr-only' = f.password_field :password, - autocomplete: 'current-password', - class: 'form-control', - placeholder: t('login.password') + autocomplete: 'current-password', + class: 'form-control', + placeholder: t('login.password') - if devise_mapping.rememberable? .form-group = render 'bootstrap/custom_checkbox_for_field', field: f, name: :remember_me do = t('login.remember_me', remember_for: distance_of_time_in_words(Usuarie.remember_for)) .actions = f.submit t('.sign_in'), - class: 'btn btn-secondary 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 eb55d707..c4413d3c 100644 --- a/app/views/devise/unlocks/new.haml +++ b/app/views/devise/unlocks/new.haml @@ -10,15 +10,15 @@ %p= t('.help') = form_for(resource, - as: resource_name, - url: unlock_path(resource_name), - html: { method: :post }) do |f| + as: resource_name, + url: unlock_path(resource_name), + html: { method: :post }) do |f| .form-group = f.label :email, class: 'sr-only' = f.email_field :email, autofocus: true, autocomplete: 'email', - class: 'form-control', - placeholder: t('activerecord.attributes.usuarie.email') + class: 'form-control', + placeholder: t('activerecord.attributes.usuarie.email') .actions = f.submit t('.resend_unlock_instructions'), - class: 'btn btn-secondary btn-lg btn-block' + class: 'btn btn-secondary btn-lg btn-block' = render 'devise/shared/links' diff --git a/app/views/layouts/_breadcrumb.haml b/app/views/layouts/_breadcrumb.haml index 7c3897ff..974b271f 100644 --- a/app/views/layouts/_breadcrumb.haml +++ b/app/views/layouts/_breadcrumb.haml @@ -1,7 +1,7 @@ %nav.navbar.flex-md-nowrap.px-0 %a.navbar-brand.order-0{ href: '/' } = inline_svg_tag 'sutty.svg', class: 'black', aria: true, - title: t('svg.sutty.title'), desc: t('svg.sutty.desc') + title: t('svg.sutty.title'), desc: t('svg.sutty.desc') - if breadcrumbs? %nav.flex-grow-1.order-2.order-md-1{ aria: { label: t('.title') } } @@ -18,18 +18,19 @@ - if @site&.tienda? %li.nav-item = link_to t('.tienda'), @site.tienda_url, - role: 'button', class: 'btn btn-secondary' + role: 'button', class: 'btn btn-secondary' %li.nav-item = link_to t('.contact_us'), t('.contact_us_href'), - class: 'btn btn-secondary', 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 btn-secondary' + method: :delete, role: 'button', class: 'btn btn-secondary' - else - params.permit! - I18n.available_locales.each do |locale| - next if locale == I18n.locale + %li.nav-item = link_to t("switch_locale.#{locale}"), params.to_h.merge(change_locale_to: locale) diff --git a/app/views/layouts/_details.haml b/app/views/layouts/_details.haml index b1e28f2c..c07ab121 100644 --- a/app/views/layouts/_details.haml +++ b/app/views/layouts/_details.haml @@ -7,9 +7,8 @@ @param :summary_class [String] Clases para el summary - local_assigns[:summary_class] ||= 'h3' -- local_assigns[:closed] ||= '▶'.html_safe; -- local_assigns[:open] ||= '▼'.html_safe; - +- local_assigns[:closed] ||= '▶'.html_safe +- local_assigns[:open] ||= '▼'.html_safe %details.details.py-2{ id: local_assigns[:id], data: { controller: 'details', action: 'toggle->details#store' }, class: local_assigns[:details_class] } %summary.d-flex.flex-row.align-items-center.justify-content-between{ class: local_assigns[:summary_class] } diff --git a/app/views/posts/attribute_ro/_related_posts.haml b/app/views/posts/attribute_ro/_related_posts.haml index aa4aff2e..5813e35c 100644 --- a/app/views/posts/attribute_ro/_related_posts.haml +++ b/app/views/posts/attribute_ro/_related_posts.haml @@ -7,4 +7,5 @@ XXX: Ignorar todos los posts no encontrados (ej: fueron borrados o el uuid cambió) - next unless p + %li= link_to p.title, site_post_path(site, p.path) diff --git a/app/views/posts/attributes/_draft.haml b/app/views/posts/attributes/_draft.haml new file mode 100644 index 00000000..351edf01 --- /dev/null +++ b/app/views/posts/attributes/_draft.haml @@ -0,0 +1,13 @@ +- if !@site.invitade?(cuenta) # esto ta mal + .form-check + = hidden_field_tag "#{base}[#{attribute}]", '0', id: '' + .custom-control.custom-switch + = check_box_tag "#{base}[#{attribute}]", '1', metadata.value, + class: "custom-control-input #{invalid(post, attribute)}", + aria: { describedby: id_for_help(attribute) }, + autofocus: autofocus + = label_tag "#{base}_#{attribute}", post_label_t(attribute, post: post), + class: 'custom-control-label' + + = render 'posts/attribute_feedback', + post: post, attribute: attribute, metadata: metadata diff --git a/app/views/posts/attributes/_file.haml b/app/views/posts/attributes/_file.haml index 0287366c..daa54157 100644 --- a/app/views/posts/attributes/_file.haml +++ b/app/views/posts/attributes/_file.haml @@ -2,43 +2,53 @@ = label_tag "#{base}_#{attribute}", post_label_t(attribute, post: post) - if metadata.static_file - case metadata.static_file.blob.content_type - - when %r{\Avideo/} - = video_tag url_for(metadata.static_file), - controls: true, class: 'img-fluid', - data: { target: 'file-preview.preview' } - - when %r{\Aaudio/} - = audio_tag url_for(metadata.static_file), - controls: true, class: 'img-fluid', - data: { target: 'file-preview.preview' } - - when 'application/pdf' - %iframe{ src: url_for(metadata.static_file) } - - else - = link_to t('posts.attribute_ro.file.download'), - url_for(metadata.static_file) + - when %r{\Avideo/} + = video_tag url_for(metadata.static_file), + controls: true, class: 'img-fluid', + data: { target: 'file-preview.preview' } + - when %r{\Aaudio/} + = audio_tag url_for(metadata.static_file), + controls: true, class: 'img-fluid', + data: { target: 'file-preview.preview' } + - when 'application/pdf' + %iframe{ src: url_for(metadata.static_file) } + - else + = link_to t('posts.attribute_ro.file.download'), + url_for(metadata.static_file) -# Mantener el valor si no enviamos ninguna imagen = hidden_field_tag "#{base}[#{attribute}][path]", metadata.value['path'] -# Los archivos requeridos solo se pueden reemplazar - unless metadata.required .custom-control.custom-switch - = check_box_tag "#{base}[#{attribute}][path]", '', false, id: "#{base}_#{attribute}_destroy", class: 'custom-control-input' - = label_tag "#{base}_#{attribute}_destroy", t('posts.attributes.file.destroy'), class: 'custom-control-label' + = check_box_tag "#{base}[#{attribute}][path]", + '', + false, + id: "#{base}_#{attribute}_destroy", + class: 'custom-control-input' + = label_tag "#{base}_#{attribute}_destroy", + t('posts.attributes.file.destroy'), + class: 'custom-control-label' .custom-file = file_field(*field_name_for(base, attribute, :path), - **field_options(attribute, metadata, required: (metadata.required && !metadata.path?)), - class: "custom-file-input #{invalid(post, attribute)}", - data: { target: 'file-preview.input', action: 'file-preview#update' }) + **field_options(attribute, + metadata, + required: (metadata.required && !metadata.path?)), + class: "custom-file-input #{invalid(post, attribute)}", + data: { target: 'file-preview.input', + action: 'file-preview#update' }) = label_tag "#{base}_#{attribute}_path", - post_label_t(attribute, :path, post: post), class: 'custom-file-label' + post_label_t(attribute, :path, post: post), + class: 'custom-file-label' = render 'posts/attribute_feedback', - post: post, attribute: [attribute, :path], metadata: metadata + post: post, attribute: [attribute, :path], metadata: metadata .form-group = label_tag "#{base}_#{attribute}_description", - post_label_t(attribute, :description, post: post, required: false) + post_label_t(attribute, :description, post: post, required: false) = text_field(*field_name_for(base, attribute, :description), - value: metadata.value['description'], - dir: dir, lang: locale, - **field_options(attribute, metadata, required: false)) + value: metadata.value['description'], + dir: dir, lang: locale, + **field_options(attribute, metadata, required: false)) = render 'posts/attribute_feedback', - post: post, attribute: [attribute, :description], metadata: metadata + post: post, attribute: [attribute, :description], metadata: metadata diff --git a/app/views/posts/attributes/_has_one.haml b/app/views/posts/attributes/_has_one.haml index b0d21f35..f486367c 100644 --- a/app/views/posts/attributes/_has_one.haml +++ b/app/views/posts/attributes/_has_one.haml @@ -1,7 +1,7 @@ .form-group = label_tag "#{base}_#{attribute}", post_label_t(attribute, post: post) = select_tag(plain_field_name_for(base, attribute), - options_for_select(metadata.values, metadata.value), - **field_options(attribute, metadata), include_blank: t('.empty')) + options_for_select(metadata.values, metadata.value), + **field_options(attribute, metadata), include_blank: t('.empty')) = render 'posts/attribute_feedback', - post: post, attribute: attribute, metadata: metadata + post: post, attribute: attribute, metadata: metadata diff --git a/app/views/posts/attributes/_image.haml b/app/views/posts/attributes/_image.haml index a0bfebde..ee988178 100644 --- a/app/views/posts/attributes/_image.haml +++ b/app/views/posts/attributes/_image.haml @@ -2,40 +2,50 @@ = label_tag "#{base}_#{attribute}", post_label_t(attribute, post: post) - if metadata.static_file = image_tag url_for(metadata.static_file), - alt: metadata.value['description'], - class: 'img-fluid', - data: { target: 'file-preview.preview' } + alt: metadata.value['description'], + class: 'img-fluid', + data: { target: 'file-preview.preview' } -# Mantener el valor si no enviamos ninguna imagen = hidden_field_tag "#{base}[#{attribute}][path]", metadata.value['path'] -# Las imágenes requeridas solo se pueden reemplazar - unless metadata.required .custom-control.custom-switch - = check_box_tag "#{base}[#{attribute}][path]", '', false, id: "#{base}_#{attribute}_destroy", class: 'custom-control-input' - = label_tag "#{base}_#{attribute}_destroy", t('posts.attributes.image.destroy'), class: 'custom-control-label' + = check_box_tag "#{base}[#{attribute}][path]", + '', + false, + id: "#{base}_#{attribute}_destroy", + class: 'custom-control-input' + = label_tag "#{base}_#{attribute}_destroy", + t('posts.attributes.image.destroy'), + class: 'custom-control-label' - else = image_tag '', - alt: metadata.value['description'], - class: 'img-fluid', - data: { target: 'file-preview.preview' } + alt: metadata.value['description'], + class: 'img-fluid', + data: { target: 'file-preview.preview' } .custom-file = file_field(*field_name_for(base, attribute, :path), - **field_options(attribute, metadata, required: (metadata.required && !metadata.path?)), - class: "custom-file-input #{invalid(post, attribute)}", - accept: ActiveStorage.web_image_content_types.join(','), - data: { target: 'file-preview.input', action: 'file-preview#update' }) + **field_options(attribute, + metadata, + required: (metadata.required && !metadata.path?)), + class: "custom-file-input #{invalid(post, attribute)}", + accept: ActiveStorage.web_image_content_types.join(','), + data: { target: 'file-preview.input', + action: 'file-preview#update' }) = label_tag "#{base}_#{attribute}_path", - post_label_t(attribute, :path, post: post), class: 'custom-file-label' + post_label_t(attribute, :path, post: post), + class: 'custom-file-label' = render 'posts/attribute_feedback', - post: post, attribute: [attribute, :path], metadata: metadata + post: post, attribute: [attribute, :path], metadata: metadata .form-group = label_tag "#{base}_#{attribute}_description", - post_label_t(attribute, :description, post: post, required: false) + post_label_t(attribute, :description, post: post, required: false) = text_field(*field_name_for(base, attribute, :description), - value: metadata.value['description'], - dir: dir, lang: locale, - **field_options(attribute, metadata, required: false)) + value: metadata.value['description'], + dir: dir, lang: locale, + **field_options(attribute, metadata, required: false)) = render 'posts/attribute_feedback', - post: post, attribute: [attribute, :description], metadata: metadata + post: post, attribute: [attribute, :description], metadata: metadata diff --git a/app/views/posts/attributes/_locales.haml b/app/views/posts/attributes/_locales.haml index 05592fbd..c4632e3c 100644 --- a/app/views/posts/attributes/_locales.haml +++ b/app/views/posts/attributes/_locales.haml @@ -3,7 +3,7 @@ %legend= post_label_t(attribute, post: post) = render 'posts/attribute_feedback', - post: post, attribute: attribute, metadata: metadata + post: post, attribute: attribute, metadata: metadata - site.locales.each do |locale| - locale_t = t("locales.#{locale}.name", default: locale.to_s.humanize) @@ -14,5 +14,6 @@ = label_tag "#{base}_#{attribute}_#{locale}", locale_t = select_tag("#{plain_field_name_for(base, attribute)}[]", - options_for_select(metadata.values[locale], value), - **field_options(attribute, metadata), include_blank: t('.empty')) + options_for_select(metadata.values[locale], value), + **field_options(attribute, metadata), + include_blank: t('.empty')) diff --git a/app/views/posts/index.haml b/app/views/posts/index.haml index 14462261..dbc5f4da 100644 --- a/app/views/posts/index.haml +++ b/app/views/posts/index.haml @@ -14,56 +14,74 @@ = render 'sites/moderation_queue', site: @site, class: 'btn-block' = render 'layouts/details', summary: t('posts.filters.title') do - - %form{method: :get} + %form{ method: :get } .border.border-magenta.p-1 - @filter_params.each do |param, values| - next if param == :layout + - [values].flatten.each do |value| - %input{ type: 'hidden', name: values.is_a?(Array) ? "#{param}[]" : param, value: value } + %input{ type: 'hidden', + name: values.is_a?(Array) ? "#{param}[]" : param, + value: value } %legend.font-weight-bold.m-0.h6= 'Tipo de contenido' - @site.schema_organization.each do |key, _| .custom-control.custom-checkbox - schema = @site.layouts[key] - = render 'schemas/filter', site: @site, key: key, schema: schema, filter: @filter_params + = render 'schemas/filter', site: @site, + key: key, + schema: schema, + filter: @filter_params %button.btn.btn-secondary.mt-3{ type: 'submit' }= t('posts.filters.submit') - = render 'layouts/details', - summary: t('posts.new'), - summary_class: "h4 magenta font-weight-bold m-0 px-2", - details_class: "d-flex border border-magenta justify-content-between align-items-center w-100 mb-3", - open: "+", closed: "+", - open_class: "h1 magenta font-weight-bold m-0", - closed_class: "h1 magenta font-weight-bold m-0" do + = render 'layouts/details', + summary: t('posts.new'), + summary_class: 'h4 magenta font-weight-bold m-0 px-2', + details_class: 'details-agregar', + open: '+', closed: '+', + open_class: 'h1 magenta font-weight-bold m-0', + closed_class: 'h1 magenta font-weight-bold m-0' do %table.table-sm.w-100 %tbody - @site.schema_organization.each do |schema, _| - schema = @site.layouts[schema] - next if schema.hidden? - = render 'schemas/row', site: @site, schema: schema, filter: @filter_params + = 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 btn-secondary' + = 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 btn-secondary' + = 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 btn-secondary', 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', - tooltip: t('usuaries.index.help.self'), - text: t('usuaries.index.title'), - type: 'info', - link: site_usuaries_path(@site) + tooltip: t('usuaries.index.help.self'), + text: t('usuaries.index.title'), + type: 'info', + link: site_usuaries_path(@site) - 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 btn-secondary' + = 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 btn-secondary' + = 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 @@ -72,7 +90,7 @@ %nav#locales - @site.locales.each do |locale| = link_to @site.data.dig(locale.to_s, 'locale') || locale, site_posts_path(@site, **@filter_params.merge(locale: locale)), - class: "mr-2 mt-2 mb-2 #{locale == @locale ? 'active font-weight-bold' : ''}" + class: "mr-2 mt-2 mb-2 #{locale == @locale ? 'active font-weight-bold' : ''}" - if @posts.empty? %h2= t('posts.empty') @@ -86,7 +104,8 @@ .d-flex.flex-row.justify-content-between %div - if reorder_allowed - = submit_tag t('posts.reorder.submit'), class: 'btn btn-secondary' + = 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 @@ -94,12 +113,18 @@ %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') - %input{ type: 'hidden', name: 'post[lang]', value: @locale } + %input{ type: 'hidden', + name: 'post[lang]', + value: @locale } - if @site.pagination %div - = link_to_prev_page @posts, t('posts.prev'), class: 'btn btn-secondary' - = link_to_next_page @posts, t('posts.next'), class: 'btn btn-secondary' + = 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 @@ -107,48 +132,61 @@ -# TODO: Solo les usuaries cachean porque tenemos que separar les botones por permisos. - - begin - - cache_if @usuarie, [post, I18n.locale] do - - checkbox_id = "checkbox-#{post.post_id}" - %tr{ id: post.post_id, data: reorder_target } - - if reorder_allowed - %td - .custom-control.custom-checkbox - %input.custom-control-input{ id: checkbox_id, type: 'checkbox', autocomplete: 'off', data: { action: 'reorder#select' } } - %label.custom-control-label{ for: checkbox_id } - %span.sr-only= t('posts.reorder.select') - -# Orden más alto es mayor prioridad - = hidden_field 'post[reorder]', post.post_id, - value: size - i, - data: { reorder: true } - %td.w-100{ class: dir } - = link_to site_post_path(@site, post.path) do - %span{ lang: post.locale, dir: dir }= post.title - - if post.front_matter['draft'].present? - %span.badge.badge-primary= I18n.t('posts.attributes.draft.label') - %br - %small - = link_to @site.layouts[post.layout].humanized_name, site_posts_path(@site, **@filter_params.merge(layout: [post.layout])) - - post.front_matter['categories']&.each do |category| - = link_to site_posts_path(@site, **@filter_params.merge(category: category)) do - %span{ lang: post.locale, dir: dir }= category - = '/' unless post.front_matter['categories'].last == category - %td.text-nowrap - = post.created_at.strftime('%F') - %br/ - = post.order - %td.text-nowrap - .d-flex.flex-row.align-items-start - - if @usuarie || policy(post).edit? - = link_to t('posts.edit_post'), edit_site_post_path(@site, post.path), class: 'btn btn-secondary' - - if @usuarie || policy(post).destroy? - = link_to t('posts.destroy'), site_post_path(@site, post.path), class: 'btn btn-secondary', method: :delete, data: { confirm: t('posts.confirm_destroy') } - -# + - cache_if @usuarie, [post, I18n.locale] do + - checkbox_id = "checkbox-#{post.post_id}" + %tr{ id: post.post_id, data: reorder_target } + - if reorder_allowed + %td + .custom-control.custom-checkbox + %input.custom-control-input{ id: checkbox_id, + type: 'checkbox', + autocomplete: 'off', + data: { action: 'reorder#select' } } + %label.custom-control-label{ for: checkbox_id } + %span.sr-only= t('posts.reorder.select') + -# Orden más alto es mayor prioridad + = hidden_field 'post[reorder]', post.post_id, + value: size - i, + data: { reorder: true } + %td.w-100{ class: dir } + = link_to site_post_path(@site, post.path) do + %span{ lang: post.locale, dir: dir }= post.title + - if post.front_matter['draft'].present? + %span.badge.badge-primary= I18n.t('posts.attributes.draft.label') + %br + %small + = link_to @site.layouts[post.layout].humanized_name, + site_posts_path(@site, **@filter_params.merge(layout: [post.layout])) + - post.front_matter['categories']&.each do |category| + = link_to site_posts_path(@site, **@filter_params.merge(category: category)) do + %span{ lang: post.locale, dir: dir }= category + = '/' unless post.front_matter['categories'].last == category + + %td.text-nowrap + = post.created_at.strftime('%F') + %br/ + = post.order + %td.text-nowrap + .d-flex.flex-row.align-items-start + - if @usuarie || policy(post).edit? + = link_to t('posts.edit_post'), + edit_site_post_path(@site, post.path), + class: 'btn btn-secondary' + - if @usuarie || policy(post).destroy? + = link_to t('posts.destroy'), + site_post_path(@site, post.path), + class: 'btn btn-secondary', + method: :delete, + data: { confirm: t('posts.confirm_destroy') } + -# Rescatar cualquier error en un post, notificarlo e ignorar su renderización. - rescue ActionView::Template::Error => e - - ExceptionNotifier.notify_exception(e.cause, data: { site: @site.name, post: @post.path.absolute, usuarie: current_usuarie.id }) + - ExceptionNotifier.notify_exception(e.cause, + data: { site: @site.name, + post: @post.path.absolute, + usuarie: current_usuarie.id }) #footnotes{ hidden: true } - @filter_params.each do |param, value| diff --git a/app/views/posts/show.haml b/app/views/posts/show.haml index 87094755..155a2679 100644 --- a/app/views/posts/show.haml +++ b/app/views/posts/show.haml @@ -3,8 +3,8 @@ .col-12.col-lg-8 %article.content.table-responsive-md = link_to t('posts.edit_post'), - edit_site_post_path(@site, @post.id), - class: 'btn btn-secondary btn-block' + edit_site_post_path(@site, @post.id), + class: 'btn btn-secondary btn-block' %table.table.table-condensed %thead diff --git a/app/views/schemas/_add.haml b/app/views/schemas/_add.haml index 6aaf51c9..2bc6519c 100644 --- a/app/views/schemas/_add.haml +++ b/app/views/schemas/_add.haml @@ -1 +1,3 @@ -= link_to t(schema.humanized_name), new_site_post_path(site, layout: schema.value), class: 'stretched-link black text-decoration-none' += link_to t(schema.humanized_name), + new_site_post_path(site, layout: schema.value), + class: 'stretched-link black text-decoration-none' diff --git a/app/views/schemas/_filter.haml b/app/views/schemas/_filter.haml index ca02b11a..b1bdd078 100644 --- a/app/views/schemas/_filter.haml +++ b/app/views/schemas/_filter.haml @@ -1,10 +1,18 @@ %div - %input.custom-control-input.magenta{ type: 'checkbox', id: schema, name: "layout[]", class: "", value: schema.name, checked: @filter_params[:layout]&.include?(key.to_s) } + %input.custom-control-input.magenta{ type: 'checkbox', + id: schema, + name: 'layout[]', + class: '', + value: schema.name, + checked: @filter_params[:layout]&.include?(key.to_s) } %label.custom-control-label.font-weight-normal{ for: schema }= schema.humanized_name - -# XXX: Solo un nivel de recursividad - unless local_assigns[:parent_schema] - schema.schemas.each do |s| - next if s.hidden? - = render 'schemas/filter', schema: s, key: s.name, site: site, filter: filter \ No newline at end of file + + = render 'schemas/filter', schema: s, + key: s.name, + site: site, + filter: filter diff --git a/app/views/schemas/_row.haml b/app/views/schemas/_row.haml index e5ff1409..494d664c 100644 --- a/app/views/schemas/_row.haml +++ b/app/views/schemas/_row.haml @@ -1,13 +1,15 @@ %tr.border-top.border-magenta - %th.font-weight-normal.w-100.position-relative{ scope: 'row' } - if local_assigns[:parent_schema] %span.text-muted — = render 'schemas/add', schema: schema, **local_assigns - + -# XXX: Solo un nivel de recursividad - unless local_assigns[:parent_schema] - schema.schemas.each do |s| - next if s.hidden? - = render 'schemas/row', schema: s, site: site, filter: filter, parent_schema: schema + = render 'schemas/row', schema: s, + site: site, + filter: filter, + parent_schema: schema diff --git a/app/views/sites/_form.haml b/app/views/sites/_form.haml index f3055bf7..4945d53e 100644 --- a/app/views/sites/_form.haml +++ b/app/views/sites/_form.haml @@ -8,7 +8,7 @@ - site.errors.messages.each_pair do |attr, error| - attr = attr.to_s - error.each do |e| - %li= link_to t('activerecord.attributes.site.' + attr) + ' ' + e, '#' + attr + %li= link_to "#{t("activerecord.attributes.site.#{attr}")} #{e}", "##{attr}" = form_for site, html: { class: form_class(site) } do |f| - unless site.persisted? @@ -21,11 +21,11 @@ No puede estar compuesto solo de números = f.text_field :name, - class: form_control(site, :name), - required: true, - pattern: '^([a-z0-9][a-z0-9\-]*)?[a-z0-9\.]$', - minlength: 1, - maxlength: 63 + class: form_control(site, :name), + required: true, + pattern: '^([a-z0-9][a-z0-9\-]*)?[a-z0-9\.]$', + minlength: 1, + maxlength: 63 - if invalid? site, :name .invalid-feedback= site.errors.messages[:name].join(', ') @@ -33,7 +33,7 @@ %h2= f.label :title %p.lead= t('.help.title') = f.text_field :title, class: form_control(site, :title), - required: true + required: true - if invalid? site, :title .invalid-feedback= site.errors.messages[:title].join(', ') @@ -41,7 +41,7 @@ %h2= f.label :description %p.lead= t('.help.description') = f.text_area :description, class: form_control(site, :description), - maxlength: 160, minlength: 10, required: true + maxlength: 160, minlength: 10, required: true - if invalid? site, :description .invalid-feedback= site.errors.messages[:description].join(', ') %hr/ @@ -53,29 +53,29 @@ - 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) + 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' + 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' + class: 'custom-control-label' .flex-fill = sanitize_markdown design.description, - tags: %w[p a strong em] + 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 btn-secondary' + target: '_blank', class: 'btn btn-secondary' - if design.license = link_to t('.design.license'), design.license, - target: '_blank', class: 'btn btn-secondary' + target: '_blank', class: 'btn btn-secondary' %hr/ .form-group.licenses#license_id @@ -83,6 +83,7 @@ %p.lead= t('.help.licencia') - Licencia.all.find_each do |licencia| - next if licencia.custom? && site.licencia != licencia + .row.license .col .media.mt-1 @@ -91,15 +92,19 @@ .media-body .custom-control.custom-radio = f.radio_button :licencia_id, licencia.id, - checked: licencia.id == site.licencia_id, - required: true, class: 'custom-control-input' + checked: licencia.id == site.licencia_id, + required: true, class: 'custom-control-input' = f.label "licencia_id_#{licencia.id}", class: 'custom-control-label' do = licencia.name = sanitize_markdown licencia.description, - tags: %w[p a strong em ul ol li h1 h2 h3 h4 h5 h6] + 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 btn-secondary', rel: 'noopener' + = link_to t('.licencia.url'), + licencia.url, + target: '_blank', + class: 'btn btn-secondary', + rel: 'noopener' %hr/ @@ -161,7 +166,7 @@ - site.deployment_list.each do |deploy| = f.fields_for :deploys, deploy do |deploy_fields| = render "deploys/#{deploy.type.underscore}", - deploy: deploy_fields, site: site + deploy: deploy_fields, site: site .form-group = f.submit submit, class: 'btn btn-secondary btn-lg btn-block' diff --git a/app/views/sites/_header.haml b/app/views/sites/_header.haml index d4302d34..306297cf 100644 --- a/app/views/sites/_header.haml +++ b/app/views/sites/_header.haml @@ -4,12 +4,17 @@ %form.mb-3{ action: site_posts_path } - @filter_params.each do |param, values| - next if param == :q + - [values].flatten.each do |value| - %input{ type: 'hidden', name: values.is_a?(Array) ? "#{param}[]" : param, value: value } + %input{ type: 'hidden', + name: values.is_a?(Array) ? "#{param}[]" : param, + value: value } .form-group.flex-grow-0.m-0 - %label.h3{for: 'q'}= t('posts.index.search') + %label.h3{ for: 'q' }= t('posts.index.search') .input-group - %input#q.form-control.border.border-magenta.border-right-0{ type: 'search', name: 'q', value: @filter_params[:q] } + %input.form-control.border.border-magenta.border-right-0#q{ type: 'search', + name: 'q', + value: @filter_params[:q] } .input-group-append %span.input-group-text.background-white.magenta.border.border-magenta.border-top.border-left-0.border-right.border-bottom %i.fa.fa-fw.fa-search @@ -17,9 +22,9 @@ - @filter_params.each do |param, values| - [values].flatten.each do |value| = link_to site_posts_path(@site, **filter_params_by(@filter_params, param, value)), - class: 'btn btn-secondary btn-sm', - title: t('posts.remove_filter_help', filter: value), - aria: { labelledby: "help-filter-#{param}" } do + class: 'btn btn-secondary btn-sm', + title: t('posts.remove_filter_help', filter: value), + aria: { labelledby: "help-filter-#{param}" } do - if param == :layout = @site.layouts[value.to_sym].humanized_name - else diff --git a/app/views/sites/fetch.haml b/app/views/sites/fetch.haml index ab7a8f3b..9daaf189 100644 --- a/app/views/sites/fetch.haml +++ b/app/views/sites/fetch.haml @@ -19,7 +19,7 @@ resumen, cortamos por el primer salto de línea doble y obtenemos todo lo demás = sanitize_markdown commit.message.split("\n\n", 2).last, - tags: %w[p a h1 h2 h3 h4 h5 h6 ol ul li strong em] + tags: %w[p a h1 h2 h3 h4 h5 h6 ol ul li strong em] %hr @@ -27,4 +27,4 @@ .row.justify-content-center .col-12.col-lg-8 = link_to t('.merge.request'), site_pull_path(@site), - method: 'post', class: 'btn btn-secondary 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 2cdfb727..febc8548 100644 --- a/app/views/sites/index.haml +++ b/app/views/sites/index.haml @@ -15,6 +15,7 @@ %tbody - @sites.each do |site| - next unless site.jekyll? + %tr %td %h2 diff --git a/app/views/stats/index.haml b/app/views/stats/index.haml index 6832b7ab..15fbdb9b 100644 --- a/app/views/stats/index.haml +++ b/app/views/stats/index.haml @@ -11,10 +11,19 @@ %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 #{@interval == interval ? 'btn-primary active' : 'btn-secondary' }" + = 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] } + %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.btn-secondary.mb-0{ type: 'submit' }= t('.filter') .mb-5 @@ -22,17 +31,27 @@ %p.lead= t('.host.description') = line_chart site_stats_host_path(@chart_params), **@chart_options - #custom-urls.mb-5 + .mb-5#custom-urls %h2= t('.urls.title') %p.lead= t('.urls.description') %form{ method: 'get', action: '#custom-urls' } - %input{ type: 'hidden', name: 'interval', value: @interval } - %input{ type: 'hidden', name: 'period_start', value: params[:period_start] } - %input{ type: 'hidden', name: 'period_end', value: params[:period_end] } + %input{ type: 'hidden', + name: 'interval', + value: @interval } + %input{ type: 'hidden', + name: 'period_start', + value: params[:period_start] } + %input{ type: 'hidden', + name: 'period_end', + value: params[:period_end] } .form-group %label{ for: 'urls' }= t('.urls.label') - %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') + %textarea.form-control#urls{ name: 'urls', + autocomplete: 'on', + required: true, + rows: @normalized_urls.size + 1, + aria_describedby: 'help-urls' }= @normalized_urls.join("\n") + %small.feedback.form-text.text-muted#help-urls= t('.urls.help') .form-group %button.btn.btn-secondary{ type: 'submit' }= t('.urls.submit') - if @normalized_urls.present? @@ -41,6 +60,7 @@ .row.mb-5.row-cols-1.row-cols-lg-2 - @columns.each_pair do |column, values| - next if values.blank? + .col.mb-5 %h2= t(".columns.#{column}.title") %p.lead= t(".columns.#{column}.description") @@ -57,7 +77,8 @@ %tbody - values.each_pair do |col, val| %tr - %th{ scope: 'row', style: 'word-break: break-all' }= col.blank? ? t(".columns.#{column}.empty") : col + %th.break-all{ scope: 'row' } + = col.blank? ? t(".columns.#{column}.empty") : col %td= val .mb-5 %h2= t('.resources.title') @@ -67,4 +88,5 @@ .mb-5 %h3= t(".resources.#{resource}.title") %p.lead= t(".resources.#{resource}.description") - = line_chart site_stats_resources_path(resource: resource, **@chart_params), **@chart_options.merge(StatsController::EXTRA_OPTIONS[resource]) + = line_chart site_stats_resources_path(resource: resource, **@chart_params), + **@chart_options.merge(StatsController::EXTRA_OPTIONS[resource]) diff --git a/app/views/usuaries/index.haml b/app/views/usuaries/index.haml index 265af56a..e0ee5e08 100644 --- a/app/views/usuaries/index.haml +++ b/app/views/usuaries/index.haml @@ -8,16 +8,16 @@ .btn-group{ role: 'group', 'aria-label': t('.actions') } - if @policy.invite? = link_to t('.invite'), - site_usuaries_invite_path(@site, invite_as: u.to_s), - class: 'btn btn-secondary', - data: { toggle: 'tooltip' }, - title: t('.help.invite', invite_as: u.to_s) + site_usuaries_invite_path(@site, invite_as: u.to_s), + 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 btn-secondary', - data: { toggle: 'tooltip' }, - title: t('.help.public_invite') + site_collaborate_path(@site), + class: 'btn btn-secondary', + data: { toggle: 'tooltip' }, + title: t('.help.public_invite') %p.lead= t(".help.#{u}") %table.table.table-condensed %tbody @@ -34,28 +34,28 @@ %span.badge.badge-info= t('.invited') %td .btn-group{ role: 'group', - aria: { label: t('.individual_actions') } } + aria: { label: t('.individual_actions') } } - if @policy.demote? && @site.usuarie?(cuenta) = link_to t('.demote.text'), - site_usuarie_demote_path(@site, cuenta), - class: 'btn btn-secondary', - data: { toggle: 'tooltip', - confirm: t('.demote.confirm') }, - title: t('.help.demote'), - method: :patch + site_usuarie_demote_path(@site, cuenta), + class: 'btn btn-secondary', + data: { toggle: 'tooltip', + confirm: t('.demote.confirm') }, + title: t('.help.demote'), + method: :patch - if @policy.promote? && @site.invitade?(cuenta) = link_to t('.promote.text'), - site_usuarie_promote_path(@site, cuenta), - class: 'btn btn-secondary', - data: { toggle: 'tooltip', - confirm: t('.promote.confirm') }, - title: t('.help.promote'), - method: :patch + site_usuarie_promote_path(@site, cuenta), + class: 'btn btn-secondary', + data: { toggle: 'tooltip', + confirm: t('.promote.confirm') }, + title: t('.help.promote'), + method: :patch - if @policy.destroy? = link_to t('.destroy.text'), - site_usuarie_path(@site, cuenta), - class: 'btn btn-secondary', - data: { toggle: 'tooltip', - confirm: t('.destroy.confirm') }, - title: t('.help.destroy'), - method: :delete + site_usuarie_path(@site, cuenta), + class: 'btn btn-secondary', + data: { toggle: 'tooltip', + confirm: t('.destroy.confirm') }, + title: t('.help.destroy'), + method: :delete diff --git a/app/views/usuaries/invite.haml b/app/views/usuaries/invite.haml index 0a9be9c8..b2f47ccb 100644 --- a/app/views/usuaries/invite.haml +++ b/app/views/usuaries/invite.haml @@ -9,8 +9,8 @@ .form-group = f.label :invitaciones do = t('.invitaciones') - %small.text-muted.form-text= t('.help.invitaciones', - invite_as: invite_as) + %small.text-muted.form-text + = t('.help.invitaciones', invite_as: invite_as) = f.text_area :invitaciones, class: 'form-control' .form-group = f.submit t('.submit'), class: 'btn btn-secondary' diff --git a/config/environments/test.rb b/config/environments/test.rb index bf72d234..d756dc68 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -46,7 +46,7 @@ Rails.application.configure do # The :test delivery method accumulates sent emails in the # ActionMailer::Base.deliveries array. config.action_mailer.delivery_method = :test - config.action_mailer.default_options = { from: ENV['DEFAULT_FROM'] } + config.action_mailer.default_options = { from: ENV.fetch('DEFAULT_FROM', nil) } config.action_mailer.default_url_options = { host: 'localhost', port: 3000 } @@ -54,8 +54,8 @@ Rails.application.configure do error_grouping: true, email: { email_prefix: '', - sender_address: ENV['DEFAULT_FROM'], - exception_recipients: ENV['EXCEPTION_TO'], + sender_address: ENV.fetch('DEFAULT_FROM', nil), + exception_recipients: ENV.fetch('EXCEPTION_TO', nil), normalize_subject: true } diff --git a/test/controllers/posts_controller_test.rb b/test/controllers/posts_controller_test.rb index 3349f09b..bc1c7e32 100644 --- a/test/controllers/posts_controller_test.rb +++ b/test/controllers/posts_controller_test.rb @@ -167,9 +167,7 @@ class PostsControllerTest < ActionDispatch::IntegrationTest end test 'si hay algún error se recupera' do - File.open(File.join(@site.path, '_es', "#{Date.today}-#{SecureRandom.hex}.markdown"), 'w') do |f| - f.write '' - end + File.write(File.join(@site.path, '_es', "#{Date.today}-#{SecureRandom.hex}.markdown"), '') get site_posts_url(@site), headers: @authorization end From a8297a934991adf5b7df89500d6874859537af62 Mon Sep 17 00:00:00 2001 From: maki Date: Tue, 4 Jun 2024 13:58:53 -0300 Subject: [PATCH 2/6] =?UTF-8?q?fix:=20m=C3=A1s=20lints?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bootstrap/_custom_checkbox_for_field.haml | 6 ++++- app/views/build_stats/index.haml | 7 ++++-- .../mailer/invitation_instructions.html.haml | 15 ++++++++---- app/views/devise/registrations/edit.haml | 3 ++- app/views/devise/registrations/new.haml | 10 ++++++-- app/views/devise/sessions/new.haml | 6 +++-- app/views/layouts/_breadcrumb.haml | 12 ++++++---- app/views/layouts/_details.haml | 5 +++- app/views/layouts/application.html.haml | 23 ++++++++++++++----- .../posts/attribute_ro/_related_posts.haml | 3 ++- app/views/posts/attributes/_draft.haml | 13 ----------- app/views/posts/index.haml | 5 ++-- app/views/schemas/_filter.haml | 2 +- app/views/sites/_form.haml | 3 ++- app/views/sites/_header.haml | 10 ++++---- app/views/stats/index.haml | 4 +++- 16 files changed, 78 insertions(+), 49 deletions(-) diff --git a/app/views/bootstrap/_custom_checkbox_for_field.haml b/app/views/bootstrap/_custom_checkbox_for_field.haml index a6d85879..8c12de57 100644 --- a/app/views/bootstrap/_custom_checkbox_for_field.haml +++ b/app/views/bootstrap/_custom_checkbox_for_field.haml @@ -2,5 +2,9 @@ - id = "#{field.object_name}_#{name}" - name = "#{field.object_name}[#{name}]" -= render 'bootstrap/custom_checkbox', id: id, name: name, content: content, required: local_assigns[:required], value: '1' do += render 'bootstrap/custom_checkbox', id: id, + name: name, + content: content, + required: local_assigns[:required], + value: '1' do = yield diff --git a/app/views/build_stats/index.haml b/app/views/build_stats/index.haml index c6ba4dfc..d505b2d4 100644 --- a/app/views/build_stats/index.haml +++ b/app/views/build_stats/index.haml @@ -1,6 +1,6 @@ %main.row %aside.menu.col-12.col-lg-3 - = render 'sites/header', site: @site + = render 'sites/header', site: @site, filter_params: @filter_params .col %h1= t('.title') @@ -14,7 +14,10 @@ - row[:urls].each do |url| %tr %th{ scope: 'row' }= row[:title] - %td= link_to_if (url.present? && url.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] diff --git a/app/views/devise/mailer/invitation_instructions.html.haml b/app/views/devise/mailer/invitation_instructions.html.haml index d2d44a67..779c5021 100644 --- a/app/views/devise/mailer/invitation_instructions.html.haml +++ b/app/views/devise/mailer/invitation_instructions.html.haml @@ -10,15 +10,20 @@ - if @resource.needs_invitation_link? %p= link_to t('devise.mailer.invitation_instructions.accept'), - accept_invitation_url(@resource, invitation_token: @token, change_locale_to: @resource.lang) + accept_invitation_url(@resource, + invitation_token: @token, + change_locale_to: @resource.lang) - if @resource.invitation_due_at %p= t('devise.mailer.invitation_instructions.accept_until', - due_date: l(@resource.invitation_due_at, - format: :'devise.mailer.invitation_instructions.accept_until_format')) + due_date: l(@resource.invitation_due_at, + format: :'devise.mailer.invitation_instructions.accept_until_format')) %p= t('devise.mailer.invitation_instructions.ignore') - elsif !@resource.confirmed? && @resource.confirmation_token - = confirmation_url(@resource, confirmation_token: @resource.confirmation_token, change_locale_to: @resource.lang) + = confirmation_url(@resource, + confirmation_token: @resource.confirmation_token, + change_locale_to: @resource.lang) - else - %p= link_to t('devise.mailer.invitation_instructions.sign_in'), root_url(change_locale_to: @resource.lang) + %p= link_to t('devise.mailer.invitation_instructions.sign_in'), + root_url(change_locale_to: @resource.lang) diff --git a/app/views/devise/registrations/edit.haml b/app/views/devise/registrations/edit.haml index 98b883fb..8574e88e 100644 --- a/app/views/devise/registrations/edit.haml +++ b/app/views/devise/registrations/edit.haml @@ -30,7 +30,8 @@ .form-group = f.label :password = f.password_field :password, autocomplete: 'new-password', - class: 'form-control', aria: { describedby: 'password-help' } + class: 'form-control', + aria: { describedby: 'password-help' } %small.text-muted.form-text#password-help = t('.leave_blank_if_you_don_t_want_to_change_it') - if @minimum_password_length diff --git a/app/views/devise/registrations/new.haml b/app/views/devise/registrations/new.haml index 0c800a1f..d19251d2 100644 --- a/app/views/devise/registrations/new.haml +++ b/app/views/devise/registrations/new.haml @@ -22,7 +22,8 @@ .form-group = f.label :password, class: 'sr-only' = f.password_field :password, autocomplete: 'new-password', - class: 'form-control', min: @minimum_password_length, + class: 'form-control', + min: @minimum_password_length, aria: { describedby: 'minimum-password-length' }, placeholder: t(password) - if @minimum_password_length @@ -47,7 +48,12 @@ - content = t(".#{field}.label") - href = t(".#{field}.href", default: '') - help_content = t(".#{field}.help") - = render 'bootstrap/custom_checkbox', id: id, name: name, content: content, required: required, value: '1' do + = render 'bootstrap/custom_checkbox', + id: id, + name: name, + content: content, + required: required, + value: '1' do - if href.present? = link_to help_content, href, target: '_blank', rel: 'noopener' - else diff --git a/app/views/devise/sessions/new.haml b/app/views/devise/sessions/new.haml index be1e01f8..e1bc85bb 100644 --- a/app/views/devise/sessions/new.haml +++ b/app/views/devise/sessions/new.haml @@ -28,8 +28,10 @@ placeholder: t('login.password') - if devise_mapping.rememberable? .form-group - = render 'bootstrap/custom_checkbox_for_field', field: f, name: :remember_me do - = t('login.remember_me', remember_for: distance_of_time_in_words(Usuarie.remember_for)) + = render 'bootstrap/custom_checkbox_for_field', + field: f, name: :remember_me do + = t('login.remember_me', + remember_for: distance_of_time_in_words(Usuarie.remember_for)) .actions = f.submit t('.sign_in'), class: 'btn btn-secondary btn-lg btn-block' diff --git a/app/views/layouts/_breadcrumb.haml b/app/views/layouts/_breadcrumb.haml index 974b271f..639d4a27 100644 --- a/app/views/layouts/_breadcrumb.haml +++ b/app/views/layouts/_breadcrumb.haml @@ -1,7 +1,8 @@ %nav.navbar.flex-md-nowrap.px-0 %a.navbar-brand.order-0{ href: '/' } = inline_svg_tag 'sutty.svg', class: 'black', aria: true, - title: t('svg.sutty.title'), desc: t('svg.sutty.desc') + title: t('svg.sutty.title'), + desc: t('svg.sutty.desc') - if breadcrumbs? %nav.flex-grow-1.order-2.order-md-1{ aria: { label: t('.title') } } @@ -13,11 +14,11 @@ - else = link_to crumb.name, crumb.url, class: 'line-clamp-1' - - if @current_usuarie || current_usuarie + - if usuarie || current_usuarie %ul.navbar-nav.order-1.order-md-2 - - if @site&.tienda? + - if site&.tienda? %li.nav-item - = link_to t('.tienda'), @site.tienda_url, + = link_to t('.tienda'), site.tienda_url, role: 'button', class: 'btn btn-secondary' %li.nav-item @@ -33,4 +34,5 @@ - next if locale == I18n.locale %li.nav-item - = link_to t("switch_locale.#{locale}"), params.to_h.merge(change_locale_to: locale) + = link_to t("switch_locale.#{locale}"), + params.to_h.merge(change_locale_to: locale) diff --git a/app/views/layouts/_details.haml b/app/views/layouts/_details.haml index c07ab121..5e8d566c 100644 --- a/app/views/layouts/_details.haml +++ b/app/views/layouts/_details.haml @@ -10,7 +10,10 @@ - local_assigns[:closed] ||= '▶'.html_safe - local_assigns[:open] ||= '▼'.html_safe -%details.details.py-2{ id: local_assigns[:id], data: { controller: 'details', action: 'toggle->details#store' }, class: local_assigns[:details_class] } +%details.details.py-2{ id: local_assigns[:id], + data: { controller: 'details', + action: 'toggle->details#store' }, + class: local_assigns[:details_class] } %summary.d-flex.flex-row.align-items-center.justify-content-between{ class: local_assigns[:summary_class] } %span= summary %span.hide-when-open{ class: local_assigns[:open_class] }= local_assigns[:closed] diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index eaa15eb4..f28c67af 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -13,16 +13,27 @@ %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', defer: true - = stylesheet_pack_tag 'application', 'data-turbolinks-track': 'reload' - = favicon_link_tag 'sutty_cuadrada.png', rel: 'apple-touch-icon', type: 'image/png' + = 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', + defer: true + = stylesheet_pack_tag 'application', + 'data-turbolinks-track': 'reload' + = favicon_link_tag 'sutty_cuadrada.png', + rel: 'apple-touch-icon', + type: 'image/png' = render 'layouts/link_rel_alternate' %body{ class: yield(:body) } .container-fluid#sutty - = render 'layouts/breadcrumb' + = render 'layouts/breadcrumb', usuarie: @current_usuarie, site: @site = render 'layouts/flash' = yield diff --git a/app/views/posts/attribute_ro/_related_posts.haml b/app/views/posts/attribute_ro/_related_posts.haml index 5813e35c..2bf51367 100644 --- a/app/views/posts/attribute_ro/_related_posts.haml +++ b/app/views/posts/attribute_ro/_related_posts.haml @@ -2,7 +2,8 @@ %th= post_label_t(attribute, post: post) %td %ul{ dir: dir, lang: locale } - - site.indexed_posts.where(locale: post.lang.value, post_id: metadata.value).find_each do |p| + - site.indexed_posts.where(locale: post.lang.value, + post_id: metadata.value).find_each do |p| -# XXX: Ignorar todos los posts no encontrados (ej: fueron borrados o el uuid cambió) diff --git a/app/views/posts/attributes/_draft.haml b/app/views/posts/attributes/_draft.haml index 351edf01..e69de29b 100644 --- a/app/views/posts/attributes/_draft.haml +++ b/app/views/posts/attributes/_draft.haml @@ -1,13 +0,0 @@ -- if !@site.invitade?(cuenta) # esto ta mal - .form-check - = hidden_field_tag "#{base}[#{attribute}]", '0', id: '' - .custom-control.custom-switch - = check_box_tag "#{base}[#{attribute}]", '1', metadata.value, - class: "custom-control-input #{invalid(post, attribute)}", - aria: { describedby: id_for_help(attribute) }, - autofocus: autofocus - = label_tag "#{base}_#{attribute}", post_label_t(attribute, post: post), - class: 'custom-control-label' - - = render 'posts/attribute_feedback', - post: post, attribute: attribute, metadata: metadata diff --git a/app/views/posts/index.haml b/app/views/posts/index.haml index dbc5f4da..989e53ee 100644 --- a/app/views/posts/index.haml +++ b/app/views/posts/index.haml @@ -8,7 +8,7 @@ %main.row %aside.menu.col-lg-3 .mb-3 - = render 'sites/header', site: @site + = render 'sites/header', site: @site, filter_params: @filter_params = render 'sites/status', site: @site = render 'sites/build', site: @site, class: 'btn-block' = render 'sites/moderation_queue', site: @site, class: 'btn-block' @@ -89,7 +89,8 @@ - if @site.locales.size > 1 %nav#locales - @site.locales.each do |locale| - = link_to @site.data.dig(locale.to_s, 'locale') || locale, site_posts_path(@site, **@filter_params.merge(locale: locale)), + = link_to @site.data.dig(locale.to_s, 'locale') || locale, + site_posts_path(@site, **@filter_params.merge(locale: locale)), class: "mr-2 mt-2 mb-2 #{locale == @locale ? 'active font-weight-bold' : ''}" - if @posts.empty? diff --git a/app/views/schemas/_filter.haml b/app/views/schemas/_filter.haml index b1bdd078..de4c03a7 100644 --- a/app/views/schemas/_filter.haml +++ b/app/views/schemas/_filter.haml @@ -4,7 +4,7 @@ name: 'layout[]', class: '', value: schema.name, - checked: @filter_params[:layout]&.include?(key.to_s) } + checked: filter[:layout]&.include?(key.to_s) } %label.custom-control-label.font-weight-normal{ for: schema }= schema.humanized_name -# XXX: Solo un nivel de recursividad diff --git a/app/views/sites/_form.haml b/app/views/sites/_form.haml index 4945d53e..20c15fb6 100644 --- a/app/views/sites/_form.haml +++ b/app/views/sites/_form.haml @@ -94,7 +94,8 @@ = f.radio_button :licencia_id, licencia.id, checked: licencia.id == site.licencia_id, required: true, class: 'custom-control-input' - = f.label "licencia_id_#{licencia.id}", class: 'custom-control-label' do + = f.label "licencia_id_#{licencia.id}", + class: 'custom-control-label' do = licencia.name = sanitize_markdown licencia.description, tags: %w[p a strong em ul ol li h1 h2 h3 h4 h5 h6] diff --git a/app/views/sites/_header.haml b/app/views/sites/_header.haml index 306297cf..01b76083 100644 --- a/app/views/sites/_header.haml +++ b/app/views/sites/_header.haml @@ -2,7 +2,7 @@ %h1= site.title %p.lead= site.description %form.mb-3{ action: site_posts_path } - - @filter_params.each do |param, values| + - filter_params.each do |param, values| - next if param == :q - [values].flatten.each do |value| @@ -14,19 +14,19 @@ .input-group %input.form-control.border.border-magenta.border-right-0#q{ type: 'search', name: 'q', - value: @filter_params[:q] } + value: filter_params[:q] } .input-group-append %span.input-group-text.background-white.magenta.border.border-magenta.border-top.border-left-0.border-right.border-bottom %i.fa.fa-fw.fa-search %input.sr-only{ type: 'submit' } - - @filter_params.each do |param, values| + - filter_params.each do |param, values| - [values].flatten.each do |value| - = link_to site_posts_path(@site, **filter_params_by(@filter_params, param, value)), + = link_to site_posts_path(site, **filter_params_by(filter_params, param, value)), class: 'btn btn-secondary btn-sm', title: t('posts.remove_filter_help', filter: value), aria: { labelledby: "help-filter-#{param}" } do - if param == :layout - = @site.layouts[value.to_sym].humanized_name + = site.layouts[value.to_sym].humanized_name - else = value × diff --git a/app/views/stats/index.haml b/app/views/stats/index.haml index 15fbdb9b..0546bee4 100644 --- a/app/views/stats/index.haml +++ b/app/views/stats/index.haml @@ -55,7 +55,9 @@ .form-group %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 + = line_chart site_stats_uris_path(urls: @normalized_urls, + **@chart_params), + **@chart_options .row.mb-5.row-cols-1.row-cols-lg-2 - @columns.each_pair do |column, values| From d098fa7131f29e5cc8c8c8cb026e6f0cb690d91a Mon Sep 17 00:00:00 2001 From: maki Date: Fri, 14 Jun 2024 15:58:09 -0300 Subject: [PATCH 3/6] fix: cambiaba el padding del details de 'Agregar contenido' al abrirlo #16509 --- app/views/layouts/_details.haml | 2 +- app/views/posts/index.haml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/layouts/_details.haml b/app/views/layouts/_details.haml index 5e8d566c..c9442c4a 100644 --- a/app/views/layouts/_details.haml +++ b/app/views/layouts/_details.haml @@ -10,7 +10,7 @@ - local_assigns[:closed] ||= '▶'.html_safe - local_assigns[:open] ||= '▼'.html_safe -%details.details.py-2{ id: local_assigns[:id], +%details.details{ id: local_assigns[:id], data: { controller: 'details', action: 'toggle->details#store' }, class: local_assigns[:details_class] } diff --git a/app/views/posts/index.haml b/app/views/posts/index.haml index 989e53ee..7b8a5ece 100644 --- a/app/views/posts/index.haml +++ b/app/views/posts/index.haml @@ -34,7 +34,7 @@ %button.btn.btn-secondary.mt-3{ type: 'submit' }= t('posts.filters.submit') = render 'layouts/details', summary: t('posts.new'), - summary_class: 'h4 magenta font-weight-bold m-0 px-2', + summary_class: 'h4 magenta font-weight-bold m-0 px-2 py-2', details_class: 'details-agregar', open: '+', closed: '+', open_class: 'h1 magenta font-weight-bold m-0', From be6d101e6c9c010ae4103fa958fb87f479ce9e00 Mon Sep 17 00:00:00 2001 From: maki Date: Fri, 14 Jun 2024 16:05:03 -0300 Subject: [PATCH 4/6] fix: padding en los details de posts/index #16509 --- app/views/posts/index.haml | 2 +- app/views/schemas/_row.haml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/posts/index.haml b/app/views/posts/index.haml index 7b8a5ece..ec76806c 100644 --- a/app/views/posts/index.haml +++ b/app/views/posts/index.haml @@ -15,7 +15,7 @@ = render 'layouts/details', summary: t('posts.filters.title') do %form{ method: :get } - .border.border-magenta.p-1 + .border.border-magenta.p-3 - @filter_params.each do |param, values| - next if param == :layout diff --git a/app/views/schemas/_row.haml b/app/views/schemas/_row.haml index 494d664c..47b046fd 100644 --- a/app/views/schemas/_row.haml +++ b/app/views/schemas/_row.haml @@ -1,5 +1,5 @@ %tr.border-top.border-magenta - %th.font-weight-normal.w-100.position-relative{ scope: 'row' } + %th.font-weight-normal.w-100.position-relative.px-3.py-2{ scope: 'row' } - if local_assigns[:parent_schema] %span.text-muted — = render 'schemas/add', schema: schema, **local_assigns From b7b046b5b967f5f7d4123987c4ee1eb35a68698c Mon Sep 17 00:00:00 2001 From: maki Date: Fri, 14 Jun 2024 16:09:24 -0300 Subject: [PATCH 5/6] =?UTF-8?q?fix:=20ajust=20m=C3=A1rgenes=20bot=C3=B3n?= =?UTF-8?q?=20de=20aplicar=20filtros=20#16509?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/posts/index.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/posts/index.haml b/app/views/posts/index.haml index ec76806c..6b9a1f2d 100644 --- a/app/views/posts/index.haml +++ b/app/views/posts/index.haml @@ -31,7 +31,7 @@ key: key, schema: schema, filter: @filter_params - %button.btn.btn-secondary.mt-3{ type: 'submit' }= t('posts.filters.submit') + %button.btn.btn-secondary.mt-2.mb-4{ type: 'submit' }= t('posts.filters.submit') = render 'layouts/details', summary: t('posts.new'), summary_class: 'h4 magenta font-weight-bold m-0 px-2 py-2', From 7f6730c1e692747155c0f5606ca81426b895facc Mon Sep 17 00:00:00 2001 From: maki Date: Fri, 14 Jun 2024 16:34:38 -0300 Subject: [PATCH 6/6] =?UTF-8?q?fix:=20t=C3=ADtulos=20de=20los=20botones=20?= =?UTF-8?q?de=20filtro=20ahora=20son=20los=20nombres=20legibles=20por=20hu?= =?UTF-8?q?manes=20+=20los=20botones=20tienen=20el=20nombre=20y=20la=20cru?= =?UTF-8?q?z=20en=20la=20misma=20fila=20#16509?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/assets/stylesheets/application.scss | 4 ++++ app/views/sites/_header.haml | 25 ++++++++++++++----------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index f90e967a..fd7c31b7 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -682,4 +682,8 @@ a.black { @extend .align-items-center; @extend .w-100; @extend .mb-3; +} + +.btn-sm-queries { + @include button-size($btn-padding-y-sm, $btn-padding-x-sm, $btn-font-size-sm, $btn-line-height, $btn-border-radius-sm); } \ No newline at end of file diff --git a/app/views/sites/_header.haml b/app/views/sites/_header.haml index 01b76083..87dd06b8 100644 --- a/app/views/sites/_header.haml +++ b/app/views/sites/_header.haml @@ -9,7 +9,7 @@ %input{ type: 'hidden', name: values.is_a?(Array) ? "#{param}[]" : param, value: value } - .form-group.flex-grow-0.m-0 + .form-group.flex-grow-0.m-0.mb-1 %label.h3{ for: 'q' }= t('posts.index.search') .input-group %input.form-control.border.border-magenta.border-right-0#q{ type: 'search', @@ -19,14 +19,17 @@ %span.input-group-text.background-white.magenta.border.border-magenta.border-top.border-left-0.border-right.border-bottom %i.fa.fa-fw.fa-search %input.sr-only{ type: 'submit' } + - filter_params.each do |param, values| - - [values].flatten.each do |value| - = link_to site_posts_path(site, **filter_params_by(filter_params, param, value)), - class: 'btn btn-secondary btn-sm', - title: t('posts.remove_filter_help', filter: value), - aria: { labelledby: "help-filter-#{param}" } do - - if param == :layout - = site.layouts[value.to_sym].humanized_name - - else - = value - × + .d-flex.flex-wrap + - [values].flatten.each do |value| + - humanized_name = site.layouts[value.to_sym].humanized_name + = link_to site_posts_path(site, **filter_params_by(filter_params, param, value)), + class: 'btn btn-secondary btn-sm-queries', + title: humanized_name, + aria: { labelledby: "help-filter-#{param}" } do + - if param == :layout + %span= humanized_name + - else + = value + %span ×