diff --git a/app/Classes/Renderer/Entities/SnappyImageClient.php b/app/Classes/Renderer/Entities/SnappyImageClient.php
deleted file mode 100644
index d46ab7e..0000000
--- a/app/Classes/Renderer/Entities/SnappyImageClient.php
+++ /dev/null
@@ -1,25 +0,0 @@
-image = $image;
- }
-
- public function generate(string $markup, string $path): string
- {
- $this->image->generateFromHtml($markup, $path, ['enable-local-file-access' => true,
- ]);
-
- return $path;
- }
-}
diff --git a/app/Classes/Renderer/Services/ImageService.php b/app/Classes/Renderer/Services/ImageService.php
deleted file mode 100644
index cf52557..0000000
--- a/app/Classes/Renderer/Services/ImageService.php
+++ /dev/null
@@ -1,88 +0,0 @@
-client = $client->whatnow();
- $this->image = $image;
- }
-
- public function createFromArray($params): Image
- {
- foreach (['instructionId', 'translationCode', 'stageRef'] as $param) {
- if (!isset($params[$param])) {
- throw ImageServiceException::missingParameter($param);
- }
- }
-
- try {
- if ($params['revision']) {
- $instruction = $this->client->getLatestInstructionRevision($params['instructionId']);
- } else {
- $instruction = $this->client->getInstruction($params['instructionId']);
- }
- } catch (RcnApiRequestException $e) {
- throw ImageServiceException::missingInstruction($params['instructionId']);
- }
-
- $translations = $instruction->getTranslationsByLanguage($params['translationCode']);
-
- if (!($translations instanceof InstructionTranslation)) {
- throw ImageServiceException::missingTranslations($params['translationCode']);
- }
-
- $items = $translations->getStages()->get($params['stageRef']);
-
- if (gettype($items) !== 'array') {
- throw ImageServiceException::invalidStageReference($params['stageRef']);
- }
-
- if (count($items) === 0) {
- throw ImageServiceException::missingStages($params['stageRef']);
- }
-
- $societyName = $instruction->getAttribution()->getName();
- $title = $translations->getTitle() ?? '';
-
- return new Image(
- $societyName,
- $title,
- $params['stageRef'],
- new Language($params['translationCode']),
- new EventType($instruction->getEventType()),
- $items
- );
- }
-
-
- public function render(ImageInterface $image, ImageFileInterface $file): string
- {
- $markup = $image->getMarkup();
-
- if ($file->exists()) {
- $file->delete();
- }
-
- return $this->image->generate($markup, $file->getPath());
- }
-}
diff --git a/app/Classes/Renderer/Services/ImageServiceException.php b/app/Classes/Renderer/Services/ImageServiceException.php
deleted file mode 100644
index 2270282..0000000
--- a/app/Classes/Renderer/Services/ImageServiceException.php
+++ /dev/null
@@ -1,39 +0,0 @@
-client = $client->whatnow();
- $this->image = $image;
}
@@ -768,24 +761,4 @@ public function publishTranslations($countryCode, Request $request)
}
}
- public function renderImage(Request $request, $instructionId, $translationCode, $stageRef)
- {
- try {
- $revision = $request->query('revision') == 'true';
- $image = $this->image->createFromArray([
- 'instructionId' => $instructionId,
- 'translationCode' => $translationCode,
- 'stageRef' => $stageRef,
- 'revision' => $revision
- ]);
- } catch (ImageServiceException $e) {
- return $this->respondWithNotFound($e, $e->getMessage());
- }
-
- $filename = $instructionId . '_' . $translationCode . '_' . $stageRef . '.jpg';
- $imageFile = new ImageFile(config('whatnowimage.directory'), $filename);
- $path = $this->image->render($image, $imageFile);
-
- return response()->file($path);
- }
}
diff --git a/app/Providers/ImageClientServiceProvider.php b/app/Providers/ImageClientServiceProvider.php
deleted file mode 100644
index e873b49..0000000
--- a/app/Providers/ImageClientServiceProvider.php
+++ /dev/null
@@ -1,28 +0,0 @@
-app->bind(ImageClientInterface::class, function ($app) {
- return $app->make(SnappyImageClient::class);
- });
-
- $this->app->bind(Image::class, function () {
- return new Image(config('whatnowimage.binary'));
- });
- }
-}
diff --git a/composer.json b/composer.json
index 25a8590..2baeba0 100644
--- a/composer.json
+++ b/composer.json
@@ -6,19 +6,16 @@
"type": "project",
"require": {
"php": ">=7.0.0",
- "aws/aws-sdk-php": "^3.216",
"darkaonline/l5-swagger": "5.8",
"fideloper/proxy": "~4.0",
"guzzlehttp/guzzle": "~6.0",
"guzzlehttp/promises": "^1.4.0",
"guzzlehttp/psr7": "^1.7.0",
- "knplabs/knp-snappy-bundle": "^1.6",
"laravel/framework": "5.8.*",
"laravel/socialite": "^3.0",
"laravel/tinker": "~1.0",
"league/csv": "^9.8",
"maatwebsite/excel": "3.1",
- "silvertipsoftware/wkhtmltoimage-amd64": "0.12.5",
"spatie/laravel-cors": "^1.0",
"symfony/polyfill-mbstring": "^1.17",
"tymon/jwt-auth": "^1.0.0-rc.1"
diff --git a/config/app.php b/config/app.php
index 1c3bd7a..bf8caaa 100644
--- a/config/app.php
+++ b/config/app.php
@@ -88,7 +88,6 @@
App\Classes\RcnApi\RcnApiServiceProvider::class,
- App\Providers\ImageClientServiceProvider::class,
],
diff --git a/config/filesystems.php b/config/filesystems.php
index 840eec2..31ea095 100644
--- a/config/filesystems.php
+++ b/config/filesystems.php
@@ -8,7 +8,6 @@
- 'cloud' => env('FILESYSTEM_CLOUD', 's3'),
@@ -26,13 +25,6 @@
'visibility' => 'public',
],
- 's3' => [
- 'driver' => 's3',
- 'key' => env('AWS_KEY'),
- 'secret' => env('AWS_SECRET'),
- 'subnationals' => env('AWS_REGION'),
- 'bucket' => env('AWS_BUCKET'),
- ],
],
diff --git a/config/queue.php b/config/queue.php
index 8df0960..e72b6b2 100644
--- a/config/queue.php
+++ b/config/queue.php
@@ -28,14 +28,6 @@
'retry_after' => 90,
],
- 'sqs' => [
- 'driver' => 'sqs',
- 'key' => 'your-public-key',
- 'secret' => 'your-secret-key',
- 'prefix' => 'https://sqs.us-east-1.amazonaws.com/your-account-id',
- 'queue' => 'your-queue-name',
- 'subnationals' => 'us-east-1',
- ],
'redis' => [
'driver' => 'redis',
diff --git a/config/services.php b/config/services.php
index e012b40..7a4fda2 100644
--- a/config/services.php
+++ b/config/services.php
@@ -4,26 +4,6 @@
- 'mailgun' => [
- 'domain' => env('MAILGUN_DOMAIN'),
- 'secret' => env('MAILGUN_SECRET'),
- ],
-
- 'ses' => [
- 'key' => env('SES_KEY'),
- 'secret' => env('SES_SECRET'),
- 'subnationals' => env('SES_REGION','us-west-1')
- ],
-
- 'sparkpost' => [
- 'secret' => env('SPARKPOST_SECRET'),
- ],
-
- 'stripe' => [
- 'model' => \App\Models\Access\User\User::class,
- 'key' => env('STRIPE_KEY'),
- 'secret' => env('STRIPE_SECRET'),
- ],
'github' => [
'client_id' => env('GITHUB_CLIENT_ID'),
diff --git a/config/whatnowimage.php b/config/whatnowimage.php
deleted file mode 100644
index b3c5c59..0000000
--- a/config/whatnowimage.php
+++ /dev/null
@@ -1,6 +0,0 @@
- base_path('vendor/bin/wkhtmltoimage-amd64'),
- 'directory' => storage_path('generated')
-];
diff --git a/package.json b/package.json
index e94e294..808556e 100644
--- a/package.json
+++ b/package.json
@@ -6,9 +6,7 @@
"watch-poll": "mix watch -- --watch-options-poll=1000",
"hot": "mix watch --hot",
"production": "mix --production",
- "lint": "eslint resources/assets/js",
- "transifex:push": "tx push -s",
- "transifex:pull": "tx pull -a"
+ "lint": "eslint resources/assets/js"
},
"dependencies": {
"@fortawesome/fontawesome": "^1.0.0",
diff --git a/resources/views/whatnowImage.blade.php b/resources/views/whatnowImage.blade.php
deleted file mode 100644
index 150ffba..0000000
--- a/resources/views/whatnowImage.blade.php
+++ /dev/null
@@ -1,189 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- @foreach ($items as $item)
- -
- {{ $item }}
-
- @endforeach
-
-
-
-
-
diff --git a/routes/api.php b/routes/api.php
index 1dee2f8..47852e5 100644
--- a/routes/api.php
+++ b/routes/api.php
@@ -15,7 +15,6 @@
Route::get('terms/latest', 'Terms\TermsController@latest'); // Get latest terms version
// Instructions and event types
- Route::get('instructions/{id}/{translation}/{stage}/download', 'WhatNow\InstructionController@renderImage'); // Download instruction image
Route::get('event-types/', 'WhatNow\EventTypeController@list'); // List all event types
Route::post('event-types/', 'WhatNow\EventTypeController@create'); // Create new event type
Route::post('admin/password/email', 'Auth\ForgotPasswordController@sendResetLinkEmail');
diff --git a/tests/Unit/Renderer/ImageServiceTest.php b/tests/Unit/Renderer/ImageServiceTest.php
deleted file mode 100644
index 801fc43..0000000
--- a/tests/Unit/Renderer/ImageServiceTest.php
+++ /dev/null
@@ -1,314 +0,0 @@
-getParams();
- $imageValues = $this->getImageValues();
-
- $stages = \Mockery::mock(Collection::class)
- ->shouldReceive('get')
- ->withArgs([$params['stageRef']])
- ->andReturn($imageValues['items'])
- ->getMock();
-
- $translations = \Mockery::mock(InstructionTranslation::class)
- ->shouldReceive('getStages')
- ->andReturn($stages)
- ->shouldReceive('getTitle')
- ->andReturn($imageValues['title'])
- ->getMock();
-
- $attribution = \Mockery::mock(Organisation::class)
- ->shouldReceive('getName')
- ->withNoArgs()
- ->andReturn($imageValues['societyName'])
- ->getMock();
-
- $instruction = \Mockery::mock(Instruction::class)
- ->shouldReceive('getTranslationsByLanguage')
- ->withArgs([$params['translationCode']])
- ->andReturn($translations)
- ->shouldReceive('getAttribution')
- ->andReturn($attribution)
- ->shouldReceive('getEventType')
- ->andReturn($imageValues['eventTypeName'])
- ->getMock();
-
- $whatNow = \Mockery::mock(WhatNowResource::class)
- ->shouldReceive('getLatestInstructionRevision')
- ->withArgs([$params['instructionId']])
- ->andReturn($instruction)
- ->getMock();
-
- $client = \Mockery::mock(RcnApiClient::class)
- ->shouldReceive('whatnow')
- ->andReturn($whatNow)
- ->getMock();
-
- $imageClient = \Mockery::mock(ImageClientInterface::class);
-
- $service = new ImageService($client, $imageClient);
- $image = $service->createFromArray($params);
-
- $this->assertEquals(Image::class, get_class($image));
-
- $this->assertEquals($imageValues['societyName'], $image->getSocietyName());
- $this->assertEquals($imageValues['title'], $image->getTitle());
- $this->assertEquals($imageValues['stageRef'], $image->getStageRef());
- $this->assertEquals($imageValues['langCode'], $image->getLanguage()->getCode());
- $this->assertEquals($imageValues['eventTypeName'], $image->getEventType()->getName());
- $this->assertEquals($imageValues['eventTypeIconName'], $image->getEventType()->getIconName());
- $this->assertEquals($imageValues['items'], $image->getItems());
- }
-
- /**
- * @dataProvider getMissingParamsWithExceptions
- */
- public function test_it_throws_exception_if_parameter_is_missing($missingParam)
- {
- $params = $this->getParams();
- unset($params[$missingParam]);
-
- $this->expectExceptionObject(ImageServiceException::missingParameter($missingParam));
-
- $whatNow = \Mockery::mock(WhatNowResource::class);
-
- $client = \Mockery::mock(RcnApiClient::class)
- ->shouldReceive('whatnow')
- ->andReturn($whatNow)
- ->getMock();
-
- $imageClient = \Mockery::mock(ImageClientInterface::class);
-
- $service = new ImageService($client, $imageClient);
- $service->createFromArray($params);
- }
-
- public function test_it_throws_exception_if_instruction_is_missing()
- {
- $params = $this->getParams();
-
- $this->expectExceptionObject(ImageServiceException::missingInstruction($params['instructionId']));
-
- $whatNow = \Mockery::mock(WhatNowResource::class)
- ->shouldReceive('getLatestInstructionRevision')
- ->withArgs([$params['instructionId']])
- ->andThrow(RcnApiRequestException::class)
- ->getMock();
-
- $client = \Mockery::mock(RcnApiClient::class)
- ->shouldReceive('whatnow')
- ->andReturn($whatNow)
- ->getMock();
-
- $imageClient = \Mockery::mock(ImageClientInterface::class);
-
- $service = new ImageService($client, $imageClient);
- $service->createFromArray($params);
- }
-
- public function test_it_throws_exception_if_translations_are_missing()
- {
- $params = $this->getParams();
-
- $this->expectExceptionObject(ImageServiceException::missingTranslations($params['translationCode']));
-
- $instruction = \Mockery::mock(Instruction::class)
- ->shouldReceive('getTranslationsByLanguage')
- ->withArgs([$params['translationCode']])
- ->andReturn(null) // this value is not an InstructionTranslation object, so should trigger the exception
- ->getMock();
-
- $whatNow = \Mockery::mock(WhatNowResource::class)
- ->shouldReceive('getLatestInstructionRevision')
- ->withArgs([$params['instructionId']])
- ->andReturn($instruction)
- ->getMock();
-
- $client = \Mockery::mock(RcnApiClient::class)
- ->shouldReceive('whatnow')
- ->andReturn($whatNow)
- ->getMock();
-
- $imageClient = \Mockery::mock(ImageClientInterface::class);
-
- $service = new ImageService($client, $imageClient);
- $service->createFromArray($params);
- }
-
- public function test_it_throws_exception_if_stage_reference_is_invalid()
- {
- $params = $this->getParams();
-
- $this->expectExceptionObject(ImageServiceException::invalidStageReference($params['stageRef']));
-
- $stages = \Mockery::mock(Collection::class)
- ->shouldReceive('get')
- ->withArgs([$params['stageRef']])
- ->andReturn(null) // this non-array value should trigger the exception
- ->getMock();
-
- $translations = \Mockery::mock(InstructionTranslation::class)
- ->shouldReceive('getStages')
- ->andReturn($stages)
- ->getMock();
-
- $instruction = \Mockery::mock(Instruction::class)
- ->shouldReceive('getTranslationsByLanguage')
- ->withArgs([$params['translationCode']])
- ->andReturn($translations)
- ->getMock();
-
- $whatNow = \Mockery::mock(WhatNowResource::class)
- ->shouldReceive('getLatestInstructionRevision')
- ->withArgs([$params['instructionId']])
- ->andReturn($instruction)
- ->getMock();
-
- $client = \Mockery::mock(RcnApiClient::class)
- ->shouldReceive('whatnow')
- ->andReturn($whatNow)
- ->getMock();
-
- $imageClient = \Mockery::mock(ImageClientInterface::class);
-
- $service = new ImageService($client, $imageClient);
- $service->createFromArray($params);
- }
-
- public function test_it_throws_exception_if_stages_are_missing()
- {
- $params = $this->getParams();
-
- $this->expectExceptionObject(ImageServiceException::missingStages($params['stageRef']));
-
- $stages = \Mockery::mock(Collection::class)
- ->shouldReceive('get')
- ->withArgs([$params['stageRef']])
- ->andReturn([]) // this empty array should trigger the exception
- ->getMock();
-
- $translations = \Mockery::mock(InstructionTranslation::class)
- ->shouldReceive('getStages')
- ->andReturn($stages)
- ->getMock();
-
- $instruction = \Mockery::mock(Instruction::class)
- ->shouldReceive('getTranslationsByLanguage')
- ->withArgs([$params['translationCode']])
- ->andReturn($translations)
- ->getMock();
-
- $whatNow = \Mockery::mock(WhatNowResource::class)
- ->shouldReceive('getLatestInstructionRevision')
- ->withArgs([$params['instructionId']])
- ->andReturn($instruction)
- ->getMock();
-
- $client = \Mockery::mock(RcnApiClient::class)
- ->shouldReceive('whatnow')
- ->andReturn($whatNow)
- ->getMock();
-
- $imageClient = \Mockery::mock(ImageClientInterface::class);
-
- $service = new ImageService($client, $imageClient);
- $service->createFromArray($params);
- }
-
- public function test_it_renders_image()
- {
- $whatNow = \Mockery::mock(WhatNowResource::class);
-
- $client = \Mockery::mock(RcnApiClient::class)
- ->shouldReceive('whatnow')
- ->andReturn($whatNow)
- ->getMock();
-
- $imageClient = \Mockery::mock(ImageClientInterface::class)
- ->shouldReceive('generate')
- ->withArgs(['image_markup', 'image_path'])
- ->andReturn('image_path')
- ->getMock();
-
- $image = \Mockery::mock(ImageInterface::class)
- ->shouldReceive('getMarkup')
- ->once()
- ->andReturn('image_markup')
- ->getMock();
-
- $file = \Mockery::mock(ImageFileInterface::class)
- ->shouldReceive('exists')
- ->once()
- ->andReturn(true)
- ->shouldReceive('delete')
- ->once()
- ->shouldReceive('getPath')
- ->once()
- ->andReturn('image_path')
- ->getMock();
-
- $service = new ImageService($client, $imageClient);
- $path = $service->render($image, $file);
-
- $this->assertEquals('image_path', $path);
- }
-
- /**
- * Data provider
- *
- * @return array
- */
- public function getMissingParamsWithExceptions()
- {
- return [
- ['instructionId'],
- ['translationCode'],
- ['stageRef']
- ];
- }
-
- protected function getParams()
- {
- return [
- 'instructionId' => 1,
- 'translationCode' => 'myTranslationCode',
- 'stageRef' => 'myStageRef'
- ];
- }
-
- protected function getImageValues()
- {
- return [
- 'societyName' => 'mySociety',
- 'title' => 'myTitle',
- 'stageRef' => $this->getParams()['stageRef'],
- 'langCode' => $this->getParams()['translationCode'],
- 'eventTypeName' => 'myEventTypeName',
- 'eventTypeIconName' => 'general@3x.png',
- 'items' => ['item1', 'item2', 'item3']
- ];
- }
-}
diff --git a/tests/Unit/Renderer/SnappyImageClientTest.php b/tests/Unit/Renderer/SnappyImageClientTest.php
deleted file mode 100644
index 1d72cca..0000000
--- a/tests/Unit/Renderer/SnappyImageClientTest.php
+++ /dev/null
@@ -1,25 +0,0 @@
-makePartial();
- $image->shouldReceive('generateFromHtml')
- ->once()
- ->withArgs(['image_markup', 'image_path'])
- ->andReturn('image_path')
- ->getMock();
-
- $client = new SnappyImageClient($image);
- $path = $client->generate('image_markup', 'image_path');
-
- $this->assertEquals('image_path', $path);
- }
-}