Use HTML beautifier to indent ERB files

We had inconsistent indentation in many places. Now we're fixing them
and adding a linter to our CI so we don't accidentally introduce
inconsistent indentations again.
This commit is contained in:
Javi Martín
2025-02-20 18:41:46 +01:00
parent b4b33926cf
commit b51aa31e6a
66 changed files with 574 additions and 558 deletions

View File

@@ -21,6 +21,8 @@ jobs:
run: npx stylelint app/assets/stylesheets run: npx stylelint app/assets/stylesheets
- name: Markdownlint - name: Markdownlint
run: bundle exec mdl *.md docs/ run: bundle exec mdl *.md docs/
- name: HTML Beautifier
run: find app/ -name "*.html.erb" -exec bundle exec htmlbeautifier --lint-only --keep-blank-lines 1 {} +
name: ${{ matrix.name }} name: ${{ matrix.name }}
steps: steps:
- name: Checkout code - name: Checkout code

View File

@@ -95,6 +95,7 @@ group :development do
gem "capistrano3-puma", "~> 5.2.0" gem "capistrano3-puma", "~> 5.2.0"
gem "erb_lint", "~> 0.9.0", require: false gem "erb_lint", "~> 0.9.0", require: false
gem "faraday-retry", "~> 2.2.1", require: false gem "faraday-retry", "~> 2.2.1", require: false
gem "htmlbeautifier", "~> 1.4.3", require: false
gem "mdl", "~> 0.13.0", require: false gem "mdl", "~> 0.13.0", require: false
gem "pronto", "~> 0.11.2", require: false gem "pronto", "~> 0.11.2", require: false
gem "pronto-erb_lint", "~> 0.1.6", require: false gem "pronto-erb_lint", "~> 0.1.6", require: false

View File

@@ -272,6 +272,7 @@ GEM
hashery (2.1.2) hashery (2.1.2)
hashie (5.0.0) hashie (5.0.0)
highline (2.0.3) highline (2.0.3)
htmlbeautifier (1.4.3)
htmlentities (4.3.4) htmlentities (4.3.4)
httparty (0.22.0) httparty (0.22.0)
csv csv
@@ -755,6 +756,7 @@ DEPENDENCIES
graphiql-rails (~> 1.8.0) graphiql-rails (~> 1.8.0)
graphql (~> 2.3.18) graphql (~> 2.3.18)
groupdate (~> 6.5.1) groupdate (~> 6.5.1)
htmlbeautifier (~> 1.4.3)
i18n-tasks (~> 0.9.37) i18n-tasks (~> 0.9.37)
image_processing (~> 1.13.0) image_processing (~> 1.13.0)
invisible_captcha (~> 2.3.0) invisible_captcha (~> 2.3.0)

View File

@@ -8,7 +8,8 @@
<div class="small-12 medium-3 column highlight padding"> <div class="small-12 medium-3 column highlight padding">
<strong><%= t("admin.poll_shifts.new.officer") %></strong> <strong><%= t("admin.poll_shifts.new.officer") %></strong>
<br><%= officer.name %> <br>
<%= officer.name %>
<%= f.hidden_field :officer_id, value: officer.id %> <%= f.hidden_field :officer_id, value: officer.id %>
</div> </div>

View File

@@ -30,7 +30,9 @@
<table class="investment-projects-summary"> <table class="investment-projects-summary">
<thead> <thead>
<tr><th colspan="2"><%= t("admin.stats.budget_balloting.votes_per_heading") %></th></tr> <tr>
<th colspan="2"><%= t("admin.stats.budget_balloting.votes_per_heading") %></th>
</tr>
</thead> </thead>
<tbody> <tbody>
@@ -49,7 +51,9 @@
<table class="investment-projects-summary user-count-by-heading"> <table class="investment-projects-summary user-count-by-heading">
<thead> <thead>
<tr><th colspan="2"><%= t("admin.stats.budget_balloting.participants_per_district") %></th></tr> <tr>
<th colspan="2"><%= t("admin.stats.budget_balloting.participants_per_district") %></th>
</tr>
</thead> </thead>
<tbody> <tbody>

View File

@@ -1,5 +1,6 @@
<div class="small-12 medium-4 column"> <div class="small-12 medium-4 column">
<%= tag.p(**options) do %> <%= tag.p(**options) do %>
<%= text %> <br><span class="number"><%= amount %></span> <%= text %> <br>
<span class="number"><%= amount %></span>
<% end %> <% end %>
</div> </div>

View File

@@ -24,7 +24,9 @@
</div> </div>
<div class="small-12 column"> <div class="small-12 column">
<div class="progress-bar-placeholder"><div class="loading-bar"></div></div> <div class="progress-bar-placeholder">
<div class="loading-bar"></div>
</div>
</div> </div>
<hr> <hr>

View File

@@ -13,7 +13,8 @@
<h1> <h1>
<%= link_to namespace_path do %> <%= link_to namespace_path do %>
<%= setting["org_name"] %> <%= setting["org_name"] %>
<br><small><%= namespaced_header_title %></small> <br>
<small><%= namespaced_header_title %></small>
<% end %> <% end %>
</h1> </h1>

View File

@@ -47,9 +47,7 @@
</p> </p>
<% option.videos.each do |video| %> <% option.videos.each do |video| %>
<%= link_to video.title, <%= link_to video.title, video.url, rel: "nofollow" %><br>
video.url,
rel: "nofollow" %><br>
<% end %> <% end %>
</div> </div>
<% end %> <% end %>

View File

@@ -56,7 +56,9 @@
<div class="small-12 medium-3 column"> <div class="small-12 medium-3 column">
<p class="featured"> <p class="featured">
<%= t "admin.stats.show.summary.proposal_votes" %> <br> <%= t "admin.stats.show.summary.proposal_votes" %> <br>
<span class="number"><%= number_with_delimiter(@proposal_votes) %> <br></span> <span class="number">
<%= number_with_delimiter(@proposal_votes) %> <br>
</span>
</p> </p>
<p> <p>
<%= t "admin.stats.show.summary.debate_votes" %> <br> <%= t "admin.stats.show.summary.debate_votes" %> <br>

View File

@@ -1,7 +1,7 @@
<% provide :title, t("budgets.executions.page_title", budget: @budget.name) %> <% provide :title, t("budgets.executions.page_title", budget: @budget.name) %>
<% content_for :meta_description do %><%= @budget.description_for_phase("finished") %><% end %> <% content_for :meta_description do %><%= @budget.description_for_phase("finished") %><% end %>
<% provide :social_media_meta_tags do %> <% provide :social_media_meta_tags do %>
<%= render "shared/social_media_meta_tags", <%= render "shared/social_media_meta_tags",
social_url: budget_executions_url(@budget), social_url: budget_executions_url(@budget),
social_title: @budget.name, social_title: @budget.name,
social_description: @budget.description_for_phase("finished") %> social_description: @budget.description_for_phase("finished") %>

View File

@@ -1,5 +1,5 @@
<% provide :social_media_meta_tags do %> <% provide :social_media_meta_tags do %>
<%= render "shared/social_media_meta_tags", <%= render "shared/social_media_meta_tags",
social_url: budget_investments_path(investment), social_url: budget_investments_path(investment),
social_title: investment.title, social_title: investment.title,
social_description: investment.description, social_description: investment.description,

View File

@@ -1,7 +1,7 @@
<% provide :title, t("budgets.results.page_title", budget: @budget.name) %> <% provide :title, t("budgets.results.page_title", budget: @budget.name) %>
<% content_for :meta_description do %><%= @budget.description_for_phase("finished") %><% end %> <% content_for :meta_description do %><%= @budget.description_for_phase("finished") %><% end %>
<% provide :social_media_meta_tags do %> <% provide :social_media_meta_tags do %>
<%= render "shared/social_media_meta_tags", <%= render "shared/social_media_meta_tags",
social_url: budget_results_url(@budget), social_url: budget_results_url(@budget),
social_title: @budget.name, social_title: @budget.name,
social_description: @budget.description_for_phase("finished") %> social_description: @budget.description_for_phase("finished") %>

View File

@@ -1,6 +1,6 @@
<% provide :title, t("stats.budgets.page_title", budget: @budget.name) %> <% provide :title, t("stats.budgets.page_title", budget: @budget.name) %>
<% provide :social_media_meta_tags do %> <% provide :social_media_meta_tags do %>
<%= render "shared/social_media_meta_tags", <%= render "shared/social_media_meta_tags",
social_url: budget_stats_url(@budget), social_url: budget_stats_url(@budget),
social_title: @budget.name, social_title: @budget.name,
social_description: @budget.description_for_phase("finished") %> social_description: @budget.description_for_phase("finished") %>

View File

@@ -1,11 +1,11 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html <%= common_html_attributes %>> <html <%= common_html_attributes %>>
<head> <head>
<title><%= t("mailers.title") %></title> <title><%= t("mailers.title") %></title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"> <meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="viewport" id="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0,maximum-scale=10.0" /> <meta name="viewport" id="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0,maximum-scale=10.0" />
</head> </head>
<body style="background: #fff; font-family:font-family: 'Open Sans','Helvetica Neue',arial,sans-serif !important; margin: 0 10px; padding: 0; text-align: left;"> <body style="background: #fff; font-family:font-family: 'Open Sans','Helvetica Neue',arial,sans-serif !important; margin: 0 10px; padding: 0; text-align: left;">
<%= render "layouts/mailer_header" %> <%= render "layouts/mailer_header" %>
@@ -18,5 +18,5 @@
</table> </table>
<%= render "layouts/mailer_footer" %> <%= render "layouts/mailer_footer" %>
</body> </body>
</html> </html>

View File

@@ -1,7 +1,7 @@
<% provide :title, @proposal.title %> <% provide :title, @proposal.title %>
<% content_for :meta_description do %><%= @proposal.summary %><% end %> <% content_for :meta_description do %><%= @proposal.summary %><% end %>
<% provide :social_media_meta_tags do %> <% provide :social_media_meta_tags do %>
<%= render "shared/social_media_meta_tags", <%= render "shared/social_media_meta_tags",
social_url: legislation_process_proposal_url(process_id: @process), social_url: legislation_process_proposal_url(process_id: @process),
social_title: @proposal.title, social_title: @proposal.title,
social_description: @proposal.summary %> social_description: @proposal.summary %>

View File

@@ -1,7 +1,7 @@
<% provide :title, t("devise_views.organizations.registrations.new.title") %> <% provide :title, t("devise_views.organizations.registrations.new.title") %>
<h2><%= t("devise_views.organizations.registrations.new.title") %></h2> <h2><%= t("devise_views.organizations.registrations.new.title") %></h2>
<%= form_for(resource, as: :user, url: organization_registration_path) do |f| %> <%= form_for(resource, as: :user, url: organization_registration_path) do |f| %>
<%= render "shared/errors", resource: resource %> <%= render "shared/errors", resource: resource %>
<div class="row"> <div class="row">
<div class="small-12 column"> <div class="small-12 column">

View File

@@ -1,6 +1,6 @@
<% provide :title, @proposal.title %> <% provide :title, @proposal.title %>
<% provide :social_media_meta_tags do %> <% provide :social_media_meta_tags do %>
<%= render "shared/social_media_meta_tags", <%= render "shared/social_media_meta_tags",
social_url: proposal_url(@proposal), social_url: proposal_url(@proposal),
social_title: @proposal.title, social_title: @proposal.title,
social_description: @proposal.summary %> social_description: @proposal.summary %>

View File

@@ -3,7 +3,9 @@
<% valid_filters.each do |filter| %> <% valid_filters.each do |filter| %>
<% if current_filter == filter %> <% if current_filter == filter %>
<li class="is-active"><h2><%= t("#{i18n_namespace}.filters.#{filter}") %></h2></li> <li class="is-active">
<h2><%= t("#{i18n_namespace}.filters.#{filter}") %></h2>
</li>
<% else %> <% else %>
<li><%= link_to t("#{i18n_namespace}.filters.#{filter}"), <li><%= link_to t("#{i18n_namespace}.filters.#{filter}"),
current_path_with_query_params(filter: filter, page: 1) %></li> current_path_with_query_params(filter: filter, page: 1) %></li>

View File

@@ -15,15 +15,15 @@ describe Admin::Stats::SDG::GoalComponent do
render_inline component render_inline component
expect(page).to have_text "Proposals 3" expect(page).to have_text "Proposals 3", normalize_ws: true
expect(page).to have_text "Polls 2" expect(page).to have_text "Polls 2", normalize_ws: true
expect(page).to have_text "Debates 1" expect(page).to have_text "Debates 1", normalize_ws: true
expect("Current budget").to appear_before("Past year budget") expect("Current budget").to appear_before("Past year budget")
expect(page).to have_text "Investment projects sent 2" expect(page).to have_text "Investment projects sent 2", normalize_ws: true
expect(page).to have_text "Winner investment projects 0" expect(page).to have_text "Winner investment projects 0", normalize_ws: true
expect(page).to have_text "Approved amount $0" expect(page).to have_text "Approved amount $0", normalize_ws: true
expect(page).to have_text "Investment projects sent 1" expect(page).to have_text "Investment projects sent 1", normalize_ws: true
expect(page).to have_text "Winner investment projects 1" expect(page).to have_text "Winner investment projects 1", normalize_ws: true
expect(page).to have_text "Approved amount $1,000" expect(page).to have_text "Approved amount $1,000", normalize_ws: true
end end
end end