diff --git a/.env b/.env index 6cdf7c94fc8c4..3562ea76b3116 100644 --- a/.env +++ b/.env @@ -46,6 +46,7 @@ MONGO_INITDB_ROOT_USERNAME=root MONGO_INITDB_ROOT_PASSWORD=test ROBOTOFF_URL=http://robotoff.openfoodfacts.localhost:5500 # connect to Robotoff running in separate docker-compose deployment EVENTS_URL= +FACETS_KP_URL = https://facets-kp.openfoodfacts.org/render-to-html # use this to push products to openfoodfacts-search # in dev: searchredis:6379 (with openfoodfacts-search running in docker in same network) REDIS_URL= diff --git a/conf/apache.conf b/conf/apache.conf index 52035640ea0ff..160b0eadca4b4 100644 --- a/conf/apache.conf +++ b/conf/apache.conf @@ -15,6 +15,7 @@ PerlPassEnv PRODUCT_OPENER_PORT PerlPassEnv PRODUCERS_PLATFORM PerlPassEnv ROBOTOFF_URL PerlPassEnv EVENTS_URL +PerlPassEnv FACETS_KP_URL PerlPassEnv EVENTS_USERNAME PerlPassEnv EVENTS_PASSWORD PerlPassEnv REDIS_URL diff --git a/docker-compose.yml b/docker-compose.yml index 0ec4fb284e8b7..9e5f1b62e51ac 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -15,6 +15,7 @@ x-backend-conf: &backend-conf - POSTGRES_PASSWORD - ROBOTOFF_URL - EVENTS_URL + - FACETS_KP_URL - EVENTS_USERNAME - EVENTS_PASSWORD - REDIS_URL diff --git a/lib/ProductOpener/Config2_docker.pm b/lib/ProductOpener/Config2_docker.pm index 424b829d80df1..95e09f40d6182 100755 --- a/lib/ProductOpener/Config2_docker.pm +++ b/lib/ProductOpener/Config2_docker.pm @@ -47,6 +47,7 @@ BEGIN { $crowdin_project_key $robotoff_url $events_url + $facets_kp_url $events_username $events_password $redis_url @@ -106,6 +107,10 @@ $events_url = $ENV{EVENTS_URL}; $events_username = $ENV{EVENTS_USERNAME}; $events_password = $ENV{EVENTS_PASSWORD}; +# Set this to your instance of https://github.com/openfoodfacts/facets-knowledge-panels +# Inject facet knowledge panels +$facets_kp_url = $ENV{FACETS_KP_URL}; + # Set this to your instance of the search service to enable writes to it $redis_url = $ENV{REDIS_URL}; diff --git a/lib/ProductOpener/Config_off.pm b/lib/ProductOpener/Config_off.pm index 5d109911b2b27..c9629b3ba61b6 100644 --- a/lib/ProductOpener/Config_off.pm +++ b/lib/ProductOpener/Config_off.pm @@ -52,6 +52,9 @@ BEGIN { $events_username $events_password + $facets_kp_url + $redis_url + $mongodb $mongodb_host $mongodb_timeout_ms @@ -351,6 +354,12 @@ $events_url = $ProductOpener::Config2::events_url; $events_username = $ProductOpener::Config2::events_username; $events_password = $ProductOpener::Config2::events_password; +# Redis is used to push updates to the search server +$redis_url = $ProductOpener::Config2::redis_url; + +# Facets knowledge panels url +$facets_kp_url = $ProductOpener::Config2::facets_kp_url; + # server options %server_options = %ProductOpener::Config2::server_options; diff --git a/lib/ProductOpener/Display.pm b/lib/ProductOpener/Display.pm index 81f71cf31c85f..2f0e802f0b2e6 100644 --- a/lib/ProductOpener/Display.pm +++ b/lib/ProductOpener/Display.pm @@ -3986,12 +3986,24 @@ HTML if (not defined $request_ref->{groupby_tagtype}) { # Pass template data to generate navigation links + # These are variables that ae used to inject data + # Used in tag.tt.html + #------------------------------------------------------- + # Results of these variables based for category/en:snacks + #---- tagtype would return-> categories ----- + #---- tagtype_path would return-> /categories ----- + #---- tagtype_name would return-> category ----- + #---- tagid would return-> en:snacks ----- + #---- tagid_path would return-> /category/snacks ----- + #---- tag_name would return-> Snacks ----- + $tag_template_data_ref->{tagtype} = $tagtype; $tag_template_data_ref->{tagtype_path} = '/' . $tag_type_plural{$tagtype}{$lc}; $tag_template_data_ref->{tagtype_name} = lang($tagtype . '_s'); $tag_template_data_ref->{tagid} = $tagid; $tag_template_data_ref->{tagid_path} = $newtagidpath; $tag_template_data_ref->{tag_name} = $display_tag; + $tag_template_data_ref->{canon_tagid} = $canon_tagid // $tagid; if (defined $tagid2) { $tag_template_data_ref->{tagtype2} = $tagtype2; @@ -4000,6 +4012,7 @@ HTML $tag_template_data_ref->{tagid2} = $tagid2; $tag_template_data_ref->{tagid2_path} = $newtagid2path; $tag_template_data_ref->{tag2_name} = $display_tag2; + $tag_template_data_ref->{canon_tagid2} = $canon_tagid2 // $tagid2; } else { @@ -4033,6 +4046,8 @@ HTML } # end of if (defined $tagtype) $tag_template_data_ref->{country} = $country; + $tag_template_data_ref->{country_code} = $cc; + $tag_template_data_ref->{facets_kp_url} = $facets_kp_url; if ($country ne 'en:world') { @@ -4138,7 +4153,7 @@ HTML $query_ref->{$field} = $tag2_is_negative ? {"\$ne" => $value} : $value; } } - + # Rendering Page tags my $tag_html; process_template('web/pages/tag/tag.tt.html', $tag_template_data_ref, \$tag_html) or $tag_html = "

tag.tt.html template error: " . $tt->error() . "

"; diff --git a/lib/ProductOpener/Redis.pm b/lib/ProductOpener/Redis.pm index 2b79b9c324c26..a5c9673e894c1 100644 --- a/lib/ProductOpener/Redis.pm +++ b/lib/ProductOpener/Redis.pm @@ -26,7 +26,7 @@ BEGIN { use vars @EXPORT_OK; use Log::Any qw/$log/; -use ProductOpener::Config2 qw/$redis_url/; +use ProductOpener::Config qw/$redis_url/; use Redis; =head2 $redis_client diff --git a/templates/web/common/site_layout.tt.html b/templates/web/common/site_layout.tt.html index cfae4a535a42f..0e788597e2b7a 100644 --- a/templates/web/common/site_layout.tt.html +++ b/templates/web/common/site_layout.tt.html @@ -286,17 +286,7 @@
-

[% title %] - - [% IF request.tagtype == "categories" %] - [% f_lang('f_help_categorize_on_hunger_games', { title => lang('categories').lcfirst } ) %] - [% ELSIF request.tagtype == "labels" %] - [% f_lang('f_help_categorize_on_hunger_games', { title => lang('labels').lcfirst } ) %] - [% ELSIF request.tagtype == "brands" %] - [% f_lang('f_help_categorize_on_hunger_games', { title => lang('brands').lcfirst } ) %] - [% END %] - -

+

[% title %]

[% content %] diff --git a/templates/web/pages/tag/tag.tt.html b/templates/web/pages/tag/tag.tt.html index 54d9792a5eaa8..4dc906d2a6a44 100644 --- a/templates/web/pages/tag/tag.tt.html +++ b/templates/web/pages/tag/tag.tt.html @@ -1,65 +1,114 @@
-
-[% IF not groupby_tagtype.defined %] -
- [% tagtype_name.ucfirst %] - [% sep %]: - [% tag_name %] +
+ [% IF not groupby_tagtype.defined %] +
+ [% tagtype_name.ucfirst %] + [% sep %]: + [% tag_name %] - [% IF tagid2.defined %] -
- [% tagtype2_name.ucfirst %] - [% sep %]: - [% tag2_name %] - [% END %] -
+ [% IF tagid2.defined %] +
+ [% tagtype2_name.ucfirst %] + [% sep %]: + [% tag2_name %] + [% END %] +
- [% IF tag_logo %] - - [% END %] + [% IF tag_logo %] + + [% END %] - [% IF canon_url %] - - [% END %] + [% IF canon_url %] + + [% END %] - [% IF weblinks %] - - [% END %] - [% IF parents_and_children %] -
- [% parents_and_children %] -
- [% END %] + [% IF weblinks and not facets_kp_url.defined %] + + [% END %] + + [% IF parents_and_children %] +
+ [% parents_and_children %] +
+ [% END %] - [% IF description %] -
- [% description %] + [% IF description %] +
+ [% description %] +
+ [% END %] + + [% END %] + + [% IF country != 'en:world' %] +

[% lang('countries_s').ucfirst %][% sep %]: [% display_taxonomy_tag("countries", country) %] + - [% world_link %] +

+ [% END %] + + [% IF products_title %] +

[% products_title %]

+ [% END %]
- [% END %] -[% END %] + +
+ [% IF tagid.defined %] + +
+

+
+
+ + [% IF facets_kp_url.defined %] + + [% END %] + [% END %]
+ \ No newline at end of file