-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from mirko-pagliai/develop
Develop
- Loading branch information
Showing
32 changed files
with
651 additions
and
1,894 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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]" | ||
|
@@ -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": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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'], | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,4 +19,4 @@ | |
<directory suffix=".php">./src/</directory> | ||
</whitelist> | ||
</filter> | ||
</phpunit> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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)); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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')) { | ||
/** | ||
|
@@ -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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
Oops, something went wrong.