5886 Commits

Author SHA1 Message Date
Javi Martín
d54971e536 Use Dart Sass to compile SCSS files
SassC/Libsass has been deprecated for years and has been replaced by
Dart Sass. However, the dartsass-rails gem, maintained by the Rails
team, doesn't support sprockets integration and doesn't allow glob
imports (using `@import something/**/*` or similar). In particular,
dartsass-rails needs to start a separate browser that makes it less
straightforward to change a file and reload the browser.

So we're using sassc-embedded, which provides Dart Sass integration with
sprockets. While there's no guarantee this gem will be maintained a few
years from now, we know for sure that SassC/Libsass won't be maintained
at all, so using sassc-embedded is an improvement over our current
situation.

On my machine, this change reduces compilation times by about 35%.

Note we still depend on the `sassc-rails` gem, for two reasons.

First, we're still importing CSS/Sass content from a couple of gems
(mainly, social-share-button and font-awesome) and we don't know how to
import this content without the `sassc-rails` gem.

And, second, it provides support for glob imports. Without it, we'd have
to manually add every single (S)CSS file we import to the
`application.scss` file instead of being able to write things like
`@import admin/**/*";`.

Note we're removing the `sass` gem from `Gemfile.lock`. We should have
done it as part of e210682ac, but when we developed that branch, it
didn't contain the changes where we removed another gem depending on the
`sass` gem (which we removed in commit 2fa713c64), so Bundler didn't
delete it. However, now that we're changing the Gemfile, Bundler is
finally removing the no-longer-needed `sass` gem and its dependencies.
2024-04-04 15:15:28 +02:00
Javi Martín
21b7f4c96e Merge pull request #5462 from consuldemocracy/bump_sprocket_rails_to_3.4.2
Bump sprockets-rails from 3.2.2 to 3.4.2
2024-04-03 16:41:09 +02:00
Javi Martín
9bfce93188 Merge pull request #5464 from consuldemocracy/stop_pinging_google
Don't ping search engines after sitemap generation
2024-04-03 16:05:32 +02:00
Javi Martín
89c0ab2635 Bump sprockets-rails from 3.2.2 to 3.4.2
Note that, since version 3.3.0, sprockets-rails uses a processor to get
digested paths for asset files [1]. This breaks the images used in
CKEditor buttons [2], so we're using the new configuration option [3] to
keep the old behavior.

[1] Pull request 476 in https://github.com/rails/sprockets-rails
[2] Issue 919 in https://github.com/galetahub/ckeditor
[3] Pull request 489 in https://github.com/rails/sprockets-rails
2024-04-03 15:46:02 +02:00
Javi Martín
d464be1d7a Don't ping search engines after sitemap generation
The Bing sitemap submission was removed in sitemap_generator 6.3.0 [1],
and Google has also deprecated the ping and we're getting an error when
deploying:

```
Ping failed for Google: #<OpenURI::HTTPError: 404 Sitemaps ping is
deprecated.
```

Since those were the only two search engines we were pinging in the
past, we're removing the code that did so.

[1] Pull request 408 in https://github.com/kjvarga/sitemap_generator
2024-04-01 05:19:48 +02:00
Javi Martín
b5b03e4496 Base staging configuration on the production one
There was only one different line between these two lines, and we really
want these two files to be as similar as possible, so testing on a
staging server we get the same results we'll get on production.

This duplication made it easy to forget to update the staging.rb file
when updating the production.rb, particularly when upgrading to a new
version of Rails, which automatically changes the production.rb file but
not the staging.rb one.

So, now that we're getting ready to upgrade to Rails 7.0, we're basing
the staging configuration on the production one, just like we based the
preproduction configuration on the staging one in commit 7b91adb16.
2024-04-01 04:59:10 +02:00
CoslaJohn
237bfb4fad Change the english translation of check ballot to avoid confusion 2024-03-29 23:41:05 +01:00
Javi Martín
ec686a8d1a Ignore touch audited callbacks globally
This is possible since audited 5.4.3, and IMHO it's useful because
audited has added a callback on touch, which could result in strange
behavior since we might use the `touch` method to expire the cache
without doing any changes.

While this doesn't affect our application because we're using the `on:`
option of the `audited` method in the budget investment model, it'll
make it easier to enable audited for other classes in custom
installations without having to worry about the (usually undesired)
touch callbacks.
2024-03-27 16:51:29 +01:00
Javi Martín
d0f6e4396f Add missing options to invisible captcha initializer
These options had been added in the gem's initializer by version 2.0,
but we forgot to add them to our initializer file. So we're doing it
now.
2024-03-27 16:12:11 +01:00
dependabot[bot]
20bc2cef53 Bump capistrano from 3.17.3 to 3.18.1
Bumps [capistrano](https://github.com/capistrano/capistrano) from 3.17.3 to 3.18.1.
- [Release notes](https://github.com/capistrano/capistrano/releases)
- [Commits](https://github.com/capistrano/capistrano/compare/v3.17.3...v3.18.1)

---
updated-dependencies:
- dependency-name: capistrano
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-03-27 15:48:29 +01:00
Javi Martín
c585eb0e26 Merge pull request #5418 from consuldemocracy/dependabot/bundler/wicked_pdf-2.8.0
Bump wicked_pdf from 2.7.0 to 2.8.0
2024-03-27 15:39:43 +01:00
Javi Martín
65e14fd23f Add initializer included in acts-as-taggable-on 10.0.0
Similar to what we do with other gems, we add the commented code.
2024-03-23 03:38:13 +01:00
Javi Martín
8d2c2c473e Base Devise initializer on the latest version
We haven't updated this initializer for years, so here's the updated
version. The `expire_auth_token_on_timeout` doesn't seem to exist
anymore, and a few more options have been added.

Note that the default Devise initializer configures
`config.responder.error_status` and `config.responder.redirect_status`
so they follow Hotwire/Turbo conventions. For now, I'm commenting these
lines because we currently don't use Hotwire/Turbo.
2024-03-23 01:12:35 +01:00
Javi Martín
45c1f93562 Add a link to skip to the main content
While people using screen readers already have keyboard shortcuts to
jump to the <main> tag, there are people who navigate the page with the
keyboard using just the tab key, and for them, this link provides a way
to save time and start reading the main content instead of having to
manually go through all the navigation links every time a new page is
loaded.

Note that we had to add an additional `width: 0` rule because
Foundation's `element-invisible` would apply `1px` and the test checking
for `visible: :hidden` would faile.
2024-03-23 00:35:47 +01:00
Sebastia
9e5344b5d7 Merge pull request #5276 from consuldemocracy/order-cards
Allow sorting homepage cards
2024-03-22 10:56:33 +01:00
coslajohn
529357c980 Merge pull request #5390 Geozone Admin maps
This makes it easier to see if Geojson has been imported correctly.
2024-03-21 18:47:37 +01:00
taitus
6059aab674 Allow saving a position when create a widget card
We are ensuring that only position field is rendered only on
non-header cards.

Note that we have 3 sections that use widget cards:
- Homepage (cards and header cards)
- Custompages (only have cards)
- Sdg Homepage (cards and header cards)
2024-03-21 18:15:50 +01:00
Javi Martín
f8e7bf042d Update wicked_pdf initializer to the latest version
We haven't been updating this file for a long time so, and this version
uses the `configure` method instead of the `config` hash.

We're also adding a few comments already included in previous versions
of wicked pdf that we hadn't copied to our initializer.
2024-03-19 21:26:05 +01:00
Javi Martín
3d63238ef6 Add missing Spanish translations
These texts were added in English in commit 7070b0915, but we forgot to
add the texts in Spanish as well.
2024-03-08 15:15:34 +01:00
Senén Rodero
15518a6316 Merge pull request #5372 from consuldemocracy/puma_socket_activation
Puma socket activation
2024-02-13 17:01:56 +01:00
Senén Rodero Rodríguez
4c997ec0ca Enable Scottish Gaelic by default 2024-02-12 22:01:04 +01:00
Consul Bot
7490c24a10 Update translation from Crowdin 2024-02-12 22:01:04 +01:00
Senén Rodero Rodríguez
1d9d467c86 Enable puma socket activation
This gives us graceful restarts
2024-02-01 20:52:05 +01:00
Senén Rodero Rodríguez
bb20e8e2bd Disable ExecJS when running Puma and Delayed Job
By default, when starting a Rails application, ExecJS checks whether there's
a runtime available in the system. Since on production we now use FNM to
manage node versions, this meant that we had to run Puma using the
`fnm exec bundle exec puma` command.

However, this causes issues when integrating Puma with Systemd. For instance,
when using `fnm exec`, the PID for the main process is no longer the Puma
process but the FNM process, meaning that stopping and restarting Puma will
no longer behave as expected and might last 90 seconds (Systemd's timeout to
stop a service). Furthermore, using a Puma Systemd socket in order to
implement hot or phased restarts won't work either, and so we'll get 502
errors while restarting the service.

So we're using the `EXECJS_RUNTIME=Disabled` environment variable in the
Systemd service, which means we can remove the `fnm exec` prefix in the
ExecStart command (which starts Puma) and now the PID for the main process
is the Puma process, stopping/restarting the service no longer times out,
and we'll be able to implement Puma socket activation and hot restarts.

However, removing `bundle` from the list of commands which use `fnm exec`
(the `fnm_map_bins`) meant that we got a `RuntimeUnavailable` exception when
 running `bundle exec bin/delayed_job`. We tried to add `delayed_job` to the
`fnm_map_bins` variable but couldn't make it work.

Since we only need the ExecJs runtime when precompiling the assets but we
don't need it in order to start Puma or Delayed Job, we're adding
`{ EXECJS_RUNTIME: "Disabled" }` to Capistrano's default environment and
we're only using the default Runtime when `fnm exec` is used, which we've
done by setting the environment variable in the prefix of the fnm command.

This way, when running `EXECJS_RUNTIME='' fnm exec bundle exec rake assets:precompile`,
the right ExecJS Runtime will be loaded, but it won't be loaded (since it
isn't needed) when starting Puma or Delayed Job.
2024-02-01 20:46:19 +01:00
Senén Rodero Rodríguez
0643606dcd Add new setting to enable/disable map marker clustering 2024-01-29 17:56:54 +01:00
Javi Martín
bfd7fd9735 Update content block field info in heading form
We moved the "Custom content blocks" menu entry from "Settings" to "Site
content" in commit a902f9e11, but we forgot to update a description
referencing the old location..
2024-01-25 14:00:07 +01:00
Senén Rodero
d7a48280a9 Merge pull request #5318 from consuldemocracy/application_timezone
Allow to set the application timezone via secrets
2024-01-19 16:16:47 +01:00
Senén Rodero Rodríguez
9646991846 Allow to set the application timezone via secrets
This will allow us to keep using the timezone used when running
the installer.

We keep using Madrid as default timezone in the installer and in
the application.
2023-11-27 16:31:32 +01:00
Senén Rodero
b8156040a5 Merge pull request #5320 from consuldemocracy/aibrake_filter
Filter sensitive information from airbrake parameters
2023-11-24 12:23:54 +01:00
Senén Rodero Rodríguez
1e46746d6a Filter airbrake parameters
As Rails does with the application log and other tools. We
are going to use the same filtering rules we use in Consul Democracy.

We are renaming the initializer file name `filter_parameter_logging.rb` so
it's loaded before the errbit initializer.
2023-11-23 18:21:29 +01:00
taitus
76128494aa Move authentication_logs secret out of security section
As this secret is currently not programmed to be customisable for each Tenant,
we take it out of the security section. The reason is that so far everything inside this security section can be overwritten per tenant. With this change we are trying
to prevent anyone from trying to overwrite it on a per Tenant basis, as it would have
no effect.
2023-11-22 16:36:27 +01:00
Javi Martín
96580afe16 Merge pull request #5178 from consuldemocracy/dependabot/bundler/puma-5.6.7
Bump puma from 4.3.12 to 5.6.7
2023-11-20 13:20:56 +01:00
Senén Rodero Rodríguez
2856a0f396 Use the absolute path to fnm binary
Otherwise the Capistrano task `puma:systemd:config` generates a
wrong ExecStart command for puma service that fails on launching.
2023-11-16 17:08:28 +01:00
Senén Rodero Rodríguez
b7073691f1 Log successful and failed login attempts in a separate log file
We log the login parameter and the request IP address.

Quoting the ENS:

> [op.acc.5.r5.1] Se registrarán los accesos con éxito y los fallidos.
2023-10-25 10:13:03 +02:00
Javi Martín
d8d4c1e9a4 Use systemd to start and monitor puma
Puma 4 is no longer maintained, and Puma 5 removed the option to run
Puma as as daemon. That means that, in order to upgrade, we need to rely
in a process monitoring tool. We're using systemd because it's installed
by default in most (all?) operating systems running Consul Democracy on
production and it's supported by both Puma and the capistrano3-puma gem.

Using systemd means Puma will be automatically started whenever it
crashes, so we no longer need the changes done in commit 40b3c9f2c and
we can now use the default tasks configuration in capistrano3-puma and
capistrano3-delayed-job.

Since Puma is also started automatically when booting the system, we
don't need a cron job to do so anymore and can remove it from the
`schedule.rb` file.
2023-10-24 23:00:12 +02:00
taitus
d54a5c2ae0 Allow define maximum_attemps and unlock_in 2023-10-24 20:21:03 +02:00
taitus
873ec84b52 Allow disable devise lockable through secrets 2023-10-24 20:20:29 +02:00
taitus
a1955531e1 Enable devise lockable module with default values
In order to the display a warn text on the last attempt
before the account is locked, we need update
config.paranoid to false as the devise documentation
explains.

Adding "config.paranoid: false" implies further changes
to the code, so for now we unncomment the default value
"config.last_attempt_warning = true" and update it to false.
2023-10-24 20:20:27 +02:00
taitus
7c771b28b5 Add password complexity 2023-10-24 19:00:43 +02:00
taitus
fe9da7988f Enable password_complexity
As it seems that adding complexity to the password is something that
might be wanted from the Consul applications, we added the necessary
changes to allow it.

In this version we simply:
- Uncomment the configuration variable "password_complexity"
- Set this variable without any restrictions
- Adapt the application so that everything still works normally.

One of the things that had to be done to adapt the application
was to remove the overwriting of the "self.included" method.

The original idea of overwriting the "self.included" method seems
to be the possibility of being able to overwrite the
:current_equal_password_validation validation.
The problem comes from the fact that by only calling that validation,
the rest of the validations that are defined (in this case
"password_complexity") are no longer applied.

It seems like a good idea to remove the overwrite of the "self.included"
method to allow all the defined validations to be applied and simply
overwrite the :current_equal_password_validation method so that
everything behaves the same.

:allow_passwords_equal_to_email configuration has been enabled too,
in order to allow existing records with this configuration.

Another change made was to uncomment the line:
and to keep everything working the same set the value to false:
config.email_validation = false.

This change has had to be made because in the documentation of
devise-security it says the following:
In other words, if we want to use the :secure_validatable module
we have to enable this configuration even if its value is "false".

If we kept the configuration variable commented out:
The following error appears:
"uninitialized constant Devise::Models::SecureValidatable::EmailValidator".

So it has been verified that if before making any change we
decommented the line and added the value of "false", the application
worked as normal.
2023-10-24 18:59:03 +02:00
taitus
56aadedc8c Update devise-security.rb
In these commits ffe9ac7 0d8def3 we updated the devise-security version.
In these versions the 'password_regex'  configuration key and some comments
were changed.

We update this file in order to use the new configuration key 'password_complexity' and keep comments updated.
2023-10-24 18:59:03 +02:00
Sebastia
c1e0d58291 Merge pull request #5274 from consuldemocracy/last-sign-in
ENS: Add security secret "last_sign_in"
2023-10-24 18:57:18 +02:00
Javi Martín
ce4939703e Merge pull request #5278 from consuldemocracy/vote_contrast
Make like/unlike buttons more accessible
2023-10-24 17:24:22 +02:00
Javi Martín
56d834783c Open links to social networks in the same window
As mentioned in earlier commits, opening external links in a new
tab/window results in usability and accessibility issues.

Since these links are usually at the top or bottom of the page and
contain icons of well-known sites, IMHO there's no need to even notify
people that these are external links.

Since we're no longer using the `shared.target_blank` translation inside
a sentence, we can remove the space and parenthesis in the translations.
2023-10-24 16:41:03 +02:00
Javi Martín
2e217a647a Merge pull request #5283 from consuldemocracy/label_links
Allow links in forms to open in new tabs
2023-10-24 16:30:59 +02:00
Javi Martín
bc1f303551 Merge pull request #5281 from consuldemocracy/pdf_links
Open PDF files in the same tab/window
2023-10-24 16:28:31 +02:00
Senén Rodero
f36248fad6 Merge pull request #5303 from consuldemocracy/fix_fnm_setup
Map node binaries whenever `rvm1:hook` is called and evaluate the `fnm_setup_command` dynamically
2023-10-24 15:24:33 +02:00
Javi Martín
834da50901 Merge pull request #5279 from jensconsul/admin_panel_branch
Add information about the project to admin index
2023-10-24 15:23:33 +02:00
Senén Rodero Rodríguez
ddc8cfdfb0 Map node binaries whenever rvm1:hook is called and evaluate the fnm_setup_command dynamically
The previous version worked fine when using Capistrano to deploy a new
release, but it did not work for other commands, like `cap npm install`
or `cap puma:start`, as they do not create a release. Therefore, the
`git:create_release` was never called, and the `map_node_bins` was not
invoked.

Since we need node binaries available to the deploy user when executing
any process that runs the application, like puma, delayed_job, and rake
tasks, among others, it makes sense to load FNM to use the correct Node
version in the same places where Capistrano loads RVM to load the correct
Ruby version.

With dynamic loading of the `fnm_setup_command`, we get the correct path
when deploying a new release and also when running any other capistrano
command that does not deploy a new release.
2023-10-24 12:59:53 +02:00
Javi Martín
95958b2080 Remove title attribute in fields to accept terms
Not sure why we introduced these titles in commit 9dce52a69. The title
attributes contained the same text as the label, which IMHO made them
useless.
2023-10-23 18:19:48 +02:00