1
0
mirror of https://github.com/ToxicCrack/PrintABrick.git synced 2025-05-16 20:30:09 -07:00

Setup Liip imagine budle to cache images

This commit is contained in:
David Hübner 2017-04-07 03:01:32 +02:00
parent f79d63be1b
commit 00e70875ff
7 changed files with 154 additions and 45 deletions

View File

@ -19,7 +19,6 @@ class AppKernel extends Kernel
new Knp\Bundle\MenuBundle\KnpMenuBundle(),
new Oneup\FlysystemBundle\OneupFlysystemBundle(),
new Knp\Bundle\PaginatorBundle\KnpPaginatorBundle(),
new Knp\Bundle\GaufretteBundle\KnpGaufretteBundle(),
new Lexik\Bundle\FormFilterBundle\LexikFormFilterBundle(),
new Liip\ImagineBundle\LiipImagineBundle(),
];

View File

@ -92,26 +92,55 @@ knp_paginator:
pagination: KnpPaginatorBundle:Pagination:semantic_ui_pagination.html.twig # sliding pagination controls template
sortable: KnpPaginatorBundle:Pagination:sortable_link.html.twig # sort link template
#liip_imagine:
# filter_sets:
# cache: ~
# square_thumb:
### cache: my_remote_resolver
# data_loader: remote.loader
## quality: 75
## filters:
## thumbnail: { size: [150, 150], mode: outbound }
liip_imagine:
loaders:
media:
flysystem:
filesystem_service: oneup_flysystem.media_filesystem
rebrickable:
stream:
wrapper: 'http://rebrickable.com/media/'
resolvers:
default:
web_path: ~
filter_sets:
model:
data_loader: media
cache: ~
quality: 80
filters:
thumbnail: { size: [200, 200], mode: inset }
rebrickable_part_min:
quality: 80
data_loader: rebrickable
cache: ~
filters:
thumbnail: { size: [200, 200], mode: inset }
rebrickable_set_mid:
quality: 80
data_loader: rebrickable
cache: ~
filters:
thumbnail: { size: [600, 600], mode: inset }
rebrickable_set_min:
quality: 80
data_loader: rebrickable
cache: ~
filters:
thumbnail: { size: [300, 300], mode: inset }
oneup_flysystem:
adapters:
media_adapter:
media:
local:
directory: "%kernel.root_dir%/../var/media/"
ldraw_library_adapter:
ldraw_library:
local:
directory: "%ldraw_library%"
filesystems:
media:
adapter: media_adapter
adapter: media
ldraw_library:
adapter: ldraw_library_adapter
adapter: ldraw_library

View File

@ -17,7 +17,7 @@ services:
app.twig_extension:
class: AppBundle\Twig\AppExtension
public: false
arguments: ['api.@manager.rebrickable']
arguments: ['@api.manager.rebrickable']
tags:
- { name: twig.extension }

View File

@ -23,10 +23,9 @@
"sensio/framework-extra-bundle": "^3.0.2",
"incenteev/composer-parameter-handler": "^2.0",
"guzzlehttp/guzzle": "^6.2",
"knplabs/knp-menu-bundle": "^2.0",
"knplabs/knp-menu-bundle": "^2.1",
"oneup/flysystem-bundle": "^1.7",
"knplabs/knp-paginator-bundle": "^2.5",
"knplabs/knp-gaufrette-bundle": "~0.3",
"lexik/form-filter-bundle": "~5.0",
"liip/imagine-bundle": "^1.7"
},

112
composer.lock generated
View File

@ -4,8 +4,67 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"content-hash": "fcff1b4aff59fb1710a57c91e6a04a6c",
"content-hash": "6a70240b303126447c6fc3c6f75bf6ff",
"packages": [
{
"name": "composer/ca-bundle",
"version": "1.0.7",
"source": {
"type": "git",
"url": "https://github.com/composer/ca-bundle.git",
"reference": "b17e6153cb7f33c7e44eb59578dc12eee5dc8e12"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/composer/ca-bundle/zipball/b17e6153cb7f33c7e44eb59578dc12eee5dc8e12",
"reference": "b17e6153cb7f33c7e44eb59578dc12eee5dc8e12",
"shasum": ""
},
"require": {
"ext-openssl": "*",
"ext-pcre": "*",
"php": "^5.3.2 || ^7.0"
},
"require-dev": {
"phpunit/phpunit": "^4.5",
"psr/log": "^1.0",
"symfony/process": "^2.5 || ^3.0"
},
"suggest": {
"symfony/process": "This is necessary to reliably check whether openssl_x509_parse is vulnerable on older php versions, but can be ignored on PHP 5.5.6+"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.x-dev"
}
},
"autoload": {
"psr-4": {
"Composer\\CaBundle\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jordi Boggiano",
"email": "j.boggiano@seld.be",
"homepage": "http://seld.be"
}
],
"description": "Lets you find a path to the system CA bundle, and includes a fallback to the Mozilla CA bundle.",
"keywords": [
"cabundle",
"cacert",
"certificate",
"ssl",
"tls"
],
"time": "2017-03-06T11:59:08+00:00"
},
{
"name": "doctrine/annotations",
"version": "v1.2.7",
@ -2233,19 +2292,20 @@
},
{
"name": "sensiolabs/security-checker",
"version": "v4.0.2",
"version": "v4.0.4",
"source": {
"type": "git",
"url": "https://github.com/sensiolabs/security-checker.git",
"reference": "56bded66985e22f6eac2cf86735fd21c625bff2f"
"reference": "9e69eddf3bc49d1ee5c7908564da3141796d4bbc"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sensiolabs/security-checker/zipball/56bded66985e22f6eac2cf86735fd21c625bff2f",
"reference": "56bded66985e22f6eac2cf86735fd21c625bff2f",
"url": "https://api.github.com/repos/sensiolabs/security-checker/zipball/9e69eddf3bc49d1ee5c7908564da3141796d4bbc",
"reference": "9e69eddf3bc49d1ee5c7908564da3141796d4bbc",
"shasum": ""
},
"require": {
"composer/ca-bundle": "^1.0",
"symfony/console": "~2.7|~3.0"
},
"bin": [
@ -2273,7 +2333,7 @@
}
],
"description": "A security checker for your composer.lock",
"time": "2017-03-09T17:33:20+00:00"
"time": "2017-03-31T14:50:32+00:00"
},
{
"name": "swiftmailer/swiftmailer",
@ -2787,16 +2847,16 @@
},
{
"name": "symfony/symfony",
"version": "v3.2.6",
"version": "v3.2.7",
"source": {
"type": "git",
"url": "https://github.com/symfony/symfony.git",
"reference": "b0f8a7fa4b8baadf9db299cb6ac87c96a8977dbe"
"reference": "1631040ea8fc5e0e405c00d35cbf2c0b7b555f64"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/symfony/zipball/b0f8a7fa4b8baadf9db299cb6ac87c96a8977dbe",
"reference": "b0f8a7fa4b8baadf9db299cb6ac87c96a8977dbe",
"url": "https://api.github.com/repos/symfony/symfony/zipball/1631040ea8fc5e0e405c00d35cbf2c0b7b555f64",
"reference": "1631040ea8fc5e0e405c00d35cbf2c0b7b555f64",
"shasum": ""
},
"require": {
@ -2927,7 +2987,7 @@
"keywords": [
"framework"
],
"time": "2017-03-10T18:35:48+00:00"
"time": "2017-04-05T12:52:29+00:00"
},
{
"name": "twig/twig",
@ -2995,49 +3055,59 @@
"packages-dev": [
{
"name": "friendsofphp/php-cs-fixer",
"version": "v2.1.2",
"version": "v2.2.0",
"source": {
"type": "git",
"url": "https://github.com/FriendsOfPHP/PHP-CS-Fixer.git",
"reference": "c7de769d7b44f2c9de68e1f678b65efd8126f60b"
"reference": "d6f17423412d33df6b69c9aaf12037b91703533b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/c7de769d7b44f2c9de68e1f678b65efd8126f60b",
"reference": "c7de769d7b44f2c9de68e1f678b65efd8126f60b",
"url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/d6f17423412d33df6b69c9aaf12037b91703533b",
"reference": "d6f17423412d33df6b69c9aaf12037b91703533b",
"shasum": ""
},
"require": {
"doctrine/annotations": "^1.2",
"ext-tokenizer": "*",
"php": "^5.3.6 || >=7.0 <7.2",
"sebastian/diff": "^1.1",
"symfony/console": "^2.3 || ^3.0",
"symfony/console": "^2.4 || ^3.0",
"symfony/event-dispatcher": "^2.1 || ^3.0",
"symfony/filesystem": "^2.4 || ^3.0",
"symfony/finder": "^2.2 || ^3.0",
"symfony/options-resolver": "^2.6 || ^3.0",
"symfony/polyfill-php54": "^1.0",
"symfony/polyfill-php55": "^1.3",
"symfony/polyfill-php70": "^1.0",
"symfony/polyfill-xml": "^1.3",
"symfony/process": "^2.3 || ^3.0",
"symfony/stopwatch": "^2.5 || ^3.0"
},
"conflict": {
"hhvm": "<3.9"
"hhvm": "<3.18"
},
"require-dev": {
"gecko-packages/gecko-php-unit": "^2.0",
"justinrainbow/json-schema": "^5.0",
"phpunit/phpunit": "^4.5 || ^5.0",
"satooshi/php-coveralls": "^1.0",
"symfony/phpunit-bridge": "^3.2"
"symfony/phpunit-bridge": "^3.2.2"
},
"suggest": {
"ext-xml": "For better performance."
"ext-mbstring": "For handling non-UTF8 characters in cache signature.",
"ext-xml": "For better performance.",
"symfony/polyfill-mbstring": "When enabling `ext-mbstring` is not possible."
},
"bin": [
"php-cs-fixer"
],
"type": "application",
"extra": {
"branch-alias": {
"dev-master": "2.2-dev"
}
},
"autoload": {
"psr-4": {
"PhpCsFixer\\": "src/"
@ -3058,7 +3128,7 @@
}
],
"description": "A tool to automatically fix PHP code style",
"time": "2017-03-15T17:13:07+00:00"
"time": "2017-03-31T16:16:30+00:00"
},
{
"name": "ircmaxell/password-compat",
@ -3210,7 +3280,7 @@
},
{
"name": "symfony/phpunit-bridge",
"version": "v3.2.6",
"version": "v3.2.7",
"source": {
"type": "git",
"url": "https://github.com/symfony/phpunit-bridge.git",

View File

@ -102,9 +102,14 @@ class LDViewService
$this->runLDView([
$file,
'-LDrawDir='.$this->ldrawLibraryFilesystem->getAdapter()->getPathPrefix(),
'-AutoCrop=1',
'-SaveAlpha=0',
'-AutoCrop=0',
'-SaveAlpha=1',
'-BackgroundColor3=0xFFFFFF',
'-DefaultColor3=0x136FC3',
'-SnapshotSuffix=.png',
'-HiResPrimitives=1',
'-CurveQuality=10',
'-DefaultLatLong=40,35',
'-SaveDir='.$this->mediaFilesystem->getAdapter()->getPathPrefix().'ldraw'.DIRECTORY_SEPARATOR.'images',
'-SaveSnapshots=1',
]);

View File

@ -3,6 +3,9 @@
namespace AppBundle\Twig;
use AppBundle\Api\Manager\RebrickableManager;
use AppBundle\Entity\Rebrickable\Color;
use AppBundle\Entity\Rebrickable\Part;
use AppBundle\Entity\Rebrickable\Set;
class AppExtension extends \Twig_Extension
{
@ -12,7 +15,7 @@ class AppExtension extends \Twig_Extension
/**
* AppExtension constructor.
*
* @param $rebrickableAPIManager
* @param RebrickableManager $rebrickableAPIManager
*/
public function __construct($rebrickableAPIManager)
{
@ -23,13 +26,17 @@ class AppExtension extends \Twig_Extension
{
return [
new \Twig_SimpleFilter('partImage', [$this, 'partImage']),
new \Twig_SimpleFilter('setImage', [$this, 'setImage']),
];
}
public function partImage($number)
public function partImage(Part $part, Color $color = null)
{
if ($part = $this->rebrickableAPIManager->getPart($number)) {
return $part->getImgUrl();
}
return '/parts/ldraw/'.($color ? $color->getId():'-1').'/'.$part->getNumber().'.png';
}
public function setImage(Set $set)
{
return '/sets/'.strtolower($set->getNumber()).'.jpg';
}
}