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

feat: add link to learn more about nutriscore + ecoscore #6701

Merged
merged 1 commit into from
Apr 27, 2022

Conversation

stephanegigandet
Copy link
Contributor

fixes #6689

related to #6679

@stephanegigandet stephanegigandet requested a review from a team as a code owner April 26, 2022 17:17
@github-actions github-actions bot added 📖 Knowledge Panels https://wiki.openfoodfacts.org/Knowledge_panels Template::Toolkit The templating toolkit used by product opener. The starting point for HTML/JS/CSS fixes. Translations We use a non-standard version of GetText, lack language variants support translate.openfoodfacts.org labels Apr 26, 2022
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

Copy link
Member

@alexgarel alexgarel left a comment

Choose a reason for hiding this comment

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

LGTM but a style comment !

"element_type": "text",
"text_element": {
"html": `
<p>&rarr; <a href="/nutriscore">[% lang('nutriscore_learn_more') %]</a></p>
Copy link
Member

Choose a reason for hiding this comment

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

Why not url_for_text("nutriscore") here ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

url_for_text() currently only works for the Eco-Score text, the /nutriscore text URL is not localized, it's the same for all languages.

=head2 url_for_text ( $textid )

Return the localized URL for a text. (e.g. "data" points to /data in English and /donnees in French)

=cut

# Note: the following urls are currently hardcoded, but the idea is to build the mapping table
# at startup from the available translated texts in the repository. (TODO)
my %urls_for_texts = (
	"ecoscore" => {
		en => "eco-score-the-environmental-impact-of-food-products",
		de => "eco-score-die-umweltauswirkungen-von-lebensmitteln",
		es => "eco-score-el-impacto-medioambiental-de-los-productos-alimenticios",
		fr => "eco-score-l-impact-environnemental-des-produits-alimentaires",
		it => "eco-score-impatto-ambientale-dei-prodotti-alimentari",
		nl => "eco-score-de-milieu-impact-van-voedingsproducten",
		pt => "eco-score-o-impacto-ambiental-dos-produtos-alimentares",
	},
);

sub url_for_text($) {

	my $textid = shift;

	# remove starting / if passed
	$textid =~ s/^\///;

	if (not defined $urls_for_texts{$textid}) {
		return "/" . $textid;
	}
	elsif (defined $urls_for_texts{$textid}{$lc}) {
		return "/" . $urls_for_texts{$textid}{$lc};
	}
	elsif ($urls_for_texts{$textid}{en}) {
		return "/" . $urls_for_texts{$textid}{en};
	}
	else {
		return "/" . $textid;
	}
}

Copy link
Member

@teolemon teolemon left a comment

Choose a reason for hiding this comment

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

What's happening to the existing NOVA link ?

@stephanegigandet
Copy link
Contributor Author

What's happening to the existing NOVA link ?

Nothing is happening, it's kept as-is. This PR adds a similar "Learn more about... " link in the Nutri-Score and Eco-Score panels.

@stephanegigandet stephanegigandet merged commit c299a55 into main Apr 27, 2022
@stephanegigandet stephanegigandet deleted the learn-more branch April 27, 2022 16:35
@stephanegigandet
Copy link
Contributor Author

Can we close this?

@teolemon
Copy link
Member

teolemon commented May 6, 2022

@stephanegigandet I can't see it in Smoothie. Has it been deployed ? Do we need tweaking client side ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📖 Knowledge Panels https://wiki.openfoodfacts.org/Knowledge_panels Template::Toolkit The templating toolkit used by product opener. The starting point for HTML/JS/CSS fixes. Translations We use a non-standard version of GetText, lack language variants support translate.openfoodfacts.org
Projects
Development

Successfully merging this pull request may close these issues.

Add the link to the full Nutri-Score explainer page at the end of the methodology knowledge panel
3 participants