Skip to content

Commit

Permalink
fix: additives table + clean HTML to remove some validation errors (#…
Browse files Browse the repository at this point in the history
…11093)

- fixes  #11060 (missing declaration of extra column for additives)
- removes an extra </ul> in pagination
- removes some HTML errors
- moves Matomo script in the body instead of the head as it contains a
noscript tag with an image for users that don't have JS
  • Loading branch information
stephanegigandet authored Dec 9, 2024
1 parent 82726d5 commit 474f68d
Show file tree
Hide file tree
Showing 58 changed files with 519 additions and 447 deletions.
30 changes: 6 additions & 24 deletions lib/ProductOpener/Display.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2596,6 +2596,11 @@ HTML
$extra_column_searchable .= ', {"searchable": false}';
}

# additive table has an extra column for risks
if ($tagtype eq 'additives') {
$extra_column_searchable .= ', {"searchable": false}';
}

$request_ref->{initjs} .= <<JS
let oTable = \$('#tagstable').DataTable({
language: {
Expand Down Expand Up @@ -5875,7 +5880,6 @@ facets.

sub display_pagination ($request_ref, $count, $limit, $page) {

my $html = '';
my $html_pages = '';

$log->debug("PAGINATION: START\n", {count => $count, limit => $limit, page => $page}) if $log->is_debug();
Expand Down Expand Up @@ -5982,29 +5986,7 @@ sub display_pagination ($request_ref, $count, $limit, $page) {
. "</ul>\n";
}

# Close the list

if (defined single_param("jqm")) {
if (defined $next_page_url) {
my $loadmore = lang("loadmore");
$html .= <<HTML
<li id="loadmore" style="text-align:center"><a href="${formatted_subdomain}/${next_page_url}&jqm_loadmore=1" id="loadmorelink">$loadmore</a></li>
HTML
;
}
else {
$html .= '<br><br>';
}
}

if (not defined $request_ref->{jqm_loadmore}) {
$html .= "</ul>\n";
}

if (not defined single_param("jqm")) {
$html .= $html_pages;
}
return $html;
return $html_pages;
}

sub search_and_export_products ($request_ref, $query_ref, $sort_by) {
Expand Down
8 changes: 4 additions & 4 deletions templates/web/common/includes/donate_banner.tt.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
<div class="donation-banner__aside">
<div class="donation-banner__main-section">
<img
width="50px"
height="50px"
width="50"
height="50"
src="https://world.openfoodfacts.org/images/logos/logo-variants/CMJN-ICON_WHITE_BG_OFF.svg"
alt="open food facts logo"
/>
Expand Down Expand Up @@ -117,8 +117,8 @@ <h3 class="donation-banner__main-title">[% lang("donation_title_2024") %]</h3>
<div>
<div class="donation-banner-footer__main-section">
<img
width="50px"
height="50px"
width="50"
height="50"
src="https://world.openfoodfacts.org/images/logos/logo-variants/CMJN-ICON_WHITE_BG_OFF.svg"
alt="open food facts logo"
/>
Expand Down
4 changes: 3 additions & 1 deletion templates/web/common/site_layout.tt.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@
[% lang("css") %]
[% styles %]
</style>
[% analytics %]
</head>
<body[% bodyabout %] class="[% page_type %]_page">

[% analytics %]

<div class="skip"><a href="#content" tabindex="0">[% lang('skip_to_content') %]</a></div>

<div id="page">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@


</style>
<!-- Matomo -->
</head>
<body class="error_page">

<!-- Matomo -->
<script>
var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
Expand All @@ -58,8 +61,7 @@
<!-- End Matomo Code -->


</head>
<body class="error_page">

<div class="skip"><a href="#content" tabindex="0">Skip to Content</a></div>

<div id="page">
Expand Down Expand Up @@ -252,8 +254,8 @@
<div class="donation-banner__aside">
<div class="donation-banner__main-section">
<img
width="50px"
height="50px"
width="50"
height="50"
src="//world.openfoodfacts.org/images/logos/logo-variants/CMJN-ICON_WHITE_BG_OFF.svg"
alt="open food facts logo"
/>
Expand Down Expand Up @@ -404,8 +406,8 @@ <h1 class="if-empty-dnone">Error</h1>
<div>
<div class="donation-banner-footer__main-section">
<img
width="50px"
height="50px"
width="50"
height="50"
src="//world.openfoodfacts.org/images/logos/logo-variants/CMJN-ICON_WHITE_BG_OFF.svg"
alt="open food facts logo"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@


</style>
<!-- Matomo -->
</head>
<body class="error_page">

<!-- Matomo -->
<script>
var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
Expand All @@ -58,8 +61,7 @@
<!-- End Matomo Code -->


</head>
<body class="error_page">

<div class="skip"><a href="#content" tabindex="0">Aller au contenu</a></div>

<div id="page">
Expand Down Expand Up @@ -252,8 +254,8 @@
<div class="donation-banner__aside">
<div class="donation-banner__main-section">
<img
width="50px"
height="50px"
width="50"
height="50"
src="//world.openfoodfacts.org/images/logos/logo-variants/CMJN-ICON_WHITE_BG_OFF.svg"
alt="open food facts logo"
/>
Expand Down Expand Up @@ -404,8 +406,8 @@ <h1 class="if-empty-dnone">Erreur</h1>
<div>
<div class="donation-banner-footer__main-section">
<img
width="50px"
height="50px"
width="50"
height="50"
src="//world.openfoodfacts.org/images/logos/logo-variants/CMJN-ICON_WHITE_BG_OFF.svg"
alt="open food facts logo"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@
.show-when-logged-in {display:none}

</style>
<!-- Matomo -->
</head>
<body class="products_page">

<!-- Matomo -->
<script>
var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
Expand All @@ -60,8 +63,7 @@
<!-- End Matomo Code -->


</head>
<body class="products_page">

<div class="skip"><a href="#content" tabindex="0">Skip to Content</a></div>

<div id="page">
Expand Down Expand Up @@ -254,8 +256,8 @@
<div class="donation-banner__aside">
<div class="donation-banner__main-section">
<img
width="50px"
height="50px"
width="50"
height="50"
src="//world.openfoodfacts.org/images/logos/logo-variants/CMJN-ICON_WHITE_BG_OFF.svg"
alt="open food facts logo"
/>
Expand Down Expand Up @@ -492,8 +494,7 @@ <h1 itemprop="name">Hazelnut spreads</h1>
</div>


</ul>


</div>
</div>

Expand Down Expand Up @@ -557,8 +558,8 @@ <h1 itemprop="name">Hazelnut spreads</h1>
<div>
<div class="donation-banner-footer__main-section">
<img
width="50px"
height="50px"
width="50"
height="50"
src="//world.openfoodfacts.org/images/logos/logo-variants/CMJN-ICON_WHITE_BG_OFF.svg"
alt="open food facts logo"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@
.show-when-logged-in {display:none}

</style>
<!-- Matomo -->
</head>
<body about="/product/0200000000235/only-product-nutella" typeof="food:foodProduct" class="product_page">

<!-- Matomo -->
<script>
var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
Expand All @@ -71,8 +74,7 @@
<!-- End Matomo Code -->


</head>
<body about="/product/0200000000235/only-product-nutella" typeof="food:foodProduct" class="product_page">

<div class="skip"><a href="#content" tabindex="0">Skip to Content</a></div>

<div id="page">
Expand Down Expand Up @@ -265,8 +267,8 @@
<div class="donation-banner__aside">
<div class="donation-banner__main-section">
<img
width="50px"
height="50px"
width="50"
height="50"
src="//world.openfoodfacts.org/images/logos/logo-variants/CMJN-ICON_WHITE_BG_OFF.svg"
alt="open food facts logo"
/>
Expand Down Expand Up @@ -3665,8 +3667,8 @@ <h2 id="data_sources" class="text-medium">Data sources</h2>
<div>
<div class="donation-banner-footer__main-section">
<img
width="50px"
height="50px"
width="50"
height="50"
src="//world.openfoodfacts.org/images/logos/logo-variants/CMJN-ICON_WHITE_BG_OFF.svg"
alt="open food facts logo"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@
.show-when-logged-in {display:none}

</style>
<!-- Matomo -->
</head>
<body class="products_page">

<!-- Matomo -->
<script>
var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
Expand All @@ -60,8 +63,7 @@
<!-- End Matomo Code -->


</head>
<body class="products_page">

<div class="skip"><a href="#content" tabindex="0">Skip to Content</a></div>

<div id="page">
Expand Down Expand Up @@ -254,8 +256,8 @@
<div class="donation-banner__aside">
<div class="donation-banner__main-section">
<img
width="50px"
height="50px"
width="50"
height="50"
src="//world.openfoodfacts.org/images/logos/logo-variants/CMJN-ICON_WHITE_BG_OFF.svg"
alt="open food facts logo"
/>
Expand Down Expand Up @@ -556,8 +558,7 @@ <h1 itemprop="name">Cakes</h1>
</div>


</ul>


</div>
</div>

Expand Down Expand Up @@ -621,8 +622,8 @@ <h1 itemprop="name">Cakes</h1>
<div>
<div class="donation-banner-footer__main-section">
<img
width="50px"
height="50px"
width="50"
height="50"
src="//world.openfoodfacts.org/images/logos/logo-variants/CMJN-ICON_WHITE_BG_OFF.svg"
alt="open food facts logo"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@
.show-when-logged-in {display:none}

</style>
<!-- Matomo -->
</head>
<body class="products_page">

<!-- Matomo -->
<script>
var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
Expand All @@ -60,8 +63,7 @@
<!-- End Matomo Code -->


</head>
<body class="products_page">

<div class="skip"><a href="#content" tabindex="0">Skip to Content</a></div>

<div id="page">
Expand Down Expand Up @@ -254,8 +256,8 @@
<div class="donation-banner__aside">
<div class="donation-banner__main-section">
<img
width="50px"
height="50px"
width="50"
height="50"
src="//world.openfoodfacts.org/images/logos/logo-variants/CMJN-ICON_WHITE_BG_OFF.svg"
alt="open food facts logo"
/>
Expand Down Expand Up @@ -533,8 +535,7 @@ <h2 id="facet_panels_title"></h2>
</div>


</ul>


</div>
</div>

Expand Down Expand Up @@ -598,8 +599,8 @@ <h2 id="facet_panels_title"></h2>
<div>
<div class="donation-banner-footer__main-section">
<img
width="50px"
height="50px"
width="50"
height="50"
src="//world.openfoodfacts.org/images/logos/logo-variants/CMJN-ICON_WHITE_BG_OFF.svg"
alt="open food facts logo"
/>
Expand Down
Loading

0 comments on commit 474f68d

Please sign in to comment.