From a868a5ff35d3c1509043b7f1cac5a3e80592895a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Mon, 21 Jun 2021 23:49:39 +0200 Subject: [PATCH 1/6] Change Foundation text direction in RTL languages This way, when the language is written form right-to-left, elements using Foundation mixins/classes will float to the opposite direction as they do in left-to-right languages. The same will apply to text alignment. To offer full support for RTL languages, we need to change every single reference to `float: left`, `float: right`, `text-align: left`, `text-align: right`, and possible adjust other properties like `left`, `margin-left`, `padding-left` or `border-left`. In the meantime, we at least partially support these languages. Replacing `float` with `flex` when possible would also improve RTL support. --- app/assets/stylesheets/application-rtl.scss | 3 +++ app/helpers/application_helper.rb | 4 ++++ app/views/layouts/_common_head.html.erb | 6 +++++- config/initializers/assets.rb | 1 + 4 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 app/assets/stylesheets/application-rtl.scss diff --git a/app/assets/stylesheets/application-rtl.scss b/app/assets/stylesheets/application-rtl.scss new file mode 100644 index 00000000000..99d12603a21 --- /dev/null +++ b/app/assets/stylesheets/application-rtl.scss @@ -0,0 +1,3 @@ +$global-text-direction: rtl; + +@import "application"; diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index b14baa148ef..e57d065766b 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -6,6 +6,10 @@ def current_path_with_query_params(query_parameters) url_for(request.query_parameters.merge(query_parameters).merge(only_path: true)) end + def rtl? + %i[ar fa he].include?(I18n.locale) + end + def markdown(text) return text if text.blank? diff --git a/app/views/layouts/_common_head.html.erb b/app/views/layouts/_common_head.html.erb index d4c0d4daf0e..abed78d196f 100644 --- a/app/views/layouts/_common_head.html.erb +++ b/app/views/layouts/_common_head.html.erb @@ -2,7 +2,11 @@ <%= content_for?(:title) ? yield(:title) : default_title %> -<%= stylesheet_link_tag "application" %> +<% if rtl? %> + <%= stylesheet_link_tag "application-rtl" %> +<% else %> + <%= stylesheet_link_tag "application" %> +<% end %> <%= javascript_include_tag "application", "data-turbolinks-track" => "reload" %> <%= csrf_meta_tags %> <%= favicon_link_tag "favicon.ico" %> diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index 1afb578ff84..6630e63f6ca 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -12,6 +12,7 @@ Rails.application.config.assets.precompile += %w[ckeditor/config.js] Rails.application.config.assets.precompile += %w[stat_graphs.js] Rails.application.config.assets.precompile += %w[dashboard_graphs.js] +Rails.application.config.assets.precompile += %w[application-rtl.css] Rails.application.config.assets.precompile += %w[print.css] Rails.application.config.assets.precompile += %w[pdf_fonts.css] Rails.application.config.assets.precompile += %w[sdg/*.png] From d827768c072f99fb3f4003a43d15caa71be14405 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Mon, 21 Jun 2021 23:59:31 +0200 Subject: [PATCH 2/6] Set HTML dir attribute in RTL languages This way properties flex layouts text direction will work properly. --- app/views/layouts/admin.html.erb | 2 +- app/views/layouts/application.html.erb | 2 +- app/views/layouts/devise.html.erb | 2 +- app/views/layouts/management.html.erb | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/layouts/admin.html.erb b/app/views/layouts/admin.html.erb index 8c3176b1274..1a78ad60aee 100644 --- a/app/views/layouts/admin.html.erb +++ b/app/views/layouts/admin.html.erb @@ -1,5 +1,5 @@ - + lang="<%= I18n.locale %>"> <%= render "layouts/common_head", default_title: "Admin" %> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 68a067c6d54..18bc7f78c87 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -1,5 +1,5 @@ - + lang="<%= I18n.locale %>" data-current-user-id="<%= current_user&.id %>"> <%= render "layouts/common_head", default_title: setting["org_name"] %> <%= render "layouts/tracking_data" %> diff --git a/app/views/layouts/devise.html.erb b/app/views/layouts/devise.html.erb index cf6753750b3..c781d44038f 100644 --- a/app/views/layouts/devise.html.erb +++ b/app/views/layouts/devise.html.erb @@ -1,5 +1,5 @@ - + lang="<%= I18n.locale %>"> <%= render "layouts/common_head", default_title: setting["org_name"] %> <%= render "layouts/meta_tags" %> diff --git a/app/views/layouts/management.html.erb b/app/views/layouts/management.html.erb index 1d427044cad..efd92bbdb74 100644 --- a/app/views/layouts/management.html.erb +++ b/app/views/layouts/management.html.erb @@ -1,5 +1,5 @@ - + lang="<%= I18n.locale %>"> <%= render "layouts/common_head", default_title: "Management" %> From d5d9eb5093efa630df542653a03e3a74b518ce66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= <35156+javierm@users.noreply.github.com> Date: Tue, 17 Aug 2021 14:15:56 +0200 Subject: [PATCH 3/6] Fix tests after replacing message with notification Looks like our test suite wasn't executed in commit 4dbc027e5, and so we weren't notified of these failures. --- spec/system/dashboard/dashboard_spec.rb | 4 ++-- spec/system/direct_messages_spec.rb | 2 +- spec/system/proposal_notifications_spec.rb | 20 ++++++++++---------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/spec/system/dashboard/dashboard_spec.rb b/spec/system/dashboard/dashboard_spec.rb index 2485a457273..1d423c4d359 100644 --- a/spec/system/dashboard/dashboard_spec.rb +++ b/spec/system/dashboard/dashboard_spec.rb @@ -360,13 +360,13 @@ expect(page).to have_link("See previous notifications") end - scenario "Dashboard has a link to send message to proposal supporters" do + scenario "Dashboard has a link to send notification to proposal supporters" do visit messages_proposal_dashboard_path(proposal) click_link("Send notification to proposal followers") fill_in "Title", with: "Thank you for supporting my proposal" fill_in "Message", with: "Please share it with others!" - click_button "Send message" + click_button "Send notification" expect(page).to have_content "Your message has been sent correctly." expect(page).to have_content "Thank you for supporting my proposal" diff --git a/spec/system/direct_messages_spec.rb b/spec/system/direct_messages_spec.rb index d7a2b1ca874..dd008174e64 100644 --- a/spec/system/direct_messages_spec.rb +++ b/spec/system/direct_messages_spec.rb @@ -85,7 +85,7 @@ login_as(author) visit new_proposal_notification_path(proposal_id: proposal.id) - click_button "Send message" + click_button "Send notification" expect(page).to have_content error_message end diff --git a/spec/system/proposal_notifications_spec.rb b/spec/system/proposal_notifications_spec.rb index d3821497821..b26f9606e25 100644 --- a/spec/system/proposal_notifications_spec.rb +++ b/spec/system/proposal_notifications_spec.rb @@ -19,7 +19,7 @@ fill_in "proposal_notification_title", with: "Thank you for supporting my proposal" fill_in "proposal_notification_body", with: "Please share it with "\ "others so we can make it happen!" - click_button "Send message" + click_button "Send notification" expect(page).to have_content "Your message has been sent correctly." expect(page).to have_content "Thank you for supporting my proposal" @@ -192,7 +192,7 @@ fill_in "proposal_notification_title", with: "Thank you for supporting my proposal" fill_in "proposal_notification_body", with: "Please share it with "\ "others so we can make it happen!" - click_button "Send message" + click_button "Send notification" expect(page).to have_content "Your message has been sent correctly." @@ -244,7 +244,7 @@ fill_in "proposal_notification_title", with: "Thank you for supporting my proposal" fill_in "proposal_notification_body", with: "Please share it with "\ "others so we can make it happen!" - click_button "Send message" + click_button "Send notification" expect(page).to have_content "Your message has been sent correctly." @@ -294,7 +294,7 @@ fill_in "proposal_notification_title", with: "Thank you for supporting my proposal" fill_in "proposal_notification_body", with: "Please share it with "\ "others so we can make it happen!" - click_button "Send message" + click_button "Send notification" expect(page).to have_content "Your message has been sent correctly." @@ -338,7 +338,7 @@ fill_in "Title", with: "Thank you for supporting my proposal" fill_in "Message", with: "Please share it with others so we can make it happen!" - click_button "Send message" + click_button "Send notification" expect(page).to have_content "Your message has been sent correctly." end @@ -362,7 +362,7 @@ login_as(author) visit new_proposal_notification_path(proposal_id: proposal.id) - click_button "Send message" + click_button "Send notification" expect(page).to have_content error_message end @@ -377,14 +377,14 @@ visit new_proposal_notification_path(proposal_id: proposal.id) fill_in "Title", with: "Thank you for supporting my proposal" fill_in "Message", with: "Please share it with others so we can make it happen!" - click_button "Send message" + click_button "Send notification" expect(page).to have_content "Your message has been sent correctly." visit new_proposal_notification_path(proposal_id: proposal.id) fill_in "Title", with: "Thank you again for supporting my proposal" fill_in "Message", with: "Please share it again with others so we can make it happen!" - click_button "Send message" + click_button "Send notification" expect(page).to have_content "You have to wait a minimum of 3 days between notifications" expect(page).not_to have_content "Your message has been sent correctly." @@ -399,7 +399,7 @@ visit new_proposal_notification_path(proposal_id: proposal.id) fill_in "Title", with: "Thank you for supporting my proposal" fill_in "Message", with: "Please share it with others so we can make it happen!" - click_button "Send message" + click_button "Send notification" expect(page).to have_content "Your message has been sent correctly." @@ -407,7 +407,7 @@ visit new_proposal_notification_path(proposal_id: proposal.id) fill_in "Title", with: "Thank you again for supporting my proposal" fill_in "Message", with: "Please share it again with others so we can make it happen!" - click_button "Send message" + click_button "Send notification" expect(page).to have_content "Your message has been sent correctly." expect(page).not_to have_content "You have to wait a minimum of 3 days between notifications" From 2c84f775d7908737bd599d615b717a1df1885f42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Tue, 17 Aug 2021 14:37:57 +0200 Subject: [PATCH 4/6] Explicitely use Debian Buster in Dockerfile Debian Bullseye was released two days ago, and is now the default distribution for the Docker image. Our image isn't compatible with Debian Bullseye right now, and we haven't done any testing with it, so for now we're staying with Buster. --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 5ec8e146882..6274055fd23 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ruby:2.6.8 +FROM ruby:2.6.8-buster ENV DEBIAN_FRONTEND noninteractive From 4557606400255d31e4268aa1eaab196b31919492 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Sun, 15 Aug 2021 19:57:28 +0200 Subject: [PATCH 5/6] Upgrade Ruby to version 2.7.4 Note this version includes Bundler 2, so we can finally upgrade. --- .gitlab-ci.yml | 4 ++-- .ruby-version | 2 +- Dockerfile | 2 +- Gemfile.lock | 2 +- README.md | 2 +- README_ES.md | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fd052c81966..76071ff9298 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,7 +3,7 @@ stages: - lint tests: - image: "ruby:2.6.8" + image: "ruby:2.7.4" stage: test services: - postgres:10.10 @@ -34,7 +34,7 @@ tests: # PRONTO_GITLAB_API_PRIVATE_TOKEN to your repository CI/CD settings # giving it the value of the Personal Access Token linters: - image: "ruby:2.6.8" + image: "ruby:2.7.4" stage: lint cache: key: consul diff --git a/.ruby-version b/.ruby-version index 743af5e1251..a4dd9dba4fb 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.6.8 +2.7.4 diff --git a/Dockerfile b/Dockerfile index 6274055fd23..6bcdab13c72 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ruby:2.6.8-buster +FROM ruby:2.7.4-buster ENV DEBIAN_FRONTEND noninteractive diff --git a/Gemfile.lock b/Gemfile.lock index fc8436ab3d6..07b07cc8530 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -795,4 +795,4 @@ DEPENDENCIES wkhtmltopdf-binary (~> 0.12.6) BUNDLED WITH - 1.17.2 + 2.1.4 diff --git a/README.md b/README.md index 06689b68172..101fb333c8d 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ You can access the main website of the project at [http://consulproject.org](htt **NOTE**: For more detailed instructions check the [docs](https://docs.consulproject.org) -Prerequisites: install git, Ruby 2.6.8, CMake, pkg-config, shared-mime-info, Node.js and PostgreSQL (>=9.5). +Prerequisites: install git, Ruby 2.7.4, CMake, pkg-config, shared-mime-info, Node.js and PostgreSQL (>=9.5). ```bash git clone https://github.com/consul/consul.git diff --git a/README_ES.md b/README_ES.md index dbef26e87ac..afbae802da4 100644 --- a/README_ES.md +++ b/README_ES.md @@ -36,7 +36,7 @@ Puedes acceder a la página principal del proyecto en [http://consulproject.org] **NOTA**: para unas instrucciones más detalladas consulta la [documentación](https://docs.consulproject.org) -Prerequisitos: tener instalado git, Ruby 2.6.8, CMake, pkg-config, shared-mime-info, Node.js y PostgreSQL (9.5 o superior). +Prerequisitos: tener instalado git, Ruby 2.7.4, CMake, pkg-config, shared-mime-info, Node.js y PostgreSQL (9.5 o superior). ```bash git clone https://github.com/consul/consul.git From 79b1040189912c3b09022ac835f80e2513360b24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Sun, 15 Aug 2021 21:17:40 +0200 Subject: [PATCH 6/6] Supress warnings in Paperclip::UrlGenerator We were getting hundreds of "warning: URI.escape is obsolete" messages. So we're using `URI::DEFAULT_PARSER.escape` instead. IMHO it's OK to add this monkey-patch because we're replacing Paperclip with Active Storage, and when we finish with that we'll delete this file. --- config/initializers/paperclip.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 config/initializers/paperclip.rb diff --git a/config/initializers/paperclip.rb b/config/initializers/paperclip.rb new file mode 100644 index 00000000000..97a4079d9b8 --- /dev/null +++ b/config/initializers/paperclip.rb @@ -0,0 +1,13 @@ +class Paperclip::UrlGenerator + private + + # Code copied from the paperclip gem, only replacing + # `URI.escape` with `URI::DEFAULT_PARSER.escape` + def escape_url(url) + if url.respond_to?(:escape) + url.escape + else + URI::DEFAULT_PARSER.escape(url).gsub(escape_regex) { |m| "%#{m.ord.to_s(16).upcase}" } + end + end +end