Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanegigandet committed Sep 29, 2017
2 parents 5f64264 + 80089c5 commit 28e62c1
Show file tree
Hide file tree
Showing 258 changed files with 3,717 additions and 2,249 deletions.
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ before_install:
install:
- cpanm --quiet --installdeps --notest --skip-satisfied .
- npm install
- bower install
- node_modules/.bin/bower install
- ln -s $TRAVIS_BUILD_DIR/lib/ProductOpener/Config_off.pm $TRAVIS_BUILD_DIR/lib/ProductOpener/Config.pm
- cp $TRAVIS_BUILD_DIR/lib/ProductOpener/Config2_sample.pm $TRAVIS_BUILD_DIR/lib/ProductOpener/Config2.pm
- ln -s $TRAVIS_BUILD_DIR/lib/ProductOpener/SiteLang_off.pm $TRAVIS_BUILD_DIR/lib/ProductOpener/SiteLang.pm
Expand All @@ -33,6 +33,7 @@ install:
script:
- prove -l
- perl -c -CS -I$TRAVIS_BUILD_DIR/lib lib/startup_apache2.pl
- jshint --show-non-errors html/js/product-multilingual.js html/js/search.js
- perl -c -CS -I$TRAVIS_BUILD_DIR/lib cgi/product_multilingual.pl
- node_modules/.bin/jshint --show-non-errors html/js/product-multilingual.js html/js/search.js
notifications:
slack: openfoodfacts:Pre9ZXKFH1CYtix8DeJAaFi2
3 changes: 2 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
],
"dependencies": {
"leaflet": ">=1.0.0",
"leaflet.markercluster": ">=1.0.0"
"leaflet.markercluster": ">=1.0.0",
"ManUp.js": "git://github.com/boyofgreen/ManUp.js"
}
}
77 changes: 77 additions & 0 deletions cgi/manifest.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/usr/bin/perl -w

# This file is part of Product Opener.
#
# Product Opener
# Copyright (C) 2011-2016 Association Open Food Facts
# Contact: [email protected]
# Address: 21 rue des Iles, 94100 Saint-Maur des Fossés, France
#
# Product Opener is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

use Modern::Perl '2012';
use utf8;

use CGI::Carp qw(fatalsToBrowser);
use CGI qw/:cgi :form escapeHTML/;

use ProductOpener::Config qw/:all/;
use ProductOpener::Store qw/:all/;
use ProductOpener::Index qw/:all/;
use ProductOpener::Display qw/:all/;
use ProductOpener::Users qw/:all/;
use ProductOpener::URL qw/:all/;
use ProductOpener::Lang qw/:all/;

use CGI qw/:cgi :form escapeHTML/;
use URI::Escape::XS;
use Storable qw/dclone/;
use Encode;
use JSON::PP;

ProductOpener::Display::init();

my $short_name = lang("site_name");
my $long_name = $short_name;

# http://stackoverflow.com/a/16533563/11963
$short_name =~ s/\b([A-Z])[a-z]+(?=\s+[A-Z][a-z])|\G(?!^)\s+([A-Z])[a-z]+/$1$2/g;

if ($cc eq 'world') {
$long_name .= " " . uc($lc);
$short_name .= " " . uc($lc);
}
else {
$long_name .= " " . uc($cc) . "/" . uc($lc);
$short_name .= " " . uc($cc) . "/" . uc($lc);
}

my %manifest;
$manifest{lang} = $lc;
$manifest{name} = $long_name;
$manifest{short_name} = $short_name;
$manifest{description} = lang('site_description');
$manifest{start_url} = format_subdomain($subdomain);
$manifest{scope} = '/';
$manifest{display} = 'standalone';

my @keys = qw(theme_color icons related_applications background_color);
foreach my $key (@keys) {
$manifest{$key} = $options{manifest}{$key} if $options{manifest}{$key};
}

my $data = encode_json(\%manifest);

print "Content-Type: application/manifest+json; charset=UTF-8\r\nCache-Control: max-age=86400\r\n\r\n" . $data;

29 changes: 18 additions & 11 deletions cgi/product_multilingual.pl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# This file is part of Product Opener.
#
# Product Opener
# Copyright (C) 2011-2016 Association Open Food Facts
# Copyright (C) 2011-2017 Association Open Food Facts
# Contact: [email protected]
# Address: 21 rue des Iles, 94100 Saint-Maur des Fossés, France
#
Expand Down Expand Up @@ -1584,7 +1584,7 @@ ($$$$$$)
}

$input .= <<HTML
<span id="nutriment_${enid}_unit_percent"$hide_percent>%</span>
<span class="nutriment_unit_percent" id="nutriment_${enid}_unit_percent"$hide_percent>%</span>
<select class="nutriment_unit" id="nutriment_${enid}_unit" name="nutriment_${enid}_unit"$hide_select>
HTML
;
Expand Down Expand Up @@ -1890,17 +1890,13 @@ ($$$$$$)
$comment = $comment . remove_tags_and_quote(decode utf8=>param('comment'));
store_product($product_ref, $comment);

my $product_url = product_url($product_ref);

# product that was moved to OBF from OFF etc.
if (defined $product_ref->{server}) {
$product_url = "https://" . $subdomain . "." . $options{other_servers}{$product_ref->{server}}{domain} . $product_url;
# product that was moved to OBF from OFF etc.
my $product_url = "https://" . $subdomain . "." . $options{other_servers}{$product_ref->{server}}{domain} . product_url($product_ref);;
$html .= "<p>" . lang("product_changes_saved") . "</p><p>&rarr; <a href=\"" . $product_url . "\">"
. lang("see_product_page") . "</a></p>";
}

$html .= "<p>" . lang("product_changes_saved") . "</p><p>&rarr; <a href=\"" . $product_url . "\">"
. lang("see_product_page") . "</a></p>";

if ($type eq 'delete') {
elsif ($type eq 'delete') {
my $email = <<MAIL
$User_id $Lang{has_deleted_product}{$lc}:
Expand All @@ -1910,6 +1906,17 @@ ($$$$$$)
;
send_email_to_admin(lang("deleting_product"), $email);

} else {
my %request = (
'titleid'=>get_fileid(product_name_brand($product_ref)),
'query_string'=>$ENV{QUERY_STRING},
'referer'=>referer(),
'code'=>$code,
'product_changes_saved'=>1,
'sample_size'=>10
);

display_product(\%request);
}

}
Expand Down
3 changes: 2 additions & 1 deletion html/js/product-multilingual.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// This file is part of Product Opener.
//
// Product Opener
// Copyright (C) 2011-2015 Association Open Food Facts
// Copyright (C) 2011-2017 Association Open Food Facts
// Contact: [email protected]
// Address: 21 rue des Iles, 94100 Saint-Maur des Fossés, France
//
Expand Down Expand Up @@ -159,6 +159,7 @@ function add_line(event, ui) {
newline.attr('id', newid + "_tr");
newline.find(".nutriment_label").attr("id",newid + "_label").attr("name",newid + "_label");
newline.find(".nutriment_unit").attr("id",newid + "_unit").attr("name",newid + "_unit");
newline.find(".nutriment_unit_percent").attr("id",newid + "_unit_percent").attr("name",newid + "_unit_percent");
newline.find(".nutriment_value").attr("id",newid).attr("name",newid);

$('#nutrition_data_table > tbody:last').append(newline);
Expand Down
44 changes: 29 additions & 15 deletions lib/ProductOpener/Config_off.pm
Original file line number Diff line number Diff line change
Expand Up @@ -188,27 +188,41 @@ $google_analytics = <<HTML
HTML
;

my @icons = (
{ "platform" => "ios", "sizes" => "57x57", "src" => "https://static.$server_domain/images/favicon/apple-touch-icon-57x57.png" },
{ "platform" => "ios", "sizes" => "60x60", "src" => "https://static.$server_domain/images/favicon/apple-touch-icon-60x60.png" },
{ "platform" => "ios", "sizes" => "72x72", "src" => "https://static.$server_domain/images/favicon/apple-touch-icon-72x72.png" },
{ "platform" => "ios", "sizes" => "76x76", "src" => "https://static.$server_domain/images/favicon/apple-touch-icon-76x76.png" },
{ "platform" => "ios", "sizes" => "114x114", "src" => "https://static.$server_domain/images/favicon/apple-touch-icon-114x114.png" },
{ "platform" => "ios", "sizes" => "120x120", "src" => "https://static.$server_domain/images/favicon/apple-touch-icon-120x120.png" },
{ "platform" => "ios", "sizes" => "144x144", "src" => "https://static.$server_domain/images/favicon/apple-touch-icon-144x144.png" },
{ "platform" => "ios", "sizes" => "152x152", "src" => "https://static.$server_domain/images/favicon/apple-touch-icon-152x152.png" },
{ "platform" => "ios", "sizes" => "180x180", "src" => "https://static.$server_domain/images/favicon/apple-touch-icon-180x180.png" },
{ "type" => "image/png", "src" => "https://static.$server_domain/images/favicon/favicon-32x32.png", "sizes" => "32x32" },
{ "type" => "image/png", "src" => "https://static.$server_domain/images/favicon/android-chrome-192x192.png", "sizes" => "192x192" },
{ "type" => "image/png", "src" => "https://static.$server_domain/images/favicon/favicon-96x96.png", "sizes" => "96x96" },
{ "type" => "image/png", "src" => "https://static.$server_domain/images/favicon/favicon-16x16.png", "sizes" => "16x16" },
);

my @related_applications = (
{ 'platform' => 'play', 'id' => 'org.openfoodfacts.scanner', 'url' => 'https://play.google.com/store/apps/details?id=org.openfoodfacts.scanner' },
{ 'platform' => 'ios', 'id' => 'id588797948', 'url' => 'https://itunes.apple.com/app/id588797948' },
);

my $manifest;
$manifest->{icons} = \@icons;
$manifest->{related_applications} = \@related_applications;
$manifest->{theme_color} = '#ffffff';
$manifest->{background_color} = '#ffffff';
$options{manifest} = $manifest;

$options{favicons} = <<HTML
<link rel="apple-touch-icon" sizes="57x57" href="/images/favicon/apple-touch-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="/images/favicon/apple-touch-icon-60x60.png">
<link rel="apple-touch-icon" sizes="72x72" href="/images/favicon/apple-touch-icon-72x72.png">
<link rel="apple-touch-icon" sizes="76x76" href="/images/favicon/apple-touch-icon-76x76.png">
<link rel="apple-touch-icon" sizes="114x114" href="/images/favicon/apple-touch-icon-114x114.png">
<link rel="apple-touch-icon" sizes="120x120" href="/images/favicon/apple-touch-icon-120x120.png">
<link rel="apple-touch-icon" sizes="144x144" href="/images/favicon/apple-touch-icon-144x144.png">
<link rel="apple-touch-icon" sizes="152x152" href="/images/favicon/apple-touch-icon-152x152.png">
<link rel="apple-touch-icon" sizes="180x180" href="/images/favicon/apple-touch-icon-180x180.png">
<link rel="icon" type="image/png" href="/images/favicon/favicon-32x32.png" sizes="32x32">
<link rel="icon" type="image/png" href="/images/favicon/android-chrome-192x192.png" sizes="192x192">
<link rel="icon" type="image/png" href="/images/favicon/favicon-96x96.png" sizes="96x96">
<link rel="icon" type="image/png" href="/images/favicon/favicon-16x16.png" sizes="16x16">
<link rel="manifest" href="/images/favicon/manifest.json">
<link rel="manifest" href="/cgi/manifest.pl">
<link rel="mask-icon" href="/images/favicon/safari-pinned-tab.svg" color="#5bbad5">
<link rel="shortcut icon" href="/images/favicon/favicon.ico">
<meta name="msapplication-TileColor" content="#da532c">
<meta name="msapplication-TileImage" content="/images/favicon/mstile-144x144.png">
<meta name="msapplication-config" content="/images/favicon/browserconfig.xml">
<meta name="theme-color" content="#ffffff">
HTML
;

Expand Down
Loading

0 comments on commit 28e62c1

Please sign in to comment.