diff --git a/.sonarcloud.properties b/.sonarcloud.properties new file mode 100644 index 0000000000000..81627a3f6f887 --- /dev/null +++ b/.sonarcloud.properties @@ -0,0 +1 @@ +sonar.sources=cgi,docker,lib,scripts,templates,scss,html/css,html/js diff --git a/cgi/search.pl b/cgi/search.pl index 34647b66c7c8f..b6732209686e0 100755 --- a/cgi/search.pl +++ b/cgi/search.pl @@ -43,26 +43,27 @@ use JSON::PP; use Log::Any qw($log); -if (0) { -if (param('jqm')) { - - print "Content-Type: application/json; charset=UTF-8\r\nAccess-Control-Allow-Origin: *\r\n\r\n" . '{"jqm":"

Suite à l\'émission Envoyé Spécial vous êtes extrèmement nombreuses et nombreux à essayer l\'app Open Food Facts et le serveur est surchargé. Nous avons du temporairement désactiver la recherche de produit (mais le scan est toujours possible). La situation devrait revenir à la normale bientôt.

Merci de votre compréhension !

Stéphane et toute l\'équipe bénévole d\'Open Food Facts

"}'; - - -return ""; -} -elsif (param('json')) { +# Passing values to the template +my $template_data_ref = { + lang => \&lang, +}; -print "Content-Type: application/json; charset=UTF-8\r\nAccess-Control-Allow-Origin: *\r\n\r\n" . +my $html; +if (0) { + if (param('jqm')) { + print "Content-Type: application/json; charset=UTF-8\r\nAccess-Control-Allow-Origin: *\r\n\r\n" . '{"jqm":"

Suite à l\'émission Envoyé Spécial vous êtes extrèmement nombreuses et nombreux à essayer l\'app Open Food Facts et le serveur est surchargé. Nous avons du temporairement désactiver la recherche de produit (mais le scan est toujours possible). La situation devrait revenir à la normale bientôt.

Merci de votre compréhension !

Stéphane et toute l\'équipe bénévole d\'Open Food Facts

"}'; + return ""; + } + elsif (param('json')) { + print "Content-Type: application/json; charset=UTF-8\r\nAccess-Control-Allow-Origin: *\r\n\r\n" . <{search_terms} = $search_terms; + my $active_list = 'active'; my $active_map = ''; my $active_graph = ''; @@ -208,127 +210,77 @@ $active_list = ''; $active_graph = 'active'; } - - # Display the search form - - my $html = start_form(-id=>"search_form", -action=>"/cgi/search.pl") ; - - $html .= < -
- - -
- - -

$Lang{search_tags}{$lang}

- -HTML -; + + $template_data_ref->{active_list} = $active_list; + $template_data_ref->{active_graph} = $active_graph; + $template_data_ref->{active_map} = $active_map; my %search_fields_labels = (); + my @tags_fields_options; + my @contains; + + push (@tags_fields_options, { + value => "search", + label => lang("search_tag"), + }); + foreach my $field (@search_fields) { + my $label; + if ((not defined $tags_fields{$field}) and (lang($field) ne '')) { - $search_fields_labels{$field} = lc(lang($field)); + $label = lc(lang($field)); } else { if ($field eq 'creator') { - $search_fields_labels{$field} = lang("users_p"); + $label = lang("users_p"); } else { - $search_fields_labels{$field} = lang($field . "_p"); + $label = lang($field . "_p"); } } + push (@tags_fields_options, { + value => $field, + label => $label, + }); } - $search_fields_labels{search_tag} = lang("search_tag"); - $html .= < -HTML -; + $template_data_ref->{tags_fields_options} = \@tags_fields_options; + + $template_data_ref->{contain_options} = [ + { value => "contains", label => lang("search_contains") }, + { value => "does_not_contain", label => lang("search_does_not_contain") }, + ]; for (my $i = 0; ($i < $tags_n) or defined param("tagtype_$i") ; $i++) { - - $html .= < -
-
-HTML -; - - $html .= popup_menu(-name=>"tagtype_$i", -id=>"tagtype_$i", -value=> $search_tags[$i][0], -values=>['search_tag', @search_fields], -labels=>\%search_fields_labels); - - $html .= < -
-HTML -; - $html .= popup_menu(-name=>"tag_contains_$i", -id=>"tag_contains_$i", -value=> $search_tags[$i][1], -values=>["contains", "does_not_contain"], - -labels=>{"contains" => lang("search_contains"), "does_not_contain" => lang("search_does_not_contain")} ); - - $html .= < -
- -
-
-
-HTML -; + + push @{$template_data_ref->{criteria}}, { + id => $i, + selected_tags_field_value => $search_tags[$i][0], + selected_contain_value => $search_tags[$i][1], + input_value => $search_tags[$i][2], + }; } - $html .= < - -

$Lang{search_ingredients}{$lang}

- -
-HTML -; - foreach my $tagtype (@search_ingredient_classes) { not defined $search_ingredient_classes{$tagtype} and $search_ingredient_classes{$tagtype} = 'indifferent'; - my $label = ucfirst(lang($tagtype . "_p")) ; - - $html .= < - -HTML -; - - - $html .= < - - - - - -
-HTML -; + push @{$template_data_ref->{ingredients}}, { + tagtype => $tagtype, + search_ingredient_classes_checked_without => $search_ingredient_classes_checked{$tagtype}{without}, + search_ingredient_classes_checked_with => $search_ingredient_classes_checked{$tagtype}{with}, + search_ingredient_classes_checked_indifferent => $search_ingredient_classes_checked{$tagtype}{indifferent}, + }; } - - $html .= < - -

$Lang{search_nutriments}{$lang}

-
-HTML -; - - - # Compute possible axis values + # Compute possible fields values my @axis_values = @{$nutriments_lists{$nutriment_table}}; my %axis_labels = (); foreach my $nid (@{$nutriments_lists{$nutriment_table}}, "fruits-vegetables-nuts-estimate-from-ingredients") { $axis_labels{$nid} = ucfirst($Nutriments{$nid}{$lc} || $Nutriments{$nid}{en}); $log->debug("nutriments", { nid => $nid, value => $axis_labels{$nid} }) if $log->is_debug(); - } + } push @axis_values, "additives_n", "ingredients_n", "known_ingredients_n", "unknown_ingredients_n"; push @axis_values, "fruits-vegetables-nuts-estimate-from-ingredients"; $axis_labels{additives_n} = lang("number_of_additives"); @@ -336,121 +288,92 @@ $axis_labels{known_ingredients_n} = lang("known_ingredients_n_s"); $axis_labels{unknown_ingredients_n} = lang("unknown_ingredients_n_s"); $axis_labels{search_nutriment} = lang("search_nutriment"); - $axis_labels{products_n} = lang("number_of_products"); - - my @sorted_axis_values = sort({ lc($axis_labels{$a}) cmp lc($axis_labels{$b}) } @axis_values); + $axis_labels{products_n} = lang("number_of_products"); - for (my $i = 0; $i < $nutriments_n ; $i++) { + my @sorted_axis_values = ("", sort({ lc($axis_labels{$a}) cmp lc($axis_labels{$b}) } @axis_values)); - $html .= < -
-
-HTML -; - - $html .= popup_menu(-class=>"select2_field", -name=>"nutriment_$i", -id=>"nutriment_$i", -value=> $search_nutriments[$i][0], -values=>["", @sorted_axis_values], -labels=>\%axis_labels); + my @fields_options = (); + + foreach my $field (@sorted_axis_values) { + push @fields_options, { + value => $field, + label => $axis_labels{$field}, + }; + } + + $template_data_ref->{fields_options} = \@fields_options; + + $template_data_ref->{compare_options} = [ + { + 'value' => "lt", + 'label' => '<', + }, + { + 'value' => "lte", + 'label' => "\N{U+2264}", + }, + { + 'value' => "gt", + 'label' => '>', + }, + { + 'value' => "gte", + 'label' => "\N{U+2265}", + }, + { + 'value' => "eq", + 'label' => '=', + }, + ]; + + for (my $i = 0; $i < $nutriments_n ; $i++) { - $html .= < -
-HTML -; - $html .= popup_menu(-name=>"nutriment_compare_$i", -id=>"nutriment_compare_$i", -value=> $search_nutriments[$i][1], -values=>['lt','lte','gt','gte','eq'], - -labels => {'lt' => '<', 'lte' => "\N{U+2264}", 'gt' => '>', 'gte' => "\N{U+2265}", 'eq' => '='} ); - - $html .= < -
- -
-
-
-HTML -; + push @{$template_data_ref->{nutriments}}, { + id => $i, + selected_field_value => $search_nutriments[$i][0], + selected_compare_value => $search_nutriments[$i][1], + input_value => $search_nutriments[$i][2], + }; } # Different types to display results - my $popup_sort = popup_menu(-name=>"sort_by", -id=>"sort_by", -value=> $sort_by, - -values=>['unique_scans_n','product_name','created_t','last_modified_t','completeness'], - -labels=>{unique_scans_n=>lang("sort_popularity"), product_name=>lang("sort_product_name"), - created_t=>lang("sort_created_t"), last_modified_t=>lang("sort_modified_t"), - completeness=>lang("sort_completeness")}); - - my $popup_size = popup_menu(-name=>"page_size", -id=>"page_size", -value=> $limit, -values=>[20, 50, 100, 250, 500, 1000]); - - $html .= < - - - -
    -
  • -

    $Lang{search_list_choice}{$lc}

    -
    - -
    -
    - - $popup_sort -
    -
    - - $popup_size -
    -
    - - -
    -
  • -HTML -; - - # Graphs and visualization - - $html .= < -

    $Lang{search_graph_choice}{$lc}

    -
    - -
    $Lang{search_graph_note}{$lang}
    - - - - -

    $Lang{search_graph_instructions}{$lc}

    - -
    -HTML -; - + push @{$template_data_ref->{sort_options}}, [ + { + 'value' => "unique_scans_n", + 'label' => lang("sort_popularity"), + }, + { + 'value' => "product_name", + 'label' => lang("sort_product_name"), + }, + { + 'value' => "created_t", + 'label' => lang("sort_created_t"), + }, + { + 'value' => "last_modified_t", + 'label' => lang("sort_modified_t"), + }, + { + 'value' => "completeness", + 'label' => lang("sort_completeness"), + }, + ]; + push @{$template_data_ref->{selected_sort_by_value}}, $sort_by; + my @size_array =(20, 50, 100, 250, 500, 1000); + push @{$template_data_ref->{size_options}}, @size_array; + + $template_data_ref->{axes} = []; foreach my $axis ('x','y') { - - $html .= < -HTML -; - $html .= "" - . popup_menu(-class=>"select2_field", -name=>"axis_$axis", -id=>"axis_$axis", -value=> $graph_ref->{"axis_" . $axis}, -values=>["", @sorted_axis_values], -labels=>\%axis_labels); - - $html .= < -HTML -; + push @{$template_data_ref->{axes}}, { + id => $axis, + selected_field_value => $graph_ref->{"axis_" . $axis}, + }; } - $html .= < - -
    -
    -

    $Lang{search_series}{$lc}

    -HTML -; - foreach my $series (@search_series, "nutrition_grades") { next if $series eq 'default'; @@ -459,71 +382,13 @@ $checked = 'checked="checked"'; } - if ($series eq 'nutrition_grades') { - $html .= < -
    -

    $Lang{or}{$lc}

    -HTML -; - } - - $html .= < - - -HTML -; + push @{$template_data_ref->{search_series}}, { + series => $series, + checked => $checked, + }; } - $html .= < -
    - - - -
    - - - - -
  • -

    $Lang{search_map_choice}{$lc}

    -
    - -
    $Lang{search_map_note}{$lc}
    - - - - - - -
    -
  • - - - -
  • -

    $Lang{search_download_choice}{$lc}

    -
    - -

    $Lang{search_download_results}{$lc}

    - - -
    - -
    - - - -
    -
  • -
- - -HTML -; $styles .= < .select2-results__options { @@ -554,10 +419,11 @@ ; - ${$request_ref->{content_ref}} .= $html; - - $request_ref->{title} = lang("search_products"); +$tt->process('search_form.tt.html', $template_data_ref, \$html); +$html .= "

" . $tt->error() . "

"; + ${$request_ref->{content_ref}} .= $html; + display_new($request_ref); } diff --git a/cgi/top_translators.pl b/cgi/top_translators.pl index e332c9207d4f5..387a7dd42882b 100644 --- a/cgi/top_translators.pl +++ b/cgi/top_translators.pl @@ -36,6 +36,11 @@ ProductOpener::Display::init(); +# Passing values to the template +my $template_data_ref = { + lang => \&lang, +}; + $scripts .= < @@ -92,41 +97,10 @@ ; $initjs .= $js; -my $html = '

' . lang('translators_lead') . '

'; - -my $translators_column_name = lang('translators_column_name'); -my $translators_column_translated_words = lang('translators_column_translated_words'); -my $translators_column_target_words = lang('translators_column_target_words'); -my $translators_column_approved_words = lang('translators_column_approved_words'); -my $translators_column_votes_made = lang('translators_column_votes_made'); - -$html .= < - - - $translators_column_name - $translators_column_translated_words - $translators_column_target_words - $translators_column_approved_words - $translators_column_votes_made - - - - - $translators_column_name - $translators_column_translated_words - $translators_column_target_words - $translators_column_approved_words - $translators_column_votes_made - - - - - -HTML -; +my $html; -$html .= '

' . lang('translators_renewal_notice') . '

'; +$tt->process('top_translators.tt.html', $template_data_ref, \$html); +$html .= "

" . $tt->error() . "

"; display_new( { title=>lang('translators_title'), diff --git a/cgi/user.pl b/cgi/user.pl index 8c857e878aa70..5a115365f8e5a 100755 --- a/cgi/user.pl +++ b/cgi/user.pl @@ -38,23 +38,9 @@ use Storable qw/dclone/; use Log::Any qw($log); -use Template; -use Data::Dumper; - my $type = param('type') || 'add'; my $action = param('action') || 'display'; - -# Initialize the Template module -my $tt = Template->new({ - INCLUDE_PATH => $data_root . '/templates', - INTERPOLATE => 1, - EVAL_PERL => 1, - STAT_TTL => 60, # cache templates in memory for 1 min before checking if the source changed - COMPILE_EXT => '.ttc', # compile templates to Perl code for much faster reload - COMPILE_DIR => $data_root . '/tmp/templates', -}); - # Passing values to the template my $template_data_ref = { lang => \&lang, diff --git a/html/images/lang/en/labels/health-star-rating-0-5.90x90.png b/html/images/lang/en/labels/health-star-rating-0-5.90x90.png new file mode 100644 index 0000000000000..e4cf812e8e7dd Binary files /dev/null and b/html/images/lang/en/labels/health-star-rating-0-5.90x90.png differ diff --git a/html/images/lang/en/labels/health-star-rating-1-5.90x90.png b/html/images/lang/en/labels/health-star-rating-1-5.90x90.png new file mode 100644 index 0000000000000..e2432d7a292b2 Binary files /dev/null and b/html/images/lang/en/labels/health-star-rating-1-5.90x90.png differ diff --git a/html/images/lang/en/labels/health-star-rating-1.90x90.png b/html/images/lang/en/labels/health-star-rating-1.90x90.png new file mode 100644 index 0000000000000..f29cd3829a69c Binary files /dev/null and b/html/images/lang/en/labels/health-star-rating-1.90x90.png differ diff --git a/html/images/lang/en/labels/health-star-rating-2-5.90x90.png b/html/images/lang/en/labels/health-star-rating-2-5.90x90.png new file mode 100644 index 0000000000000..785be57f5c560 Binary files /dev/null and b/html/images/lang/en/labels/health-star-rating-2-5.90x90.png differ diff --git a/html/images/lang/en/labels/health-star-rating-2.90x90.png b/html/images/lang/en/labels/health-star-rating-2.90x90.png new file mode 100644 index 0000000000000..937e88fa592a9 Binary files /dev/null and b/html/images/lang/en/labels/health-star-rating-2.90x90.png differ diff --git a/html/images/lang/en/labels/health-star-rating-3-5.90x90.png b/html/images/lang/en/labels/health-star-rating-3-5.90x90.png new file mode 100644 index 0000000000000..29364f7938928 Binary files /dev/null and b/html/images/lang/en/labels/health-star-rating-3-5.90x90.png differ diff --git a/html/images/lang/en/labels/health-star-rating-3.90x90.png b/html/images/lang/en/labels/health-star-rating-3.90x90.png new file mode 100644 index 0000000000000..56748575d0740 Binary files /dev/null and b/html/images/lang/en/labels/health-star-rating-3.90x90.png differ diff --git a/html/images/lang/en/labels/health-star-rating-4-5.90x90.png b/html/images/lang/en/labels/health-star-rating-4-5.90x90.png new file mode 100644 index 0000000000000..d499ab71cda14 Binary files /dev/null and b/html/images/lang/en/labels/health-star-rating-4-5.90x90.png differ diff --git a/html/images/lang/en/labels/health-star-rating-4.90x90.png b/html/images/lang/en/labels/health-star-rating-4.90x90.png new file mode 100644 index 0000000000000..fdce76990e85b Binary files /dev/null and b/html/images/lang/en/labels/health-star-rating-4.90x90.png differ diff --git a/html/images/lang/en/labels/health-star-rating-5.90x90.png b/html/images/lang/en/labels/health-star-rating-5.90x90.png new file mode 100644 index 0000000000000..84808dff8667e Binary files /dev/null and b/html/images/lang/en/labels/health-star-rating-5.90x90.png differ diff --git a/html/images/misc/co2-high.svg b/html/images/misc/co2-high.svg index d7c33d286eed8..18efff852d28a 100644 --- a/html/images/misc/co2-high.svg +++ b/html/images/misc/co2-high.svg @@ -1,6 +1,12 @@ - - - - - + + + co2-high + + + + + + + + diff --git a/html/images/misc/co2-low.svg b/html/images/misc/co2-low.svg index e5d5a22a37ae6..b76db2f5bfd33 100644 --- a/html/images/misc/co2-low.svg +++ b/html/images/misc/co2-low.svg @@ -1,6 +1,12 @@ - - - - - + + + co2-low + CO2 low + + + + + + + diff --git a/html/images/misc/co2-medium.svg b/html/images/misc/co2-medium.svg index 12f2c5d58b5a3..bb1370908445d 100644 --- a/html/images/misc/co2-medium.svg +++ b/html/images/misc/co2-medium.svg @@ -1,6 +1,12 @@ - - - - - + + + co2-medium + CO2 Medium + + + + + + + diff --git a/lang/en/texts/sendinblue.html b/lang/en/texts/sendinblue.html index 5aa9562b8618f..e7b08e53e9355 100644 --- a/lang/en/texts/sendinblue.html +++ b/lang/en/texts/sendinblue.html @@ -99,7 +99,7 @@
diff --git a/lang/fr/texts/application-mobile-open-food-facts.html b/lang/fr/texts/application-mobile-open-food-facts.html index e1821e6e578fd..23d08f18236eb 100644 --- a/lang/fr/texts/application-mobile-open-food-facts.html +++ b/lang/fr/texts/application-mobile-open-food-facts.html @@ -2,19 +2,44 @@

Installez l'application mobile Open Food Facts

Pour scanner les produits alimentaires, obtenir leur note Nutri-Score, leur groupe NOVA pour savoir s'il s'agit d'un aliment ultra-transformé, et pour décrypter les additifs alimentaires, installez l'application gratuite Open Food Facts !

- Disponible sur l'App Store + Disponible sur l'App Store - Disponible sur Google Play + Disponible sur Google Play - Windows Phone Store + Disponible sur le Windows Phone Store - Android APK + Android APK

Vous pourrez de plus ajouter de nouveaux produits à Open Food Facts et ainsi construire un bien commun pour améliorer l'alimentation et la santé de tous. Merci !

Si vous utilisez l'app et appréciez le projet Open Food Facts, cela serait sympa de laisser un avis sur l'App Store ou le Play Store pour encourager d'autres personnes à l'installer. Merci !

+
+ +
+

C'est nouveau !

+ +

+Juillet 2019 : Une meilleure alimentation pour une meilleure santé : on se mobilise !
Campagne de financement participatif pour imaginer et créer ensemble l'app idéale !

+Soutenir le développement de l'app
+ +

Juin 2019 : Nouvelles apps Open Food Facts pour iPhone et Android
+Nouvelles fonctions : scan en continu, mode hors connexion, comparaison de produits, listes, historique illimité et plus ! +

+
+ +
+
+App mobile Open Food Facts + +
+
+ +Essayez la nouvelle app Open Food Facts +
+
+ + +