Commit Graph

138 Commits

Author SHA1 Message Date
Javi Martín
2b962f2789 Use a <main> tag on every page
Many pages had this tag, but many other didn't, which made navigation
inconsistent for people using screen readers.

Note that there are slight changes in two pages:

* The homepage now includes the banner and the content of the
  `shared/header` element inside the <main> tag
* The budgets index now includes the banner inside the <main> tag

I see both potential advantages and disadvantages of this approach,
since banners aren't necessarily related to the main content of a page
but on the other hand they aren't the same across pages and people using
screen readers might accidentally skip them if they jump to the <main>
tag.

So I'm choosing the option that is easier to implement.

Note we're adding a `public-content` class to the <main> element in the
application layout. This might be redundat because the element could
already be accessed through the `.public main` selector, but this is
consistent with the `admin-content` class used in the admin section, and
without it the <main> element would sometimes have an empty class
attribute and we'd have to use `if content_for?(:main_class)` or
`tag.main` which IMHO makes the code less consistent.

The Capybara::DSL monkey-patch is only done on the `visit` method
because it's the only reliable one. Other methods like `click_link`
generate AJAX requests, so `expect(page).to have_css "main", count: 1`
might be executed before the AJAX request is finished, meaning it
wouldn't properly test anything.
2024-03-23 00:35:43 +01:00
Javi Martín
629e208e9d Add and apply ArgumentAlignment rubocop rule
We're choosing the default `with_first_argument` style because it's the
one we use the most.
2023-08-18 14:56:16 +02:00
Javi Martín
4b42a68b6a Use the vote action to vote featured proposals
The action and the views were almost identical, with the supports
progress and the HTML classes of the success message element being the
only exceptions; we can use CSS for the styles instead.
2022-02-21 18:47:13 +01:00
Javi Martín
c45a0bd8ac Remove unused welcome#verification action
The route was deleted in commit 1cd47da9d and this feature was probably
only used in Madrid.
2021-12-20 14:42:53 +01:00
taitus
e639cab994 Move specific partial for the homepage to shared
This partial to render the header of the hompage will be used in
the sdg index.
2021-02-26 16:16:51 +01:00
Javi Martín
a7bbdb1bd0 Simplify rendering a banner
Now the banner component accepts either a banner or a section and loads
the banner if it's a section, so we don't have to add the `@banners`
variable in several controllers.
2021-01-20 17:22:05 +01:00
Javi Martín
5907ddf884 Use local variable in cards partial
This way it's going to be easier to reuse.
2021-01-14 17:45:14 +01:00
Javi Martín
e8e920ee50 Rename Widgets components to Widget
So naming is consistent with the way Admin::Widget controllers are
named.
2021-01-12 14:50:37 +01:00
Javi Martín
13fbf4e4b3 Use h2 tags in feed headers
We were jumping from h1 to h3 and some of these sections (cards and
processes) had h3 tags inside them.

My best guess is we were using h3 so the titles were smaller. So I'm
adding a CSS mixin to easily use a font size of a different heading tag.
2020-12-27 21:42:42 +01:00
Javi Martín
fae52274a4 Reuse code between feed components
They were all following the same format.

Note we need to group the `see_all` translation keys together (the same
way it's done with the `most_active` keys) so we don't have an unused
translation warning.

We're also moving the "see all" link in processes outside the feed
content; the same way it's done in debates and proposals and removing
unnecessary classes in the processes feed: the column class is causing
the processes not to be aligned with the debates above them, and the
margin bottom is not needed because the margin of the footer is already
enough.
2020-12-27 21:42:40 +01:00
Javi Martín
330efe5a41 Extract components for feeds 2020-12-27 16:44:51 +01:00
decabeza
8e01b11569 Move conditional into shared banner partial
To avoid always writing if has_banners? every time the partial is used it has been moved within this partial.
2020-05-08 12:00:03 +02:00
decabeza
caedd21da8 Move cards to shared partials 2020-04-21 12:54:16 +02:00
decabeza
a8537f7e19 Replace equalizer to display flex on cards 2020-04-14 17:14:52 +02:00
Javi Martín
7bf4e4d611 Sanitize descriptions in the views
Sanitizing descriptions before saving a record has a few drawbacks:

1. It makes the application rely on data being safe in the database. If
somehow dangerous data enters the database, the application will be
vulnerable to XSS attacks
2. It makes the code complicated
3. It isn't backwards compatible; if we decide to disallow a certain
HTML tag in the future, we'd need to sanitize existing data.

On the other hand, sanitizing the data in the view means we don't need
to triple-check dangerous HTML has already been stripped when we see the
method `auto_link_already_sanitized_html`, since now every time we use
it we sanitize the text in the same line we call this method.

We could also sanitize the data twice, both when saving to the database
and when displaying values in the view. However, doing so wouldn't make
the application safer, since we sanitize text introduced through
textarea fields but we don't sanitize text introduced through input
fields.

Finally, we could also overwrite the `description` method so it
sanitizes the text. But we're already introducing Globalize which
overwrites that method, and overwriting it again is a bit too confusing
in my humble opinion. It can also lead to hard-to-debug behaviour.
2019-10-21 21:32:02 +02:00
Javi Martín
c62da726b8 Apply SpaceAroundErbTag ERB Lint rule 2019-09-10 20:02:15 +02:00
Javi Martín
24359f8152 Remove extra space in HTML tags 2019-09-10 20:02:15 +02:00
Javi Martín
488461b8ac Remove consecutive blank lines 2019-09-10 20:02:15 +02:00
Angel Perez
cb1ed017f9 Use separator key when parameterizing arguments 2019-04-17 17:40:55 +02:00
Javi Martín
3e4e65ead7 Use double quotes inside ERB
We were using single quotes inside ERB code when that code was inside
HTML double quotes.
2019-03-25 14:58:54 +01:00
Julian Herrero
f6489bc604 Use double quotes in app/views 2019-03-19 12:33:07 +01:00
Julian Herrero
87be6f302c Add default site customization pages
From now on these static pages:

`/privacy'
`/conditions'
`/accesibility'
`/help/faq'
`/welcome'

have been moved to the DB and can be modified easily by any
administrator in `/admin/site_customization/pages'
2019-03-14 18:35:51 +01:00
decabeza
05e4c344f2 Improve feed image styles and move image to right 2019-03-06 13:08:35 +01:00
decabeza
54f39ab80e Refactor feeds layout to align proposals without image
Also remove redundant feature images condition.
2019-02-20 13:32:38 +01:00
decabeza
a9d96f7e23 Show card label only if it is present on welcome page 2019-02-20 13:30:49 +01:00
decabeza
b6efc2699f Align proposal feed description without image on welcom page 2019-02-20 13:30:45 +01:00
Alberto
14e73e9086 Merge pull request #3269 from consul/homepage-feeds
[Backport] Change layout on homepage if feed debates and proposals are enabled
2019-02-06 14:32:46 +01:00
decabeza
218c8e1ae7 Change layout on homepage if feed debates and proposals are enabled 2019-02-05 17:28:57 +01:00
decabeza
6bb3c0a3da Add columns on welcome card view 2019-01-31 17:20:04 +01:00
Javi Martín
aa45c39d3e Remove trailing whitespace 2018-12-10 12:59:03 +01:00
Javier Martín
ef16efe5e4 Merge pull request #2899 from papayalabs/2980-hide-featured-section-with-no-cards
Hide Featured section on Home Page if there are no cards
2018-12-10 12:55:32 +01:00
Javi Martín
56df8050df Use @cards.each instead of @cards.find_each
Using `find_each` ignores the scope order we set in `Widget::Card.body`,
and since we don't expect to have thousands of cards, using batches
isn't necessary.

This way we remove the "WARN Scoped order and limit are ignored, it's
forced to be batch order and batch size" message we were getting in the
specs.
2018-11-29 20:10:23 +01:00
decabeza
3a718d88c0 Shows help link only if feature is enabled 2018-11-14 12:45:52 +01:00
Papaya Labs
f7c10de627 Fix indentation and include specs 2018-09-18 15:16:31 -05:00
Papaya Labs
357b3406ed Hide Featured section on Home Page if there are no cards 2018-09-13 15:33:24 -05:00
Angel Perez
303b96553a Replace .all.each with .find_each when rendering cards 2018-09-10 11:38:32 -04:00
Angel Perez
26965b43ee Clean I18n codebase 2018-07-26 19:06:29 -04:00
Raúl Fuentes
6d6dc32c38 Complete basic I18n backend and frontend 2018-07-26 19:06:19 -04:00
iagirre
0d9da5398b Fix banners in user pages
Banners were not been shown in certain pages; now
they are.

Spec to check if the banner is been shown correctly
added. Before it was in admins specs, now it has it's
own spec out of admins folder.
2018-07-12 10:17:25 -04:00
decabeza
79eea245a4 Adds gradient overlapping card image 2018-06-22 18:01:12 +02:00
decabeza
5afe255c1b Adds data-equalizer to fix height on homepage cards 2018-06-22 14:02:51 +02:00
Alberto
d8d97b30db Merge pull request #2663 from consul/homepage-custom
Homepage layout
2018-06-06 19:31:51 +02:00
decabeza
ee0bbe42fd Improves homepage layout 2018-06-06 17:42:54 +02:00
decabeza
be8bcf9269 Adds missing i18n on welcome recommendations 2018-06-06 17:33:15 +02:00
decabeza
0bf31bde6c Updates all active to is-active classes 2018-06-06 12:02:13 +02:00
decabeza
8664ac887a Expands proposals content if there no have image 2018-06-01 18:01:01 +02:00
decabeza
a9eca180a4 Adds missing label for header card 2018-06-01 17:01:10 +02:00
decabeza
304143d051 Updates localization and home specs 2018-05-29 13:22:23 +02:00
decabeza
316c816836 Expands cards if feed processes is not enabled 2018-05-28 18:52:59 +02:00
decabeza
7732a6704c Adds styles and i18n for homepage 2018-05-28 18:17:26 +02:00