Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove non-JS list of products #10743

Merged
merged 2 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/ProductOpener/Display.pm
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ my $uri_finder = URI::Find->new(
# Sort keys of JSON output
# $json has utf8 disabled: it encodes to Perl Unicode strings
my $json = JSON::MaybeXS->new->utf8(0)->allow_nonref->canonical;
my $json_indent = JSON::MaybeXS->new->indent(1)->utf8(0)->allow_nonref->canonical;
# $json_utf8 has utf8 enabled: it encodes to UTF-8 bytes
my $json_utf8 = JSON::MaybeXS->new->utf8(1)->allow_nonref->canonical;

Expand Down Expand Up @@ -5645,7 +5646,8 @@ sub search_and_display_products ($request_ref, $query_ref, $sort_by, $limit, $pa
my $products_json = '[]';

if (defined $request_ref->{structured_response}{products}) {
$products_json = $json->encode($request_ref->{structured_response}{products});
# We indent the JSON in the generated HTML so that we can easily see diffs in integration tests outputs
$products_json = $json_indent->encode($request_ref->{structured_response}{products});
Comment on lines +5649 to +5650
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

}

my $contributor_prefs_json = $json->encode(
Expand Down
15 changes: 2 additions & 13 deletions templates/web/common/includes/list_of_products.tt.html
Original file line number Diff line number Diff line change
Expand Up @@ -113,20 +113,9 @@
[% product.product_name %]
</a>
</li>
[% ELSE %]
<li>
[% IF product.product_name == '' %]
<a href="[% product.url %]" title="[% product.code %]">
[% ELSE %]
<a href="[% product.url %]" title="[% product.product_name %]">
[% END %]
<div>[% product.img %]</div>
<span>[% product.product_name %]</span>
</a>
</li>
[% END %]
Comment on lines -116 to -127
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a message (to make it clear for people not having JS activated in some way):

     [% ELSE %]
       <div>Product list loading from javascript…</div>
     [% END %]

[% END %]
[% IF (jqm.defined) && !(jqm_loadmore.defined) %]
[% END %]
[% IF (jqm.defined) && !(jqm_loadmore.defined) %]
</ul>
[% ELSE %]
</ul>
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,8 @@ <h3 class="title-5 text-medium">Descubre el proyecto</h3>
var page_type = "products";
var preferences_text = "Clasifica los productos 0 de acuerdo a tus preferencias";
var contributor_prefs = {"display_barcode":null,"edit_link":null};
var products = [];
var products = []
;
</script>
<script src="//static.openfoodfacts.localhost/js/product-preferences.js"></script>
<script src="//static.openfoodfacts.localhost/js/product-search.js"></script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,8 @@ <h3 class="title-5 text-medium">Discover the project</h3>
var page_type = "products";
var preferences_text = "Classify the 0 products below according to your preferences";
var contributor_prefs = {"display_barcode":null,"edit_link":null};
var products = [];
var products = []
;
</script>
<script src="//static.openfoodfacts.localhost/js/product-preferences.js"></script>
<script src="//static.openfoodfacts.localhost/js/product-search.js"></script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,8 @@ <h3 class="title-5 text-medium">Discover the project</h3>
var page_type = "products";
var preferences_text = "Classify the 0 products below according to your preferences";
var contributor_prefs = {"display_barcode":null,"edit_link":null};
var products = [];
var products = []
;
</script>
<script src="//static.openfoodfacts.localhost/js/product-preferences.js"></script>
<script src="//static.openfoodfacts.localhost/js/product-search.js"></script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,8 @@ <h3 class="title-5 text-medium">Discover the project</h3>
var page_type = "products";
var preferences_text = "Classify the 0 products below according to your preferences";
var contributor_prefs = {"display_barcode":null,"edit_link":null};
var products = [];
var products = []
;
</script>
<script src="//static.openfoodfacts.localhost/js/product-preferences.js"></script>
<script src="//static.openfoodfacts.localhost/js/product-search.js"></script>
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,8 @@ <h3 class="title-5 text-medium">Discover the project</h3>
var page_type = "products";
var preferences_text = "Classify the 0 products below according to your preferences";
var contributor_prefs = {"display_barcode":null,"edit_link":null};
var products = [];
var products = []
;
</script>
<script src="//static.openfoodfacts.localhost/js/product-preferences.js"></script>
<script src="//static.openfoodfacts.localhost/js/product-search.js"></script>
Expand Down

Large diffs are not rendered by default.

1,031 changes: 994 additions & 37 deletions tests/integration/expected_test_results/web_html/fr-categories.html

Large diffs are not rendered by default.

2,398 changes: 2,313 additions & 85 deletions tests/integration/expected_test_results/web_html/fr-index.html

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2,057 changes: 1,984 additions & 73 deletions tests/integration/expected_test_results/web_html/world-categories.html

Large diffs are not rendered by default.

4,450 changes: 4,293 additions & 157 deletions tests/integration/expected_test_results/web_html/world-index-signedin.html

Large diffs are not rendered by default.

4,450 changes: 4,293 additions & 157 deletions tests/integration/expected_test_results/web_html/world-index.html

Large diffs are not rendered by default.

1,715 changes: 1,654 additions & 61 deletions tests/integration/expected_test_results/web_html/world-label-organic.html

Large diffs are not rendered by default.

1,715 changes: 1,654 additions & 61 deletions tests/integration/expected_test_results/web_html/world-search-results.html

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"original_query_string" : "api/v0/attribute_groups",
"page" : 1,
"query_string" : "api/v0/attribute_groups",
"rate_limiter_bucket" : null,
"rate_limiter_blocking" : 0,
"rate_limiter_bucket" : null,
"rate_limiter_limit" : null,
"rate_limiter_user_requests" : null
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"original_query_string" : "api/v3/product/03564703999971",
"page" : 1,
"query_string" : "api/v3/product/03564703999971",
"rate_limiter_bucket" : "product",
"rate_limiter_blocking" : 0,
"rate_limiter_bucket" : "product",
"rate_limiter_limit" : 100,
"rate_limiter_user_requests" : null
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"original_query_string" : "api/v3/product/https%3A%2F%2Fid.gs1.org%2F01%2F03564703999971%2F10%2FABC%2F21%2F123456%3F17%3D211200",
"page" : 1,
"query_string" : "api/v3/product/https%3A%2F%2Fid.gs1.org%2F01%2F03564703999971%2F10%2FABC%2F21%2F123456%3F17%3D211200",
"rate_limiter_bucket" : "product",
"rate_limiter_blocking" : 0,
"rate_limiter_bucket" : "product",
"rate_limiter_limit" : 100,
"rate_limiter_user_requests" : null
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
"page" : 1,
"param" : {},
"query_string" : "category/breads/ingredients",
"rate_limiter_blocking" : 0,
"rate_limiter_bucket" : "facet_tags",
"rate_limiter_limit" : null,
"rate_limiter_user_requests" : null,
"tag" : "es:breads",
"tag_prefix" : "",
"tagid" : "es:breads",
Expand All @@ -22,9 +26,5 @@
"tagtype" : "categories"
}
],
"tagtype" : "categories",
"rate_limiter_bucket": "facet_tags",
"rate_limiter_blocking" : 0,
"rate_limiter_limit" : null,
"rate_limiter_user_requests" : null
"tagtype" : "categories"
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
"page" : 1,
"param" : {},
"query_string" : "category/breads/ingredients",
"rate_limiter_blocking" : 0,
"rate_limiter_bucket" : "facet_tags",
"rate_limiter_limit" : null,
"rate_limiter_user_requests" : null,
"tag" : "en:breads",
"tag_prefix" : "",
"tagid" : "en:breads",
Expand All @@ -22,9 +26,5 @@
"tagtype" : "categories"
}
],
"tagtype" : "categories",
"rate_limiter_bucket": "facet_tags",
"rate_limiter_blocking" : 0,
"rate_limiter_limit" : null,
"rate_limiter_user_requests" : null
"tagtype" : "categories"
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
"page" : "4",
"param" : {},
"query_string" : "category/breads/4",
"rate_limiter_blocking" : 0,
"rate_limiter_bucket" : "facet_products",
"rate_limiter_limit" : null,
"rate_limiter_user_requests" : null,
"tag" : "en:breads",
"tag_prefix" : "",
"tagid" : "en:breads",
Expand All @@ -21,9 +25,5 @@
"tagtype" : "categories"
}
],
"tagtype" : "categories",
"rate_limiter_bucket" : "facet_products",
"rate_limiter_blocking" : 0,
"rate_limiter_limit" : null,
"rate_limiter_user_requests" : null
"tagtype" : "categories"
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"page" : "4",
"param" : {},
"query_string" : "category/bread/4",
"rate_limiter_bucket" : "facet_products",
"rate_limiter_blocking" : 0,
"rate_limiter_bucket" : "facet_products",
"rate_limiter_limit" : 5,
"rate_limiter_user_requests" : null,
"tag" : "en:bread",
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/expected_test_results/routing/facet-url.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"page" : 1,
"param" : {},
"query_string" : "category/breads",
"rate_limiter_bucket" : "facet_products",
"rate_limiter_blocking" : 0,
"rate_limiter_bucket" : "facet_products",
"rate_limiter_limit" : 10,
"rate_limiter_user_requests" : null,
"tag" : "en:breads",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"original_query_string" : "api/v3/geopip/12.45.23.45",
"page" : 1,
"query_string" : "api/v3/geopip/12.45.23.45",
"rate_limiter_bucket" : null,
"rate_limiter_blocking" : 0,
"rate_limiter_bucket" : null,
"rate_limiter_limit" : null,
"rate_limiter_user_requests" : null
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"original_query_string" : "api/v3/geopip/2001:ac8:25:3b::e01d",
"page" : 1,
"query_string" : "api/v3/geopip/2001:ac8:25:3b::e01d",
"rate_limiter_bucket" : null,
"rate_limiter_blocking" : 0,
"rate_limiter_bucket" : null,
"rate_limiter_limit" : null,
"rate_limiter_user_requests" : null
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"page" : 1,
"param" : {},
"query_string" : "category/breads/no-nutrition-data",
"rate_limiter_bucket" : null,
"rate_limiter_blocking" : 0,
"rate_limiter_bucket" : null,
"rate_limiter_limit" : null,
"rate_limiter_user_requests" : null,
"status_code" : 404,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"original_query_string" : "products/3564703999971",
"page" : 1,
"query_string" : "products/3564703999971",
"rate_limiter_bucket" : null,
"rate_limiter_blocking" : 0,
"rate_limiter_bucket" : null,
"rate_limiter_limit" : null,
"rate_limiter_user_requests" : null,
"search" : 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"original_query_string" : "products/3564703999971,3564703999972",
"page" : 1,
"query_string" : "products/3564703999971,3564703999972",
"rate_limiter_bucket" : null,
"rate_limiter_blocking" : 0,
"rate_limiter_bucket" : null,
"rate_limiter_limit" : null,
"rate_limiter_user_requests" : null,
"search" : 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@
"page" : 1,
"param" : {},
"query_string" : "category/breads",
"rate_limiter_bucket" : "facet_products",
"rate_limiter_blocking" : 0,
"rate_limiter_bucket" : "facet_products",
"rate_limiter_limit" : 10,
"rate_limiter_user_requests" : null,
"tag" : "en:breads",
"tag_prefix" : "",
"tagid" : "en:breads",
"user_id": "userid",
"tags" : [
{
"tag" : "en:breads",
Expand All @@ -26,5 +25,6 @@
"tagtype" : "categories"
}
],
"tagtype" : "categories"
"tagtype" : "categories",
"user_id" : "userid"
}
Loading