Skip to content

Commit

Permalink
Raw implementation of gallery
Browse files Browse the repository at this point in the history
resolves #28
  • Loading branch information
kellerrennkadse committed Jun 16, 2018
1 parent 8fb57f3 commit d687301
Show file tree
Hide file tree
Showing 42 changed files with 65 additions and 29 deletions.
5 changes: 2 additions & 3 deletions assets/css/pages/gallery.scss
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
div.gallery {
margin: 5px;
margin-bottom: 25px;
border: 1px solid #ccc;
float: left;
min-width: 180px;
min-width: 230px;
max-width: 320px;
}

Expand Down
Binary file added assets/static/gallery/files/de/Artikel13Rolle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/static/gallery/files/de/Flyer_RGB.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/static/gallery/files/de/Flyer_RGB_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/static/gallery/files/de/Flyer_SW.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/static/gallery/files/de/Flyer_SW_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
File renamed without changes.
Binary file added assets/static/gallery/files/de/Illegal-Flyer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/static/gallery/files/de/Schriftrolle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/static/gallery/files/de/Social banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/static/gallery/files/de/Twitter1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/static/gallery/files/de/Twitter2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/static/gallery/files/de/Twitter3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/static/gallery/files/de/Unbenannt-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/static/gallery/files/de/WMBait-Flyer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/static/gallery/files/de/rettungsring2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
Empty file.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"symfony/asset": "^4.1",
"symfony/cache": "^4.1",
"symfony/console": "^4.1",
"symfony/finder": "^4.1",
"symfony/flex": "^1.0",
"symfony/framework-bundle": "^4.1",
"symfony/lts": "^4@dev",
Expand Down
4 changes: 2 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docker/app/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ RUN apt-get update \
&& apt-get update \
&& apt-get install -y php7.1-fpm php7.1-cli php7.1-gd \
php7.1-mbstring php7.1-xml php7.1-curl \
php7.1-sqlite3 \
php7.1-sqlite3 php7.1-imagick \
&& php -r "readfile('http://getcomposer.org/installer');" | php -- --install-dir=/usr/bin/ --filename=composer \
&& if [ ! -x /usr/bin/composer ]; then echo "Composer not found" && exit 1; fi \
&& mkdir /run/php \
Expand Down
49 changes: 46 additions & 3 deletions src/Controller/IndexController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@

namespace App\Controller;

use App\Kernel;
use App\Services\TweetService;
use Smalot\Github\Webhook\Webhook;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Finder\SplFileInfo;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\KernelEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Component\Routing\Annotation\Route;

class IndexController extends Controller
Expand Down Expand Up @@ -53,12 +57,37 @@ public function privacy(): Response
}

/**
* @param string $_locale
* @return Response
*/
public function gallery(string $_locale): Response
public function gallery(KernelInterface $kernel): Response
{
return $this->render('gallery/index.html.twig');
$base = realpath($kernel->getRootDir() . '/../public/build/static/gallery');
$files = $base . '/files/';
$preview = $base . '/preview/';

$finder = new Finder();

$finder->files()->depth('< 3')->name('/\.(png|jpg)$/i')->in($files);

$galleryImages = [];

foreach ($finder as $file) {
$name = $file->getFilename();
$langcode = basename(dirname($file->getRealPath()));
$thumb = sprintf('%s/thumb_%s', $langcode, $name);

if(!file_exists($preview . $thumb)) {
$this->resizeImage($file, $preview . $thumb);
}

$galleryImages[] = [
'name' => sprintf('%s/%s', $langcode, $name),
'thumb' => $thumb,
'langcode' => $langcode
];
}

return $this->render('gallery/index.html.twig', ['images' => $galleryImages]);
}

/**
Expand Down Expand Up @@ -115,4 +144,18 @@ public function update(Request $request)

return new Response();
}

private function resizeImage(SplFileInfo $file, $destinationName)
{
$imagick = new \Imagick($file->getRealPath());

$imagick->resizeImage(453,640, 0, 1, true);

$imageWidth = $imagick->getImageWidth();
if($imagick->getImageHeight() > $imageWidth * 1.5) {
$imagick->cropImage($imageWidth,$imageWidth * 1.5,0,0);
}

return $imagick->writeImage($destinationName);
}
}
24 changes: 4 additions & 20 deletions templates/gallery/components/content.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,10 @@
<span>{% trans %}gallery_title{% endtrans %}</span>
</h2>
<br>
<div class="gallery">
<a target="_blank" href="{{ absolute_url(asset('build/static/gallery/files/ILLEGAL-4x.pdf')) }}">
<span class="flag-icon flag-icon-de"></span>
<img src="{{ absolute_url(asset('build/static/gallery/preview/ILLEGAL-4x.png')) }}" alt="ILLEGAL-4x.pdf" width="300" height="200">
</a>
<div class="desc"><span class="label danger">{% trans %}gallery_download_pdf{% endtrans %}</span></div>
</div>
<div class="gallery">
<a target="_blank" href="{{ absolute_url(asset('build/static/gallery/files/flyer_illegal_4x.pdf')) }}">
<span class="flag-icon flag-icon-de"></span>
<img src="{{ absolute_url(asset('build/static/gallery/preview/flyer_illegal_4x.png')) }}" alt="flyer_illegal_4x.pdf" width="300" height="200">
</a>
<div class="desc"><span class="label danger">{% trans %}gallery_download_pdf{% endtrans %}</span></div>
</div>
<div class="gallery">
<a target="_blank" href="{{ absolute_url(asset('build/static/gallery/files/4x4_illegal_klein.pdf')) }}">
<span class="flag-icon flag-icon-de"></span>
<img src="{{ absolute_url(asset('build/static/gallery/preview/4x4_illegal_klein.png')) }}" alt="4x4_illegal_klein.pdf" width="300" height="200">
</a>
<div class="desc"><span class="label danger">{% trans %}gallery_download_pdf{% endtrans %}</span></div>
<div class="row">
{% for image in images %}
{% include 'gallery/components/image.html.twig' %}
{% endfor %}
</div>
</div>
</div>
Expand Down
9 changes: 9 additions & 0 deletions templates/gallery/components/image.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<div class="col">
<div class="gallery">
<a target="_blank" href="/build/static/gallery/files/{{ image.name }}">
<span class="flag-icon flag-icon-{{ image.langcode }}"></span>
<img src="/build/static/gallery/preview/{{ image.thumb}}" alt="{{ image.name }}" width="300" height="200">
</a>
<!--<div class="desc"><span class="label danger">{% trans %}gallery_download_pdf{% endtrans %}</span></div>-->
</div>
</div>

0 comments on commit d687301

Please sign in to comment.