Skip to content

Commit 4725245

Browse files
committed
Initial commit
0 parents  commit 4725245

File tree

166 files changed

+12019
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

166 files changed

+12019
-0
lines changed

.env.dist

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
###> symfony/framework-bundle ###
3+
APP_ENV=dev
4+
APP_SECRET=change-me-please
5+
#TRUSTED_PROXIES=127.0.0.1,127.0.0.2
6+
#TRUSTED_HOSTS=localhost,example.com
7+
###< symfony/framework-bundle ###
8+
9+
###> doctrine/doctrine-bundle ###
10+
# Format described at http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
11+
# For an SQLite database, use: "sqlite:///%kernel.project_dir%/var/data.db"
12+
# Configure your db driver and server_version in config/packages/doctrine.yaml
13+
DATABASE_URL=sqlite:///%kernel.project_dir%/var/mappics_%kernel.environment%.db
14+
###< doctrine/doctrine-bundle ###
15+
16+
###> API keys (see README.md) ###
17+
DARK_SKY_API_KEY=null
18+
MAPBOX_API_KEY=null
19+
###< API keys (see README.md) ###

.gitignore

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
###> symfony/framework-bundle ###
2+
.env
3+
/public/bundles/
4+
/var/
5+
/vendor/
6+
###< symfony/framework-bundle ###
7+
8+
###> symfony/web-server-bundle ###
9+
.web-server-pid
10+
###< symfony/web-server-bundle ###
11+
12+
###> symfony/phpunit-bridge ###
13+
.phpunit
14+
/phpunit.xml
15+
###< symfony/phpunit-bridge ###
16+
17+
/public/galleries/*
18+
!/public/galleries/.keep
19+
deploy.php
20+
.php_cs.cache
21+
/build/

.travis.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
language: php
2+
3+
services:
4+
- docker
5+
6+
before_install:
7+
- docker-compose build
8+
- docker-compose run --rm mappics composer install
9+
- docker-compose run --rm mappics bin/console cache:clear --env=test
10+
- docker-compose run --rm mappics bin/console doctrine:migrations:migrate --env=test --no-interaction
11+
12+
script:
13+
- mkdir -p build/logs
14+
- docker-compose run --rm mappics bin/phpunit --coverage-clover=coverage.xml
15+
16+
after_success:
17+
- bash <(curl -s https://codecov.io/bash)

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 Antonello D'Ippolito
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Mappics
2+
3+
[![Build Status](https://travis-ci.org/antodippo/mappics.svg?branch=master)](https://travis-ci.org/antodippo/mappics)
4+
[![codecov](https://codecov.io/gh/antodippo/mappics/branch/master/graph/badge.svg)](https://codecov.io/gh/antodippo/mappics)
5+
6+
Mappics is a **map based** travel photos gallery, with automatic **place** and **weather description** of the very moment the photos are taken.
7+
8+
It will process all the images placed in a specific directory and perform these operations:
9+
10+
- it fetches **Exif data**, (https://en.wikipedia.org/wiki/Exif), which usually contain camera model and settings, GPS information, and date and time the photo was taken
11+
- it fetches **place description**. A short one (like `Goðafoss Waterfall` and a long one (like `Goðafoss Waterfall, Goðafossvegur, Öxará, Þingeyjarsveit, Norðurland eystra, Ísland`). This is based on the Exif GPS information stored in the photo and obtained from [Nominatim and OpenStreetMap APIs](https://nominatim.openstreetmap.org/)
12+
- it fetches **weather forecast** in the place and moment the photo was taken. This is based on the Exif GPS information and the creation date of the photo, and obtained from the [DarkSky APIs](https://darksky.net/dev)
13+
- it creates a **resized version** of the image and a **thumbnail**, and store them in a different folder from the original one
14+
15+
All these information are shown in galleries and pop up with photos and details, using [Leaflet](https://leafletjs.com/) javascript library and [Mapbox](https://www.mapbox.com/) maps. Frontend is based on [Bootstrap](https://getbootstrap.com) framework and backend is written in PHP on top of some [Symfony](https://symfony.com/) components.
16+
17+
You can see a working version here: http://pics.antodippo.com.
18+
19+
## Usage
20+
21+
Mappics provides a simple console command to process images.
22+
To configure and run the command you will have to:
23+
24+
1. obtain API keys from external services:
25+
- Dark Sky API: https://darksky.net/dev/register
26+
- Mapbox: https://account.mapbox.com/auth/signin/?route-to=%22/access-tokens/%22
27+
2. deploy the application (see dedicated paragraph for details)
28+
3. edit your `/.env` file adding the keys from step 1
29+
4. place your images in the `<root>/var/galleries` directory (Mappics supports `jpg` and `png` images), organized in folders (they will become galleries)
30+
5. run the console command `bin/console mappics:process-galleries` from the `<root>` directory
31+
6. go to the home page and enjoy your photos!
32+
33+
If you have a lot of images this command can take a long time, so you may want to run it in background:
34+
35+
`bin/console mappics:process-galleries &`
36+
37+
or, if you want to set-it-and-forget-it and just upload photo every now and then, you could run it as a cron job (it has a lock which prevents multiple execution):
38+
39+
`0 * * * * /var/www/mappics/current/bin/console mappics:process-galleries`
40+
41+
## Deploy
42+
43+
One option is to make Mappics run on Apache with PHP module. You will have to install and enable the following PHP extensions:
44+
45+
```
46+
php-curl
47+
php-mbstring
48+
php-zip
49+
php-gd
50+
php-xml
51+
php-exif
52+
```
53+
54+
You can find a sample virtual host file in `/docker/vhost.conf` and a `Dockerfile` to have a better understanting of the system stack needed.
55+
56+
To deploy and update Mappics you can also find a simple configuration for [https://deployer.org](https://deployer.org), in `/deploy.sample.php`, so you will have to:
57+
58+
1. [install Deployer](https://deployer.org/docs/getting-started.html)
59+
2. edit the sample file adding you host information (see comments in file and [documentation](https://deployer.org/docs/hosts.html))
60+
3. rename the file in `deploy.php`
61+
4. run `dep deploy` (to install the latest version)
62+
63+
If you want to deploy a specific version you can also use the tag option: `dep deploy --tag="1.0.0"`
64+
65+
## Run on your local machine
66+
67+
The suggested way to run and work on Mappics in a local enviroment is [Docker](https://www.docker.com/):
68+
69+
1. [install Docker](https://www.docker.com/get-started) on your machine
70+
2. clone the repository: `git clone git@github.com:antodippo/mappics.git`
71+
3. build Mappics image: `docker-compose build`
72+
4. run tests: `bin/run-tests`
73+
5. run application setup: `bin/prepare-application`
74+
6. run application: `docker-compose up -d`
75+
7. browse Mappics on http://localhost:8080
76+
77+
You should get an empty Mappics home page. To fill it, see the "Usage" paragraph.

bin/console

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
use App\Kernel;
5+
use Symfony\Bundle\FrameworkBundle\Console\Application;
6+
use Symfony\Component\Console\Input\ArgvInput;
7+
use Symfony\Component\Debug\Debug;
8+
use Symfony\Component\Dotenv\Dotenv;
9+
10+
set_time_limit(0);
11+
12+
require __DIR__.'/../vendor/autoload.php';
13+
14+
if (!class_exists(Application::class)) {
15+
throw new \RuntimeException('You need to add "symfony/framework-bundle" as a Composer dependency.');
16+
}
17+
18+
if (!isset($_SERVER['APP_ENV'])) {
19+
if (!class_exists(Dotenv::class)) {
20+
throw new \RuntimeException('APP_ENV environment variable is not defined. You need to define environment variables for configuration or add "symfony/dotenv" as a Composer dependency to load variables from a .env file.');
21+
}
22+
(new Dotenv())->load(__DIR__.'/../.env');
23+
}
24+
25+
$input = new ArgvInput();
26+
$env = $input->getParameterOption(['--env', '-e'], $_SERVER['APP_ENV'] ?? 'dev');
27+
$debug = ($_SERVER['APP_DEBUG'] ?? ('prod' !== $env)) && !$input->hasParameterOption(['--no-debug', '']);
28+
29+
if ($debug) {
30+
umask(0000);
31+
32+
if (class_exists(Debug::class)) {
33+
Debug::enable();
34+
}
35+
}
36+
37+
$kernel = new Kernel($env, $debug);
38+
$application = new Application($kernel);
39+
$application->run($input);

bin/phpunit

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
if (!file_exists(dirname(__DIR__).'/vendor/symfony/phpunit-bridge/bin/simple-phpunit')) {
5+
echo "Unable to find the `simple-phpunit` script in `vendor/symfony/phpunit-bridge/bin/`.\n";
6+
exit(1);
7+
}
8+
if (false === getenv('SYMFONY_PHPUNIT_REMOVE')) {
9+
putenv('SYMFONY_PHPUNIT_REMOVE=symfony/yaml');
10+
}
11+
if (false === getenv('SYMFONY_PHPUNIT_VERSION')) {
12+
putenv('SYMFONY_PHPUNIT_VERSION=6.5');
13+
}
14+
if (false === getenv('SYMFONY_PHPUNIT_DIR')) {
15+
putenv('SYMFONY_PHPUNIT_DIR='.__DIR__.'/.phpunit');
16+
}
17+
18+
require dirname(__DIR__).'/vendor/symfony/phpunit-bridge/bin/simple-phpunit';

bin/prepare-application

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env bash
2+
3+
docker-compose run --rm mappics composer install
4+
docker-compose run --rm mappics bin/console doctrine:migrations:migrate --env=dev --no-interaction

bin/run-tests

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
docker-compose run --rm mappics composer install
4+
docker-compose run --rm mappics bin/console cache:clear --env=test
5+
docker-compose run --rm mappics bin/console doctrine:migrations:migrate --env=test --no-interaction
6+
docker-compose run --rm mappics bin/phpunit

composer.json

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
{
2+
"type": "project",
3+
"license": "proprietary",
4+
"require": {
5+
"php": "^7.2",
6+
"ext-curl": "*",
7+
"ext-exif": "*",
8+
"ext-iconv": "*",
9+
"ext-json": "*",
10+
"ext-mbstring": "*",
11+
"ext-zip": "*",
12+
"ext-zlib": "*",
13+
"gumlet/php-image-resize": "^1.9",
14+
"guzzlehttp/guzzle": "^6.3",
15+
"javiereguiluz/easyslugger": "^1.0",
16+
"league/tactician": "^1.0",
17+
"league/tactician-bundle": "^1.1",
18+
"miljar/php-exif": "^0.6.3",
19+
"nesbot/carbon": "^2.11",
20+
"nette/finder": "^2.4",
21+
"phake/phake": "^3.0",
22+
"ramsey/uuid": "^3.7",
23+
"sensiolabs/security-checker": "^5.0",
24+
"symfony/asset": "^4.0",
25+
"symfony/console": "^4.0",
26+
"symfony/dotenv": "^4.1",
27+
"symfony/flex": "^1.0",
28+
"symfony/framework-bundle": "^4.1",
29+
"symfony/lock": "^4.1",
30+
"symfony/monolog-bundle": "^3.3",
31+
"symfony/orm-pack": "^1.0",
32+
"symfony/phpunit-bridge": "^4.0",
33+
"symfony/requirements-checker": "^1.1",
34+
"symfony/stopwatch": "^4.1",
35+
"symfony/twig-bundle": "^4.0",
36+
"symfony/web-server-bundle": "^4.0",
37+
"symfony/yaml": "^4.0",
38+
"twig/extensions": "^1.5",
39+
"webmozart/assert": "^1.4"
40+
},
41+
"require-dev": {
42+
"doctrine/doctrine-fixtures-bundle": "^3.0",
43+
"php-coveralls/php-coveralls": "^1.0",
44+
"symfony/profiler-pack": "^1.0"
45+
},
46+
"config": {
47+
"preferred-install": {
48+
"*": "dist"
49+
},
50+
"sort-packages": true
51+
},
52+
"autoload": {
53+
"psr-4": {
54+
"App\\": "src/"
55+
}
56+
},
57+
"autoload-dev": {
58+
"psr-4": {
59+
"App\\Tests\\": "tests/"
60+
}
61+
},
62+
"replace": {
63+
"symfony/polyfill-iconv": "*",
64+
"symfony/polyfill-php71": "*",
65+
"symfony/polyfill-php70": "*",
66+
"symfony/polyfill-php56": "*"
67+
},
68+
"scripts": {
69+
"auto-scripts": {
70+
"cache:clear": "symfony-cmd",
71+
"assets:install --symlink --relative %PUBLIC_DIR%": "symfony-cmd",
72+
"requirements-checker": "script",
73+
"security-checker security:check": "script"
74+
},
75+
"post-install-cmd": [
76+
"@auto-scripts"
77+
],
78+
"post-update-cmd": [
79+
"@auto-scripts"
80+
]
81+
},
82+
"conflict": {
83+
"symfony/symfony": "*"
84+
},
85+
"extra": {
86+
"symfony": {
87+
"id": "01C1JT3KH3RK0PXZY0AJCJSK3X",
88+
"allow-contrib": true
89+
}
90+
}
91+
}

0 commit comments

Comments
 (0)