diff --git a/README.md b/README.md index 072ac18..9d8682d 100755 --- a/README.md +++ b/README.md @@ -1,47 +1,57 @@ # Italian petrol pumps comparator ![Italian petrol pumps comparator](http://fuel.reyboz.it/images/fuel-64px.png) This web app allows you to list in a map and sort all fuel suppliers who are in a particular area, also it provides the current prices on every suppliers. We have engineered this solution in a Hackathon that was sponsored by *Facile.it*, an Italian price comparator. This submission **won the competition**. ## Use Use the http://fuel.reyboz.it online mirror. It has data updated on a daily basis. ## More about Heroes and original technologies in the [/about.php](http://fuel.reyboz.it/about.php) page of the online mirror. ## Hacking -Clone the source code using Bazaar: +Go in your `www` folder and clone the source code using Bazaar: - bzr clone lp:it-fuel-stations-comparator + bzr branch lp:it-fuel-stations-comparator ## Installation Have GNU/Linux, PHP and MySQL/MariaDB working. This project is built over the [Boz-PHP - Another PHP framework](https://github.com/valerio-bozzolan/boz-php-another-php-framework). Install it in your `/usr/share`: bzr branch lp:boz-php-another-php-framework /usr/share/boz-php-another-php-framework Import in MySQL/MariaDB the `database-schema.sql` from the `installation` folder. Also in the `installation` folder copy the `load-sample.php` in the root folder as `load.php` and fill with your MySQL/MariaDB credentials. ## Import data from MISE Please download data from the Italian [Ministero dello Sviluppo Economico](http://www.sviluppoeconomico.gov.it/index.php/it/open-data/elenco-dataset/2032336-carburanti-prezzi-praticati-e-anagrafica-degli-impianti): * http://www.sviluppoeconomico.gov.it/images/exportCSV/prezzo_alle_8.csv * http://www.sviluppoeconomico.gov.it/images/exportCSV/anagrafica_impianti_attivi.csv They are released under the terms of the Italian [Open Data License v2.0](http://www.dati.gov.it/iodl/2.0/). -The `cli/import-mise.php` can import them into your DB: +### Manually import MISE .csv +The `cli/import-mise.php` helps you: php ./cli/import-mise.php anagrafica_impianti_attivi.csv prezzo_alle_8.csv +### Automatically download and import MISE .csv +Put a similar line in your cronjob: + + /var/www/cli/download-import-mise.sh "php /var/www/cli/import-mise.php" + +.. or: + + su www-data -s /bin/sh -c '/var/www/cli/download-import-mise.sh "php /var/www/cli/import-mise.php"' + ## Pull requests Push in Launchpad: https://code.launchpad.net/it-fuel-stations-comparator ## License This is a **Free** as in **Freedom** project. It comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under the terms of the **GNU Affero General Public License v3+**. diff --git a/cli/download-import-mise.sh b/cli/download-import-mise.sh new file mode 100755 index 0000000..68e1eba --- /dev/null +++ b/cli/download-import-mise.sh @@ -0,0 +1,53 @@ +#!/bin/sh +############################################################################# +# +# Copyright (C) 2015 Valerio Bozzolan +# +############################################################################# +# +# This program 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 . +# +############################################################################# + +# This script downloads two files from the MISE and import them + +path="$1" +if [ -z "$path" ]; then + echo "Usage: $0 IMPORTER" + echo "Example: $0 \"php /var/www/cli/import-mise.php\"" + echo "The IMPORTER will receive two args: the petrol stations and the prices, as downloaded from the MISE" + exit 1; +fi + +# You are wrong.. I'm not curl! +wgets() { + curl "http://www.sviluppoeconomico.gov.it/images/exportCSV/$1" -o "$2" \ + -H 'Host: www.sviluppoeconomico.gov.it' \ + -H 'User-Agent: Mozilla/5.0 (X11; Debian; Linux x86_64; rv:39.0) Gecko/20100101 Iceweasel/39.0' \ + -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' \ + -H 'Accept-Language: en-US,it-IT;q=0.8,it;q=0.5,en;q=0.3' \ + --compressed -H 'Connection: keep-alive' +} + +stations="$(mktemp)" +prices="$(mktemp)" + +wgets "anagrafica_impianti_attivi.csv" "$stations" +wgets "prezzo_alle_8.csv" "$prices" + +# This will be something as: +# php .cli/import-mise.php /tmp/tmp.asduioasd /tmp/tmp.oisuodiasu +$1 "$stations" "$prices" + +rm "$stations" "$prices" diff --git a/cli/localize.sh b/cli/localize.sh index 6d221a2..12ee77e 100755 --- a/cli/localize.sh +++ b/cli/localize.sh @@ -1,53 +1,53 @@ #!/bin/sh ############################################################################# # # Copyright (C) 2015 Valerio Bozzolan # ############################################################################# # # This program 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 . # ############################################################################# -# This script do the entire Gettext i18n workflow +# This script does the entire GNU Gettext workflow # The copyright older of your localization copyright="Valerio Bozzolan" # The prefix of your localization's files # You have to know how GNU Gettext works to change it. package="fuel.reyboz.it" rtfm() { echo Usage: echo $1 SITE_ROOT echo Example: echo $1 /var/www/mysite } path="$1" if [ -z "$path" ]; then rtfm $0 exit 1 fi # Generate/update the .pot file from the single script (index.php) xgettext --copyright-holder="$copyright" --package-name=$package --from-code=UTF-8 --keyword=_e --default-domain=$package -o "$path"/l10n/$package.pot "$path"/*.php "$path"/*/*.php # Generate/update the .po files from the .pot file find "$path"/l10n -name \*.po -execdir msgmerge -o $package.po $package.po ../../$package.pot \; # Generate/update the .mo files from .po files find "$path"/l10n -name \*.po -execdir msgfmt -o $package.mo $package.po \;