Skip to content

Commit

Permalink
Merge pull request #23 from mirko-pagliai/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
mirko-pagliai authored Aug 10, 2017
2 parents 05c9c6c + 955afed commit 3daec0d
Show file tree
Hide file tree
Showing 32 changed files with 651 additions and 1,894 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ after_success:
- if [[ $COVERAGE = 1 ]]; then bash <(curl -s https://codecov.io/bash); fi

notifications:
email: false
email: false
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# 1.x branch
## 1.1 branch
# 1.1.1
* fixed bug when using similar format name, , as `jpeg` or `tif`;
* added `TestCase::assertFileExtension()` and `TestCase::assertThumbPath()`
methods;
* added `ThumbTrait`;
* added `Thumber\TestSuite\IntegrationTestCase` class;
* removed `thumbUrl()` global function. Use instead `ThumbTrait::getUrl()`;
* significantly improved and simplified all tests;
* the MIT license has been applied.

# 1.1.0
* configuration parameters have the name of the plugin (`Thumber`) as prefix. So
now they are `Thumber.driver` and `Thumber.target`;
Expand Down Expand Up @@ -30,4 +40,4 @@
* by default, the `ThumbHelper` creates jpg thumbnails.

### 1.0.0
* first release.
* first release.
661 changes: 0 additions & 661 deletions COPYNG

This file was deleted.

19 changes: 19 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Thumber

[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.txt)
[![Build Status](https://travis-ci.org/mirko-pagliai/cakephp-thumber.svg?branch=master)](https://travis-ci.org/mirko-pagliai/cakephp-thumber)
[![Coverage Status](https://img.shields.io/codecov/c/github/mirko-pagliai/cakephp-thumber.svg?style=flat-square)](https://codecov.io/github/mirko-pagliai/cakephp-thumber)

Expand Down
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Thumber plugin for CakePHP",
"homepage": "https://github.com/mirko-pagliai/cakephp-thumber",
"type": "cakephp-plugin",
"license": "AGPL",
"license": "MIT",
"authors": [{
"name": "Mirko Pagliai",
"email": "[email protected]"
Expand All @@ -14,7 +14,8 @@
"intervention/image": "^2.3"
},
"require-dev": {
"cakephp/cakephp-codesniffer": "2.*",
"cakephp/cakephp-codesniffer": "^3.0",
"mirko-pagliai/reflection": "^1.0",
"phpunit/phpunit": "^5.7|^6.0"
},
"autoload": {
Expand Down
22 changes: 6 additions & 16 deletions config/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,13 @@
/**
* This file is part of cakephp-thumber.
*
* cakephp-thumber 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.
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* cakephp-thumber 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 cakephp-thumber. If not, see <http://www.gnu.org/licenses/>.
*
* @author Mirko Pagliai <[email protected]>
* @copyright Copyright (c) 2016, Mirko Pagliai for Nova Atlantis Ltd
* @license http://www.gnu.org/licenses/agpl.txt AGPL License
* @link http://git.novatlantis.it Nova Atlantis Ltd
* @copyright Copyright (c) Mirko Pagliai
* @link https://github.com/mirko-pagliai/cakephp-thumber
* @license https://opensource.org/licenses/mit-license.php MIT License
*/
use Cake\Core\Configure;

Expand Down
25 changes: 8 additions & 17 deletions config/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,18 @@
/**
* This file is part of cakephp-thumber.
*
* cakephp-thumber 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.
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* cakephp-thumber 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 cakephp-thumber. If not, see <http://www.gnu.org/licenses/>.
*
* @author Mirko Pagliai <[email protected]>
* @copyright Copyright (c) 2016, Mirko Pagliai for Nova Atlantis Ltd
* @license http://www.gnu.org/licenses/agpl.txt AGPL License
* @link http://git.novatlantis.it Nova Atlantis Ltd
* @copyright Copyright (c) Mirko Pagliai
* @link https://github.com/mirko-pagliai/cakephp-thumber
* @license https://opensource.org/licenses/mit-license.php MIT License
*/
use Cake\Routing\RouteBuilder;
use Cake\Routing\Router;

Router::plugin(THUMBER, ['path' => '/thumb'], function ($routes) {
Router::plugin(THUMBER, ['path' => '/thumb'], function (RouteBuilder $routes) {
$routes->connect(
'/:basename',
['controller' => 'Thumbs', 'action' => 'thumb'],
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@
<directory suffix=".php">./src/</directory>
</whitelist>
</filter>
</phpunit>
</phpunit>
28 changes: 10 additions & 18 deletions src/Controller/ThumbsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,27 @@
/**
* This file is part of cakephp-thumber.
*
* cakephp-thumber 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.
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* cakephp-thumber 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 cakephp-thumber. If not, see <http://www.gnu.org/licenses/>.
*
* @author Mirko Pagliai <[email protected]>
* @copyright Copyright (c) 2016, Mirko Pagliai for Nova Atlantis Ltd
* @license http://www.gnu.org/licenses/agpl.txt AGPL License
* @link http://git.novatlantis.it Nova Atlantis Ltd
* @copyright Copyright (c) Mirko Pagliai
* @link https://github.com/mirko-pagliai/cakephp-thumber
* @license https://opensource.org/licenses/mit-license.php MIT License
*/
namespace Thumber\Controller;

use Cake\Controller\Controller;
use Cake\Core\Configure;
use Thumber\Network\Exception\ThumbNotFoundException;
use Thumber\ThumbTrait;

/**
* Thumbs controller class
*/
class ThumbsController extends Controller
{
use ThumbTrait;

/**
* Renders a thumbnail
* @param string $basename Encoded thumbnail basename
Expand All @@ -39,7 +31,7 @@ class ThumbsController extends Controller
*/
public function thumb($basename)
{
$file = Configure::read(THUMBER . '.target') . DS . base64_decode($basename);
$file = $this->getPath(base64_decode($basename));

if (!is_readable($file)) {
throw new ThumbNotFoundException(__d('thumber', 'File `{0}` doesn\'t exist', $file));
Expand Down
36 changes: 6 additions & 30 deletions src/Core/global_functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,15 @@
/**
* This file is part of cakephp-thumber.
*
* cakephp-thumber 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.
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* cakephp-thumber 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 cakephp-thumber. If not, see <http://www.gnu.org/licenses/>.
*
* @author Mirko Pagliai <[email protected]>
* @copyright Copyright (c) 2016, Mirko Pagliai for Nova Atlantis Ltd
* @license http://www.gnu.org/licenses/agpl.txt AGPL License
* @link http://git.novatlantis.it Nova Atlantis Ltd
* @copyright Copyright (c) Mirko Pagliai
* @link https://github.com/mirko-pagliai/cakephp-thumber
* @license https://opensource.org/licenses/mit-license.php MIT License
*/
use Cake\Filesystem\Folder;
use Cake\Routing\Router;

if (!function_exists('isUrl')) {
/**
Expand All @@ -46,16 +35,3 @@ function rtr($path)
return preg_replace(sprintf('/^%s/', preg_quote(Folder::slashTerm(ROOT), DS)), null, $path);
}
}

if (!function_exists('thumbUrl')) {
/**
* Returns the url for a thumbnail
* @param string $path Thumbnail path
* @param bool $full If `true`, the full base URL will be prepended to the result
* @return string
*/
function thumbUrl($path, $full = true)
{
return Router::url(['_name' => 'thumb', base64_encode(basename($path))], $full);
}
}
22 changes: 6 additions & 16 deletions src/Network/Exception/ThumbNotFoundException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,13 @@
/**
* This file is part of cakephp-thumber.
*
* cakephp-thumber 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.
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* cakephp-thumber 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 cakephp-thumber. If not, see <http://www.gnu.org/licenses/>.
*
* @author Mirko Pagliai <[email protected]>
* @copyright Copyright (c) 2016, Mirko Pagliai for Nova Atlantis Ltd
* @license http://www.gnu.org/licenses/agpl.txt AGPL License
* @link http://git.novatlantis.it Nova Atlantis Ltd
* @copyright Copyright (c) Mirko Pagliai
* @link https://github.com/mirko-pagliai/cakephp-thumber
* @license https://opensource.org/licenses/mit-license.php MIT License
* @since 1.0.4
*/
namespace Thumber\Network\Exception;
Expand Down
54 changes: 54 additions & 0 deletions src/TestSuite/IntegrationTestCase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php
/**
* This file is part of cakephp-thumber.
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Mirko Pagliai
* @link https://github.com/mirko-pagliai/cakephp-thumber
* @license https://opensource.org/licenses/mit-license.php MIT License
* @since 1.1.1
*/
namespace Thumber\TestSuite;

use Cake\TestSuite\IntegrationTestCase as CakeIntegrationTestCase;
use Thumber\ThumbTrait;

/**
* IntegrationTestCaseTest class
*/
abstract class IntegrationTestCase extends CakeIntegrationTestCase
{
use ThumbTrait;

/**
* Teardown any static object changes and restore them
* @return void
*/
public function tearDown()
{
parent::tearDown();

foreach (glob($this->getPath('*')) as $file) {
//@codingStandardsIgnoreLine
unlink($file);
}
}

/**
* Asserts content type
* @param string $type The content-type to check for
* @param string $message The failure message that will be appended to the
* generated message
* @return void
*/
public function assertContentType($type, $message = '')
{
$this->skipIf(!version_compare(PHP_VERSION, '7.0', '>') &&
in_array($type, ['image/x-ms-bmp', 'image/vnd.adobe.photoshop']));

parent::assertContentType($type, $message);
}
}
Loading

0 comments on commit 3daec0d

Please sign in to comment.